Cannot play AVI files with Diamondback Debian OpenCV
I can't seem to play AVI files using the latest ROS OpenCV Debian packages under Diamondback and Ubuntu 10.04. Is anyone else able to do this? I am wondering if the Debian packages were compiled without ffmpeg support? Googling around, I found a few sites that recommended first converting the original video like this:
$ mencoder original.avi -ovc raw -vf format=i420 -o out.avi
which I have done. I have then tried both Python and C++ programs to play the out.avi file, but neither produces any image. Here is the C++ source I tried just now:
/**
* How to Play AVI Files with OpenCV
*
* Author Nash
* License GPL
* Website http://nashruddin.com
*/
#include <stdio.h>
#include "cv.h"
#include "highgui.h"
int main( int argc, char** argv )
{
IplImage *frame;
int key;
/* supply the AVI file to play */
assert( argc == 2 );
/* load the AVI file */
CvCapture *capture = cvCaptureFromAVI( argv[1] );
/* always check */
if( !capture ) return 1;
int fps = ( int )cvGetCaptureProperty( capture, CV_CAP_PROP_FPS );
/* display video */
cvNamedWindow( "video", 0 );
while( key != 'q' ) {
/* get a frame */
frame = cvQueryFrame( capture );
/* always check */
if( !frame ) break;
/* display frame */
cvShowImage( "video", frame );
/* quit if user press 'q' */
//key = cvWaitKey( 1000 / fps );
key = cvWaitKey( 50 );
}
/* free memory */
cvReleaseCapture( &capture );
cvDestroyWindow( "video" );
return 0;
}