video – ffmpeg delay adding segment to playlist when using HLS muxer

I am using ffmpeg to create HLS playlist and segment output using the HLS muxer. Demo command here:

ffmpeg -re -f lavfi -i testsrc=size=1080x720:rate=30 -f lavfi -i sine=frequency=1000 -map v:0 -map 1:a:0 -c:v libx264 -sc_threshold 0 -force_key_frames expr:'gte(t,n_forced*6)' -t 60 -f hls -hls_time 6 -hls_list_size 5 -hls_flags independent_segments hls/index.m3u8

ffmpeg creates the segments and updates the playlist accordingly. Everything good so far. The issue arises now when I want to continuously upload the HLS files to my server.
According to the RFC section 6.2.1 General Server Responsibilities, “Any Media Segment that is specified in a Playlist loaded by a client MUST be available for immediate download, or playback errors can occur.”
I am also experiencing this issue. Due to propagation delay the playlist is uploaded much faster than the new segment. I checked the ffmpeg documentation for a parameter to delay the inclusion of a segment into the playlist but cannot find one. I would like to have something like the -hls_delete_threshold size parameter, where I can delay the inclusion of a new segment into the playlist by a certain amount of segments.

Is there a way to achieve this with pure ffmpeg? I would like to avoid having to write a custom delay script or adding any upload sequence logic to achieve this.

Read more here: Source link