用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);
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值