r_movie.m 1 KB
function r_movie(movfile,fr)
% R_MOVIE - Assemble all jpeg files present in the current directory
% into a Motion JPEG AVI file.
% 
% Syntax:  r_movie(movfile,fr)
% 
% Inputs:
%    movfile - The output video file name
%    fr      - Number of frames per seconds
% 
% Example:
%    r_movie('test5_cam1',25);
% 
% Other m-files required: Image Processing Toolbox
% Subfunctions: none
% MAT-files required: none
% 
% See also: R_ROTATE, R_SHOW
% 
% Author: Dany Dumont
% UQAR/ISMER
% email: dany_dumont@uqar.ca
% Website: http://www.ismer.ca/dumont-dany
% July 2013; Last revision: August 2013
% ______________________________________________________________________

%imfiles = dir('*.png');
imfiles = dir('*.jpg');
nFrames = size(imfiles,1);

writerObj = VideoWriter([movfile,'.avi'],'Motion JPEG AVI');
writerObj.FrameRate = fr;
open(writerObj)

disp(' ... in progress ...');

for n=1:nFrames
    I = imread(imfiles(n).name);
    M = im2frame(I,[0 1 0]);
    writeVideo(writerObj,M);
end

close(writerObj);
disp(' done!');