Skip to Main Content Skip to Search
Product Documentation

addframe (avifile) - Add frame to Audio/Video Interleaved (AVI) file

Syntax

aviobj = addframe(aviobj,frame)
aviobj = addframe(aviobj,frame1,frame2,frame3,...)
aviobj = addframe(aviobj,mov)
aviobj = addframe(aviobj,h)

Description

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,frame1,frame2,frame3,...) adds multiple frames to an 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.

Tips

Examples

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);

See Also

avifile | close (avifile) | movie2avi | VideoWriter

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS