The Computer Oracle

Simplify FFmpeg amerge and volume customization

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Drifting Through My Dreams

--

Chapters
00:00 Simplify Ffmpeg Amerge And Volume Customization
01:52 Accepted Answer Score 16
02:46 Thank you

--

Full question
https://superuser.com/questions/714879/s...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#ffmpeg

#avk47



ACCEPTED ANSWER

Score 16


One command to bind them

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<c0+c2:c1<c1+c3[out]" \
-map 1:v -map "[out]" -c:v copy -c:a libfdk_aac -shortest output.mp4

You may have to adjust the values for volume.


Potential problems

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<c0+c2:c1<c1+c3[out]" \
-map 1:v -map "[out]" -c:v copy -c:a libfdk_aac -shortest output.mp4