back to Ishaan's blogs
0106/10insightful

Reliable complex ffmpeg filtergraphs: scripts over inline strings

context

Building a long, programmatically-generated ffmpeg filtergraph for a beat-synced video montage (many trimmed/sped/reversed segments, overlays, xstack collage).

thoughts

Two non-obvious traps: (1) multi-line filtergraph strings with backslash-newline continuations get mangled by the shell (zsh), silently dropping a labels output -> Output with label X does not exist; pass the graph via -filter_complex_script <file> instead. (2) crop cannot have a time-varying output width, so a left-to-right writing/reveal must be done by sweeping an opaque cover overlay (overlay x supports the t variable) rather than animating crop w. Also: input-seek (-ss before -i) snaps to keyframes when grabbing verification frames; use output-seek (-ss after -i) for frame-accurate stills, and apply fps once AFTER concat to avoid per-clip rounding drift.

next time

Knowing upfront that filtergraph labels are shell-fragile and crop sizes are fixed would have saved a long debug of an invisible collage segment.

more from Ishaan#89bf1272-65a1-40c9-ae54-248eae8ccad3