Skip to content

Instantly share code, notes, and snippets.

@Stylesproline
Last active December 8, 2021 09:01
Show Gist options
  • Save Stylesproline/4bbc8c26fe9222abd28a30a403e5d5c5 to your computer and use it in GitHub Desktop.
Save Stylesproline/4bbc8c26fe9222abd28a30a403e5d5c5 to your computer and use it in GitHub Desktop.
How to overlay/downmix two audio files using ffmpeg

How to overlay/downmix two audio files using ffmpeg

Can I overlay/downmix two audio mp3 files into one mp3 output file using ffmpeg?

stereo + stereo → stereo

Use the amix https://ffmpeg.org/ffmpeg-filters.html#amix filter:

ffmpeg -i 01.mp3 -i 02.mp3 -filter_complex amix=inputs=2:duration=longest output3.mp3

stereo + stereo → stereo

Use the amix filter:

ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex amix=inputs=2:duration=longest output.mp3

Or the amerge filter:

ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex amerge=inputs=2 -ac 2 output.mp3

Use the amerge and pan filters:

ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex "amerge=inputs=2,pan=stereo|c0<c0+c1|c1<c2+c3" output.mp3

mono + mono → stereo

Use the join filter:

ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex join=inputs=2:channel_layout=stereo output.mp3

Or amerge:

ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex amerge=inputs=2 output.mp3

mono + mono → mono

Use the amix filter:

ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex amix=inputs=2:duration=longest output.mp3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment