Skip to content

MediaSDK encode decode backend

Maksim Shabunin edited this page Nov 1, 2017 · 3 revisions

Building OpenCV with MediaSDK support

  1. Install MediaSDK
  2. Make sure corresponding environment variable is set, Windows: INTELMEDIASDKROOT, Linux: MFX_HOME
  3. Build with -DWITH_MFX option turned on:
    cmake -DWITH_MFX=ON <path-to-opencv-sources>
    cmake --build .

Decoding

Media containers are not supported yet, so it is only possible to decode raw video stream stored in a file. It can be extracted from a container manually using the FFmpeg tool (source1, source2) or any other tools:

# H264
ffmpeg -i video.avi -vcodec copy -an -bsf:v h264_mp4toannexb video.264
# H265
ffmpeg -i in.mkv -c:v copy -bsf hevc_mp4toannexb out.h265

Then you can use VideoCapture object to decode the resulting file:

VideoCapture cap(“video.264”, CAP_INTEL_MFX);

Note! The file extension is important, because it will be used to determine the codec. It can be one of .264, .h264, .mp2, .mpeg2, .265 or .hevc.

Encoding

Use the VideoWriter object:

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

Where fourcc can be one of MPG2, H264, X264, AVC , H265 or HEVC.

Clone this wiki locally
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy