{"record":{"id":"e8e75158f862f244","repo":"tonhowtf/omniget","slug":"n-o-consegui-medir-o-loudness","errorCode":null,"errorMessage":"não consegui medir o loudness: {}","messagePattern":"não consegui medir o loudness: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/audio_clean.rs","lineNumber":166,"sourceCode":"    pub error: Option<String>,\n}\n\n#[derive(Debug, Clone, Serialize)]\npub struct CleanResult {\n    pub items: Vec<CleanItem>,\n}\n\nasync fn measure(ffmpeg: &Path, input: &Path, filter: &str) -> anyhow::Result<Loudness> {\n    let out = crate::core::process::command(ffmpeg)\n        .args([\"-hide_banner\", \"-nostats\", \"-i\"])\n        .arg(input)\n        .args([\"-af\", filter, \"-f\", \"null\", \"-\"])\n        .output()\n        .await\n        .map_err(|e| anyhow!(\"ffmpeg nao iniciou: {}\", e))?;\n    let stderr = String::from_utf8_lossy(&out.stderr).to_string();\n    parse_measure(&stderr).ok_or_else(|| {\n        anyhow!(\n            \"não consegui medir o loudness: {}\",\n            stderr.lines().last().unwrap_or(\"\").trim()\n        )\n    })\n}\n\nasync fn clean_one(ffmpeg: &Path, opts: &CleanOptions, input: &str) -> anyhow::Result<CleanItem> {\n    let inp = Path::new(input);\n    let probe = crate::core::ffmpeg::probe(inp).await?;\n    if !probe.streams.iter().any(|s| s.codec_type == \"audio\") {\n        return Err(anyhow!(\"o arquivo não tem trilha de áudio\"));\n    }\n    let has_video = probe\n        .streams\n        .iter()\n        .any(|s| s.codec_type == \"video\" && s.codec_name != \"mjpeg\" && s.codec_name != \"png\");\n    let (target_i, target_tp) = target_for(&opts.target);\n","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/audio_clean.rs#L148-L184","documentation":"After ffmpeg runs the loudness analysis, measure parses the loudness values from stderr with parse_measure; if parsing yields nothing, it errors with \"não consegui medir o loudness: {last stderr line}\". This means ffmpeg ran but did not produce the expected loudness report output.","triggerScenarios":"measure called with an input ffmpeg cannot decode or that has no audio stream: the ebur128/loudnorm filter prints no measured values, unsupported codec, or ffmpeg aborted before printing the summary line.","commonSituations":"Input file with no audio track (should be caught earlier but can slip through odd streams); corrupt/truncated media; ffmpeg version whose stderr format differs from what parse_measure expects; locale/encoding issues in stderr.","solutions":["Inspect the stderr tail included in the message to see why ffmpeg produced no measurement","Ensure the input has a decodable audio stream before measuring (ffprobe check)","Update parse_measure to match the loudness summary format of the installed ffmpeg version","Run ffmpeg manually with the same -af filter to reproduce and compare output"],"exampleFix":"// before\nparse_measure(&stderr).ok_or_else(|| {\n    anyhow!(\"não consegui medir o loudness: {}\", stderr.lines().last().unwrap_or(\"\").trim())\n})\n// after\nmatch parse_measure(&stderr) {\n    Some(m) => Ok(m),\n    None => {\n        if stderr.contains(\"does not contain any stream\") || stderr.contains(\"Stream specifier ':a'\") {\n            anyhow::bail!(\"input has no audio stream; skipping loudness measurement\");\n        }\n        anyhow::bail!(\"não consegui medir o loudness: {}\", stderr.lines().last().unwrap_or(\"\").trim())\n    }\n}","handlingStrategy":"validation","validationCode":"// Ensure the input has a decodable audio stream before measuring\nlet probe = crate::core::ffmpeg::probe(&input).await?;\nanyhow::ensure!(\n    probe.streams.iter().any(|s| s.codec_type == \"audio\"),\n    \"no audio stream: loudness measurement impossible\"\n);","typeGuard":null,"tryCatchPattern":"let m = measure(&ffmpeg, &input, &filter).await\n    .map_err(|e| anyhow::anyhow!(\"loudness measurement failed for {}: {e}\", input.display()))?;","preventionTips":["Pre-probe inputs with ffprobe before running filters","Test parse_measure against your target ffmpeg version's output","Always log the stderr tail included in the error","Handle corrupt/truncated media explicitly before analysis"],"tags":["ffmpeg","loudness","parsing","audio","rust"],"backgroundTag":"unexpected-response-shape","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"}