MATLAB: How to create one .avi-video from a folder with i.png files

image processingvideovideo processing

Hi, I have a folder with 20000 .png files named 1.png, 2.png, and so on until 20000. I would like to make a .avi-video of it. The size of the entire folder is about 90MB. I read the documentation about the video writer but it did not address this specific problem.
I wonder if someone could help or suggest me which commands to load and and make the .png to a video file.
I thank you in advance for your help
Emerson

Best Answer

writerObj = VideoWriter('YourAVI.avi');
open(writerObj);
for K = 1 : 20000
filename = sprintf('%d.png', K);
thisimage = imread(filename);
writeVideo(writerObj, thisimage);
end
close(writerObj);