Thursday 24 January 2013

Extracting frames from a Video file Matlab Code


%%%%%%              Extracting frames from a Video file Matlab Code           %%%%%%%


clc;
close all;

% Open an sample avi file

filename = '.\003.AVI';
mov = MMREADER(filename);

% Output folder

outputFolder = fullfile(cd, 'frames');
if ~exist(outputFolder, 'dir')
mkdir(outputFolder);
end

%getting no of frames

numberOfFrames = mov.NumberOfFrames;
numberOfFramesWritten = 0;
for frame = 1 : numberOfFrames

thisFrame = read(mov, frame);
outputBaseFileName = sprintf('%3.3d.png', frame);
outputFullFileName = fullfile(outputFolder, outputBaseFileName);
imwrite(thisFrame, outputFullFileName, 'png');
progressIndication = sprintf('Wrote frame %4d of %d.', frame,numberOfFrames);
disp(progressIndication);
numberOfFramesWritten = numberOfFramesWritten + 1;
end
progressIndication = sprintf('Wrote %d frames to folder "%s"',numberOfFramesWritten, outputFolder);
disp(progressIndication);



You might also like : Frames to AVI using Matlab Code

6 comments:

  1. how to extract text from video can you help me out please.

    ReplyDelete
  2. Fantastic blog! I'm so glad to find your page.I really appreciated the concept that you have posted here. Thanks for sharing !

    ReplyDelete
  3. sir can u send for torn film detection and correction to v.vishakha22@gmail.com

    ReplyDelete
  4. I get an error :s : The frame index requested is beyond the end of the file.
    with the same source code

    ReplyDelete
  5. hello friends............does anyone have the code for key frame extraction based on entropy difference...........or code for scene change detection.....if anyone has.please sent it to the mail id: divyankg@gmail.com

    ReplyDelete
  6. Hi! Does anyone have a code for counting number of human beings in an image and counting number of cars in an image? Please mail me to bhaskarsngh19@gmail.com

    ReplyDelete