Determine video properties (dimensions of frames)
8 views (last 30 days)
Show older comments
Hi,
I would like to determine the pixel dimensions of every frame in a video, and the dimensionality of the array per frame.
I have imported the video, but is it possible to output the pixel dimensions of every frame and the dimensionality of the array per frame?
video = VideoReader('video.mp4');
Thank you.
3 Comments
Walter Roberson
on 29 Aug 2019
video.Height and video.Width do indeed return number of pixels. Each frame returned will have that number of pixels vertically and horizontally.
I am not clear as to what you mean by the "dimensionality". Perhaps you want to use size() on the array. When you are using VideoReader like you are, the rows and columns will match the Height and Width properties. The size in the third dimension will depend upon whether it is grayscale or RGB . If you need to find that out in advance, you can examine the VideoFormat property, or you can take BitsPerPixel and divide by 8 to get the number of color planes.
The exact same size of image will be returned for every frame. MATLAB does not support videos that have varying frame sizes. (It is potentially possible for .gif to have different frame sizes, but those are not handled by any of the video readers.)
Note: the rules about size versus properties are a little different when capturing from a device using the Image Acquisition Toolbox such as a webcam or gige camera: in such cases, the sizes reported by the device might refer to the size before demosaicing or before converting to RGB -- and indeed those routines can return mosaiced frames or frames in color spaces such as YCrCb
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!