Problem with Intel Media SDK Backend for VideoCapture

asked 2019-02-01 09:09:02 -0500

LuisK gravatar image

Hey, so I installed "Intel Distribution of OpenVINO Toolkit" which, among other things, comes with an opencv version precompiled to be able to use hardware acceleration on Intel CPUs. I did the full installation on Linux (Ubuntu 18.04) and it ran without any problems.

Now, the single most important thing I need from this toolkit is the hardware accelerated video encoding and decoding in opencv.

To test this, I downloaded the 720p 30MB mp4 sample video from https://www.sample-videos.com/ and sucessfully used the code from https://www.learnopencv.com/read-writ... to decode, display and write it. Doing this pushed my CPU to 100% usage on all cores, monitored via htop.

Simply adding the CAP_INTEL_MFX backend Flag to the writer initialization as decribed in https://github.com/opencv/opencv/wiki..., brought that down to about 70% usage:

int fourcc = VideoWriter::fourcc('H', '2', '6', '4'); VideoWirter video("outcpp.avi", CAP_INTEL_MFX, fourcc, 10, Size(frame_width, frame_height));

This, to me, suggests that hardware acceleration via the Media SDK indeed works for encoding the video.

Converting the .mp4 to .264 as described in https://github.com/opencv/opencv/wiki... and then running the prgram WITHOUT Hardware acceleration on the VideoCapture object works as well.

But when I add the CAP_INTEL_MFX flag to the VideoCapture object, he fails the cap.isOpened() check and prints "Error openening video stream". (As defined in the code from https://www.learnopencv.com/read-writ....)

VideoCapture cap("video.264"); // works! VideoCapture cap("video.264", CAP_INTEL_MFX); // fails!

Now I'm a bit confused, since encoding seems to work fine, but this fails and doesn't seem to be a problem with the file.

Did anything regarding the Media SDK integration change since that GH Wiki page was created? Or do you people habe any other ideas about what could go wrong here?

Thanks!

edit retag flag offensive close merge delete