我不能通过ffmpeg使用QSV的HW编码器

时间:2017-06-25 14:33:09

标签: ffmpeg centos

我想用Intel H / W编码QSV进行编码。

  

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

     

lspci -nn -s 0:02.0   00:02.0 VGA兼容控制器[0300]:Intel Corporation Broadwell-U Integrated Graphics [8086:1626](rev 09)

我可以安装MediaServerStudioEssentials2017R2和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

# 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 )

但是,我尝试编码如下。

# 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)
・・・

似乎编码是由软件使用的。它很慢。 如何进行H / W编码?如果您知道,请告诉我。

贝斯茨,

1 个答案:

答案 0 :(得分:2)

看起来ffmpeg正在寻找qsv类型设备的设备列表而没有找到它。您可以使用-init_hw_device qsv=qsv:MFX_IMPL_hw创建ffmpeg硬件设备,然后使用-hwaccel qsv -hwaccel_device qsv选择它。你应该只需要做一次init。

有关详细信息,请参阅the official documentation on these flags