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 Center および File ExchangeIntroduction 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