Record video frames directly to file, screen traversal
I am making a video from a sequence of graphs using VideoWriter
. It works mostly OK (following the next tip, this SO answer ). However, it looks like Matlab is trying to display all 3000 frames to the screen sequentially after it has done the animation, which makes my window manager jittery and the computer freezes for a few minutes.
Is there a way to record video frames directly to disc without going through the screen display? It seems that getframe
in writeVideo(vid, getframe(f))
necessarily makes the figure visible; is there a way to avoid this?
source to share
Using avifile and addframe will allow you to create a video and not display it on screen. This seems to be a slower way of doing things, though.
Here's an example based on the position indicated:
mov = avifile('myPeaks2.avi','fps',15);
set(gcf, 'visible', 'off')
for k=1:20
surf(sin(2*pi*k/20)*Z,Z);
mov = addframe(mov, gcf);
end
mov = close(mov);
Of course, this method is deprecated, so eventually you won't be able to use it.
source to share