Search code examples
audioffmpegmultilingual

ffmpeg: two videos side-by-side with audio1 lang=ger & audio2 lang=eng


I have two videos from two GoPro cameras. Both videos are rendered via ffmpeg side-by-side into a single video (left and right) and the audio is currently combined/mixed into two channels (stereo). I can hear both camera audio channels at the same time.

Two channels stereo:

ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[0:v][1:v]hstack=inputs=2[v]; [0:a][1:a]amerge[a]" -map "[v]" -map "[a]" -ac 2 side-by-side.mp4

audio from both videos mixed into a single file with 2 channels - mediainfo

Now I want to switch between the two audio channels (cam1 or cam2) while I'm playing the side-by-side video.

My first try: With four channels (without -ac 2 parameter):

ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[0:v][1:v]hstack=inputs=2[v]; [0:a][1:a]amerge[a]" -map "[v]" -map "[a]" side-by-side.mp4

audio from both videos mixed into a single file with 4 channels - mediainfo

But the most video players can't easily select the channels 1+2 or 3+4 while playing.

So I tried two languages:

ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[0:v][1:v]hstack=inputs=2[v]; [0:a][1:a]amerge[a]" -map "[v]" -map "[a]" -metadata:s:a:0 language=ger -metadata:s:a:1 language=eng side-by-side.mp4

audio from both videos mixed into a single file with 4 channels with languages - mediainfo

But that's wrong. I can only see german with 4 channels. How can I put channels 1+2 into german and channels 3+4 into english? Afterwards I should be able to use the multi language feature from most video players to switch the audio between cameras.

Thank you,
Miriam


Solution

  • This worked for me

    ffmpeg -i Video1.mp4 -i Video2.mp4 -filter_complex "[0:v][1:v]hstack=inputs=2[v]" -map [v] -map 0:a:0 -map 1:a:0 -metadata:s:a:0 language=ger -metadata:s:a:1 language=eng output.mp4
    

    With this you should be able to switch between the audios