I am stuck on how to create an video file from from a sequence of images.
I have a folder with images as follows:
image01.png
image02.png
...
image150.png
How do I combine them to a video in Matlab?
I saw this link explaining it, but I could not understand it exactly.
You may want to do something like this:
nImage = 150; % L1
fps = 3.0; % L2
addToInFolder = 'Address\to\Input\Images\Folder'; % L3
addToOutFolder = 'Address\to\Output\Video\Folder'; % L4
oVideo = VideoWriter(fullfile(addToOutFolder, 'myVideo.avi')); % L5
oVideo.FrameRate = fps; % L6
open(oVideo) % L7
for i = 1:nImage % L8
fname = ['image' num2str(i, '%.2d') '.png']; % L9
curImage = imread(fullfile(addToInFolder,fname)); % L10
writeVideo(oVideo, curImage); % L11
end % L12
close(oVideo) % L13
Since you could not follow the example, here is a break down of what is going on per line:
fps
. FrameRate
is a property of a video object. See this page for the complete list of properties you can play with. There are properties you may want to play with like Quality
, Duration
, CompressionRatio
, etc).curImage
curImage
to the video file pointed by oVideo
oVideo
) that was opened beforeCollected from the Internet
Please contact [email protected] to delete if infringement.
Comments