% Make an avi movie from a collection of PNG images in a folder.
% Specify the folder.
myFolder = 'C:\Users\bende\Documents\MATLAB\ppframes';% Get a directory listing.
filePattern = fullfile(myFolder, '*.PNG');pngFiles = dir(filePattern);% Open the video writer object.
writerObj = VideoWriter('YourAVI.avi');% Go through image by image writing it out to the AVI file.
for frameNumber = 1 : length(pngFiles) % Construct the full filename.
baseFileName = pngFiles(frameNumber).name; fullFileName = fullfile(myFolder, baseFileName); % Display image name in the command window.
fprintf(1, 'Now reading %s\n', fullFileName); % Display image in an axes control.
imageArray = imread(fullFileName); imshow(imageArray) % Display image.
% Write this frame out to the AVI file.
writeVideo(writerObj, imageArray);end% Close down the video writer object to finish the file.
close(writerObj);
*I get this error***
Error using VideoWriter/writeVideo (line 338)OBJ must be open before writing video. Call open(obj) before calling writeVideo.Error in Frame_2_vid (line 22) writeVideo(writerObj, imageArray);
Best Answer