I found that running the line matlab.video.read.UseHardwareAcceleration('off') fixed my issue. I am going to include it at the top of my code so that it runs every time I run the script. However through tests, I found the setting persists even when you open and close MATLAB.
Why is VideoReader() loading the incorrect video height in Windows 10?
7 views (last 30 days)
Show older comments
I am loading a .avi video file using VideoReader(). I am testing this script in MATLAB 2017b on Windows 7 64-bit and Windows 10. In both Win7, and Win10, the video properties from the file manager show the video size being 720 x 480. The script goes like this:
vidpath = 'video.avi';
vidObj = VideoReader(vidpath)
width = vidObj.Width;
height = vidObj.Height;
frameR = vidObj.FrameRate;
vidStr = struct('cdata', zeros(height, width, 3, 'unit8', 'colormap', []);
nFrames = 0;
while hasFrame(vidObj)
nFrames = nFrames + 1;
vidStr(nFrames).cdata = readFrame(vidObj)
end
movie(vidStr, 1, frameR)
Running this script on MATLAB 2017b in Win7, VideoReader() returns the correct size, and shows a clean video. Running it on Win10 with MATLAB 2017b, it returns a height of 540, and the video is completely distorted with varying horizontal lines. Attempting to override the height problem by simply writing height = 480;, does not fix this problem.
All of my GPU drivers are up to date, and I have in fact tested this on two different Win10 machines. Any help would be appreciated.
0 Comments
Accepted Answer
Dante
on 12 Oct 2018
2 Comments
Ryan Troha
on 10 Dec 2021
Hi, I was having the same problem originally posted here and I've tried including the line that @Dante mentioned, but I still have the same problem (height is reading as 540, but should be 480). At what point in mind code should I include the additional line? Before or after the VideoReader function? Thanks.
More Answers (0)
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!