我试图用matlab中的95个图像制作视频。当我运行程序时,我收到此错误:
Error using VideoWriter/writeVideo (line 383)
Frame must be 481 by 272
Error in savenew (line 14)
writeVideo(writerObj,im2frame(Frame)
虽然当我用于制作视频的图像数量低于11时,我没有问题,程序正在构建我想要的视频。你知道我怎么解决这个问题吗?
提前致谢
这是我的更新代码:
ImagesFolder=uigetdir;
jpegFiles = dir(strcat(ImagesFolder,'\*.jpg'));
S = [jpegFiles(:).datenum];
[S,S] = sort(S);
jpegFilesS = jpegFiles(S);
VideoFile=strcat(ImagesFolder,'\MyVideo');
writerObj = VideoWriter(VideoFile);
fps= 10;
writerObj.FrameRate = fps;
open(writerObj);
for t= 1:length(jpegFilesS)
Frame=imread(strcat(ImagesFolder,'\',jpegFilesS(t).name));
B = imresize(Frame, 1.0);
C=im2double(B);
writeVideo(writerObj,im2frame(C));
end
close(writerObj);
implay('C:\Program Files\MATLAB\R2013a\bin\sfalmata neo\MyVideo.avi');
答案 0 :(得分:3)
视频的所有帧必须具有相同的大小。使用“imresize”调整帧大小。如果数据类型不同,也应用'im2double'