[FFmpeg-user] FFMPEG HLS Resume, keeping history?

Benjamin Smith yesthatguy at gmail.com
Thu Mar 17 17:59:51 EET 2022


I have ffmpeg streaming video cameras to HLS. Intention is to keep a long
history of video footage to "scroll back" should a security incident occur.

It's working so long as the ffmpeg encoding process is never interrupted,
but, anytime anything happens to the ffmpeg encoder, all the history gets
lost in the browser, even when the video files are verified to be present.

In the below incantation:

$START is the number of the last segment found, +1.
$CAMERA is the name of the camera. EG: "SouthView"

The idea is that if the encoding script is restarted (EG: after a system
reboot) that it should continue encoding where the previous instance of the
script left off.  The new ffmpeg instance does start creating the next .ts
files starting at $START and doesn't overwrite the previous ones.

HOWEVER, I'm aware of at least two issues:

1) The .m3u8 file generated by the new instance doesn't refer to the
previous .ts files, so access to them is lost, and
2) ffmpeg no longer deletes the older .ts files as they age out.

ffmpeg \

 -i "rtsp://$IP//user=admin&password=&channel=1&stream=1" \

 -vf scale=1280x720 \

 -c:v libx264 \

 -crf 21 -preset slow \

 -an \

 -framerate 10 \

 -f hls \

 -truncate 0 \

 -start_number $START \

 -segment_time 60 \

 -hls_list_size 1440 \

 -hls_flags delete_segments \

 -hls_delete_threshold 1 \

 /ngpool/video/www/$CAMERA.stream.m3u8;

I've verified that, if I take the previous .m3u8 file and merge it with the
new one, that the previous history is accessible from the browser - so the
problem is solely that the new ffmpeg instance is writing a .m3u8 file that
doesn't refer to the previous .ts files.

Is there an option to tell ffmpeg to continue updating the .m3u8 file and
consider the already existing .ts files so that access to the video camera
history from the browser is preserved?

Thanks


More information about the ffmpeg-user mailing list