MATLAB Answers

Pause a Frame in an Animation

조회 수: 54(최근 30일)
Jnandeep Talukdar
Jnandeep Talukdar 15 Mar 2021
Hello,
I am trying to create an animation using VideoWriter. In between the animation, I want a frame to be paused for 10 seconds. Can anybody help me with this?
Also, is it possible to have a different frame rate for a single video object? Like, the initial frames have fps 20 while the other part have fps 10. If yes, how?
( PS: If you have answer to only one of the question, you are still welcome to answer. )
  댓글 수: 1
KSSV
KSSV 15 Mar 2021
Read about pause

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

답변(1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 15 Mar 2021
편집: KALYAN ACHARJYA 15 Mar 2021
Adjust the frame rate this way?
video_data=VideoWriter('test_video');
video_data.FrameRate=5;
open(video_data)
for i=1:50
clf;
data=uint8(randi([0,255],[500,500]));
imshow(data);
pause(randi(3)); % You have to adjust this accordingly
frame=getframe(gcf);
writeVideo(video_data,frame);
end
close(video_data);
  댓글 수: 1
Jnandeep Talukdar
Jnandeep Talukdar 15 Mar 2021
I tried implementing the code but the frame rate remains the same throughout the animation (5 fps here). In my original code I have an initial frame rate of 5 fps and I want to freeze the 100th frame for 10 seconds in the animation. Sorry if I wasn't clear in the question. Can you help me out now?

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

Community Treasure Hunt

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

Start Hunting!

Translated by