4代Intel CPU在CentOS7上开启硬解4K

in Linux with 0 comment

首先,4代CPU不能使用Media-Driver,4代CPU支持应该是intel-vaapi-driver这个驱动。装了Media-Driver的一定要先卸载掉,不然检验驱动的时候会报错。

所需驱动及程序:

编译安装libva

wget https://github.com/intel/libva/releases/download/2.11.0/libva-2.11.0.tar.bz2
tar -Jxvf libva-2.11.0.tar.bz2 && cd libva-2.11.0
./autogen.sh --libdir=/usr/lib64
./configure
make -j5
make install

编译安装libva-utils

wget https://github.com/intel/libva-utils/releases/download/2.11.1/libva-utils-2.11.1.tar.bz2
tar -Jxvf libva-utils-2.11.1.tar.bz2 && cd libva-utils-2.11.1
./autogen.sh --libdir=/usr/lib64
./configure
make -j5
make install
如果./autogen.sh时报错找不到libva-drm,则手动导入环境变量,export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/这是默认的安装目录,改过目录的自行修改路径

装完后即可检测驱动是否安装成功,用一下命令查看,输出如下:

server#vainfo --display drm --device /dev/dri/renderD128 
libva info: VA-API version 1.11.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_11
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.11 (libva 2.11.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Desktop - 2.4.0.pre1 (2.3.0-31-gd87db21)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD

编译安装ffmpeg

git clone -b release/4.4 https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
./configure --prefix=/usr --pkg-config-flags="--static" --extra-libs="-lpthread -lm" --enable-gpl --enable-vaapi --enable-libx264 --enable-libx265 --enable-nonfree
make -j5 
make install

测试ffmpeg硬解是否正常

ffmpeg -i "test.mp4" -vf "select=eq(pict_type\,I)" -vsync vfr -qscale:v 2 -f image2 "%08d.jpg"

如果正常应该会提示如下信息,同时目录下生成很多jpg文件:

ffmpeg version N-102461-g8649f5d Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10.2.0 (GCC)
  configuration: --pkg-config-flags=--static --extra-libs='-lpthread -lm' --enable-gpl --enable-vaapi --enable-libx264 --enable-nonfree --prefix=/usr --disable-x86asm
  libavutil      57.  0.100 / 57.  0.100
  libavcodec     59.  1.100 / 59.  1.100
  libavformat    59.  0.101 / 59.  0.101
  libavdevice    59.  0.100 / 59.  0.100
  libavfilter     8.  0.101 /  8.  0.101
  libswscale      6.  0.100 /  6.  0.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
  Duration: 01:37:55.21, start: 0.000000, bitrate: 3570 kb/s
  Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 96000 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      handler_name    : Sound Media Handler
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 3372 kb/s, 24 fps, 24 tbr, 12288 tbn (default)
    Metadata:
      handler_name    : Video Media Handler
      vendor_id       : [0][0][0][0]
      encoder         : AVC Coding
Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler @ 0x3016a40] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to '%08d.jpg':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    encoder         : Lavf59.0.101
  Stream #0:0(und): Video: mjpeg, yuvj420p(pc, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24 fps, 24 tbn (default)
    Metadata:
      handler_name    : Video Media Handler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc59.1.100 mjpeg
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
frame=    8 fps=2.9 q=2.0 Lsize=N/A time=00:00:43.58 bitrate=N/A speed=15.8x    
video:883kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Exiting normally, received signal 2.

硬解测试成功后即可在jellyfin中开启硬解。

参考文章:ubuntu 基于intel vaapi 接口调用集成显卡硬编解码
视频和视频帧:FFMPEG+Intel QSV硬解的环境安装篇

Comments are closed.