{"record":{"id":"7511df1e2acb66bf","repo":"tonhowtf/omniget","slug":"n-o-consegui-medir-a-dura-o","errorCode":null,"errorMessage":"não consegui medir a duração","messagePattern":"não consegui medir a duração","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/silence_cut.rs","lineNumber":224,"sourceCode":"                threshold_db,\n                min_silence.max(0.05)\n            ),\n            \"-f\",\n            \"null\",\n            \"-\",\n        ])\n        .output()\n        .await\n        .map_err(|e| anyhow!(\"ffmpeg nao iniciou: {}\", e))?;\n    Ok(String::from_utf8_lossy(&out.stderr).to_string())\n}\n\nasync fn cut_one(ffmpeg: &Path, opts: &SilenceOptions, input: &str) -> anyhow::Result<SilenceItem> {\n    let inp = Path::new(input);\n    let probe = crate::core::ffmpeg::probe(inp).await?;\n    let total = probe.duration_seconds;\n    if total <= 0.0 {\n        return Err(anyhow!(\"não consegui medir a duração\"));\n    }\n    let has_audio = probe.streams.iter().any(|s| s.codec_type == \"audio\");\n    if !has_audio {\n        return Err(anyhow!(\"o arquivo não tem trilha de áudio\"));\n    }\n\n    let stderr = detect(ffmpeg, inp, opts.threshold_db, opts.min_silence).await?;\n    let spans = parse_spans(&stderr, total);\n    let (spans, skipped) = cap_spans(spans, MAX_SEGMENTS);\n    let keeps = keep_ranges(&spans, total, opts.padding.max(0.0));\n    let kept: f64 = keeps.iter().map(|k| k.duration()).sum();\n\n    let mut item = SilenceItem {\n        input: input.to_string(),\n        output: None,\n        duration_before: total,\n        duration_after: kept,\n        seconds_removed: (total - kept).max(0.0),","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/silence_cut.rs#L206-L242","documentation":"cut_one probes the input with ffprobe and requires a positive duration before doing silence detection. When probe.duration_seconds is <= 0 (missing, unparseable, or zero), it throws 'não consegui medir a duração' (could not measure the duration). Without a reliable duration, keep-range math for silence cutting cannot work.","triggerScenarios":"Calling cut_one/run on a file whose probe reports no usable duration: corrupt/unfinalized files, raw streams without container headers, network URLs that ffprobe cannot fully read, or a container ffprobe cannot parse.","commonSituations":"Feeding a partially downloaded MP4 (moov atom missing); passing an image or unsupported format; interrupted recording; probing a live/stream URL without duration metadata.","solutions":["Verify the input file plays in a standard player and probe it manually with ffprobe to inspect duration.","Remux/repair the file (e.g. ffmpeg -i in.mp4 -c copy fixed.mp4) to regenerate container metadata.","Only pass complete, finalized media files to the silence-cut API.","Check that the path/URL is correct and fully accessible."],"exampleFix":"// before\nrun(&opts, \"partial-download.mp4\").await?;\n// after\nffmpeg_repair(\"partial-download.mp4\", \"fixed.mp4\").await?;\nrun(&opts, \"fixed.mp4\").await?;","handlingStrategy":"validation","validationCode":"// Rust\nlet probe = ffmpeg_probe(path).await?;\nanyhow::ensure!(probe.duration_seconds > 0.0, \"arquivo sem duracao valida\");","typeGuard":"fn has_duration(p: &Probe) -> bool { p.duration_seconds > 0.0 }","tryCatchPattern":"match cut_one(&ffmpeg, &opts, input).await {\n    Err(e) if e.to_string().contains(\"nao consegui medir\") => {\n        // remuxar/reparar o arquivo e tentar de novo\n    }\n    r => r?,\n}","preventionTips":["Only pass finalized, fully downloaded media files","Pre-probe every input and fail fast on duration <= 0","Avoid probing live/stream URLs without duration metadata","Repair truncated MP4s (remux) before processing"],"tags":["ffmpeg","ffprobe","media-duration","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"}