在这里,我正在尝试将图像帧转换为视频。图像框包含在文件夹'folder_1'中。每当我试图运行它时,我都会收到错误:''RIFF'没有按预期显示'。下面是代码。这里可能有什么问题?是的,图像采用高动态范围格式。
files = dir('folder_1');
aviobj = avifile('a.avi'); %creating a movie object
for i=1:numel(files) %number of images to be read
a = hdrread(file(i));
a = uint8(a);%convert the images into unit8 type
M = im2frame(a);%convert the images into frames
aviobj = addframe(aviobj,M);%add the frames to the avi object created previously
fprintf('adding frame = %i\n', i);
end
disp('Closing movie file...')
aviobj = close(aviobj);
disp('Playing movie file...')
implay('a.avi');
答案 0 :(得分:3)
% Create a video writer object
writerObj = VideoWriter('Video.avi');
% Set frame rate
writerObj.FrameRate = 30;
% Open video writer object and write frames sequentially
open(writerObj)
for i = 1:30 % Some number of frames
% Read frame
frame = sprintf('frame %d.jpg', i);
input = imread(frame);
% Write frame now
writeVideo(writerObj, input);
end
% Close the video writer object
close(writerObj);
% 'Video.avi' will be created in the folder that contains the code.
此代码可以使用。
答案 1 :(得分:2)
files = dir('folder_1');
N=10;
nframe=3000;
writerObj = VideoWriter( 'MINALIVE .avi' );
writerObj.FrameRate = N;
open(writerObj);
figure;
for i=1:numel(files) %number of images to be read
a = hdrread(file(i));
a = uint8(a);%convert the images into unit8 type
f.cdata = a;
f.colormap = [];
writeVideo(writerObj,f);
end
close(writerObj);
你可以尝试一下这可能有效!