Jump to content
Sign in to follow this  
Tom28pl

ffmpeg - how to continue recording after connectiont timeout

Recommended Posts

Hi

 

I'm using Linux ffmpeg to capture stream with RTSP cameras.

It is working excellent since few years with below commands:

 

ffmpeg -rtsp_transport tcp -progress /media/stats.txt -i rtsp://192.168.1.220:554/live/h264/ch0 -c:v copy -c:a copy -strict 1 -map 0 -f segment -strftime 1 -segment_time 1800 /media/cam2_%d_%m_%Y_%H_%M_%S.mkv

 

The problem is that ffmpeg will not restart capturing after connection was dropped.

 

So I'm checking the progress file (stats.txt) with another script:

 

while true

do

frames_1=`tail -n 11 /media/stats.txt | grep "frame=" | awk -F "=" '{print $2}'`

sleep 10 // wait 10 seconds

frames_2=`tail -n 11 /media/stats.txt | grep "frame=" | awk -F "=" '{print $2}'`

.....

 

if [ $frames_2 -eq $frames_1 ]; then

 

/// here restarting the ffmpeg

// so if the frame number is the same as it was 10 seconds ago, I'm restarting ffmpeg.

 

The problem is that this is giving false alarms.

For few cameras, when light to the camera or scene changed a lot or for example when camera moves from day to light mode, in the stats.txt the frame number is not changing, so $frames_1 and $frames_2 has the same value which is restarting the ffmpeg. After that, I'm loosing about 5-8 seconds of video.

 

So video is working fine.

I tried many things, different cameras (I-frame rate, CBR, VBR) - always the same.

Now I added "-r 25" to the ffmpeg, but I'm trying to figure out why this is working like this.

Few days ago I mounted SANYO VCC-HD2500P which is great....and has the same problem.

 

I'm thinking about some settings to ffmpeg like vsync or etc.

any suggestions?

 

thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×