Ask Your Question
0

error write avi file

asked 2012-08-03 19:56:25 -0500

aeromind gravatar image

updated 2012-08-06 03:41:45 -0500

sammy gravatar image

Hello there, i got started recently in opencv and i'm having the following error when i try run a code that convert the video to a grayscale:

OpenCV Error: Unsupported format or combination of formats (Gstreamer Opencv backend doesn't support this codec acutally.) in CvVideoWriter_GStreamer::open, file /home/daniel/Downloads/OpenCV-2.4.2/modules/highgui/src/cap_gstreamer.cpp, line 479 terminate called after throwing an instance of 'cv::Exception' what(): /home/daniel/Downloads/OpenCV-2.4.2/modules/highgui/src/cap_gstreamer.cpp:479: error: (-210) Gstreamer Opencv backend doesn't support this codec acutally. in function CvVideoWriter_GStreamer::open

the code is:


// argv[1]: input video file
// argv[2]: name of new output file
//
#include "cv.h"
#include "highgui.h"
int main( int argc, char* argv[] )
{
    CvCapture* capture = 0;
    capture = cvCreateFileCapture( argv[1] );
    if(!capture)
    {
        return -1;
    }
    IplImage *bgr_frame=cvQueryFrame(capture);//Init the video read
    double fps = cvGetCaptureProperty (
    capture,
    CV_CAP_PROP_FPS
    );

    CvSize size = cvSize(
    (int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH),
    (int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT)
    );
    CvVideoWriter *writer = cvCreateVideoWriter("window",
    CV_FOURCC('M','J','P','G'),
    fps,
    size
    );
    IplImage* logpolar_frame = cvCreateImage(
    size,
    IPL_DEPTH_8U,
    3
    );
    while( (bgr_frame=cvQueryFrame(capture)) != NULL ) {
    cvLogPolar( bgr_frame, logpolar_frame,
    cvPoint2D32f(bgr_frame->width/2,
    bgr_frame->height/2),
    40,
    CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS );
    cvWriteFrame( writer, logpolar_frame );
    }
    cvReleaseVideoWriter( &writer );
    cvReleaseImage( &logpolar_frame );
    cvReleaseCapture( &capture );
    return(0);
}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-08-05 21:12:27 -0500

Hi!

Are you certain to have installed the video codecs? According to the documentation:

(Optional) ffmpeg, libgstreamer, libv4l, libxine, unicap, libdc1394 2.x.

You should have some/all of these packages installed (together with associated development packages) to add video capturing, video decoding and video encoding capabilities to highgui. The output of the cmake will show you, which of the packages have been detected and will be used in highgui. Enable full video support with FFMPEG. For example, on Ubuntu 9.10 all the necessary ffmpeg files can be installed using the following command: sudo apt-get install libavformat-dev libswscale-dev

edit flag offensive delete link more

Comments

i thought that i had all the codecs installed sucessfully,but i'm going to check it right now and soon give the feedback

aeromind gravatar imageaeromind ( 2012-08-07 10:59:11 -0500 )edit

i still have problems with it. i reinstalled the ffmpeg, but the error remains the same.what should i do?

aeromind gravatar imageaeromind ( 2012-08-07 21:52:42 -0500 )edit

Did you activated the flag WITH_FFMPEG=ON when you executed CMake?

Martin Peris gravatar imageMartin Peris ( 2012-08-08 02:19:14 -0500 )edit

No,how can i do that? i just followed the steps in this site: https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide

aeromind gravatar imageaeromind ( 2012-08-08 06:57:07 -0500 )edit

i'm certain that i installed it because i checked the version and showed: daniel@ubuntu:~$ ffmpeg -version ffmpeg version git-2012-08-08-e40f7f1 built on Aug 7 2012 23:31:39 with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1) configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-version3 --enable-x11grab libavutil 51. 66.101 / 51. 66.101 libavcodec 54. 51.100 / 54. 51.100 libavformat 54. 22.101 / 54. 22.101 libavdevice 54. 2.100 / 54. 2.100 libavfilter 3. 6.100 / 3. 6.100 libswscale 2. 1.101 / 2. 1.101 libswresample 0. 15.100 / 0. 15.100 libpostproc 52. 0.100 / 52. 0.100

aeromind gravatar imageaeromind ( 2012-08-08 08:09:27 -0500 )edit

it's working now! i don't know exactly what made the error,maybe a lib was left behind before the last installation. thank you!

aeromind gravatar imageaeromind ( 2012-08-08 11:13:38 -0500 )edit

I am glad that it is working now :)

Martin Peris gravatar imageMartin Peris ( 2012-08-08 22:12:03 -0500 )edit
1

I had the same problem. I fixed it (after half a days work) by addin '.avi' to the filename where I store the video files.

toby gravatar imagetoby ( 2013-09-02 06:56:19 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2012-08-03 19:56:25 -0500

Seen: 5,374 times

Last updated: Aug 06 '12