-
-
Notifications
You must be signed in to change notification settings - Fork 56.4k
MediaSDK encode decode backend
Maksim Shabunin edited this page Nov 1, 2017
·
3 revisions
- Install MediaSDK
- Make sure corresponding environment variable is set, Windows: INTELMEDIASDKROOT, Linux: MFX_HOME
- Build with
-DWITH_MFXoption turned on:cmake -DWITH_MFX=ON <path-to-opencv-sources> cmake --build .
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.h265Then 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.
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.
© Copyright 2019-2025, OpenCV team
- Home
- Deep Learning in OpenCV
- Running OpenCV on Various Platforms
- OpenCV 5
- OpenCV 4
- OpenCV 3
- Development process
- OpenCV GSoC
- Archive