tonhowtf/omniget · error · anyhow::Error

legenda não encontrada

Error message

legenda não encontrada

What it means

subtitle::burn checks that opts.subtitle exists on disk before invoking ffmpeg; if not it throws "legenda não encontrada" (subtitle not found). It is an explicit pre-flight existence check so ffmpeg isn't started with a missing subtitles filter input.

Solutions

  1. Check the path with std::path::Path::exists() before calling burn
  2. Convert relative paths to absolute before passing them in BurnOptions
  3. Ensure the subtitle file was actually downloaded/written before burning

Example fix

// before
burn(&BurnOptions { subtitle: "subs.srt".into(), .. })
// after
let sub = std::fs::canonicalize("subs.srt")?;
burn(&BurnOptions { subtitle: sub.to_string_lossy().into(), .. })
Defensive patterns

Strategy: validation

Validate before calling

let sub = std::path::Path::new(&opts.subtitle);
if !sub.is_file() { return Err(format!("subtitle file missing: {}", sub.display())); }

Try / catch

match burn(opts, progress).await {
    Err(e) if e.to_string().contains("legenda não encontrada") => { /* re-pick subtitle file in UI */ }
    other => other,
}

Prevention

When it happens

Trigger: Calling burn with BurnOptions.subtitle pointing at a path that does not exist — deleted/moved file, relative path resolved from a different working directory, or a typo in the path.

Common situations: Passing a URL or an output filename that will be created later instead of an existing subtitle file; working-directory mismatch making relative paths break; subtitle file removed between selection and burn.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/7f9548234ef3b938. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/subtitle.rs:468

    pub suffix: String,
}

fn default_font_size() -> u32 {
    24
}

/// O filtro `subtitles` recebe o caminho dentro de uma string do FFmpeg:
/// dois-pontos separam opções e a barra invertida do Windows é escape.
pub fn escape_filter_path(path: &str) -> String {
    path.replace('\\', "/").replace(':', "\\:")
}

pub async fn burn(opts: BurnOptions, progress: super::ProgressFn) -> anyhow::Result<String> {
    let ffmpeg = crate::core::dependencies::ensure_ffmpeg().await?;
    let video = Path::new(&opts.video);
    let sub = Path::new(&opts.subtitle);
    if !sub.exists() {
        return Err(anyhow!("legenda não encontrada"));
    }
    let dir = if opts.output_dir.trim().is_empty() {
        video.parent().map(|p| p.to_path_buf()).unwrap_or_default()
    } else {
        PathBuf::from(opts.output_dir.trim())
    };
    std::fs::create_dir_all(&dir)?;
    let stem = video
        .file_stem()
        .map(|s| s.to_string_lossy().to_string())
        .unwrap_or_else(|| "video".into());
    let suffix = if opts.suffix.is_empty() {
        "-legendado"
    } else {
        opts.suffix.as_str()
    };
    let output = dir.join(format!("{}{}.mp4", stem, suffix));

View on GitHub (pinned to 8600b91f42)