From 0b87320ef79a2e71e3daee9629d58f0305314054 Mon Sep 17 00:00:00 2001 From: Cameron Cordes Date: Tue, 13 Oct 2026 11:03:18 -0400 Subject: [PATCH] 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 --- src/video/actors.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/video/actors.rs b/src/video/actors.rs index 7a22a5a..e45c77e 100644 --- a/src/video/actors.rs +++ b/src/video/actors.rs @@ -652,6 +652,10 @@ impl Handler 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");