how to merge two audios files by the using FFmpeg with special condition?

6,318

Downmix each input into specific output channel

Downmix each input into specific output channel

You can do everything in one command using the amerge and pan filters:

ffmpeg -i fisrt.wav -i second.wav -filter_complex "[0][1]amerge=inputs=2,pan=stereo|FL<c0+c1|FR<c2+c3[a]" -map "[a]" output.wav
Share:
6,318

Related videos on Youtube

Nyamkhuu Buyanjargal
Author by

Nyamkhuu Buyanjargal

I am a software engineer.

Updated on September 18, 2022

Comments

  • Nyamkhuu Buyanjargal
    Nyamkhuu Buyanjargal almost 2 years

    I have a special issue. Maybe not :D

    I have two audios files. First of all. The first audio file has been changed just hear the right side of the headphone. Because of I used that FFmpeg command.

    ffmpeg -i fisrt.wav -af “an=stereo|c1=c1” outr.wav
    

    Then, Second audio file has been changed just hear the left side of the headphone. I used this command.

    ffmpeg -i second.wav -af “pan=stereo|c0=c0” outl.wav
    

    Problem

    I want to merge these files with the special condition. This condition is the first audio/outr.wav/ is just heard the right side of the headphone. Then, second audio/outl.wav/ is just heard the left side of the headphone. So, I tried this command.

    ffmpeg -i left.mp3 -i right.mp3 -filter_complex "[0:a][1:a]amerge=inputs=2[a]" -map "[a]" output.wav
    

    Unfortunately, this result is don't want. The result hears both sides of headphone with different volume.

    Can you help me, please?!