Search code examples
audioffmpeg

FFmpeg: How to join multiple mono files into one multichannel file?


I have e.g. 3 mono wav files. I would like to join them in one wave file which has 3 channels (not 2.1). The duration o this wave should inherit from the longest duration of mono files. I tried many commands, but no one of them gave me the expected result. Could you help?


Solution

  • apad + join

    One method is to use apad on the two shorter inputs and then mix them with the join filter:

    ffmpeg -i front_left.wav -i front_right.wav -i front_center.wav -filter_complex "[0]apad[FL];[1]apad[FR];[FL][FR][2]join=inputs=3:channel_layout=3.0:map=0.0-FL|1.0-FR|2.0-FC" output.wav
    

    apad + amerge + channelmap

    Similar to above, but channelmap (or pan) has to be added because amerge has no mapping functionality and assumes 2.1 instead of 3.0:

    ffmpeg -i front_left.wav -i front_right.wav -i front_center.wav -filter_complex "[0]apad[FL];[1]apad[FR];[FL][FR][2]amerge=inputs=3,channelmap=map=FL-FL|FR-FR|LFE-FC" output.wav