How to rewind in VideoReader?
Ältere Kommentare anzeigen
If I have read several frames in VideoReader, how can I rewind to the first frame? In this example, let's say I stop the replay after 5 frames (enter 0 when prompted at the 5th frame). After that I want to rewind to the 1st frame, for example if I want to display the first frame again. How do I rewind?
vidObj = VideoReader('xylophone.mp4'); % Make a video object of an example video on everyone's path
iStop = []; % Stop the frame display if this is not empty
while hasFrame(vidObj) & isempty(iStop) % Loop through all frames
vidFrame = readFrame(vidObj);
imagesc(vidFrame);
iStop = input('0 to stop, return to continue ');
end
4 Kommentare
Adam
am 9 Mär. 2016
You can set
vidObj.CurrentTime;
to specify the time in seconds from which you would read the next frame. You can also get the 'NumberOfFrames' and 'FrameRate' settings if you need to calculate the time (if it were something other than the start).
Not sure if that helps or not. I am not familiar with VideoReader myself so I just looked at the help documentation.
Walter Roberson
am 10 Mär. 2016
time_to_remember = vidObj.CurrentTime;
.... do some things that read frames ...
vidObj.CurrentTime = time_to_remember; %position back to where we were
Image Analyst
am 11 Mär. 2016
Put these comments in the "Answers" section.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Audio and Video Data finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!