readFrame is only reading half of of my video frames
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
v=VideoReader('crosswalk.mp4');
NrFrames = v.NumFrames % this one gives me 450 frames
t=0;
while hasFrame(v)
I = readFrame(v);
t=t+1;
end
% but the variable t gives me 225 frames
I`m using the code below to read the number of frames of my video but when I use readFrame it will cound half of my frames which is 225 but the total number of frames is 450 which v.NumFrames gives.
I`ve attached my video too. MY video
I really appreciate your support. Thanks
0 Commenti
Risposta accettata
LO
il 17 Apr 2021
it is probably because the frame rate of the video is detected as 15 fps
v=VideoReader('crosswalk.mp4');
t=0;
while hasFrame(v)
I = readFrame(v);
t=t+1;
end
duration = t/v.FrameRate % frames /fps = sec
you could do 2 things
either run another script to convert the frame rate of your video (basically use videowrite, set the right number of frames, load frame by frame and write each from to a new video... or try using some external software to correct the frame rate reading (ffmpeg could work).
I guess matlab is fine but simply the video info is read wrongly.
I found someone having had the same issue
see if it helps
https://www.mathworks.com/matlabcentral/answers/106048-problem-for-read-frame-of-video-clip-mp4
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!