[FFmpeg-user] change inputs or mapping while recording

Stephan Monecke stephanmonecke at gmail.com
Fri Apr 24 11:50:23 EEST 2020


I have two identical rtsp video-sources stream1, stream2 and an audio
source. I currently merge stream1 with the audio for a rtmp-server


/usr/bin/ffmpeg                    \
    -i "$stream1"                  \
    -itsoffset $AUDIOVIDEOOFFSET   \
    -f pulse                       \
    -i default                     \
    -vcodec copy                   \
    -map 0:v -map 1:a              \
    -f flv "rtmp://streamingserver"

I would now like to add stream2 as second video input and switch
between stream1 and stream2 back and forth without interrupting the
audio. Both streams are identical / come from identical cameras.

Is there any sane way to do this with ffmpeg? Or how would you
recommend doing it?

Just stopping the process and restarting it using stream2 instead of
stream1 with some timeoff on the rtmp-server should work but would
result in several seconds outage on the stream and is the current the
worst case scenario I would like to improve.

Thanks a ton!


P.s. Maybe some additional visual information: Since students
currently can't attend, we want to record university
blackboard-lectures (math) but have an array of blackboards that each
get its own camera. Hence we try to keep the audio stream running
while switching the input source when the lecturer switches the

More information about the ffmpeg-user mailing list