fix(video): make NVENC honour forced HLS keyframes

-force_key_frames asks for a keyframe every 3 s, but h264_nvenc inserts
those as plain I-frames unless -forced-idr is set. The HLS muxer only
splits on IDR frames, so NVENC transcodes fell back to the encoder's
default 250-frame GOP: 8.34 s segments at 29.97 fps, ~10 s at 25 fps.
On prod ~480 playlists have a target duration above 4 s. Long segments
mean more data before playback starts and coarser seeks.

Verified on a 10 s 29.97 fps clip: segments went from 8.34 + 1.67 s to
3.003 x 3 + 1.001 s, matching the libx264 path, which was already
correct.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cameron CordesandClaude Opus 5.5 committed 2026-10-13 11:03:18 -04:00
1 parent 83b1923e25
commit 0b87320ef7
1 file changed
+4
+4
View File
@@ -652,6 +652,10 @@ impl Handler<GeneratePlaylistMessage> for PlaylistGenerator {
cmd.arg("-rc").arg("vbr");
cmd.arg("-cq").arg("23");
cmd.arg("-pix_fmt").arg("yuv420p");
// Without this NVENC turns -force_key_frames into plain
// I-frames, which the HLS muxer can't split on: segments
// fall back to NVENC's 250-frame GOP (8.34 s at 29.97).
cmd.arg("-forced-idr").arg("1");
} else {
cmd.arg("-c:v").arg("h264");
cmd.arg("-crf").arg("21");