MATLAB Answers

How to rewind in VideoReader?

조회 수: 24(최근 30일)
K E
K E 2016년 3월 9일
답변: Walter Roberson 2016년 3월 12일
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
Image Analyst
Image Analyst 2016년 3월 11일
Put these comments in the "Answers" section.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2016년 3월 12일
time_to_remember = vidObj.CurrentTime;
.... do some things that read frames ...
vidObj.CurrentTime = time_to_remember; %position back to where we were

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by