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

56 visualizaciones (últimos 30 días)
Bradley
Bradley el 23 de Oct. de 2025 a las 16:34
Comentada: Harald el 24 de Oct. de 2025 a las 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 comentarios
Bradley
Bradley el 24 de Oct. de 2025 a las 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 el 24 de Oct. de 2025 a las 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by