clc; clear all;
%使用avifile,可进行很多参数的设定修改
aviobj = avifile('test.avi');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%可调整的参数
% Adjustable parameters:
% Fps: 15.0000
% Compression: 'Indeo5'
% Quality: 75
% KeyFramePerSec: 2.1429
% VideoName: 'test.avi'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%
%%自动获得的参数
% Automatically updated parameters:
% Filename: 'test.avi'
% TotalFrames: 0
% Width: 0
% Height: 0
% Length: 0
% ImageType: 'Unknown'
% CurrentState: 'Open'
%%%%%%%%%%%%%%%%%%%%%%%
%使用addframe把图片写入视频
len = 9;%自己设定图片个数
for i = 1 : len
x=int2str(i);
str=strcat('D:\test\',x,'.jpg');%自己设定路径
picdata = imread(str);
aviobj=addframe(aviobj, picdata);
end
aviobj=close(aviobj);
示例:
- vidObj=VideoWriter('test.avi');
- open(vidObj);
- aviobj.Quality = 100;
- aviobj.Fps = 25;
- aviobj.compression='None';
- for i=1:100 ;%此处修改成自己的范围,起始位置
- fname=strcat('img',num2str(i,'%.5d'),'.png');
- adata=imread(fname);
- writeVideo(vidObj,adata);
- end
- close(vidObj);