Ask Your Question
0

Cannot play AVI files with Diamondback Debian OpenCV

asked 2011-05-30 05:59:03 -0500

Pi Robot gravatar image

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;
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2011-05-30 06:19:36 -0500

updated 2011-05-30 06:20:13 -0500

Someone in the lab ran into this as well. Apparently the binary distribution of vision_opencv does not come with ffmped support. I haven't tested this, but they told me to download it from source, and change the following line in the Makefile:

-D WITH_FFMPEG=OFF \

Then recompile.

Hope this helps

edit flag offensive delete link more

Comments

Thanks Ivan--that did the trick. Support for ffmpeg seems to have been turned off deliberately as I found here: https://code.ros.org/trac/ros-pkg/changeset/15321. I submitted a new ticket (https://code.ros.org/trac/ros-pkg/ticket/4980) to see if it can be turned back on. --patrick
Pi Robot gravatar imagePi Robot ( 2011-05-30 12:30:10 -0500 )edit

Hi My ROS vervion is hydro, and I cannot find the makefile. Could you tell me where is the Opencv's Makefile? Thanks

yuky gravatar imageyuky ( 2014-05-25 16:42:40 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-05-30 05:59:03 -0500

Seen: 1,006 times

Last updated: May 30 '11