3
$\begingroup$

I have 10 images in the folder say "D:\images\" named as frame1,frame2,...,frame10. I want to make a movie from the color images with frame rate as per choice.Also i want to save created video file in .mp4 format at the location "D:\video\".

Is it possible to do so in MATLAB?how?

$\endgroup$
  • $\begingroup$ This isn't a DSP question. This is a general and a Stack Overflow question. $\endgroup$ – Scott Jul 28 '14 at 2:34
2
$\begingroup$

It is easy to do using the VideoWriter class.

You easily add frame (Image) using the proper method which is writeVideo.

After creating a video object, videoObject and given an image by mImage001, adding frame is done by:

writeVideo(videoObject, mImage001);

Enjoy...

Code Sample

Here is a code sample based on Mathworks documentation with some remarks of mine:

% Creating Video Writer Object
writerObj = VideoWriter('peaks.avi');
% Using the 'Open` method to open the file
open(writerObj);

% Creating a figure.
% Each frame will be a figure data
Z = peaks; surf(Z); 
axis tight
set(gca,'nextplot','replacechildren');
set(gcf,'Renderer','zbuffer');

for k = 1:20 
   surf(sin(2*pi*k/20)*Z,Z)
   % Frame includes image data
   frame = getframe;
   % Adding the frame to the video object using the 'writeVideo' method
   writeVideo(writerObj,frame);
end

% Closing the file and the object using the 'Close' method
close(writerObj);

This should be straight forward.

$\endgroup$
  • $\begingroup$ sir,can u explain it using any simple example.because i am getting difficulty in making video of color images like colormap adjustments and writevideo command.so can u take example $\endgroup$ – ramdas1989 Jul 27 '14 at 14:21
  • 1
    $\begingroup$ I added code sample. Enjoy... $\endgroup$ – Royi Jul 27 '14 at 17:01
  • $\begingroup$ thank u very much sir for your help ;-) $\endgroup$ – ramdas1989 Jul 28 '14 at 14:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.