Skip to content

BUG: multi-frame writes through pyav fail with av 18.1.0 - #1207

Merged
FirefoxMetzger merged 4 commits into
imageio:masterfrom
swimmingbrain:fix/pyav-stream-size
Sep 26, 2026
Merged

FirefoxMetzger merged 4 commits into
imageio:masterfrom
swimmingbrain:fix/pyav-stream-size

Conversation

@swimmingbrain

Copy link
Copy Markdown
Contributor

Writing more than one frame with libx264 through the pyav plugin raises RuntimeError: Cannot change width after codec is open with av 18.1.0, see #1205. The plugin decided whether the stream size still had to be set by looking at stream.frames, which counts muxed packets. A codec that buffers its first frames leaves that at zero, so the size was assigned a second time after the first encode call had opened the codec, and av 18.1 refuses that.

The check now asks the codec context whether it is open instead. It stays below the filter, so a rescaling filter still decides the size, and it covers the flush path too, where a buffering filter hands over its first frame. There is a new test that writes five frames with libx264 and reads them back, the single-frame case never triggered this. On master test_mp4_writing fails the same way with av 18.1.0, with this change the pyav tests pass.

Closes #1205

swimmingbrain and others added 4 commits September 7, 2026 15:39
Unpinned pypy-3.11 now resolves to PyPy 8.0 on macOS, whose pp80 ABI has no pillow-heif wheels.

Co-authored-by: Cursor <[email protected]>
The package has no wheels for current PyPy, and the HEIF tests already skip when it is missing.

Co-authored-by: Cursor <[email protected]>
@FirefoxMetzger
FirefoxMetzger merged commit bbcb9e3 into imageio:master Sep 26, 2026
17 checks passed
@FirefoxMetzger

Copy link
Copy Markdown
Contributor

Thanks for the fix! reviewed, merged, should go live monday.

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.

pyav plugin: multi-frame video write fails with av 18.1.0 (Cannot change width after codec is open)

2 participants