OpenCV 4.1.1のCAP_INTEL_MFXの利用

OpenCVをWITH_MFXでビルドすることでIntelのQuick Sync VIdeoを利用することは出来るようになったのですが、どうも圧縮率が悪い…

調べたところ、ここに対処法がありました。

After I changed the code params.mfx.TargetKbps = (mfxU16)cvRound(frameSize.area() * fps / 500); to params.mfx.TargetKbps = (mfxU16)cvRound(4000000);, the video file which was written by the VideoWriter has now only 15 MB large for 1 min instead of 300 MB large for 1 min. (The resolution is Full HD.)

https://github.com/Intel-Media-SDK/MediaSDK/issues/944

大元のソースコードを修正するのは躊躇しましたが、試してみたところ、効果絶大でした。これでようやく安定的にUSBカメラの製造を録画できそうです。