Page 1 of 1

Switch rtsp stream in one container mp4

Posted: Wed Jan 30, 2019 10:31 pm
by jax2121
as I am looking for a way to switch the rtsp capture source via ffmpeg to a final file (mp4). In practice I would like to create a video surveillance system for two rooms where there are ipcam. Instead of recording two separated video streams, I would like a switch based on motion detection (with external software). I'm using the ffmpeg library (the one I know best) and I currently use the following capture commands:

Client room1:

ffmpeg -rtsp_transport tcp -i rtsp: // admin: [email protected]/av1_0 -an -f h254 -vcodec copy -y udp: //127.0.0.1: 20000? fifo_size = 100000
Room2 client:

ffmpeg -rtsp_transport tcp -i rtsp: // admin: [email protected]/av1_0 -an -f h254 -vcodec copy -y udp: //127.0.0.1: 20000? fifo_size = 100000
Server:

ffmpeg -i udp: //127.0.0.1: 20000 -an -f mp4 -vcodec copy -y out.mp4
The SERVER command is launched and waits for the two CLIENTS that are activated according to the motion detection of the external software.

The final out.mp4 video is generated correctly and the switch works. Very often, however, immediately after the switch the initial frames are corrupted and the lower part of the video is seen to flicker.

Is there a way to solve my problem?