Why is VideoReader telling me the duration of every video is 0?
46 views (last 30 days)
Show older comments
I am trying to use VideoReader to gather data about a video. Ultimatly what I want to do is define a time stamp and extract the frame that corresponds to that time frame. For some reason when I use VideoReader I get all of the usual data except for the Duration which always reads 0. Ive tried a few videos and they all read 0. Below is my code.
Edit: The video im trying to load is roughly an hour long
VideoName = "video.mp4";
V = VideoReader(VideoName);
VideoHeight = V.Height;
VideoWidth = V.Width;
VideoFrames = V.NumFrames;
VideoFrameRate = V.FrameRate;
VideoLength = VideoFrames/VideoFrameRate;
TargetTimeStamp = 0;
V.CurrentTime = TargetTimeStamp;
Frame = readFrame(V);
imshow(Frame)
Here is the output of VideoReader:
Duration 0 1×1 double
Name 'video.mp4' 1×38 char
Path 'C:\Users\' 1×46 char
BitsPerPixel 24 1×1 double
FrameRate 31.4136 1×1 double
Height 1080 1×1 double
NumFrames 2328 1×1 double
VideoFormat 'RGB24' 1×5 char
Width 1920 1×1 double
Tag '' 0×0 char
UserData [ ] 0×0 double
CurrentTime 0.0318 1×1 double
6 Comments
Harald
on 24 Oct 2025 at 16:04
That's interesting, and I am happy for you! :)
As I wrote, it was working fine with me, and I am working on Windows. So, if you are still interested in making it work on Windows as well, please try what I suggested as an initial investigation.
Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing 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!