DEV Community

Rochelle Vale
Rochelle Vale

Posted on

Three ffmpeg traps that cost me a wasted render

I build short vertical videos from a still image, a narration track, and a few text cards. No editor, no generation credits, just ffmpeg and Pillow. That constraint is the whole point: when you can't eyeball your way to a good cut, you have to measure.

These are three traps that each produced a render that exited 0 and was still wrong, plus the one habit that catches all of them.

1. overlay with eof_action=repeat never ends the filtergraph

If you layer a card over a moving background and let the shorter input repeat, the graph keeps pumping frames forever:

-filter_complex "[0:v][1:v]overlay=eof_action=repeat[out]"
Enter fullscreen mode Exit fullscreen mode

The encode runs, produces gigabytes, and never finishes on its own. You need to cap it explicitly:

-t 20
Enter fullscreen mode Exit fullscreen mode

eof_action=repeat is doing what it says: repeating the last frame of the shorter stream. That means no EOF, which means no natural end, which means you must tell it when to stop. If your render "hangs," check the filtergraph before you blame the machine.

2. A single-frame PNG needs an explicit loop

Passing a one-frame image as a normal input gives you one frame. If a fade lives on that stream, the alpha can hit zero before the frame is ever displayed, and you get a blank layer with a perfectly healthy log.

For a plain input:

-loop 1 -i card.png
Enter fullscreen mode Exit fullscreen mode

For a filter input:

loop=loop=-1:size=1:start=0
Enter fullscreen mode Exit fullscreen mode

Either way, the single frame has to be told to behave like a stream. Without it, your text card is null and you find out only by looking at pixels.

3. zoompan d is in input frames, not output seconds

The push-in I use is subtle: scale up a hair over the length of the clip. But d counts per input frame. If you set it in the wrong units the motion either stutters or stalls halfway, and the encode looks fine.

The rule I use: d must cover the clip in frames. A 20 second clip at 30 fps is d=600. Do the arithmetic instead of guessing.

The habit that catches all three: measure the output, not the exit code

A render can exit 0 and be wrong. I once shipped a video with no visible text at all. Nothing errored. I caught it by probing pixel luminance of a few frames, not by watching it.

Two cheap checks worth adding to any pipeline:

  • Probe a frame you care about and assert it isn't flat black where text should be.
  • Assert the container duration matches what you intended. ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 out.mp4

The lesson after the traps: the words were never the problem

My first cut was five cards at roughly six seconds each over a portrait that never moved. 18 people opened it and 0 watched to the end.

I could have rewritten the script. Instead I measured the shape of it: the narration had long silences, every card held too long, and nothing in the frame ever moved. So I silence-detected the narration, trimmed the speech with 0.12 second gaps, and added a slow zoompan push-in. Same words. Different retention shape.

Retention is a property of pacing and motion, not of phrasing. That sounds obvious until you've spent a day making the words better.


The whole method is just: keep the pipeline cheap enough to iterate, and measure the output instead of trusting it. If you have a filtergraph that looks fine and an encode that hangs, check eof_action first.

Top comments (0)