FS#59290 - [opencv] 3.4.2 fails to work with gstreamer

Attached to Project: Arch Linux
Opened by Juan Manuel (the_phet) - Tuesday, 10 July 2018, 10:04 GMT
Last edited by Antonio Rojas (arojas) - Wednesday, 11 July 2018, 17:37 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Antonio Rojas (arojas)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description: When trying to read or create a video using python opencv, it fails with the following error:

python:15977): GStreamer-CRITICAL **: 18:19:37.484: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed Unable to stop the stream: Inappropriate ioctl for device

Running with export OPENCV_VIDEOIO_DEBUG=TRUE

[juanma@juanmahostname img_proc]$ export OPENCV_VIDEOIO_DEBUG=TRUE
[juanma@juanmahostname img_proc]$ python test_svm.py pat00100_2_fast15.avi
[ WARN:0] VIDEOIO(createGStreamerCapture(filename)): trying ...

(python:11745): GStreamer-CRITICAL **: 09:24:32.751: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed
[ WARN:0] VIDEOIO(createGStreamerCapture(filename)): result=(nil) isOpened=-1 ...

[ WARN:0] VIDEOIO(cvCreateCameraCapture_V4L(filename.c_str())): trying ...

Unable to stop the stream: Inappropriate ioctl for device
[ WARN:0] VIDEOIO(cvCreateCameraCapture_V4L(filename.c_str())): result=(nil) ...

[ WARN:0] VIDEOIO(cvCreateFileCapture_Images(filename.c_str())): trying ...

[ WARN:0] VIDEOIO(cvCreateFileCapture_Images(filename.c_str())): result=(nil) ...

[ WARN:0] VIDEOIO(createMotionJpegCapture(filename)): trying ...

[ WARN:0] VIDEOIO(createMotionJpegCapture(filename)): result=(nil) isOpened=-1 ...

[ WARN:0] VIDEOIO(createGPhoto2Capture(filename)): trying ...

[ WARN:0] VIDEOIO(createGPhoto2Capture(filename)): result=(nil) isOpened=-1 ...

[ WARN:0] VIDEOIO(cvCreateVideoWriter_GStreamer (filename.c_str(), fourcc, fps, frameSize, isColor)): trying ...

(python:11745): GStreamer-CRITICAL **: 09:24:32.792: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
[ WARN:0] VIDEOIO(cvCreateVideoWriter_GStreamer (filename.c_str(), fourcc, fps, frameSize, isColor)): result=0x564e3cfc57d0...


Additional info:
* package version: 3.4.2 (downgrading to 3.4.1 works fine)

Steps to reproduce:

Using opencv python3, just try to read or create a video and it will report the error above.
This task depends upon

Closed by  Antonio Rojas (arojas)
Wednesday, 11 July 2018, 17:37 GMT
Reason for closing:  Not a bug
Comment by Juan Manuel (the_phet) - Tuesday, 10 July 2018, 10:06 GMT
This is the stuff about gstreamer I have installed:

