Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't use HW encoder of QSV by ffmpeg

Tags:

ffmpeg

centos

I would like to use to encode by Intel H/W encode QSV.

Intel(R) Core(TM) i7-5650U CPU @ 2.20GHz

lspci -nn -s 0:02.0 00:02.0 VGA compatible controller [0300]: Intel Corporation Broadwell-U Integrated Graphics [8086:1626] (rev 09)

I could install MediaServerStudioEssentials2017R2 and ffpemg.

# vainfo | grep -v 'unknown'
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
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileVP8Version0_3          : VAEntrypointEncSlice
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

and

# ffmpeg -codecs | grep qsv
ffmpeg version N-86584-g4976a34 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-11)
  configuration: --enable-libmfx
  libavutil      55. 66.100 / 55. 66.100
  libavcodec     57. 99.100 / 57. 99.100
  libavformat    57. 73.100 / 57. 73.100
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 94.100 /  6. 94.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
 DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_qsv h264_cuvid ) (encoders: h264_nvenc h264_qsv h264_vaapi nvenc nvenc_h264 )
 DEV.L. hevc                 H.265 / HEVC (High Efficiency Video Coding) (decoders: hevc hevc_qsv hevc_cuvid ) (encoders: nvenc_hevc hevc_nvenc hevc_qsv hevc_vaapi )
 DEV.L. mpeg2video           MPEG-2 video (decoders: mpeg2video mpegvideo mpeg2_qsv mpeg2_cuvid ) (encoders: mpeg2video mpeg2_qsv mpeg2_vaapi )
 D.V.L. vc1                  SMPTE VC-1 (decoders: vc1 vc1_qsv vc1_cuvid )
 DEV.L. vp8                  On2 VP8 (decoders: vp8 vp8_cuvid vp8_qsv ) (encoders: vp8_vaapi )

But, I tried to encode as below.

# ffmpeg -i test.avi -c:v h264_qsv -b:v 2000k -r 30 -s 720x480 -acodec copy -look_ahead 0 qsv.mp4
・・・
[h264_qsv @ 0x3139f40] No device available for encoder (device type qsv for codec h264_qsv).
[h264_qsv @ 0x3139f40] Encoder will work with partial HW acceleration
[h264_qsv @ 0x3139f40] Warning in encoder initialization: partial acceleration (4)
・・・

It seems like that the encoding is using by software. It's slow. How can I do by H/W encode? If you know it, let me know it.

Bests,

like image 753
Ubunkun Avatar asked Jun 25 '17 14:06

Ubunkun


1 Answers

It looks like ffmpeg is looking in its list of devices for a qsv type device and not finding it. You can create a ffmpeg hardware device with -init_hw_device qsv=qsv:MFX_IMPL_hw and then choose it with -hwaccel qsv -hwaccel_device qsv. You should only need to do the init once.

see the official documentation on these flags for more information

like image 173
TheAtomicOption Avatar answered Oct 18 '22 19:10

TheAtomicOption