I am reading a video file frame by frame, but not displaying it. I createt the following relevant objects:
- AVURLAsset
- AVAssetTrack
- AVAssetReader
- AVAssetReaderTrackOutput
but none of these gives me the (pixel x pixel) size ot the data returned by assetReaderTrackOutput.copyNextSampleBuffer()
The AVAssetTrack has a naturalSize variable, but it isn't in pixels; some of my video has a natural size of 853x480, but the pixel size is 704x480 according to the Finder. (Right now I just kludge the width value.) Is there a robust way to get this information? I can see that it is buried in the metadata, but why is it not exposed in any of the AV objects I'm using?
Get the (first) format description from the AVAssetTrack, then use
CMVideoFormatDescriptionGetPresentationDimensions(…) on it. This function has flags where you can specify if you want the result with or without pixel aspect ratios taken into account (what seems to be the "problem" in your case), among others.