0

input:

Two audio file, It may be stereo or mono.

output:

  • A stereo file, and the stereo FL uses one file all channels, and FR uses other file all channels.
  • The total duration is based on the longest file.
  • I hope it can be achieved through FFmpeg.

There are four case:

  • mono + mono -> stereo
  • mono + stereo -> stereo
  • stereo + mono -> stereo
  • stereo + stereo -> stereo

I hope someone can help me, I am a newbie to FFmpeg.

1 Answer 1

1
  1. Get duration of each input with ffprobe to determine which audio is shortest.
  2. Convert each input to mono with the aformat filter.
  3. Apply the apad filter to the shorter input.
  4. Join multiple input streams into one multi-channel stream with the join filter.

Example:

ffmpeg -i input0 -i input1 -filter_complex "[0:a]aformat=channel_layouts=mono:sample_rates=44100,apad[a0];[1:a]aformat=channel_layouts=mono:sample_rates=44100[a1];[a0][a1]join=inputs=2:channel_layout=stereo[a]" -map "[a]" output

Also see FFmpeg Wiki: Audio Channels.

1
  • You are such a genius, thank you very much!!!
    – TW520
    Commented Aug 13, 2021 at 3:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .