ffmpeghttp-live-streaming

ffmpeg HTTP LIVE STREAMING remove old segments


Hello i Have a Live HTTP stream input for ffmpeg i want to create HLS streaming im using ffmpeg to do this

ffmpeg -i http://127.0.0.1:4242/bysid/7275 -map 0 -codec:v libx264 -codec:a copy -f ssegment -segment_list playlist.m3u8 -segment_list_type hls -segment_list_size 10 -segment_list_flags +live -segment_time 10 out%03d.ts

i works fine i just want to delete the old segmens that are not shown in playlist.m3u8

segment_list_size 10

this will keep the last 10 in the playlist file i want to keep only these files on hard disk


Solution

  • You can use the recently added option to the HLS segmenter:

    -hls_flags delete_segments
    

    You will need to change your command to use the HLS segmenter rather than the stream segmenter by using -f hls instead of -f ssegment.

    I've been using this option and it doesn't do exactly what you request, but rather it's implemented to be compliant with the HLS spec. See the ffmpeg documentation for more information: https://www.ffmpeg.org/ffmpeg-formats.html