Info

This question is closed. Reopen it to edit or answer.

photos to movie

4 views (last 30 days)
Sivakumaran Chandrasekaran
Answered: yanqi liu on 26 Nov 2021
i have a software to convert photos to videos.. is there any option in MATLAB to achieve it?

Answers (2)

Walter Roberson
Walter Roberson on 9 Jun 2012
See the example in the VideoWriter documentation.
  2 Comments
Sivakumaran Chandrasekaran
hi walter,
where to get the details about videowriter. I am not able to get details about this in my version
Walter Roberson
Walter Roberson on 9 Jun 2012
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
yanqi liu on 26 Nov 2021
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);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!