tonhowtf/omniget · error
ffmpeg nao converteu a imagem
Error message
ffmpeg nao converteu a imagem {} What it means
ensure_jpeg converts a downloaded image (any format) to JPEG using ffmpeg at quality -q:v 2. If the conversion process exits non-zero, it throws 'ffmpeg nao converteu a imagem {idx}' (ffmpeg did not convert image idx), including the image index. This indicates ffmpeg could not decode the input image or write the JPEG output.
Solutions
- Validate the downloaded bytes are actually an image (content-type/magic bytes) before conversion.
- Log ffmpeg stderr around the call to see the exact decode failure.
- Add a pre-check on Content-Type and reject non-image responses before calling ensure_jpeg.
- Ensure ffmpeg has decoders for the source format, or convert via an alternative tool (e.g. ImageMagick).
Example fix
// before
let bytes = http_get(url).await?;
ensure_jpeg(&bytes_path, idx).await?;
// after
let resp = http_get(url).await?;
anyhow::ensure!(
resp.content_type().starts_with("image/"),
"URL nao retornou uma imagem"
);
ensure_jpeg(&bytes_path, idx).await?; Defensive patterns
Strategy: validation
Validate before calling
// Rust
async fn looks_like_image(bytes: &[u8]) -> bool {
bytes.starts_with(b"\xFF\xD8") // jpeg
|| bytes.starts_with(b"\x89PNG")
|| bytes.starts_with(b"GIF8")
} Type guard
fn is_image_response(ct: &str) -> bool { ct.starts_with("image/") } Try / catch
match ensure_jpeg(&input, idx).await {
Err(e) if e.to_string().contains("nao converteu a imagem") => {
eprintln!("imagem {idx} invalida ou formato sem decoder");
}
r => r?,
} Prevention
- Validate Content-Type and magic bytes before feeding downloads to ffmpeg
- Handle HTTP error pages/rate limits before treating the body as an image
- Ensure ffmpeg has decoders for expected formats (avoid SVG/HEIC without support)
- Check for zero-byte/truncated downloads before conversion
When it happens
Trigger: Calling download() with a slide image whose format ffmpeg can't decode (corrupt download, HTML error page saved as image, unsupported/proprietary format), or an output path that can't be written.
Common situations: Remote URL returns an error page or rate-limits and the body is fed to ffmpeg; SVG/HEIC input without decoder support; zero-byte or truncated downloads; disk full.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/f3783b84cde594e0.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/slides.rs:77
/// Converte qualquer imagem em JPEG pelo ffmpeg (webp/png escapam do DCTDecode).
pub(crate) async fn ensure_jpeg(data: Vec<u8>, work: &Path, idx: usize) -> anyhow::Result<Vec<u8>> {
if super::jpeg_pdf::is_jpeg(&data) {
return Ok(data);
}
let ffmpeg = crate::core::dependencies::ensure_ffmpeg().await?;
let input = work.join(format!("{}.img", idx));
let output = work.join(format!("{}.jpg", idx));
tokio::fs::write(&input, &data).await?;
let o = crate::core::process::command(&ffmpeg)
.args(["-y", "-hide_banner", "-loglevel", "error", "-i"])
.arg(&input)
.args(["-q:v", "2"])
.arg(&output)
.output()
.await?;
if !o.status.success() {
return Err(anyhow!("ffmpeg nao converteu a imagem {}", idx));
}
Ok(tokio::fs::read(&output).await?)
}
pub async fn download(
url: &str,
dest_dir: &str,
progress: super::ProgressFn,
) -> anyhow::Result<SlidesResult> {
if !url.contains("slideshare.net") {
return Err(anyhow!("cole um link do slideshare.net"));
}
let client = super::client()?;
let html = client
.get(url)
.send()
.await?
.error_for_status()?View on GitHub (pinned to 8600b91f42)