intel / cartwheel-ffmpeg

Intel developer staging area for unmerged upstream patch contributions to FFmpeg
GNU Lesser General Public License v2.1
83 stars 31 forks source link

Error creating a MFX session: -9 if the user is not logged in to Windows #334

Open nyanmisaka opened 6 days ago

nyanmisaka commented 6 days ago
CPU: i7-13700H
GPU: Xe integrated graphics on the CPU
GPU Driver: 31.0.101.5379/31.0.101.5590/31.0.101.5535
OS: Windows 11 Professional Edition

According to user reports, when using VPL loader (FFmpeg 6+) instead of MSDK loader (FFmpeg 5), the user must log in to Windows to initialize the QSV device, for example log in with the Windows RDP.

But once the user closes RDP or logs out, the VPL loader will not find the device and return MFX_ERR_NOT_FOUND: -9 error.

Strangely, the D3D11 device has been initialized successfully, but the QSV device cannot be derived from it.

# ffmpeg -init_hw_device d3d11va=dx11:,vendor_id=0x8086 -init_hw_device qsv=qs@dx11

[AVHWDeviceContext @ 000002533d2eacc0] Using device 8086:a7a0 (Intel(R) Iris(R) Xe Graphics).
[AVHWDeviceContext @ 000002533b7aa300] Error creating a MFX session: -9.
Device creation failed: -1313558101.
Failed to set value 'qsv=qs@dx11' for option 'init_hw_device': Unknown error occurred

https://github.com/FFmpeg/FFmpeg/blob/0b67c83b2eadf6350587ae7c4a63a8f9bba67cae/libavutil/hwcontext_qsv.c#L1179-L1284 Apparently the VPL loader takes a more complex approach mfxLoader + MFXEnumImplementations to filtering devices, which I think may be the cause of the problem. Because there is no problem when running the old code path in the MSDK loader in the same environment.

qsv_device_derive()
-> qsv_device_derive_from_child() // MFX_HANDLE_D3D11_DEVICE; (MFX_IMPL_HARDWARE_ANY | MFX_IMPL_VIA_D3D11)
-> qsv_create_mfx_session()
-> qsv_new_mfx_loader()
-> qsv_create_mfx_session_from_loader() // failed in MFXEnumImplementations() ?

This usage scenario is a headless server. Is this expected behavior or is it an issue? Thanks in advance.

feiwan1 commented 5 days ago

I couldn't reproduce this issue on my windows 11 home edition with CPU i7-1165G7 after log out and SSH to it by using another machine. What if you run vpl-inspect -ex on your environment? They have samilar initialization. If the issue is still there, you can report it to libVPL.