Media (Intel® Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK
Announcements
The Intel Media SDK project is no longer active. For continued support and access to new features, Intel Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® Video Processing Library (VPL), and to move to VPL as soon as possible.
For more information, see the VPL website.

How to set params for H264 in MFX with OpenCV

Luo__Yiyun
Beginner
1,603 Views

Hello, I'm trying to use OpenCV with Intel Media SDK backend to write a programm which can write video by intel gpu with H264 very fast.

I used code from OpenCV tutorial for Intel Media SDK backend.

int fourcc = VideoWriter::fourcc('H', '2', '6', '4');
VideoWriter writer(filename, CAP_INTEL_MFX, fourcc, fps, frameSize, isColor=true);

However, the video files that have been written are very large. For about 1 minute the file is already 300 MB large.

In gstreamer I can set parameters for H.264, and with ffmpeg in terminal I can also set parameters for H.264. But how can I set parameters in OpenCV? Or is there any other reason that the files are so large?

If someone here has experience with Media SDK in OpenCV, please tell me how you have worked with it. Thanks!

Greetings,

Yiyun

0 Kudos
1 Reply
Mark_L_Intel1
Moderator
1,603 Views

Hi Yiyun,

You have answered one of my questions in your other post, I am still not clear your process to build the MediaSDK backend enabled OpenCV application.

Before you build the application, you should rebuild OpenCV library in order to add Media SDK to OpenCV:

OpenCV should be rebuilt for this:

  • Download and unpack sources: https://github.com/opencv/opencv/archive/4.0.0-openvino.zip
  • Install Visual Studio, cmake and MediaSDK (do not forget to set environment variable INTELMEDIASDKROOT)
  • Create build directory and run following commands in it (CMD console, assuming VS2015): 
    • call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
    • cmake -G”Visual Studio 14 2015 Win64” -DCMAKE_INSTALL_PREFIX=install -DWITH_MFX=ON ..\opencv
    • cmake --build . --config Release --target install
  • set OpenCV_DIR environment variable to point to <build>/install folder (OpenCVConfig.cmake file should be located there).

My understanding is, you have to build your application after you did this.

Mark

0 Kudos
Reply