Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

VideoWriter: recorded video play too fast

Hello all, I'm new to OpenCv, computer vision in general and to this forum too (so...nice to meet you :-) ). I'm working on the most simple example of reading video from the cam of my laptop and store it in a file (well, to be honest, I apply a log polar transformation before). The problem is that the saved video plays too fast. Here's my basic code:

VideoCapture capture;
capture.open(0);
double fps = capture.get( CAP_PROP_FPS ); // get the fps of the camera, which is 30
VideoWriter writer;
Size size((int)capture.get(CAP_PROP_FRAME_WIDTH),(int)capture.get(CAP_PROP_FRAME_HEIGHT));
writer.open( "sample.avi", VideoWriter::fourcc('M','J','P','G'), fps, size);
Mat logpolar_frame, frame;
for(;;)
{
  capture >> frame;
  imshow("window1", frame);
  logPolar(frame, logpolar_frame,...);
  imshow(window2", logpolar_frame);
  writer.write(logpolar_frame);
  char c = waitKey(1000/fps); // here I tried lot of values, also fps and 1
  if ( c == 27 )
    break;
}
capture.release();
writer.release();

Do you have any idea? Thank you.

VideoWriter: recorded video play too fast

Hello all, I'm new to OpenCv, computer vision in general and to this forum too (so...nice to meet you :-) ). I'm working on the most simple example of reading video from the cam of my laptop and store it in a file (well, to be honest, I apply a log polar transformation before). The problem is that the saved video plays too fast. Here's my basic code:

VideoCapture capture;
capture.open(0);
double fps = capture.get( CAP_PROP_FPS ); // get the fps of the camera, which is 30
VideoWriter writer;
Size size((int)capture.get(CAP_PROP_FRAME_WIDTH),(int)capture.get(CAP_PROP_FRAME_HEIGHT));
writer.open( "sample.avi", VideoWriter::fourcc('M','J','P','G'), fps, size);
Mat logpolar_frame, frame;
for(;;)
{
  capture >> frame;
  imshow("window1", frame);
  logPolar(frame, logpolar_frame,...);
  imshow(window2", imshow("window2", logpolar_frame);
  writer.write(logpolar_frame);
  char c = waitKey(1000/fps); // here I tried lot of values, also fps and 1
  if ( c == 27 )
    break;
}
capture.release();
writer.release();

Do you have any idea? Thank you.