How read frames within specified time interval exactly from video?
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, everyone.
In Matlab R2017b, I tried to read video frames within specified time interval in this URL ->(https://jp.mathworks.com/help/matlab/import_export/read-video-files.html?searchHighlight=CurrentTime&s_tid=doc_srchtitle)
However, I could not read frames in exact time. When I tried this, extracted frames is always misaligned about 15 frames from the original video.
Are there any ideas for solving this problem or another way to read frames?
5 Commenti
Tohru Kikawada
il 13 Feb 2018
Modificato: Tohru Kikawada
il 14 Feb 2018
The code you shared works on my end. Could you please clarify the problem you are facing? Otherwise, it might be a problem depending on the codec which is installed on your end.

vidObj = VideoReader('xylophone.mp4');
s = struct('cdata',zeros(vidObj.Height,vidObj.Width,3,'uint8'),...
'colormap',[]);
k = 1;
currAxes = axes;
while hasFrame(vidObj)
% Acquire the current time
t = vidObj.CurrentTime;
% Acquire the video frame
vidFrame = readFrame(vidObj);
% Needs Computer Vision System Toolbox
vidFrame = insertText(vidFrame,[0 0],num2str(t,'time:% f'),'FontSize',40);
% Capture the video frames at the specified duration
if 0.6 <= t && t <= 0.9
s(k).cdata = vidFrame;
k = k+1;
end
% Show the video frame slowly
image(vidFrame, 'Parent', currAxes);
currAxes.Visible = 'off';
drawnow limitrate;
pause(1/vidObj.FrameRate);
end
% Display the captured results
frames = cat(4,s.cdata);
figure, montage(frames);
Anna Karchevskaya
il 21 Set 2020
Modificato: Anna Karchevskaya
il 22 Set 2020
Good day, I used the same code on my video, but I have two questions:
1) Is it possible to reduce numer of frames? I want to get frames for every 150 ms for a specific period of time. I mean, I got the idea, how to do it:
But I cant understand how to implement this code into your?
2) How can I export these frames one by one (for a specific period of time), so I won't get the "montage" - picture in the end. I mean, what should be written in the code in this case?
Thank you
Risposte (0)
Vedere anche
Categorie
Scopri di più su オーディオとビデオ in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!