tonhowtf/omniget · error

legenda não encontrada

Error message

legenda não encontrada: {}

What it means

run() validates that the subtitle/danmaku file (opts.subtitle) exists as a regular file after trimming. If missing, it throws 'legenda não encontrada: <path>'. The subtitle is the second required input for burning danmaku comments into the video.

Solutions

  1. Verify the subtitle file exists with std::path::Path::is_file() before calling run
  2. Run the danmaku export stage first and thread its actual output path into BurnOptions.subtitle
  3. Handle the no-comments case explicitly (empty danmaku) instead of passing a missing file path

Example fix

// before
burn::run(&BurnOptions { subtitle: "danmaku.ass".into(), ..opts })
// after
let sub = "danmaku.ass";
anyhow::ensure!(
    std::path::Path::new(sub).is_file(),
    "legenda ausente: {} — exporte os comentários antes de gravar",
    sub
);
burn::run(&BurnOptions { subtitle: sub.into(), ..opts })
Defensive patterns

Strategy: validation

Validate before calling

fn ensure_subtitle(path: &str) -> Result<(), String> {
    if std::path::Path::new(path.trim()).is_file() { Ok(()) }
    else { Err(format!("legenda não encontrada: {}", path)) }
}

Type guard

fn has_subtitle(opts: &BurnOptions) -> bool {
    !opts.subtitle.trim().is_empty() && std::path::Path::new(opts.subtitle.trim()).is_file()
}

Try / catch

match burn::run(&opts, &progress).await {
    Err(e) if e.to_string().starts_with("legenda não encontrada") => skip_burn_or_reexport_danmaku(&opts),
    Err(e) => propagate(e)?,
    Ok(res) => use_result(res),
}

Prevention

When it happens

Trigger: Calling burn::run with BurnOptions.subtitle pointing to a non-existent, empty-string, or deleted subtitle file (e.g. the danmaku export step of export.rs never ran or wrote to a different path).

Common situations: Danmaku export was skipped or failed; subtitle written to a temp dir that was cleaned; mismatch between export output path and burn input path; video has no comments so no subtitle was produced.

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/4e143accecee9c1b. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/src/platforms/bilibili/danmaku/burn.rs:81

pub struct BurnResult {
    pub output: String,
    pub bytes: u64,
    pub duration_secs: f64,
    /// Quantos comentários sobraram dentro da janela.
    pub dialogues: usize,
    /// 0 quando a codificação foi por CRF.
    pub video_kbps: u32,
    pub audio_kbps: u32,
}

pub async fn run(opts: &BurnOptions, progress: &ProgressFn) -> Result<BurnResult> {
    let video = PathBuf::from(opts.video.trim());
    if !video.is_file() {
        return Err(anyhow!("vídeo não encontrado: {}", opts.video));
    }
    let sub = PathBuf::from(opts.subtitle.trim());
    if !sub.is_file() {
        return Err(anyhow!("legenda não encontrada: {}", opts.subtitle));
    }
    let ffmpeg = omniget_core::core::dependencies::ensure_ffmpeg().await?;

    report(
        progress,
        ID,
        "progress",
        0,
        Some(3),
        Some("lendo o vídeo".into()),
    );
    let probe = omniget_core::core::ffmpeg::probe(&video).await?;
    let has_audio = probe.streams.iter().any(|s| s.codec_type == "audio");
    let start = opts.start.max(0.0);
    let window = if opts.duration > 0.0 {
        opts.duration
    } else {
        (probe.duration_seconds - start).max(0.0)

View on GitHub (pinned to 8600b91f42)