[FFmpeg-user] Fill gaps among captured RTSP streams

Wu-bin Zhen vvubin at gmail.com
Tue Apr 12 20:06:26 CEST 2016

I have an IP encoder with a built-in RTSP server, and the command "ffmpeg
-rtsp_transport tcp -i rtsp://<ip_address>/live.sdp -c copy
captured_file.mkv" works perfectly without any issues.

The problem is that the IP encoder could be rebooted anytime, which
interrupts the ffmpeg capturing. I used a shell script to restart the
ffmpeg capturing infinitely so nothing will be lost.

The only issue is to fill the gap between two partial video files. I
recorded the ffmpeg start timestamp every time it restarts, use it to
generate an empty video block with the duration (2nd ffmpeg timestamp - 1st
ffmpeg timestamp + 1st RTSP video duration), and use concat to merge 1st
partial video + generated_gap + 2nd partial video.

This method works, but it's not accurate because of the several seconds of
initializing and buffering. Is there a way to get and store the timestamp
when the first frame is being written? I googled some people saying to use
pts/dts from RTCP, but couldn't find an exact way to archive it with ffmpeg.

Please advise how to fill the gaps among partial RTSP streams precisely
with ffmpeg.


More information about the ffmpeg-user mailing list