ffmpeg HTTP LIVE STREAMING remove old segments

35,383

Solution 1

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

Solution 2

USE

-segment_wrap 10

for wrap and rewrite segment files

Share:
35,383

Related videos on Youtube

k961
Author by

k961

Started From HTML, js .. .. .. trying to get into the linux kernel 6__9

Updated on July 09, 2022

Comments

  • k961
    k961 almost 2 years

    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

  • Dr.jacky
    Dr.jacky almost 9 years
    I replaced -f segment to -f hls, but I got error: Could not write header for output file #0 (incorrect codec parameters ?): Invali d argument
  • super_ylam
    super_ylam about 3 years
    An example using -f hls and also -hls_flags delete_segments: ffmpeg -v verbose -i "rtsp://admin:[email protected]:554/cam/realmonitor?channel=1‌​&subtype=0" -vf scale=1920:1080 -vcodec libx264 -r 25 -b:v 1000000 -crf 31 -an -sc_threshold 0 -f hls -hls_time 5 -hls_list_size 5 -hls_flags delete_segments stream.m3u8