我想使用 Intel H/W 编码 QSV 进行编码。
我可以安装 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 编码?如果你知道,请告诉我。
最好的,
最佳答案
看起来 ffmpeg 正在其设备列表中查找 qsv 类型设备,但没有找到。您可以使用 -init_hw_device qsv=qsv:MFX_IMPL_hw
创建一个 ffmpeg 硬件设备,然后使用 -hwaccel qsv -hwaccel_device qsv
选择它。您应该只需要执行一次 init。
有关更多信息,请参阅 the official documentation on these flags