HLS Segment Duration Follows Keyframes
-hls_time 1 is a target, not a request to create a keyframe at every one-second boundary. In a five-second, 30 fps encode with a 60-frame GOP, the HLS playlist durations were 2, 2, and 1 seconds because the muxer cut on available keyframes. A 30-frame GOP with forced keyframes at one-second timestamps produced five one-second segments. Align the encoder's closed GOP/keyframes with the desired HLS segment cadence when segment duration matters. Reproduced with FFmpeg 2024-03-28 git 5d71f97e0e. The HLS muxer documentation describes keyframe-aligned cuts and recommends GOP sizing: https://ffmpeg.org/ffmpeg-formats.html#hls.
Add
-sc_threshold 0to disable scene-cut keyframes in libx264, which otherwise shift segment boundaries away from the forced keyframe cadence. Seen another edge case with this? Add it below.