Info
此问题已关闭。 请重新打开它进行编辑或回答。
photos to movie
3 次查看(过去 30 天)
显示 更早的评论
i have a software to convert photos to videos.. is there any option in MATLAB to achieve it?
0 个评论
回答(2 个)
Walter Roberson
2012-6-9
See the example in the VideoWriter documentation.
2 个评论
Walter Roberson
2012-6-9
http://www.mathworks.com/help/techdoc/ref/videowriterclass.html
See also http://www.mathworks.com/help/techdoc/ref/avifile.html
http://www.mathworks.com/help/techdoc/ref/movie2avi.html
http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
yanqi liu
2021-11-26
yes,sir,let us use the imgFilePath jpgs to avi file,such as
function Images2Video(imgFilePath, filename_out)
if nargin < 2
imgFilePath = fullfile(pwd, 'david\img');
filename_out = fullfile(pwd, 'out.avi');
end
% 清理空间
clc;
% 起始帧
startnum = 1;
% 默认结束帧为jpg图像数目
endnum = size(ls(fullfile(imgFilePath, '*.jpg')), 1);
% 创建对象句柄
writerObj = VideoWriter(filename_out);
% 设置帧率
writerObj.FrameRate = 24;
% 开始打开
open(writerObj);
% 进度条
h = waitbar(0, '', 'Name', 'Write Video File...');
% 总帧数
steps = endnum - startnum;
for num = startnum : endnum
% 当前序号的名称
file = sprintf('%04d.jpg', num);
% 当前序号的位置
file = fullfile(imgFilePath, file);
% 读取
frame = imread(file);
% 转化为帧对象
frame = im2frame(frame);
% 写出
writeVideo(writerObj,frame);
% 刷新
pause(0.01);
% 进度
step = num - startnum;
% 显示进度条
waitbar(step/steps, h, sprintf('Process:%d%%', round(step/steps*100)));
end
% 关闭句柄
close(writerObj);
% 关闭进度条
close(h);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!