Add frame to Audio/Video Interleaved (AVI) file
Note: avifile has been removed. Use VideoWriter instead.
aviobj = addframe(aviobj,frame1,frame2,frame3,...)
aviobj = addframe(aviobj,mov)
aviobj = addframe(aviobj,h)
aviobj = addframe(aviobj,frame) appends the data in frame to the AVI file identified by aviobj, which was created by a previous call to avifile. frame can be either an indexed image (m-by-n) or a truecolor image (m-by-n-by-3) of double or uint8 precision. If frame is not the first frame added to the AVI file, it must be consistent with the dimensions of the previous frames.
addframe returns a handle to the updated AVI file object, aviobj. For example, addframe updates the TotalFrames property of the AVI file object each time it adds a frame to the AVI file.
aviobj = addframe(aviobj,mov) appends the frames contained in the MATLAB® movie mov to the AVI file aviobj. MATLAB movies that store frames as indexed images use the colormap in the first frame as the colormap for the AVI file, unless the colormap has been previously set.
aviobj = addframe(aviobj,h) captures a frame from the figure or axis handle h and appends this frame to the AVI file. addframe renders the figure into an offscreen array before appending it to the AVI file. This ensures that the figure is written correctly to the AVI file even if the figure is obscured on the screen by another window or screen saver.
This example calls addframe to add frames to the AVI file object aviobj.
aviobj = avifile('example.avi','compression','None'); t = linspace(0,2.5*pi,40); fact = 10*sin(t); fig=figure; [x,y,z] = peaks; for k=1:length(fact) h = surf(x,y,fact(k)*z); axis([-3 3 -3 3 -80 80]) axis off caxis([-90 90]) F = getframe(fig); aviobj = addframe(aviobj,F); end close(fig); aviobj = close(aviobj);
avifile cannot write files larger than 2 GB. Use VideoWriter and writeVideo to create larger files.
If you are creating an animation from a figure with an EraseMode property set to 'xor', you must use getframe to capture the graphics into a frame of a MATLAB movie. Add the frame to the AVI file using the syntax aviobj = addframe(aviobj,mov). See the example for an illustration.