Skip to content

video: Add support for NV12 pixel format - #24335

Open
X1nto wants to merge 2 commits into
ruffle-rs:masterfrom
X1nto:feature/nv12-pixels
Open

video: Add support for NV12 pixel format#24335
X1nto wants to merge 2 commits into
ruffle-rs:masterfrom
X1nto:feature/nv12-pixels

Conversation

@X1nto

@X1nto X1nto commented Jul 31, 2026

Copy link
Copy Markdown

Description

Previously, the NV12 pixel format was unsupported, logging Unsupported pixel format: Nv12 to the console. This adds support for decoding videos with NV12 pixel format in webcodecs.

This PR also fixes video freezes. I'm not entirely sure if I should include this fix here, but without it I couldn't even test my changes properly. Looking into the console I found ruffle was spamming these: decoding video frame XXX failed: No output frame produced by the decoder. As far as I noticed, when one frame failed to decode in time, instead of skipping over that frame, the decoder waited until it finished decoding and only then continued decoding subsequent frames. This caused the frames to accumulate and stall, causing videos to freeze.

Testing

I couldn't find a way to write tests for this, as there are no reference tests for other pixel formats. One of the suggestions was to create an HTML wrapping Flash and let Ruffle polyfill it, but tests require GPU acceleration to be disabled and NV12 doesn't work without GPU acceleration.

Here's an NV12 encoded video, extracted from one of the games I was testing, which inspired me to make this PR: pitkEqim.flv.

I'm not familiar with ActionScript, but I can probably whip up a test script that loads the video attached above to help test this. Please let me know.

Checklist

  • I, a human, have self-reviewed this PR and fully understand the changes within.
  • I have made or updated tests where possible.
  • All of my commits are properly scoped, compile successfully, and pass all tests.
  • This PR does not make sense to split up into smaller PRs.
  • An LLM was involved in the authoring of this code.

X1nto added 2 commits August 1, 2026 00:09
VideoFrames handed to the output callback hold on to the decoder's output buffer, which is only returned to the pool once the frame is closed. Stalled frames, if not closed, block subsequent frames from processing, causing videos to freeze. Closing the VideoFrame frees up the pool and lets the decoder properly skip frames that take too much time to decode.
@Lord-McSweeney Lord-McSweeney added A-video T-fix Type: Bug fix (in something that's supposed to work already) labels Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-video T-fix Type: Bug fix (in something that's supposed to work already)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants