I remultiplex two multicasts into one using something like the following:
ffmpeg -i udp://239.1.1.1:5000 -i udp://239.1.1.2:5000 -map 0:v -map 0:a -map 1:a -codec copy -f mpegts udp://239.1.1.3:5000
If one of the multicasts disappears, the other quite quickly overruns its circular buffer, causing that input thread to quit as expected.
Unfortunately, the other circular buffer does not overrun since there is no input, and so ffmpeg hangs doing nothing.
Is it possible to configure ffmpeg in such a way that if any of the input threads exits, ffmpeg will stop?
Thanks in advance!
The answer is to add -xerror
to the options to force ffmpeg to stop and exit on error.
This can be combined with a -timeout
value for the input in question, in which case ffmpeg will quit as soon as no data arrives for that period of time.
Alternatively, circular buffer overrun can be used to trigger the error, but ffmpeg will not actually fail until the next read from the input buffer to the thread message queue, which requires the failed multicast to come back because the thread message queue will be blocked (depending on the fifo_size
and thread_queue_size
options specified).