{"record":{"id":"afd2887ef3498ccc","repo":"tonhowtf/omniget","slug":"failed-to-convert-thumbnail-to-jpeg","errorCode":null,"errorMessage":"Failed to convert thumbnail to JPEG","messagePattern":"Failed to convert thumbnail to JPEG","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/ffmpeg.rs","lineNumber":624,"sourceCode":"                \"-y\",\n                \"-i\",\n                &thumb_path.to_string_lossy(),\n                &jpg_path.to_string_lossy(),\n            ])\n            .stdout(std::process::Stdio::null())\n            .stderr(std::process::Stdio::null())\n            .status()\n            .await;\n\n        let _ = std::fs::remove_file(&thumb_path);\n\n        if let Ok(status) = convert_result {\n            if status.success() {\n                return Ok(jpg_path);\n            }\n        }\n        let _ = std::fs::remove_file(&jpg_path);\n        return Err(anyhow!(\"Failed to convert thumbnail to JPEG\"));\n    }\n\n    Ok(thumb_path)\n}\n\nfn parse_out_time_us(line: &str) -> Option<u64> {\n    let line = line.trim();\n    if let Some(val) = line.strip_prefix(\"out_time_us=\") {\n        return val.trim().parse::<u64>().ok();\n    }\n    if let Some(val) = line.strip_prefix(\"out_time_ms=\") {\n        return val.trim().parse::<u64>().ok().map(|ms| ms * 1000);\n    }\n    None\n}\n","sourceCodeStart":606,"sourceCodeEnd":640,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/ffmpeg.rs#L606-L640","documentation":"If the downloaded thumbnail is WebP/AVIF or another format ffmpeg cannot transcode to JPEG for mp4 cover art, the spawned ffmpeg conversion exits non-zero and the temp jpg is removed, then this generic error is thrown. The message carries no ffmpeg stderr, so the root cause must be found elsewhere.","triggerScenarios":"ffmpeg binary fails or is missing; the image format isn't decodable (e.g., AVIF); the source thumbnail file was removed before conversion; ffmpeg argument issue.","commonSituations":"ffmpeg not installed or not on PATH; YouTube/CDN now serving WebP thumbnails with a JPEG content-type fallback missing; corrupt or truncated image bytes.","solutions":["Verify ffmpeg is installed and on PATH (ffmpeg -version).","Capture and log ffmpeg stderr in convert_result to see the real decode error.","Log the actual content-type/extension; some hosts send image/webp with an .jpg URL — detect via magic bytes instead of content-type.","Fall back to embedding the original thumbnail file if ffmpeg conversion fails."],"exampleFix":"// before\nlet _ = std::fs::remove_file(&jpg_path);\nreturn Err(anyhow!(\"Failed to convert thumbnail to JPEG\"));\n// after\nlet _ = std::fs::remove_file(&jpg_path);\nlet stderr = String::from_utf8_lossy(&convert_output.stderr).to_string();\nanyhow::bail!(\"Failed to convert thumbnail to JPEG: {stderr}\");","handlingStrategy":"fallback","validationCode":"// Verify ffmpeg exists before spawning\nif which::which(\"ffmpeg\").is_err() {\n    log::warn!(\"ffmpeg not found; skipping jpeg conversion\");\n    return Ok(thumb_path);\n}","typeGuard":null,"tryCatchPattern":"match convert_result {\n    Ok(status) if status.success() => return Ok(jpg_path),\n    Ok(status) => log::warn!(\"ffmpeg exited {status} converting thumbnail\"),\n    Err(e) => log::warn!(\"ffmpeg spawn failed: {e}\"),\n}\nOk(thumb_path) // fall back to original thumbnail","preventionTips":["Bundle or verify ffmpeg at app startup, not at embed time.","Detect image format from magic bytes (WebP/AVIF) rather than content-type alone.","Log ffmpeg stderr to make conversion failures diagnosable.","Keep the original thumbnail as a fallback input for embedding."],"tags":["ffmpeg","thumbnail","image-conversion","subprocess"],"backgroundTag":"ffmpeg-conversion-failed","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}