Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Have a look on VideoCapture::get, where using the property identifier CV_CAP_PROP_FPS you will get the frame rate, using this you can,

  • Convert start time and stop time to frame count using

     start_frame_count = frame_per_sec * 60 * start_time_in_min;   
     stop_frame_count = frame_per_sec * 60 * stop_time_in_min;
    
  • Count frames in while loop.

  • Check whether the count reaches on start or stop frame count.

    The code look like,

     frameCount=0;
      while(1)
      {
       frameCount++;
       capture.read(frame); 
       if(frameCount>=start_frame_count&&frameCount<stop_frame_count) 
          VideoWriter.write(frame); 
       else if(frameCount == stop_frame_count)
         break;
       }
    

Also refer the answer here, might be useful.

Note: The code is not tested.