I need to combine one video and 2 stereo audio streams from a srt input to send a one video and 4.0 audio stream to the decklink output.
From:
Stream #0:0[0x100]: Video: h264 , 90k tbn ...
Stream #0:1[0x101]: Audio: aac (LC) ...
Stream #0:2[0x102]: Audio: aac (LC) ...
To
Stream #0:0: Video: wrapped_avframe, uyvy422(tv, top coded first (swapped)) ...
Stream #0:1: Audio: pcm_s16le, 48000 Hz, 7.1, s16,...
The audio 1 and 2 from stream #0:1 and audio 3 and 4 from from #0:2
It works fine with the join filter:
ffmpeg -i srt://:25000?mode=listener -map 0:v -filter_complex "[0:a:0][0:a:1]join=inputs=2:channel_layout=3.1:map=0.0-FL |0.1-FR|1.0-FC|1.1-LFE[a]" -map "[a]" -f decklink -pix_fmt uyvy422 -s 1920x1080 -r 25000/1000 -c:a pcm_s16le -ac 8 -ar 48000 -format_code Hi50 "DeckLink Duo (1)"
Also with the merge filter:
ffmpeg -i srt://:25000?mode=listener -filter_complex "[0:a:0][0:a:1][0:a:1]amerge=inputs=3" -f decklink -pix_fmt uyvy422 - s 1920x1080 -r 25000/1000 -c:a pcm_s16le -ac 8 -ar 48000 -format_code Hi50 "DeckLink Duo (1)"
The problem is that sometimes I only receive a single audio stream on the input. In this case the two options fails because the second stream 0:a:1 does not exist.
Is there a way to do one FFmpeg command compatible with 2x Stereo to 4.0 conversion and 1x Stereo to 2.0 (or more) conversion?
It is for an application that’s work unattended.