Red Hat Bugzilla – Bug 987905
GStreamer Theora error with VideoWriter in Python
Last modified: 2014-08-19 02:52:03 EDT
Description of problem:
When I try to use VideoWriter in Python and I use Theora as a codec, it shows traceback:
>>> vw = cv2.VideoWriter("test.ogv", cv2.cv.CV_FOURCC('T', 'H', 'E', 'O'), 2, (1024, 768), True)
OpenCV Error: Unspecified error (GStreamer: cannot link elements
) in CvVideoWriter_GStreamer::open, file /builddir/build/BUILD/opencv-2.4.5/modules/highgui/src/cap_gstreamer.cpp, line 552
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cv2.error: /builddir/build/BUILD/opencv-2.4.5/modules/highgui/src/cap_gstreamer.cpp:552: error: (-2) GStreamer: cannot link elements
in function CvVideoWriter_GStreamer::open
I don't really know what codec I should use for VideoWriter, because Theora doesn't work and MPEG is proprietary.
Steps to Reproduce:
1. Install opencv-python bindings.
2. Start python console, import cv2.
3. Run "cv2.VideoWriter("test.ogv", cv2.cv.CV_FOURCC('T', 'H', 'E', 'O'), 2, (1024, 768), True)"
It shows "unspecified error".
It should work.
I don't why it doesn't work with THEO, maybe related to the content or size expected by the encoder ?
Now it seems to work with VP80, please verify to have the libvpx gstreamer plugin.
It may be problem in GStreamer and not in cv2, but I don't know. Are you able to create VideoWriter using THEO? Anyway, VP8, as it seems, works.
No I cannot create a VideoWriter with THEO either.
To be honest, I am still unable to create video using VideoWriter and VP80 codec. I create VideoWriter using "vw = cv2.VideoWriter("out.webm", cv2.cv.CV_FOURCC(*"VP80"), 2, (1024, 768), True)", load several 1024x768 PNG images with cv2.imread() and write them using "vw.write(image)", but out.webm is somehow corrupted and it seems that "vw.write(image)" doesn't really write images into output file.
Did you tried with others codec ?
I am able to create output video file using XVID, but I think that I had to install something from rpmfusion to be able to do it.
Using additional dependencies would have been expected, because the encoder and even the decoder are not in fedora. But it should work on free codec provided that the encoder is installed (which might not be done by default)