Ask Your Question
1

ViderWriter does not work with fourcc=-1

asked 2017-09-27 10:01:07 -0600

aleksejs.fomins gravatar image

Hi,

I'm trying to run OpenCV 3.3 under Ubuntu 16.04, compiled from sources using cmake. Here's a simple example program

#include "opencv2/opencv.hpp"

int main() {
  cv::VideoWriter outputVideo;
  int fps = 30;
  int fourcc = 0;
  cv::Size S = cv::Size(1024, 768);
  outputVideo.open("trollz.avi", fourcc, fps, S, true);
  if (!outputVideo.isOpened())  { std::cerr << "Could not open the output video" << std::endl; }

  return(0);
}

When fourcc=0, the program runs and produces an empty movie trollz.avi, as expected.

The tutorial in the documentation, namely,

http://docs.opencv.org/3.3.0/d7/d9e/t...

states that, when fourcc=-1, a window must open that would allow the user to select the extension from a list. However, in my case, when fourcc=-1, I get a runtime error:

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/aleksejs/work/inst/OpenCV/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/aleksejs/work/inst/OpenCV/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

Could not open the output video

Please help

edit retag flag offensive close merge delete

Comments

It's been a while, but I ran into this issue once. I believe the answer was passing fourcc of -1 to VideoWriter::open doesn't work on linux. I don't remember how I came to this conclusion. You may be able to look in the source code to figure it out.

mfisher gravatar imagemfisher ( 2017-09-27 10:21:17 -0600 )edit

1 answer

Sort by » oldest newest most voted
1

answered 2017-09-27 10:08:55 -0600

berak gravatar image

updated 2017-09-27 10:12:50 -0600

that "choose a codec" window will only appear on windows, and also it will let you only use the deprecated VFW graph.

(there's nothing wrong with your install, the docs seem to be misleading)

if you need something like a "default" fourcc, choose VideoCapture::fourcc('M','J','P','G'), and a .avi file extension, which is supplied from opencv core, and thus does not rely on ffmpeg or gstreamer support

edit flag offensive delete link more

Comments

1

Thanks. MJPG and PIM1 and such all seem to work, only -1 does not work. I guess I can live without it :)

aleksejs.fomins gravatar imagealeksejs.fomins ( 2017-09-27 10:12:39 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-09-27 10:01:07 -0600

Seen: 2,557 times

Last updated: Sep 27 '17