babysor/MockingBird · error · RuntimeError

ffmpeg failed: {' '.join(cmd)}\n{proc.stderr}

Error message

ffmpeg failed: {' '.join(cmd)}\n{proc.stderr}

What it means

RuntimeError raised by _run_ff whenever an ffmpeg subprocess exits non-zero; stderr is captured and included. All audio processing steps (pad/trim, atempo, delay, final mix) funnel through this helper.

Source

Thrown at skills/speak/scripts/render_timeline.py:118

    return v, v


def resolve_segment_cfg(index: int, config: Dict[str, Any]) -> Dict[str, Any]:
    merged = dict(config.get("default", {}))
    for key, seg_cfg in config.get("segments", {}).items():
        lo, hi = parse_segment_key(key)
        if lo <= index <= hi:
            merged.update(seg_cfg)
    return merged


# ── ffmpeg helpers ────────────────────────────────────────────────────


def _run_ff(cmd: List[str]) -> None:
    proc = subprocess.run(cmd, capture_output=True, text=True)
    if proc.returncode != 0:
        raise RuntimeError(f"ffmpeg failed: {' '.join(cmd)}\n{proc.stderr}")


def ensure_ffmpeg() -> None:
    if not shutil.which("ffmpeg"):
        raise RuntimeError("ffmpeg not found in PATH.")


def probe_duration_ms(path: Path) -> float:
    proc = subprocess.run(
        [
            "ffprobe", "-v", "error", "-show_entries", "format=duration",
            "-of", "default=noprint_wrappers=1:nokey=1", str(path),
        ],
        capture_output=True, text=True,
    )
    if proc.returncode != 0:
        raise RuntimeError(f"ffprobe failed on {path}: {proc.stderr}")
    return float(proc.stdout.strip()) * 1000

View on GitHub (pinned to 28dc5e14f1)

Solutions

  1. Read the embedded ffmpeg stderr — it names the exact failing filter/option
  2. Reproduce the command manually in a shell to iterate quickly
  3. Upgrade ffmpeg to a recent build if a filter/encoder is unsupported
  4. Verify input audio files are valid and output dir is writable
Defensive patterns

Strategy: try-catch

Validate before calling

import shutil
assert shutil.which('ffmpeg'), 'ffmpeg required'

Try / catch

try:
    _run_ff(cmd)
except RuntimeError as e:
    print(e); subprocess.run(' '.join(cmd), shell=True)  # reproduce manually
    raise

Prevention

When it happens

Trigger: Any ffmpeg filter error: invalid adelay/amix/atempo arguments, unsupported/corrupt input file, missing encoder for the requested output format, or output path not writable.

Common situations: Old ffmpeg build lacking a filter or encoder, mistyped output extension (e.g. .m4a without an AAC encoder enabled), paths with characters that break arg assembly, or truncated TTS output files fed in.

Related errors


AI-assisted analysis of babysor/MockingBird@28dc5e14f1 (2026-08-27). Data as JSON: /api/errors/9aeef3eb19dbffbf. Report an issue: GitHub.