The next point on our MUSTFIX-list of the mediastreamvalidator is:

If EXT-X-INDEPENDENT-SEGMENTS is not in master playlist, then you MUST use the EXT-X-INDEPENDENT-SEGMENTS tag in all video media playlists

Independent Segments

What does this mean? This is the definition from the RFC8216:

The EXT-X-INDEPENDENT-SEGMENTS tag indicates that all media samples in a Media Segment can be decoded without information from other segments. It applies to every Media Segment in the Playlist.

FFmpeg has a flag called “independent_segments” that can be used for this.

Add the #EXT-X-INDEPENDENT-SEGMENTS to playlists that has video segments and when all the segments of that playlist are guaranteed to start with a Key frame.

Since we parametrized FFmpeg in the Part 2 of this series of articles that every second is a keyframe and the segmentation is made exactly every 4 seconds, we know for a 100% that the first frame of a segment is a keyframe.

FFmpeg command

Ok after adding this parameter to the command it looks now like:

./ffmpeg -listen 1 -i rtmp:// \
    -filter_complex "[v:0]split=2[vtemp001][vout002];[vtemp001]scale=w=960:h=540[vout001]" \
    -preset veryfast -g 25 -sc_threshold 0 \
    -map [vout001] -c:v:0 libx264 -b:v:0 2000k \
    -map [vout002] -c:v:1 libx264 -b:v:1 6000k \
    -map a:0 -map a:0 -c:a aac -b:a 128k -ac 2 \
    -f hls -hls_time 4 -hls_playlist_type event -hls_flags independent_segments \
    -master_pl_name master.m3u8 \
    -hls_segment_filename stream_%v/data%06d.ts \
    -use_localtime_mkdir 1 \
    -var_stream_map "v:0,a:0 v:1,a:1" stream_%v.m3u8

And again after a new validation this message is fixed.