readFrame is only reading half of of my video frames

18 ビュー (過去 30 日間)
Armin Panjehpour
Armin Panjehpour 2021 年 4 月 17 日
回答済み: LO 2021 年 4 月 17 日
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

採用された回答

LO
LO 2021 年 4 月 17 日
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 件)

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by