1 extra/clutter-gst 3.0.26-1 [installed]
GStreamer bindings for clutter
2 extra/gnome-video-effects 0.4.3+13+g6867955-1 (gnome) [installed]
Collection of GStreamer effects for GNOME
3 extra/gst-libav 1.14.1-1
GStreamer Multimedia Framework ffmpeg Plugin
4 extra/gst-plugins-bad 1.14.1-2 [installed]
GStreamer Multimedia Framework Bad Plugins
5 extra/gst-plugins-base 1.14.1-1 [installed]
GStreamer Multimedia Framework Base Plugins
6 extra/gst-plugins-base-libs 1.14.1-1 [installed]
GStreamer Multimedia Framework Base Libraries
7 extra/gst-plugins-good 1.14.1-1 [installed]
GStreamer Multimedia Framework Good Plugins
8 extra/gst-plugins-ugly 1.14.1-1
GStreamer Multimedia Framework Ugly Plugins
9 extra/gst-python 1.14.1-1
GStreamer Python 3 binding overrides
10 extra/gst-python2 1.14.1-1
GStreamer Python 2 binding overrides
11 extra/gstreamer 1.14.1-1 [installed]
GStreamer open-source multimedia framework core library
12 extra/gstreamer-vaapi 1.14.1-1
GStreamer Multimedia Framework VAAPI Plugin
13 extra/libcanberra-gstreamer 0.30+2+gc0620e4-1
GStreamer plugin for libcanberra
14 extra/phonon-qt4-gstreamer 4.9.0-4
Phonon GStreamer backend for Qt4
15 extra/phonon-qt5-gstreamer 4.9.0-4 [installed]
Phonon GStreamer backend for Qt5
16 extra/qt-gstreamer 1.2.0-1
Qt bindings for GStreamer
17 extra/totem 3.26.1-1 (gnome) [installed]
Movie player for the GNOME desktop based on GStreamer
18 community/gambas3-gb-media 3.11.3-1 (gambas3)
Simplified interface to the GStreamer library component
19 community/gst-editing-services 1.14.1-1
GStreamer library for creating audio/video editors
20 community/gst-plugins-espeak 0.5.0-1
Use espeak as a sound source for gstreamer
21 community/gst-transcoder 1.14.0-1
GStreamer Transcoding API library
22 community/gst-validate 1.14.1-1
Debugging tool for GStreamer
23 community/gstreamermm 1.10.0-1
C++ interface for GStreamer
24 community/gstreamermm-docs 1.10.0-1
C++ interface for GStreamer (documentation)
25 community/parole 1.0.1-1 (xfce4-goodies)
Modern media player based on the GStreamer framework
26 community/pitivi 0.99-4
Editor for audio/video projects using the GStreamer framework
27 community/transmageddon 1.5-3
Simple python application for transcoding video into formats supported by GStreamer
Comment by Antonio Rojas (arojas) - Tuesday, 10 July 2018, 10:09 GMT
Can you attach the test_svm.py script?
Comment by Juan Manuel (the_phet) - Tuesday, 10 July 2018, 16:27 GMT
Just creating a new VideoCapture fails. The file attached just has 1 line.

It returns:

(python:3391): GStreamer-CRITICAL **: 17:25:47.520: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed
Unable to stop the stream: Inappropriate ioctl for device
Comment by Antonio Rojas (arojas) - Tuesday, 10 July 2018, 17:24 GMT
I have tested the 3 examples from http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html and they all work correctly, even though they give the same error message as your last example. So in order to do something about this you'll have to attach a full script that doesn't work, and describe what you expect it to do.
Comment by Juan Manuel (the_phet) - Wednesday, 11 July 2018, 14:07 GMT
The second example (I didnt try the first one because I dont have a camera around) from that link works for me on 3.4.1 but it doesn't work on 3.4.2. I get the following error:

(python:18682): GStreamer-CRITICAL **: 15:04:32.641: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed
Unable to stop the stream: Inappropriate ioctl for device
Traceback (most recent call last):
File "test.py", line 12, in <module>
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.error: OpenCV(3.4.2) /build/opencv/src/opencv-3.4.2/modules/imgproc/src/color.hpp:253: error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'CvtHelper'

The video I am trying to read (and works fine with 3.4.1 but not with 3.4.2) was created in blender, compressed using FFMPEG. VLC gives the following details about the video: Code is H264 - MPEG-4 AVC (part10) (h264). 800x600 resolution, framerate is 30.
Comment by Antonio Rojas (arojas) - Wednesday, 11 July 2018, 16:35 GMT
Please attach or post a link to one such video. I have tried many different formats and still can't reproduce this. Does the video work with gst-play?
Comment by Juan Manuel (the_phet) - Wednesday, 11 July 2018, 17:35 GMT
After trying to use gst-play, I realised my problem was missing codecs related to gst. In particular I was missing gst-libav-1.14.1-1. After installing it, it works fine.

Loading...