{"record":{"id":"a69bfee540daa44c","repo":"tonhowtf/omniget","slug":"ffmpeg-nao-conseguiu-converter-o-audio","errorCode":null,"errorMessage":"ffmpeg nao conseguiu converter o audio: {}","messagePattern":"ffmpeg nao conseguiu converter o audio: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/whisper.rs","lineNumber":280,"sourceCode":"    pub srt_path: String,\n    pub vtt_path: String,\n    pub txt_path: String,\n    pub seconds: f64,\n}\n\n/// Áudio como o whisper.cpp quer: WAV 16 kHz mono PCM16.\nasync fn to_wav16k(input: &Path) -> anyhow::Result<PathBuf> {\n    let ffmpeg = crate::core::dependencies::ensure_ffmpeg().await?;\n    let out = super::temp_dir().join(format!(\"whisper-{}.wav\", uuid::Uuid::new_v4()));\n    let output = crate::core::process::command(&ffmpeg)\n        .args([\"-y\", \"-hide_banner\", \"-loglevel\", \"error\", \"-i\"])\n        .arg(input)\n        .args([\"-vn\", \"-ac\", \"1\", \"-ar\", \"16000\", \"-c:a\", \"pcm_s16le\"])\n        .arg(&out)\n        .output()\n        .await?;\n    if !output.status.success() {\n        return Err(anyhow!(\n            \"ffmpeg nao conseguiu converter o audio: {}\",\n            String::from_utf8_lossy(&output.stderr).trim()\n        ));\n    }\n    Ok(out)\n}\n\nfn parse_whisper_json(text: &str) -> anyhow::Result<(String, Vec<Cue>)> {\n    let json: serde_json::Value = serde_json::from_str(text)?;\n    let language = json[\"result\"][\"language\"]\n        .as_str()\n        .unwrap_or(\"\")\n        .to_string();\n    let mut cues = Vec::new();\n    if let Some(items) = json[\"transcription\"].as_array() {\n        for it in items {\n            let from = it[\"offsets\"][\"from\"].as_u64().unwrap_or(0);\n            let to = it[\"offsets\"][\"to\"].as_u64().unwrap_or(from);","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/whisper.rs#L262-L298","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nlet result = whisper::transcribe(opts, progress).await?;\n\n// after\nmatch whisper::transcribe(opts.clone(), progress.clone()).await {\n    Ok(result) => result,\n    Err(e) if e.to_string().contains(\"ffmpeg\") => {\n        eprintln!(\"audio unreadable, check with ffprobe: {}\", opts.input);\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","handlingStrategy":"validation","validationCode":"// require a readable file with an audio stream before transcribing\nlet ok = std::path::Path::new(&opts.input).is_file();\nif !ok { eprintln!(\"not a readable file: {}\", opts.input); }\n// optionally pre-check with ffprobe for an audio stream","typeGuard":null,"tryCatchPattern":"match whisper::transcribe(opts, progress).await {\n    Err(e) if e.to_string().contains(\"ffmpeg nao conseguiu\") => {\n        // surface ffmpeg's stderr (embedded in e) to the user\n    }\n    other => other?,\n}","preventionTips":["Verify input media has an audio stream (ffprobe) before transcribing.","Ship/require a full ffmpeg build with common decoders.","Avoid DRM-protected inputs."],"tags":["ffmpeg","audio","external-process","transcription"],"backgroundTag":"command-failed","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}