用matlab 将图片序列导出视频

code:


aviobj = avifile('video1(6).avi');%名字
aviobj.Quality = 100;
aviobj.Fps = 6;%帧速率
aviobj.compression='None';
for i=1:29   ;%此处修改成自己的范围,起始位置
    x=int2str(i);%
       fname=strcat('E:\d4-19-basic-0.0001\d4-19-basic-0.0001\',x,'.jpg')
       adata=imread(fname);
    aviobj = addframe(aviobj,uint8(adata));
end
aviobj=close(aviobj);

以下是help matlab 对于avifile的解释:

AVIFILE Create a new AVI file
AVIOBJ = AVIFILE(FILENAME) creates an AVIFILE object AVIOBJ with the
default parameter values. If FILENAME does not include an extension,
then ‘.avi’ will be used.//可以只写文件名,省略后缀
Use AVIFILE/CLOSE to close the file opened by
AVIFILE. Use “clear mex” to close all open AVI files.

AVIOBJ = AVIFILE(FILENAME,'PropertyName',VALUE,'PropertyName',VALUE,...)
returns an AVIFILE object with the specified property values.

AVIFILE parameters

**FPS**         - The frames per second for the AVI movie. This parameter
must be set before using ADDFRAME. The default is 15 fps.

**COMPRESSION** - A string indicating the compressor to use.  On UNIX, this
value must be 'None'.  Valid values for this parameter on Windows are
'Indeo3', 'Indeo5', 'Cinepak', 'MSVC', 'RLE' or 'None'.

To use a custom compressor, the value can be the four character code as
specified by the codec documentation. An error will result during the
call to ADDFRAME if it can not find the specified custom compressor. 
This parameter must be set before using ADDFRAME. 
The default is 'Indeo5' on Windows and 'None' on UNIX.
Note: Indeo5 may not be available in some versions of Windows.

**QUALITY**      - A number between 0 and 100. This parameter has no effect
on uncompressed movies. This parameter must be set before using
ADDFRAME. Higher quality numbers result in higher video quality and
larger file sizes, where lower quality numbers result in lower video
quality and smaller file sizes.  The default is 75. 

**KEYFRAME**     - For compressors that support temporal compression, this
is the number of key frames per second.  This parameter must be set
before using ADDFRAME.  The default is 2 key frames per second.

**COLORMAP**     - An M-by-3 matrix defining the colormap to be used for indexed
AVI movies.  M must be no greater than 256 (236 if using Indeo
compression). This parameter must be set before calling ADDFRAME, unless
you are using ADDFRAME with the MATLAB movie syntax.  There is no
default colormap.

**VIDEONAME**    - A descriptive name for the video stream.  This parameter
must be no greater than 64 characters long and must be set before using
ADDFRAME. The default is the filename. 


AVIFILE properties may also be set using MATLAB structure syntax.  For
example, to set the Quality property to 100 use the following syntax: 

   aviobj = avifile(filename);
   aviobj.Quality = 100;


Example: 

   t = linspace(0,2.5*pi,40);
   fact = 10*sin(t);
   fig=figure;
   aviobj = avifile('example.avi')
   [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);

你可能感兴趣的:(matlab)