Skip to Main Content Skip to Search
Product Documentation

avifile - Create new Audio/Video Interleaved (AVI) file

Syntax

aviobj = avifile(filename)
avifile(filename, ParameterName, ParameterValue)

Description

aviobj = avifile(filename) creates an avifile object, giving it the name specified in filename, using default values for all avifile object properties. If filename does not include an extension, avifile appends .avi to the file name. AVI is a file format for storing audio and video data.

avifile returns a handle to an AVI file object aviobj. Use this object to refer to the AVI file in other functions. An AVI file object supports properties and methods that control aspects of the AVI file created.

aviobj = avifile(filename, ParameterName, ParameterValue) accepts one or more comma-separated parameter name/value pairs. Set parameter values before any calls to addframe. The following table lists the available parameters and values.

Parameter Name

Value

Default

'colormap'

An m-by-3 matrix defining the colormap for indexed AVI movies, where m is no more than 256 (236 for Indeo compression).

Valid only when the 'compression' is 'MSVC', 'RLE', or 'None'.

No default

'compression'

A text string specifying the compression codec to use. To create an uncompressed file, specify a value of 'None'.

On UNIX® operating systems, the only valid value is 'None'.

On Windows systems, valid values include:

  • 'MSVC'

  • 'RLE'

  • 'Cinepak' on 32-bit systems.

  • 'Indeo3' or 'Indeo5' on 32-bit Windows XP systems.

Alternatively, specify a custom compression codec on Windows systems using the four-character code that identifies the codec (typically included in the codec documentation). If MATLAB cannot find the specified codec, it returns an error.

'Indeo5' on Windows systems.

'None' on UNIX systems.

'fps'

A scalar value specifying the speed of the AVI movie in frames per second (fps).

15 fps

'keyframe'

For compressors that support temporal compression, the number of key frames per second.

2.1429 key frames per second

'quality'

A number from 0 through 100. Higher quality numbers result in higher video quality and larger file sizes. Lower quality numbers result in lower video quality and smaller file sizes.

Valid only for compressed movies.

75

'videoname'

A descriptive name for the video stream, no more than 64 characters.

filename

Tips

Examples

Create the AVI file example.avi:

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

Alternatives

Use VideoWriter rather than avifile to create AVI files. VideoWriter supports files larger than 2 GB, and by default, creates files with Motion JPEG compression, which all platforms support.

See Also

addframe (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