Skip to content

Fix two ffmpeg 7.1 regressions: lost blends and an overlay deadlock - #13

Merged
davior merged 2 commits into
mainfrom
claude/lucid-archimedes-afkjtn
Oct 23, 2026
Merged

davior merged 2 commits into
mainfrom
claude/lucid-archimedes-afkjtn

Conversation

@davior

@davior davior commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

This fixes two problems with #12 on the Docker image's ffmpeg (Debian trixie, 7.1.5). Neither shows up on the 6.1 that the tests and CI run.

1. Blends were joined as cuts

Wherever one run of the chunked stitch ends inside a shot and the next one starts, the stitch trims that shot. On ffmpeg 7.x, trim leaves the stream with a frame rate of 1/0, and xfade then refuses to run:

[Parsed_xfade_16] The inputs needs to be a constant frame rate; current rate of 1/0 is invalid

The render caught the failure and fell back to joining every shot with a plain cut, showing the warning "Blends were joined as cuts". The fix restores the rate after the trim with an fps filter at the shot's own frame rate. The frames are already at that rate, so no frame is dropped or repeated.

2. The overlay pass deadlocked

#12 made each overlay an input that starts late, using -itsoffset. On 7.1.5 the pass froze as the picture reached the first overlay. ffmpeg sat at 0.2% CPU and the preview stayed on "Drawing overlays" until the step's time limit, about an hour for a 10-minute video. The partial overlaid.mp4 had stopped about 135 s in, and the first overlay starts at 139.85 s. The same command doesn't hang on 6.1, 7.0.2 or 7.1.1.

Each overlay is now its PNG read once as a single frame and repeated inside the filter graph, for its window only (loop → trim → settb → setpts). No input starts late, so nothing depends on how ffmpeg schedules its inputs. The window keeps its last frame. The timestamps move onto AV_TIME_BASE first, because the PNG demuxer's 1/25 timebase would round the fades to 40 ms.

Testing

  • Stitch: reproduced on 7.1.1 with 45 dissolved shots and dips every seventh join, about 9.6 minutes. It failed before the fix. After it, the output length matches the planned timeline to within two frames.
  • Overlays: ran the stuck production command's exact timings and video length on 6.1, 7.0.2 and 7.1.1. Compared with the -itsoffset output it gives 59.6 dB average and 32 dB minimum. The only differences are inside the fades: an overlay now starts at its own time instead of being snapped to the 1/30 s grid. 30 overlays went from 359 MB and 7 s to 293 MB and 3–5 s. I couldn't get a 7.1.5 build in this sandbox, so the deadlock fix is verified by taking away the mechanism that hung (late-starting inputs), not by reproducing it.
  • pytest -q: 674 passed on 6.1. The render tests also pass against 7.1.1.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WJkfhgbVRktPf2Lg6XXfNs

ffmpeg 7 leaves a trimmed stream with no frame rate (1/0), and xfade refuses
one: "The inputs needs to be a constant frame rate". Every run of a chunked
stitch that starts or ends inside a shot trims it, so on the Docker image's
ffmpeg 7.1 the blended stitch failed and the render fell back to joining every
shot with a cut. ffmpeg 6.1, which the tests and CI run, keeps the rate, so
nothing caught it. An fps filter at the shot's own rate puts it back without
dropping or repeating a frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJkfhgbVRktPf2Lg6XXfNs
Each overlay was an input that started late, via -itsoffset. On Debian's
ffmpeg 7.1.5 that deadlocked when the picture reached the first layer: ffmpeg
sat idle, the preview stuck on "Drawing overlays", until the pass timed out
an hour later. It did not reproduce on 6.1, 7.0.2 or 7.1.1.

A layer is now its PNG read once as a single frame and repeated inside the
graph for its window only (loop, trim, setpts), so no input waits on ffmpeg's
scheduling and the overlay pulls frames as it needs them. The window keeps
its last frame (ceil), and the frames sit on AV_TIME_BASE rather than the
image demuxer's 1/25, which would round the fades to 40 ms. Against the
-itsoffset output on 7.1.1, 59.6 dB average, with the remaining difference
inside the fades: the layer now starts at its own time instead of the 1/30 s
grid. 30 layers: 359 -> 293 MB, 7 s -> 3-5 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJkfhgbVRktPf2Lg6XXfNs
@davior davior changed the title Keep blends working on ffmpeg 7: set the frame rate back after a trim Fix two ffmpeg 7.1 regressions: lost blends and an overlay deadlock Oct 23, 2026
@davior
davior marked this pull request as ready for review October 23, 2026 00:44
@davior
davior merged commit e218adc into main Oct 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants