When I use hevec_qsv encoding, ffmpeg always fails as follows. And also multimedia/handbrake doesn't show QSV encodings on the Video encoder menu. ``` $ ffmpeg -i /zpool/video/test.avi -vcodec hevc_qsv hevec_qsv_test.mp4 (snip) Input #0, avi, from '/zpool/video/test.avi': Metadata: software : Lavf58.29.100 Duration: 00:03:45.28, start: 0.000000, bitrate: 412 kb/s Stream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 312x232 [SAR 1:1 DAR 39:29], 208 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 30k tbc Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 44100 Hz, stereo, fltp, 192 kb/s Stream mapping: Stream #0:0 -> #0:0 (mpeg4 (native) -> hevc (hevc_qsv)) Stream #0:1 -> #0:1 (ac3 (native) -> aac (native)) Press [q] to stop, [?] for help [hevc_qsv @ 0x806a75e00] Error initializing an internal MFX session: unsupported (-3) Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height [aac @ 0x806a76d00] Qavg: 2305.336 [aac @ 0x806a76d00] 2 frames left in the queue on closing Conversion failed! ``` If I downgrade intel-media-sdk to 21.3.0, it works as I expected. It seems that hardware detection method has been changed since 21.3.1. Setting environment variable as `INTEL_MEDIA_RUNTIME=MSDK` works for me as a workaround.
Auto-detection fails (MFX_HW_UNKNOWN) because libmfx.so wants to enumerate all Intel GPUs by reading /sys/class/drm/renderD*/device/device, limiting MFX to the legacy GPUs. On FreeBSD neither /sys is mounted by default nor supports render nodes. A proper fix would be to convert the code to libpciaccess or libpci but this is non-trivial, so let's revert to the old behavior for now. oneVPL hasn't been ported yet, anyway. https://github.com/Intel-Media-SDK/MediaSDK/blob/intel-mediasdk-21.3.5/api/mfx_dispatch/linux/device_ids.h#L425 https://github.com/oneapi-src/oneVPL-intel-gpu requires Tiger Lake or newer.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=0402cf13b3cc4b3c1fe6bd68b1286c2054f0ee3f commit 0402cf13b3cc4b3c1fe6bd68b1286c2054f0ee3f Author: Jan Beich <jbeich@FreeBSD.org> AuthorDate: 2021-10-07 13:21:34 +0000 Commit: Jan Beich <jbeich@FreeBSD.org> CommitDate: 2021-10-07 13:35:12 +0000 multimedia/intel-media-sdk: unbreak runtime after f4faca97f05b $ ffmpeg ... -c:v hevc_qsv ... [AVHWDeviceContext @ 0x8062d0140] Error initializing an MFX session: -3. Device creation failed: -1313558101. PR: 258976 Reported by: Yuichiro NAITO multimedia/intel-media-sdk/Makefile | 1 + .../intel-media-sdk/files/patch-msdk-default (new) | 28 ++++++++++++++++++++++ 2 files changed, 29 insertions(+)
A commit in branch 2021Q4 references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=4c4f0e624c8251a9e2eea6e1d912426355b1475e commit 4c4f0e624c8251a9e2eea6e1d912426355b1475e Author: Jan Beich <jbeich@FreeBSD.org> AuthorDate: 2021-10-07 13:21:34 +0000 Commit: Jan Beich <jbeich@FreeBSD.org> CommitDate: 2021-10-07 13:36:26 +0000 multimedia/intel-media-sdk: unbreak runtime after f4faca97f05b $ ffmpeg ... -c:v hevc_qsv ... [AVHWDeviceContext @ 0x8062d0140] Error initializing an MFX session: -3. Device creation failed: -1313558101. PR: 258976 Reported by: Yuichiro NAITO (cherry picked from commit 0402cf13b3cc4b3c1fe6bd68b1286c2054f0ee3f) multimedia/intel-media-sdk/Makefile | 1 + .../intel-media-sdk/files/patch-msdk-default (new) | 28 ++++++++++++++++++++++ 2 files changed, 29 insertions(+)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=1f08de175960433c739c0c1ae027778b2394475a commit 1f08de175960433c739c0c1ae027778b2394475a Author: Jan Beich <jbeich@FreeBSD.org> AuthorDate: 2021-11-12 11:12:43 +0000 Commit: Jan Beich <jbeich@FreeBSD.org> CommitDate: 2021-11-12 14:45:28 +0000 multimedia/intel-media-sdk: detect GPU generation for VPL handover PR: 258976 Inspired by: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/201 multimedia/intel-media-sdk/Makefile | 1 + .../intel-media-sdk/files/patch-drm-to-pciid (new) | 86 ++++++++++++++++++++++ .../files/patch-msdk-default (gone) | 28 ------- 3 files changed, 87 insertions(+), 28 deletions(-)