I am using writevideo to make a movie while creating the images. I have gotten it to work before however, this time it is skipping the last frame although I haven't changed the code. the code is:
if true
narr_anim(7) = struct('cdata',[],'colormap',[]);
myVideo = VideoWriter('dove_anim.avi');
myVideo.FrameRate = 1;
open(myVideo);
for m = 1 : 7
narr_anim(m) = getframe(gcf)
writeVideo(myVideo, narr_anim);
end
close(myVideo);
end
Am I missing something?

 채택된 답변

Ben11
Ben11 2014년 8월 1일

0 개 추천

Maybe use
narr_anim(m).cdata
in your loop? Other than that your code looks fine to me

댓글 수: 7

When playing the video in mediaplayer the video goes black before the last frame. All frames are printed to the screen. When I add your suggestion it gives:
if true
If the colormap field is empty in a frame, cdata must contain an RGB image.
end
Do I need probably need a pause in the writing. My loop is actually two loops. I provided the inner loop.
Leyon
Leyon 2014년 8월 1일
It seems the problem is with windows media player. When I play the video in realplayer it shows all frames correctly. I guess mediaplayer isn't holding for the last frame.
Ben11
Ben11 2014년 8월 1일
ok glad it worked! What windows media player does is kind of weird though.
Leyon
Leyon 2014년 8월 1일
Running the latest version. Version 12.0.7601.18150 on Windows 7 Pro
Ben11
Ben11 2014년 8월 1일
what about vlc?
Leyon
Leyon 2014년 8월 1일
vlc doesn't even play the video. It opens the first frame, runs the length of the movie but doesn't show the other images.
Leyon
Leyon 2014년 8월 1일
videowriter captured all the frames and if I stop WMP it shows the last frame. But during playback, WMP goes black before the last frame is rendered.

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

추가 답변 (0개)

카테고리

태그

질문:

2014년 8월 1일

댓글:

2014년 8월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by