MATLAB Function Reference |
Create a new Audio Video Interleaved (AVI) file
Syntax
aviobj = avifile(filename)
aviobj =
avifile(filename,'PropertyName',value,'PropertyName',value,...)
Description
aviobj = avifile(filename)
creates an AVI file, giving it the name specified in
filename
, using default values for all AVI file object properties. If filename
does not include an extension, avifile
appends .avi
to the filename. AVI is a file format for storing audio and video data.
avifile
returns a handle to an AVI
file object, aviobj
. You 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,'Param',Value,'Param',Value,...)
creates an AVI file with the specified parameter settings. This table lists available parameters.
Parameter |
Value | Default |
|
'colormap' |
An m -by-3 matrix defining the colormap to be used for indexed AVI movies, where m must be no greater than 256 (236 if using Indeo compression). You must set this parameter before calling addframe , unless you are using addframe with the MATLAB movie syntax. | There is no default colormap. |
|
'compression' |
A text string specifying which compression codec to use. | ||
|
On Windows:'Indeo3' ''Cinepak ''MSVC ''None' |
On Unix: 'None' |
'Indeo3' , on Windows. 'None' on Unix. |
|
To use a custom compression codec, specify the four-character code that identifies the codec (typically included in the codec documentation). The addframe function reports an error if it can not find the specified custom compressor. | ||
'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, this is the number of key frames per second. | 2 key frames per second. |
|
'name' |
A descriptive name for the video stream. This parameter must be no greater than 64 characters long. | The default is the filename. |
|
'quality' |
A number between 0 and 100. This parameter has no effect on uncompressed movies. Higher quality numbers result in higher video quality and larger file sizes. Lower quality numbers result in lower video quality and smaller file sizes. | 75 |
You can also use structure syntax to set AVI file object properties. For example, to set the quality property to 100 use the following syntax:
aviobj = avifile(filename); aviobj.Quality = 100;
Example
This example shows how to use the avifile
function to create the AVI file example.avi
.
fig=figure; set(fig,'DoubleBuffer','on'); set(gca,'xlim',[-80 80],'ylim',[-80 80],... 'NextPlot','replace','Visible','off') mov = avifile('example.avi') x = -pi:.1:pi; radius = 0:length(x); for i=1:length(x) h = patch(sin(x)*radius(i),cos(x)*radius(i),... [abs(cos(x(i))) 0 0]); set(h,'EraseMode','xor'); F = getframe(gca); mov = addframe(mov,F); end mov = close(mov);
See Also
auwrite | aviinfo |