From 46d1a18378cd2db623c54a7a3196f9b31ef3cfcc Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Fri, 2 Jan 2026 20:25:32 -0500 Subject: [PATCH] feat: add automatic GPU detection for hardware encoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implemented automatic hardware encoder selection when hardware acceleration is set to 'auto'. The system now detects the GPU vendor and automatically selects the appropriate encoder: - NVIDIA GPU → nvenc (h264_nvenc, hevc_nvenc, av1_nvenc) - AMD GPU → amf (h264_amf, hevc_amf, av1_amf) - Intel GPU → qsv (h264_qsv, hevc_qsv, av1_qsv) - No compatible GPU → none (software encoding) Detection uses the existing sysinfo.Detect() function which identifies GPUs via nvidia-smi, lspci, wmic, and system_profiler depending on the platform. Location: main.go line 5867-5883 --- main.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/main.go b/main.go index 4fecbab..3e79bc2 100644 --- a/main.go +++ b/main.go @@ -5862,6 +5862,26 @@ func buildFFmpegCommandFromJob(job *queue.Job) string { // Determine codec (simplified) codec := "libx264" hardwareAccel, _ := cfg["hardwareAccel"].(string) + + // Resolve "auto" to actual GPU vendor + if hardwareAccel == "auto" { + hwInfo := sysinfo.Detect() + switch hwInfo.GPUVendor { + case "nvidia": + hardwareAccel = "nvenc" + logging.Debug(logging.CatFFMPEG, "auto hardware accel resolved to nvenc (detected NVIDIA GPU)") + case "amd": + hardwareAccel = "amf" + logging.Debug(logging.CatFFMPEG, "auto hardware accel resolved to amf (detected AMD GPU)") + case "intel": + hardwareAccel = "qsv" + logging.Debug(logging.CatFFMPEG, "auto hardware accel resolved to qsv (detected Intel GPU)") + default: + hardwareAccel = "none" + logging.Debug(logging.CatFFMPEG, "auto hardware accel resolved to none (no compatible GPU detected)") + } + } + switch { case videoCodec == "H.265" && hardwareAccel == "nvenc": codec = "hevc_nvenc"