intel / gstreamer-media-SDK

GNU Lesser General Public License v2.1
90 stars 53 forks source link

Gstreamer MFX Plugins do not load in OpenCV Version 3.4 & 3.0 VideoCapture #120

Closed skyline220 closed 6 years ago

skyline220 commented 6 years ago

Hardware: UP Squared Maker Board (Intel Pentium N4200 Processor)

OS: Ubuntu 16.04 LTS Kernel: 4.14.16 Upgraded according to: https://software.intel.com/en-us/articles/build-and-debug-open-source-media-stack

Install completed using this repo.

In the terminal:

gst-inspect-1.0 mfxvpp Command Succeeds

gst-inspect-1.0 mfxdecode Command Succeeds

gst-launch-1.0 udpsrc port=5000 ! application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! mfxdecode ! videoconvert ! appsink Command Succeeds

In OpenCV VideoCapture cap("udpsrc port=5000 ! application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! mfxdecode ! videoconvert ! appsink");

Command Returns Error with: OpenCV Error: Unspecified error (GStreamer: unable to start pipeline ) in cvCaptureFromCAM_GStreamer, file /home/home/Downloads/OpenCV/opencv-3.4.0/modules/videoio/src/cap_gstreamer.cpp, line 890 VIDEOIO(cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, reinterpret_cast<char *>(index))): raised OpenCV exception:

/home/home/Downloads/OpenCV/opencv-3.4.0/modules/videoio/src/cap_gstreamer.cpp:890: error: (-2) GStreamer: unable to start pipeline in function cvCaptureFromCAM_GStreamer

OpenCV Error: Unspecified error (GStreamer: unable to start pipeline ) in cvCaptureFromCAM_GStreamer, file /home/home/Downloads/OpenCV/opencv-3.4.0/modules/videoio/src/cap_gstreamer.cpp, line 890 VIDEOIO(cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, reinterpret_cast<char *>(index))): raised OpenCV exception:

/home/home/Downloads/OpenCV/opencv-3.4.0/modules/videoio/src/cap_gstreamer.cpp:890: error: (-2) GStreamer: unable to start pipeline in function cvCaptureFromCAM_GStreamer

Command also fails in OpenCV 3.0 with:

init done opengl support available libva info: VA-API version 0.39.0 libva info: va_getDriverName() returns 0 libva info: User requested driver 'iHD' libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so libva error: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so has no function __vaDriverInit_0_32 libva info: va_openDriver() returns -1 GStreamer Plugin: Embedded video playback halted; module mfxdec0 reported: Could not initialize supporting library. OpenCV Error: Unspecified error (GStreamer: unable to start pipeline ) in icvStartPipeline, file /home/home/Downloads/OpenCV/opencv-3.0.0/modules/videoio/src/cap_gstreamer.cpp, line 383 terminate called after throwing an instance of 'cv::Exception' what(): /home/home/Downloads/OpenCV/opencv-3.0.0/modules/videoio/src/cap_gstreamer.cpp:383: error: (-2) GStreamer: unable to start pipeline in function icvStartPipeline

I have also tried exporting these environment variables in the terminal before launching the OpenCV program but to no avail on 3.0 and 3.4: export LIBVA_DRIVER_NAME=iHD export LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri

The program runs fine in OpenCV 3.0 and 3.4 when I use jpegdec instead of mfxdecode.

Please provide any assistance you can, thanks!

ishmael1985 commented 6 years ago

You may look into this when building OpenCV using CMake - https://docs.opencv.org/3.1.0/d1/daa/group__core__va__intel.html

But you should really only report issues specific to gst-mfx plugins, not related to third party software.

skyline220 commented 6 years ago

Hi Ishmael,

Thanks for your response. I wasn't sure how this issue overlaps with OpenCV, for example I discovered a WITH_MFX command during Cmake. I have tried the Cmake command in the link you provided but Intel Vaapi still remains off unfortunately during the build and the error persists. Do you have any other suggestions, I'd really appreciate your thoughts on this issue.

I've tried building:

WITH_VA=ON WITH_VA_INTEL=ON WITH_MFX=ON

https://gist.github.com/okanon/c09669f3ff3351c864742bc2754b01ea

I used this big list of plugins.

Thanks

ishmael1985 commented 6 years ago

This issue is definitely a problem with your build setup. Did you build libva and open-source msdk from source? When you build OpenCV you need to build against the corresponding library versions, it's pretty obvious from the messagelibva error: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so has no function __vaDriverInit_0_32 that you are building OpenCV against the wrong libva version.

ishmael1985 commented 6 years ago

@skyline220 here's a good reference for your problem : https://github.com/intel/media-driver/issues/235

ishmael1985 commented 6 years ago

@skyline220 anything new on this issue? Can you close this if this issue has been resolved on your side?

skyline220 commented 6 years ago

This issue is still not resolved but I think you pointed me in the right direction to fix it so I will close this issue for now. I apologize for the delay in my response.