Ask Your Question
0

video write ubuntu [closed]

asked 2018-07-25 03:25:13 -0600

burakakde gravatar image

Hi

I am trying to save results of YOLO to .avi file. Having already seen the following post https://github.com/pjreddie/darknet/i... (I even asked the question there) I could NOT find any solution. I here is the code in which I am trying to save the .avi.

{
    CvSize size;
    size.width = disp->width;
    size.height = disp->height;

    static CvVideoWriter* output_video = NULL;    // cv::VideoWriter output_video;
    if (output_video == NULL)
    {
        printf("\n SRC output_video = %p \n", output_video);
        const char* output_name = "test_dnn_out.avi";
        output_video = cvCreateVideoWriter(output_name, CV_FOURCC('D', 'I', 'V', 'X'), 25, size, 1);
        printf("\n cvCreateVideoWriter, DST output_video = %p  \n", output_video);
    }
        cvWriteFrame(output_video, disp);
}

Trying plenty of codecs ( changing CV_FOURCC('D', 'I', 'V', 'X') ) I get errors below:

**CODEC :-1**

**ERROR**

SRC output_video = (nil) 
OpenCV: FFMPEG: tag 0xffffffff/'����' is not found (format 'avi / AVI (Audio Video Interleaved)')'
OpenCV Error: Unsupported format or combination of formats (Gstreamer Opencv backend does not support this codec.) in CvVideoWriter_GStreamer::open, file /home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line 1522
VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps, frameSize, is_color)): raised OpenCV exception:

/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1522: error: (-210) Gstreamer Opencv backend does not support this codec. in function CvVideoWriter_GStreamer::open


**CODEC: CV_FOURCC('M', 'J', 'P', 'G')**

**ERROR**

SRC output_video = (nil) 
OpenCV Error: Unspecified error (GStreamer: cannot put pipeline to play
) in CvVideoWriter_GStreamer::open, file /home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line 1690
VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps, frameSize, is_color)): raised OpenCV exception:

/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1690: error: (-2) GStreamer: cannot put pipeline to play
 in function CvVideoWriter_GStreamer::open


**CODEC: CV_FOURCC('P','I','M','1')**
SRC output_video = (nil) 

**ERROR**

** (Demo:6801): CRITICAL **: gst_ffmpeg_cfg_set_property: assertion 'qdata->size == sizeof (gint64)' failed
OpenCV Error: Unspecified error (GStreamer: cannot put pipeline to play
) in CvVideoWriter_GStreamer::open, file /home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line 1690
VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps, frameSize, is_color)): raised OpenCV exception:

/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1690: error: (-2) GStreamer: cannot put pipeline to play
 in function CvVideoWriter_GStreamer::open



**CODEC:CV_FOURCC('M', 'P', '4', '2')**

**ERROR**

SRC output_video = (nil) 

** (Demo:7437): CRITICAL **: gst_ffmpeg_cfg_set_property: assertion 'qdata->size == sizeof (gint64)' failed
OpenCV Error: Unspecified error (GStreamer: cannot put pipeline to play
) in CvVideoWriter_GStreamer::open, file /home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line 1690
VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps, frameSize, is_color)): raised OpenCV exception:

/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1690: error: (-2) GStreamer: cannot put pipeline to play
 in function CvVideoWriter_GStreamer::open


**CODEC::CV_FOURCC('D', 'I', 'V', '3')**

**ERROR** 

SRC output_video = (nil) 
OpenCV Error: Unspecified error (GStreamer: cannot put pipeline to play
) in CvVideoWriter_GStreamer::open, file /home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line 1690
VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps, frameSize, is_color)): raised OpenCV exception:

/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1690: error: (-2) GStreamer: cannot put pipeline to play
 in function CvVideoWriter_GStreamer::open




**CODEC:CV_FOURCC('D', 'I ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by burakakde
close date 2018-08-10 06:54:52.002380

Comments

2

please DO NOT try anything with opencv's deprecated and no more maintained c-api.

berak gravatar imageberak ( 2018-07-25 03:32:51 -0600 )edit

If you want to break open Darknet itself, to add this generation functionality, have a look at a video generating commit at our research groups public darknet repo. This worked until OpenCV 3.4.0 so be sure to check out that branch before compiling!

StevenPuttemans gravatar imageStevenPuttemans ( 2018-07-25 03:45:56 -0600 )edit

I exactly copied the changes in image.c but still get the following error. OpenCV Error: Unspecified error (GStreamer: cannot put pipeline to play ) in CvVideoWriter_GStreamer::open, file /home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line 1690 VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps, frameSize, is_color)): raised OpenCV exception:

/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1690: error: (-2) GStreamer: cannot put pipeline to play in function CvVideoWriter_GStreamer::open

burakakde gravatar imageburakakde ( 2018-07-25 04:01:45 -0600 )edit

Try building OpenCV without Gstreamer but using v4l2 instead.

StevenPuttemans gravatar imageStevenPuttemans ( 2018-07-25 04:16:02 -0600 )edit

1 answer

Sort by » oldest newest most voted
1

answered 2018-08-03 07:39:43 -0600

burakakde gravatar image

Thx for the replies. I just figured out that the file in which i am trying to write was write protected. So changing the file permissions solved the problem.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-07-25 03:25:13 -0600

Seen: 1,212 times

Last updated: Jul 25 '18