Repository navigation
AVFoundation player: load non-square-pixel (anamorphic) video at its real pixel size (revives #4949) - #8656
Merged
Conversation
Member
Author
Test resultRan a standalone harness that builds
On this PR the HDV clip also reports Not covered: the iOS player (separate class, untouched), the streaming-URL path, and a full oF app drawing the texture. The harness is not part of this PR. |
…Videos now play at true size. Partially addresses openframeworks#4937 (cherry picked from commit 4834bcd)
(cherry picked from commit 3c62e0a)
danoli3
force-pushed
the
avf-anamorphic-pixels
branch
from
November 8, 2026 06:02
6fc8e2c to
7f9a645
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Revives #4949 by @ofTheo, which no longer applies to
master. Fixes #4937.Problem
ofAVFoundationPlayertakes the video size fromAVAssetTrack.naturalSize, which is the display size. Anamorphic video (for example HDV, 1440x1080 stored and shown as 1920x1080) stores fewer pixels than that. The player reports 1920x1080 while theCVPixelBufferis 1440x1080, sopixels.allocate(getWidth(), getHeight())is too wide for the vImage conversion (which reads the buffer's own size), and the texture is drawn stretched. See the forum thread: https://forum.openframeworks.cc/t/issues-with-pixel-ratios-in-ofvideoplayer/22120/10Change
-x, authorship kept.ofAVFoundationVideoPlayer.mnow reads the pixel aspect ratio from the track's format description and setsgetWidth()/getHeight()to the real pixel size.ofAVFoundationPlayer::getDisplayWidth(),getDisplayHeight()andisAnamorphic(), so users can draw at the intended size. Drawing stays up to the user, as in the original PR.Adapted for current
master, since the load code is now in a block usingself->:ofAVFoundationVideoPlayer.mandofAVFoundationPlayer.h(tabs vs spaces).NSNumber(notNSString), require both spacings above zero, and round instead of truncating.presentationSize(display size) now sets the display size from it and the pixel size from the firstCVPixelBuffer.Example:
Platforms
ofxiOSVideoPlayeruses its ownaddons/ofxiOS/src/video/AVFoundationVideoPlayer.m, which already takes the size fromCVPixelBufferGetWidth/Height, so it is not affected and is untouched.Tested
ofAVFoundationVideoPlayer.mandofAVFoundationPlayer.mmpassclang -fsyntax-onlywith ARC on macOS (10.15 target); the.malso passes against the iOS 15 simulator SDK. No new warnings.