[FFmpeg-trac] #7933(avcodec:new): Intel QSV Windows init

FFmpeg trac at avcodec.org
Thu May 30 21:15:56 EEST 2019


#7933: Intel QSV Windows init
-----------------------------------+----------------------------------
             Reporter:  ajax16384  |                     Type:  defect
               Status:  new        |                 Priority:  normal
            Component:  avcodec    |                  Version:  4.0.3
             Keywords:  qsv        |               Blocked By:
             Blocking:             |  Reproduced by developer:  0
Analyzed by developer:  0          |
-----------------------------------+----------------------------------
 I have found that ffmpeg qsv encoder command line
 ffmpeg -i input.mp4 -b:v 10000k -vcodec h264_qsv -preset fast output.mp4
 may throw: "Error initializing an internal MFX session: unsupported (-3)"
 message on "windows" box configuration.
 (first noticed on ffmpeg 4.0.2 but recent master build also suffers from
 with problem).
 OBS-Studio+QSV works without problem on same machine.

 By using several test machines(4 different windows boxes) i narrowed the
 circle of suspects and here is repro:
  - windows 10 x64 1809
  - internal intel graphics enabled in bios (windows driver intstalled) but
 monitor is not connected
  - discrete graphics card enabled and multiple monitors (>=2) connected
 OBS works, ffmpeg fails
 If only one monitor is connected to discrete card then ffmpeg starting to
 work.

 So i digged in source comparision cause OBS-studio and ffmpeg depending on
 same libmfx (but different version).

 ffmpeg uses this piece of code:
 ffmpeg/libavcodec/qsv.c
     mfxIMPL impl   = MFX_IMPL_AUTO_ANY;
     mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } };
     ....
     ret = MFXInit(impl, &ver, session);

 obs:
 https://github.com/obsproject/obs-
 studio/blob/a4f602b15afcd54e588e76437c639c38278841f6/plugins/obs-qsv11
 /obs-qsv11-plugin-main.c#L70
         mfxIMPL impl = MFX_IMPL_HARDWARE_ANY | MFX_IMPL_VIA_D3D11;
         mfxVersion ver = {{0 , 1}};
         ....
         sts = MFXInit(impl, &ver, &session);

         if (sts == MFX_ERR_NONE) {
         ....
         } else {
                 impl = MFX_IMPL_HARDWARE_ANY | MFX_IMPL_VIA_D3D9;
                 sts = MFXInit(impl, &ver, &session);
                 if (sts == MFX_ERR_NONE) {
         ....

 OBS force mfx to use HW implementation with "manual" fallback from dx11 to
 dx9.
 I have changed ffmpeg to use OBS technique and it starts to initialize
 even multiple monitors were connected.

 Conclusion:
 For some completely unknown reason MFXInit(MFX_IMPL_AUTO_ANY ...) call
 fails with multi monitor config.
 It might be releated to some libmfx bug, but OBS-Studio implementation did
 not triggers it.
 So it would be nice if FFmpeg adopts this technique (by adding option to
 force HW DX11 or/and DX9 QSV implementation)

--
Ticket URL: <https://trac.ffmpeg.org/ticket/7933>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list