Alex Balgavy

Just some stuff about me.

Here's my dotfiles repository.

Check out my blog.

My keys: PGP, SSH

My crypto wallets (BTC, XMR)

how to mix additional audio on an mp4

Written by John Riselvato - original link

Adding an additional audio source on top of the audio already in a video can be accomplished with the amix filter. This might be useful for adding background music to a commentary video as seen in the example below:

  $ ffmpeg -i input.mp4 -i input.mp3 -filter_complex "amix" -map 0:v -map 0:a -map 1:a output.mp4

A common issue that comes up with amix is the volume of one input over powers the second, to solve this, setting the louder input volume down can resolve this. In the example below the volume of the first input audio [0:a] will be reduce 40%:

  $ ffmpeg -i input.mp4 -i input.mp3 -filter_complex [0:a]volume=0.40,amix -map 0:v -map 0:a -map 1:a -shortest output.mp4

Now you have two audio streams playing in a single video. Quick and easy.