diff --git a/src/video/actors.rs b/src/video/actors.rs index e45c77e..a884e69 100644 --- a/src/video/actors.rs +++ b/src/video/actors.rs @@ -633,14 +633,24 @@ impl Handler for PlaylistGenerator { // ffmpeg writes them next to the playlist (relative refs). let playlist_tmp = format!("{}.tmp", playlist_file); + let nvenc = !use_copy && crate::video::ffmpeg::is_nvenc_available().await; + let mut cmd = tokio::process::Command::new("ffmpeg"); - cmd.arg("-y").arg("-i").arg(&video_file); + cmd.arg("-y"); + if nvenc { + // Decode on NVDEC too. Without it a 4K source is decoded on + // the CPU and only the encode runs on the GPU: ~4.5x the CPU + // time. Frames come back to system memory, so the CPU + // filters (autorotate, scale) still apply, and ffmpeg falls + // back to software decode for codecs NVDEC lacks (ProRes). + cmd.arg("-hwaccel").arg("cuda"); + } + cmd.arg("-i").arg(&video_file); if use_copy { cmd.arg("-c:v").arg("copy"); cmd.arg("-c:a").arg("aac"); } else { - let nvenc = crate::video::ffmpeg::is_nvenc_available().await; if nvenc { // NVENC: no CRF, use VBR + target CQ. p1 = fastest // preset — prioritizes encoder throughput over bitrate