0

I am trying to process some FHD video on Win10 in Python. I enabled the integrated GPU in BIOS, installed latest driver through Intel driver support, installed Intel Media SDK successfully and rebooted. Then I downloaded OpenCV 4.5 with all hardware codecs from here and added to a dummy project (made sure no other OpenCV exists). When I tried to use it for decoding/encoding, I had the following errors.

In decoding, I got error like

decoder = cv.VideoCapture('myfile.hevc', cv.CAP_INTEL_MFX)
# MFX: LoadPlugin failed for codec: 1129727304

but using cv.CAP_FFMPEG worked ok.

In encoding, I got error like

writer = cv.VideoWriter('output.hevc', apiPreference = cv.CAP_INTEL_MFX, fourcc = cv.VideoWriter_fourcc('h','v','c','1'), fps = 20.0, frameSize = (640,480))
# MFX: Unsupported FourCC: hvc1 (0x31637668)
# 'hevc' or 'h265' give same error code
# write to 'output.mp4' with 'mp4v' yield a different error code 0x7634706d

While writing with ffmpeg works

writer = cv.VideoWriter('C:/testData/output.mp4', apiPreference = cv.CAP_FFMPEG , fourcc = cv.VideoWriter_fourcc('m','p','4','v'), fps = 20.0, frameSize = (640,480))
# success

Much appreciated.

[Edit 01]

Here is the screenshot of running mediasdk_system_analayzer_64.exe.

[Edit 02]

Even though HW decoder does not show up in the analyzer, it works after I disable all monitors but 1 as suggested here.

.\sample_multi_transcode.exe -i::h265 myfile.hevc -o::h265 output.hevc -hw
# session 0 [0000023D33FCA130] PASSED (MFX_ERR_NONE) 8.34417 sec, 226 frames, 27.085 fps

VideoCapture with cv.CAP_INTEL_MFX works now. Yet VideoWriter gives the same error.

Jason M
  • 411
  • 5
  • 19
  • Execute `mediasdk_system_analayzer_64.exe`, and make sure Hardware Encode and Decode is supported. I suggest starting with H.264 codec, because H.265 encoding requires one of the latest CPU models. What is `fourcc('h','v','c','1')`? I don't think `fourcc('m','p','4','v')` uses the integrated GPU. – Rotem May 18 '21 at 11:13
  • Thanks @Rotem. I've added the screenshot. No HW decoder show up in the packages, so they are not available? – Jason M May 19 '21 at 00:50
  • Both HW decoder end encoder are available. But what is `cv.VideoWriter_fourcc('h','v','c','1')` ? Shouldn't it be `cv.VideoWriter_fourcc('h','e','v','c')` ? – Rotem May 19 '21 at 05:42
  • @Rotem Either 'hevc' or 'hvc1' give the same error code: MFX: Unsupported FourCC: hvc1 (0x31637668) – Jason M May 19 '21 at 06:06
  • Try `fourcc('H', '2', '6', '4')` first (just for testing). – Rotem May 19 '21 at 07:17

0 Answers0