Opened 7 years ago

Closed 6 years ago

#6378 closed defect (fixed)

hevc_qsv encoder failed with 'Selected ratecontrol mode is not supported by the QSV runtime. Choose a different mode.'

Reported by: ChenglinHuang Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: hevc_qsv
Cc: xinsuiyuer@gmail.com Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

The issue:

$ ffmpeg -loglevel verbose -y -i src_55A16E560CEFFFF7F98994D086A220F0.mp4 -an -c:v hevc_qsv -load_plugin hevc_hw -preset fast -profile:v main -b:v 500k -maxrate 1500k out.mp4
ffmpeg version N-85917-gcc25a88 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
  configuration: --disable-ffplay --disable-ffserver --extra-libs='-lstdc++ -lm -lrt -ldl -lnuma' --enable-gpl --enable-version3 --disable-shared --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --enable-libmp3lame --enable-libopenjpeg --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libmfx --enable-nonfree --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-libxcb-shape
  libavutil      55. 61.100 / 55. 61.100
  libavcodec     57. 94.101 / 57. 94.101
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 88.100 /  6. 88.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
[h264 @ 0x3e33280] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 0x3e33280] Increasing reorder buffer to 1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'src_55A16E560CEFFFF7F98994D086A220F0.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41
    creation_time   : 2017-04-28T15:39:04.000000Z
  Duration: 00:33:27.72, start: 0.000000, bitrate: 2019 kb/s
    Stream #0:0(eng): Video: h264 (Main), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, left), 1920x1080 (1920x1088), 1698 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2017-04-28T15:39:04.000000Z
      handler_name    : Alias Data Handler
      encoder         : AVC Coding
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
    Metadata:
      creation_time   : 2017-04-28T15:39:04.000000Z
      handler_name    : Alias Data Handler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> hevc (hevc_qsv))
Press [q] to stop, [?] for help
[h264 @ 0x3e5f520] Reinit context to 1920x1088, pix_fmt: yuv420p
[graph 0 input from stream 0:0 @ 0x51225a0] w:1920 h:1080 pixfmt:yuv420p tb:1/25000 fr:25/1 sar:0/1 sws_param:flags=2
[auto_scaler_0 @ 0x4d08600] w:iw h:ih flags:'bicubic' interl:0
[format @ 0x3e30da0] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'format'
[auto_scaler_0 @ 0x4d08600] w:1920 h:1080 fmt:yuv420p sar:0/1 -> w:1920 h:1080 fmt:nv12 sar:0/1 flags:0x4
[hevc_qsv @ 0x44d2920] Initialized an internal MFX session using hardware accelerated implementation
[hevc_qsv @ 0x44d2920] Using the variable bitrate (VBR) ratecontrol method
[hevc_qsv @ 0x44d2920] MFXVideoENCODE_Query() = -9
[hevc_qsv @ 0x44d2920] Selected ratecontrol mode is not supported by the QSV runtime. Choose a different mode.
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
Conversion failed!

MFXVideoENCODE_Query() in qsvenc.c returns -9(MFX_ERR_NOT_FOUND), and I don't knonw what does it mean.
I have checked the system(Media Server Studio 2017 R2, CentOS 7.2 “Gold”) with sample_encode and samples_decode, they work fine.

I have read these the issue report, but nothing help.
https://trac.ffmpeg.org/ticket/5859
https://trac.ffmpeg.org/ticket/5899

The ffmpeg is built from git cc25a887c5467be5c7b004665047a32d36c9cf42.
Any help will be appreciated.

sample_decode testing:

$ ./sample_decode h265 -i ../content/test_stream.265 -o test.yuv -hw
plugin_loader.h :170 [INFO] Plugin was loaded from GUID: { 0x33, 0xa6, 0x1c, 0x0b, 0x4c, 0x27, 0x45, 0x4c, 0xa8, 0xd8, 0x5d, 0xde, 0x75, 0x7c, 0x6f, 0x8e } (Intel (R) Media SDK HW plugin for HEVC DECODE)
pretending that stream is 30fps one
pretending that aspect ratio is 1:1
libva info: VA-API version 0.99.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_0_32
libva info: va_openDriver() returns 0
Decoding Sample Version 7.0.16053634


Input video	HEVC
Output format	NV12
Input:
  Resolution	176x96
  Crop X,Y,W,H	0,0,0,0
Output:
  Resolution	176x96
Frame rate	30.00
Memory type		system
MediaSDK impl		hw
MediaSDK version	1.21

Decoding started
Frame number:  101, fps: 2419.509, fread_fps: 0.000, fwrite_fps: 0.000
Decoding finished
plugin_loader.h :196 [INFO] MFXBaseUSER_UnLoad(session=0x0x7fa74d4d01e0), sts=0

