tonhowtf/omniget · error

MB não cabem s de vídeo — aumente o alvo ou encurte o clipe

Error message

{:.0} MB não cabem {:.0}s de vídeo — aumente o alvo ou encurte o clipe

What it means

When opts.target_mb > 0, run() asks video_compress::plan_bitrates to fit the window into the target size (audio floor 128 kbps, 0.97 overhead factor). If no bitrate plan is mathematically possible, it throws '<X> MB não cabem <Y>s de vídeo — aumente o alvo ou encurte o clipe'.

Solutions

  1. Increase opts.target_mb so it exceeds window * 128_000 / 8 / 1_048_576 MB (audio floor) plus margin
  2. Reduce the clip duration (window) for the same target
  3. Lower the audio bitrate floor if the caller can accept less audio quality (requires changing the plan_bitrates call)

Example fix

// before
let opts = BurnOptions { target_mb: 2.0, duration: 120.0, ..base }; // infeasible
// after
let window = 120.0;
let min_mb = (window * 128_000.0 / 8.0 / (1024.0 * 1024.0)) * 1.15; // audio floor + margin
let opts = BurnOptions { target_mb: opts.target_mb.max(min_mb), duration: window, ..base };
Defensive patterns

Strategy: validation

Validate before calling

fn target_feasible(target_mb: f64, window_secs: f64) -> bool {
    let audio_floor_mb = window_secs * 128_000.0 / 8.0 / (1024.0 * 1024.0);
    target_mb <= 0.0 || target_mb > audio_floor_mb * 1.1
}

Try / catch

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

Prevention

When it happens

Trigger: target_mb * 8 Mbit is smaller than window * 128 kbps of mandatory audio (plus overhead), i.e. target size too small for the clip length — e.g. 1 MB for a 60s clip needs at least ~0.96 MB of audio alone.

Common situations: User sets an aggressive size target (WhatsApp/Discord limits) for a long clip; forgetting the 128 kbps audio floor makes the plan infeasible regardless of video bitrate.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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

Appendix: source

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

        .map(|s| s.to_string_lossy().to_string())
        .unwrap_or_else(|| "clipe".into());
    let suffix = if opts.suffix.trim().is_empty() {
        "-danmaku"
    } else {
        opts.suffix.trim()
    };
    let output = out_dir.join(format!("{}{}.mp4", stem, suffix));

    let filters = filter_chain(&work, opts.fonts_dir.trim(), opts.max_height);
    let cut = cut_args(start, window);
    let audio = audio_args(has_audio, 0);

    let result = if opts.target_mb > 0.0 {
        let target_bytes = (opts.target_mb * 1024.0 * 1024.0) as u64;
        let (video_kbps, audio_kbps) =
            video_compress::plan_bitrates(window, target_bytes, 128, has_audio, 0.97).ok_or_else(
                || {
                    anyhow!(
                        "{:.0} MB não cabem {:.0}s de vídeo — aumente o alvo ou encurte o clipe",
                        opts.target_mb,
                        window
                    )
                },
            )?;
        let log_dir = work_dir.join(format!("danmaku-2pass-{}", uuid::Uuid::new_v4()));
        std::fs::create_dir_all(&log_dir)?;
        let log = log_dir.join("pass");
        let common = bitrate_args(video_kbps, &opts.preset);

        report(
            progress,
            ID,
            "progress",
            1,
            Some(3),
            Some("passagem 1 de 2".into()),

View on GitHub (pinned to 8600b91f42)