Skip to main content

Simplify FFmpeg amerge and volume customization


I have 3 consecutive FFmpeg commands that will customize the volume of an audio, customize the volume of a video, and amerge audio and video to a final output.


First command, edit volume level of a mp3 File


  ffmpeg -i music.mp3 -vol 100 music2.mp3

Second command, edit volume level of a mp4 file


ffmpeg -i video.mp4 -vol 200 video2.mp4

Third command,merge music2.mp3andvideo2.mp4


ffmpeg -i music2.mp3 -i ruby.mp4 -filter_complex \
"[0:a][1:a]amerge,pan=stereo:c0 -map 1:v -map "[out]" -c:v copy -c:a libfdk_aac -shortest video2.mp4

Is there an easy way to simplify and breakdown processes into just one process/command?


I've tried this one, but not working:


ffmpeg -i music.mp3 -vol 100 -i video.mp4 -vol 200 -filter_complex \
"[0:a][1:a]amerge,pan=stereo:c0 -map 1:v -map "[out]" -c:v copy -c:a libfdk_aac -shortest output.mp4

Error log(s):


    ffmpeg version N-60332-ga0d5204 Copyright (c) 2000-2014 the FFmpeg developers
built on Feb 4 2014 21:31:51 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid
libavutil 52. 63.100 / 52. 63.100
libavcodec 55. 49.101 / 55. 49.101
libavformat 55. 29.101 / 55. 29.101
libavdevice 55. 7.100 / 55. 7.100
libavfilter 4. 1.102 / 4. 1.102
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mp3, from 'adele.mp3':
Metadata:
title : Chasing Pavements
artist : Adele
track : 3
album : 19 (Deluxe Edition)
date : 2008
Duration: 00:03:30.55, start: 0.025056, bitrate: 160 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 159 kb/s
Stream #0:1: Video: mjpeg, yuvj420p(pc), 600x600 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
Metadata:
title :
comment : Other
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'Ruby on Rails 101- What is Ruby on Rails_.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2013-12-21 07:56:20
Duration: 00:05:42.40, start: 0.000000, bitrate: 1214 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 1020 kb/s, 30 fps, 30 tbr, 60 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 191 kb/s (default)
Metadata:
creation_time : 2013-12-21 07:56:23
handler_name : IsoMedia File Produced by Google, 5-11-2011
[Parsed_pan_1 @ 0x7fcd23d00680] This syntax is deprecated. Use '|' to separate the list items.
-vol has been deprecated. Use the volume audio filter instead.
-vol is forwarded to lavfi similarly to -af volume=0.781250.
-vol has been deprecated. Use the volume audio filter instead.
-vol is forwarded to lavfi similarly to -af volume=0.781250.
File 'output.mp4' already exists. Overwrite ? [y/N] y
[Parsed_amerge_0 @ 0x7fcd23d00000] No channel layout for input 1
Last message repeated 1 times
[AVFilterGraph @ 0x7fcd23c0f5a0] The following filters could not choose their formats: Parsed_amerge_0
Consider inserting the (a)format filter near their input or output.

Answer




You can do this in one command using the volume audio filter instead of the old -vol option (as mentioned by your console output):


ffmpeg -i music.mp3 -i videowithaudio.mp4 -filter_complex \
"[0:a]volume=0.390625[a1];[1:a]volume=0.781250[a2]; \
[a1][a2]amerge,pan=stereo:c0-map 1:v -map "[out]" -c:v copy -c:a libfdk_aac -shortest output.mp4

You may have to adjust the values for volume.





syntax is deprecated


[Parsed_pan_4 @ 0x244c980] This syntax is deprecated. Use '|' to separate the list items.

Don't worry – you can ignore this message.


could not choose their formats


[AVFilterGraph @ 0x26549a0] The following filters could not choose their formats: Parsed_amerge_3
Consider inserting the (a)format filter near their input or output.

All inputs must have the same sample rate and format for amerge. If they are different then you will have to use the aformat audio filter:


ffmpeg -i music.mp3 -i videowithaudio.mp4 -filter_complex \
"[0:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=0.5[a1]; \
[1:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=0.8[a2]; \
[a1][a2]amerge,pan=stereo:c0-map 1:v -map "[out]" -c:v copy -c:a libfdk_aac -shortest output.mp4

Comments

Popular Posts

Use Google instead of Bing with Windows 10 search

I want to use Google Chrome and Google search instead of Bing when I search in Windows 10. Google Chrome is launched when I click on web, but it's Bing search. (My default search engine on Google and Edge is http://www.google.com ) I haven't found how to configure that. Someone can help me ? Answer There is no way to change the default in Cortana itself but you can redirect it in Chrome. You said that it opens the results in the Chrome browser but it used Bing search right? There's a Chrome extension now that will redirect Bing to Google, DuckDuckGo, or Yahoo , whichever you prefer. More information on that in the second link.

linux - Using an index to make grep faster?

I find myself grepping the same codebase over and over. While it works great, each command takes about 10 seconds, so I am thinking about ways to make it faster. So can grep use some sort of index? I understand an index probably won't help for complicated regexps, but I use mostly very simple patters. Does an indexer exist for this case? EDIT: I know about ctags and the like, but I would like to do full-text search. Answer what about cscope , does this match your shoes? Allows searching code for: all references to a symbol global definitions functions called by a function functions calling a function text string regular expression pattern a file files including a file

How do I transmit a single hexadecimal value serial data in PuTTY using an Alt code?

I am trying to sent a specific hexadecimal value across a serial COM port using PuTTY. Specifically, I want to send the hex codes 9C, B6, FC, and 8B. I have looked up the Alt codes for these and they are 156, 182, 252, and 139 respectively. However, whenever I input the Alt codes, a preceding hex value of C2 is sent before 9C, B6, and 8B so the values that are sent are C2 9C, C2 B6, and C2 8B. The value for FC is changed to C3 FC. Why are these values being placed before the hex value and why is FC being changed altogether? To me, it seems like there is a problem internally converting the Alt code to hex. Is there a way to directly input hex values without using Alt codes in PuTTY? Answer What you're seeing is just ordinary text character set conversion. As far as PuTTY is concerned, you are typing (and reading) text , not raw binary data, therefore it has to convert the text to bytes in whatever configured character set before sending it over the wire. In other words, when y

networking - Windows 10, can ping other PC but cannot access shared folders! What gives?

I have a computer running Windows 7 that shares a Git repo on drive D. Let's call this PC " win7 ". This repo is the origin of a project that we push to and pull from. The network is a wireless network. One PC on this network is running on Windows 10. Let's call this PC " win10 ". Win10 can ping every other PC on the network including win7 . Win7 can ping win10 . Win7 can access all shared files on win10 . Neither of the PCs have passwords. Problem : Win10 cannot access any shared files on win7 , not from Explorer, nor from Git Bash or any other Git management system (E-Git on Eclipse or Visual Studio). So, win10 cannot pull/push. Every other PC on the network can access win7 shared files and push/pull to/from the shared Git origin. What's wrong with Windows 10? I have tried these: Control Panel\All Control Panel Items\Network and Sharing Center\Advanced sharing settings\ File sharing is on, Discovery is on, Password protected sharing is off Adapte