Why is VideoReader telling me the duration of every video is 0?

조회 수: 46 (최근 30일)
Bradley
Bradley 2025년 10월 23일 16:34
댓글: Harald 2025년 10월 24일 16:04
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
Bradley
Bradley 2025년 10월 24일 15:51
I moved all of my code over to a linux machine and got everything working. I was on windows and the video format was an MP4 file. it is infact 66 minutes long not a minute, I dont understand why this wasnt working on my windows machine, maybe it was an encoder issue im not sure. Thanks for the input everyone I was able to get everything working!
Harald
Harald 2025년 10월 24일 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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2025b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by