I am trying to read a video from 4 seconds in. I use this:
v = VideoReader('IMG_3557.MOV','CurrentTime',4); % read video file
But when I do ths:
numbframes = v.NumFrames;
I get the same number of frames as the entire video from the beginning. I'm not sure what I'm doing wrong. Thanks

3 Kommentare

Chidiebere - since the number of frames are the same, does that mean the duration is the same too? For example, what is
duration = v.Duration;
for the full video and the full video less the four seconds?
Chidiebere Brendan Obiechefu
Bearbeitet: Chidiebere Brendan Obiechefu am 18 Mai 2021
Yeah it gives me same duration as well which I also don’t get. The video is 30fps so I expected to see numframes less by 120.
Steven Lord
Steven Lord am 18 Mai 2021
Just because you're skipping over the frames doesn't mean the file has fewer frames.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Steven Lord
Steven Lord am 18 Mai 2021

0 Stimmen

Have you read the data from the VideoReader or have you just created the object?
If I open to page 23 of a 345 page long book but then ask how many pages the book has, I'll have to flip to the last page to get the answer 345.
If I ask the question how many pages do I still have to read, one way to do that is to read the pages one by one and count each page as I read it.
I think the "Read Video Using Frame Index and Time Interchangeably" example on the documentation page does something like what you're trying to do.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by