tonhowtf/omniget · error
ffmpeg nao conseguiu converter o audio
Error message
ffmpeg nao conseguiu converter o audio: {} What it means
to_wav16k() shells out to ffmpeg to convert input audio to 16 kHz mono PCM16 WAV, which is what whisper.cpp requires. When ffmpeg exits nonzero, the error embeds ffmpeg's trimmed stderr, so the actual cause (bad codec, unreadable file, no audio stream) is in the message suffix.
Solutions
- Read the ffmpeg stderr in the error message — it names the failing stream/codec.
- Verify the input is a media file with an audio stream (`ffprobe <file>`).
- Install a full ffmpeg build with common codecs if the bundled one is missing decoders.
- Test the conversion manually: ffmpeg -y -i input -vn -ac 1 -ar 16000 -c:a pcm_s16le out.wav.
Example fix
// before
let result = whisper::transcribe(opts, progress).await?;
// after
match whisper::transcribe(opts.clone(), progress.clone()).await {
Ok(result) => result,
Err(e) if e.to_string().contains("ffmpeg") => {
eprintln!("audio unreadable, check with ffprobe: {}", opts.input);
return Err(e);
}
Err(e) => return Err(e),
} Defensive patterns
Strategy: validation
Validate before calling
// require a readable file with an audio stream before transcribing
let ok = std::path::Path::new(&opts.input).is_file();
if !ok { eprintln!("not a readable file: {}", opts.input); }
// optionally pre-check with ffprobe for an audio stream Try / catch
match whisper::transcribe(opts, progress).await {
Err(e) if e.to_string().contains("ffmpeg nao conseguiu") => {
// surface ffmpeg's stderr (embedded in e) to the user
}
other => other?,
} Prevention
- Verify input media has an audio stream (ffprobe) before transcribing.
- Ship/require a full ffmpeg build with common decoders.
- Avoid DRM-protected inputs.
When it happens
Trigger: Calling transcribe() (which calls to_wav16k) with an input file ffmpeg cannot decode: unsupported container/codec, file that is video-only or image, DRM-protected media, or a truncated/corrupt audio file.
Common situations: Passing an .m4b audiobook with a codec the bundled ffmpeg lacks; a path with special characters mishandled; the file has no audio stream (-vn drops video leaving nothing); protected iTunes/DRM media.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/a69bfee540daa44c.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/whisper.rs:280
pub srt_path: String,
pub vtt_path: String,
pub txt_path: String,
pub seconds: f64,
}
/// Áudio como o whisper.cpp quer: WAV 16 kHz mono PCM16.
async fn to_wav16k(input: &Path) -> anyhow::Result<PathBuf> {
let ffmpeg = crate::core::dependencies::ensure_ffmpeg().await?;
let out = super::temp_dir().join(format!("whisper-{}.wav", uuid::Uuid::new_v4()));
let output = crate::core::process::command(&ffmpeg)
.args(["-y", "-hide_banner", "-loglevel", "error", "-i"])
.arg(input)
.args(["-vn", "-ac", "1", "-ar", "16000", "-c:a", "pcm_s16le"])
.arg(&out)
.output()
.await?;
if !output.status.success() {
return Err(anyhow!(
"ffmpeg nao conseguiu converter o audio: {}",
String::from_utf8_lossy(&output.stderr).trim()
));
}
Ok(out)
}
fn parse_whisper_json(text: &str) -> anyhow::Result<(String, Vec<Cue>)> {
let json: serde_json::Value = serde_json::from_str(text)?;
let language = json["result"]["language"]
.as_str()
.unwrap_or("")
.to_string();
let mut cues = Vec::new();
if let Some(items) = json["transcription"].as_array() {
for it in items {
let from = it["offsets"]["from"].as_u64().unwrap_or(0);
let to = it["offsets"]["to"].as_u64().unwrap_or(from);View on GitHub (pinned to 8600b91f42)