title: How to extract frames at particular intervals from video using matlab
body: <p>I am using matlab 2013a software for my project.</p>
  
  <p>I face a problem while splitting video into individual frames.</p>
  
  <p>I want to know how to get frames at a specific intervals from video.. i.e., i want to grab frames at the rate of one frame per second(frame/sec) .My input video has 50 frames/sec. In the code I have used <strong>step()</strong> to slice the video into frames.</p>
  
  <p>The following is my code , basically a face detection code(detects multiple faces in a video) . This code captures every frame in the video(i.e 50fp approx) and processes it. I want to process frames at the rate of 1 fps. Please help me.</p>
  
  <pre><code>clear classes;
  videoFileReader = vision.VideoFileReader('C:\Users\Desktop\project\05.mp4');
  **videoFrame      = step(videoFileReader);**
  faceDetector = vision.CascadeObjectDetector(); % Finds faces by default
  tracker = MultiObjectTrackerKLT;
  videoPlayer  = vision.VideoPlayer('Position',[200 100       fliplr(frameSize(1:2)+30)]);
  
  bboxes = [];
  while isempty(bboxes)
    **framergb = step(videoFileReader);**
    frame = rgb2gray(framergb);
    bboxes = faceDetector.step(frame); 
  end
  
  tracker.addDetections(frame, bboxes);
  frameNumber = 0;
  keepRunning = true;
  
  while keepRunning
  
     **framergb = step(videoFileReader);**
     frame = rgb2gray(framergb);
  
     if mod(frameNumber, 10) == 0
        bboxes = 2 * faceDetector.step(imresize(frame, 0.5));
        if ~isempty(bboxes)
          tracker.addDetections(frame, bboxes);
        end
     else
      % Track faces
      tracker.track(frame);
     end
  end
  
  %% Clean up
  release(videoPlayer);
  </code></pre>
  
  <p>But this actually considers every frame. I want to grab 1fps.</p>