sample_encode testing:

$ ./sample_encode h265 -i ../content/test_stream_176x96.yuv -o test.265 -h 176 -w 96 -hw
plugin_loader.h :170 [INFO] Plugin was loaded from GUID: { 0x6f, 0xad, 0xc7, 0x91, 0xa0, 0xc2, 0xeb, 0x47, 0x9a, 0xb6, 0xdc, 0xd5, 0xea, 0x9d, 0xa3, 0x47 } (Intel (R) Media SDK HW plugin for HEVC ENCODE)
libva info: VA-API version 0.99.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_0_32
libva info: va_openDriver() returns 0
Encoding Sample Version 7.0.16053634

Input file format	YUV420
Output video		HEVC
Source picture:
	Resolution	96x176
	Crop X,Y,W,H	0,0,96,176
Destination picture:
	Resolution	96x176
	Crop X,Y,W,H	0,0,96,176
Frame rate	30.00
Bit rate(Kbps)	366
Gop size	0
Ref dist	0
Ref number	0
Idr Interval	0
Target usage	balanced
Memory type	system
Media SDK impl		hw
Media SDK version	1.21

Processing started
Frame number: 101
plugin_loader.h :196 [INFO] MFXBaseUSER_UnLoad(session=0x0x7ff2b9e32d90), sts=0

Processing finished

The system configuration:

$ cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)

$ uname -a
Linux multimedia 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux


$ lscpu 
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Core(s) per socket:    4
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 94
Model name:            Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
Stepping:              3
CPU MHz:               800.000
BogoMIPS:              6382.03
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              6144K
NUMA node0 CPU(s):     0-3

--------

$ vainfo 
error: can't connect to X server!
libva info: VA-API version 0.99.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_0_32
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.99 (libva 1.67.0.pre1)
vainfo: Driver version: 16.5.1.59511-ubit
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	<unknown entrypoint>
      VAProfileH264ConstrainedBaseline:	<unknown entrypoint>
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264Main               :	<unknown entrypoint>
      VAProfileH264Main               :	<unknown entrypoint>
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264High               :	<unknown entrypoint>
      VAProfileH264High               :	<unknown entrypoint>
      VAProfileMPEG2Simple            :	VAEntrypointEncSlice
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointEncSlice
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointEncPicture
      VAProfileVP8Version0_3          :	VAEntrypointEncSlice
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileVP8Version0_3          :	<unknown entrypoint>
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileVP9Profile0            :	<unknown entrypoint>
      <unknown profile>               :	VAEntrypointVideoProc
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileNone                   :	<unknown entrypoint>


$ python ~/sys_analyzer_linux.py 
--------------------------
Hardware readiness checks:
--------------------------
 [ OK ] Processor name: Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
--------------------------
OS readiness checks:
--------------------------
 [ OK ] GPU visible to OS
--------------------------
Intel(R) Media Server Studio Install:
--------------------------
 [ OK ] user in video group
 [ OK ] libva.so.1 found
 [ OK ] vainfo reports valid codec entry points
 [ OK ] /dev/dri/renderD128 connects to Intel i915

--------------------------
Media SDK Plugins available:
(for more info see /opt/intel/mediasdk/plugins/plugins.cfg)
--------------------------
    H264LA Encoder 	= 588f1185d47b42968dea377bb5d0dcb4
    VP8 Decoder 	= f622394d8d87452f878c51f2fc9b4131
    HEVC Decoder 	= 33a61c0b4c27454ca8d85dde757c6f8e
    HEVC Encoder 	= 6fadc791a0c2eb479ab6dcd5ea9da347
--------------------------
Component Smoke Tests:
--------------------------
 [ OK ] Media SDK HW API level:1.21
 [ OK ] Media SDK SW API level:1.21
 [ OK ] OpenCL check:platform:Intel(R) OpenCL GPU OK CPU OK

Change History (2)

comment:1 by ChenglinHuang, 7 years ago

Cc: xinsuiyuer@gmail.com added

comment:2 by Zhong,Li, 6 years ago

Resolution: fixed
Status: newclosed

QSV HEVC encoding on linux was broken quite a long time.
A patch on libav was to fix it(https://patches.libav.org/patch/62401/), but hasn't merged and actually thus should be fixed in MSDK: https://github.com/Intel-Media-SDK/MediaSDK/issues/559.
Please update MSDK with commit https://github.com/Intel-Media-SDK/MediaSDK/pull/640 and then hevc encoding on Linux should work.

Note: See TracTickets for help on using tickets.