tonhowtf/omniget · error · anyhow::Error
Failed to convert thumbnail to JPEG
Error message
Failed to convert thumbnail to JPEG
What it means
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.
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.
Example fix
// before
let _ = std::fs::remove_file(&jpg_path);
return Err(anyhow!("Failed to convert thumbnail to JPEG"));
// after
let _ = std::fs::remove_file(&jpg_path);
let stderr = String::from_utf8_lossy(&convert_output.stderr).to_string();
anyhow::bail!("Failed to convert thumbnail to JPEG: {stderr}"); Defensive patterns
Strategy: fallback
Validate before calling
// Verify ffmpeg exists before spawning
if which::which("ffmpeg").is_err() {
log::warn!("ffmpeg not found; skipping jpeg conversion");
return Ok(thumb_path);
} Try / catch
match convert_result {
Ok(status) if status.success() => return Ok(jpg_path),
Ok(status) => log::warn!("ffmpeg exited {status} converting thumbnail"),
Err(e) => log::warn!("ffmpeg spawn failed: {e}"),
}
Ok(thumb_path) // fall back to original thumbnail Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/afd2887ef3498ccc.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/ffmpeg.rs:624
"-y",
"-i",
&thumb_path.to_string_lossy(),
&jpg_path.to_string_lossy(),
])
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status()
.await;
let _ = std::fs::remove_file(&thumb_path);
if let Ok(status) = convert_result {
if status.success() {
return Ok(jpg_path);
}
}
let _ = std::fs::remove_file(&jpg_path);
return Err(anyhow!("Failed to convert thumbnail to JPEG"));
}
Ok(thumb_path)
}
fn parse_out_time_us(line: &str) -> Option<u64> {
let line = line.trim();
if let Some(val) = line.strip_prefix("out_time_us=") {
return val.trim().parse::<u64>().ok();
}
if let Some(val) = line.strip_prefix("out_time_ms=") {
return val.trim().parse::<u64>().ok().map(|ms| ms * 1000);
}
None
}
View on GitHub (pinned to 8600b91f42)