I am trying to create a video mosaic using ffmpeg. My complete command looks like this:
ffmpeg -i rtmp://localhost:1935/live/output1 -i rtmp://localhost:1935/live/output2 -i rtmp://localhost:1935/live/output3 -i rtmp://localhost:1935/live/output4 -filter_complex "nullsrc=size=640x480 [base]; [0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft]; [1:v] setpts=PTS-STARTPTS, scale=320x240 [upperright]; [2:v] setpts=PTS-STARTPTS, scale=320x240 [lowerleft]; [3:v] setpts=PTS-STARTPTS, scale=320x240 [lowerright]; [base][upperleft] overlay=shortest=0 [tmp1]; [tmp1][upperright] overlay=shortest=0:x=320 [tmp2]; [tmp2][lowerleft] overlay=shortest=0:y=240 [tmp3]; [tmp3][lowerright] overlay=shortest=0:x=320:y=240" -filter_complex amix=inputs=4:duration=longest -c:a aac -strict -2 -ar 44100 -c:v libx264 -f flv rtmp://localhost:1935/live/myStream
This works well while all 4 input streams are running. But say that one of the threads crashes for a while and returns online. The output continues to show this thread as stuck (paused). Since after terminating the stream (AVERROR_EOF) ffmpeg stops trying to get more packets from the input stream. I have to restart the ffmpeg process in order to return everything in order to work again.
Is there a way to add retry logic here that tells ffmpeg to keep trying to process all the source sources while the process is alive?
source share