Intel QuickSyncVideo Transcoding on debian 8 (QSV on Debian)

category 서버/리눅스 서버 2017.07.06 20:14

안녕하세요. 도정진입니다.


카페에 정리되어 있는 착한유령님의 글과 구글 서칭을 통해서 결국에 QSV 트랜스코딩에 성공하였습니다. 


아직까지 libmfx 를 pkg-config 과 연동을 하지 못하여 컴파일을 하지 못하고 있습니다.


(FFMPEG 를 컴파일 하려고 하면 libmfx 가 없다고 뜹니다. 이 문제를 어떻게 해결해야할지....)


그러나 이미 빌드된 바이너리를 가지고 동작을 해 보면 작동이 매우 잘 됩니다. 부정확한 부분은 덧글로 알려주시길 바랍니다.!!


시작합니다.



1. 하드웨어 호환성


QSV 는 intel ark 로 보시면 QSV 지원 여부가 나옵니다.


저는 I5-4350U 시스템에 설치를 하였습니다. 


https://ark.intel.com/ko


4350U 의 경우 지원한다고 나와 있습니다.



그러나 CPU 정보에서 QSV 가 지원된다고 나와 있어도 윈도우에서는 지원이 잘 되나 리눅스에서는 메이저급 CPU 만 지원이 되고 있습니다. 


예를 들어서 N3150 의 경우 QSV 가 가능한 CPU 이지만 리눅스에서 사용할 수 있는 드라이버는 제공이 되지 않고 있습니다. 제가 생각해 보았을 때, 최소 I3 이상은 가야 QSV 가 리눅스에서 동작합니다. (윈도우 에서는 문제 없이 작동합니다.)



2. Intel Media Server Studio 버전 관련


다음으로 QSV 인코더 및 디코더를 사용하기 위해서는 인텔에서 제공하는 미디어 서버 스튜디오를 깔아야 합니다. 그런데 버전별로 지원하는 세대가 다르기 떄문에 맞게 다운받으셔야 합니다.


아래의 문서에 따르면 각 CPU 세대마다 필요한 버전은 아래와 같습니다.


https://software.intel.com/en-us/articles/driver-support-matrix-for-media-sdk-and-opencl



3세대의 경우 2015버전을 / 4세대의 경우 2015 2016버전을 / 5세대의 경우 2015 2016 2017 을 사용할 수 있다고 나오네요.


저는 4세대이기 때문에 2016버전을 사용하도록 하겠습니다.


intel media server studio 리눅스 파일들은 아래의 홈페이지에서 받을 수 있습니다.


https://software.intel.com/en-us/intel-media-server-studio




3. 전반적인 진행 과정


1. 미디어 스튜디오 압축 풀기

2. libdrm 설치

3. libva 설치

4. libmfx 설치

5. 커널 패치 및 컴파일 (5세대 부터는 필요가 없습니다. 백포트 커널 설치하시면 문제없이 작동합니다.)

- 이 부분은 이 글에서 다루지 않습니다.

6. libmfx 모듈 등록

7. ffmpeg 를 사용해 트랜스코딩 테스트



4. 의존성 패키지 및 인텔 미디어 서버 스튜디오 설치


의존성 패키지를 설치합니다. 다음으로 미디어 서버 스튜디오를 받으셨으면 압축을 풉니다.


root@4350:~# apt-get install gcc gobjc pkg-config libpthread-stubs0-dev libpciaccess-dev make patch yasm g++ autoconf cmake automake build-essential libass-dev libfreetype6-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libx11-dev libxext-dev libxfixes-dev texi2html zlib1g-dev libx264-dev libmp3lame-dev libfaac-dev librtmp-dev libvo-aacenc-dev libx264-dev cifs-utils lsb-release


root@4350:~# ls

MediaServerStudioProfessionalEvaluation2016.tar.gz


root@4350:~# tar xf MediaServerStudioProfessionalEvaluation2016.tar.gz 

root@4350:~# cd MediaServerStudioProfessionalEvaluation2016/


# 여기서 SDK2016Production16.4.4.tar.gz 파일이 오늘 필요한 파일입니다.

root@4350:~/MediaServerStudioProfessionalEvaluation2016# ls

Audio2016.tar.gz MediaSamples_Linux_2016_bin.tar.gz     SDK2016Production16.4.4.tar.gz  vtune_amplifier_xe_2016_update2.tar.gz

HEVCEvaluation2016.tar.gz media_server_studio_professional_release_notes.pdf  site_license_materials.txt

intel_code_builder_for_opencl_mss_2015_5.2.0.66_x64.tgz  PTIR2016.tar.gz     third_party_programs.txt

Intel(R) Media Server Studio EULA.pdf redist.txt     VideoQualityCaliper2016.tar.gz

root@4350:~/MediaServerStudioProfessionalEvaluation2016# 


SDK2016Production 파일 압축을 풉니다.


root@4350:~/MediaServerStudioProfessionalEvaluation2016# tar xf SDK2016Production16.4.4.tar.gz 

root@4350:~/MediaServerStudioProfessionalEvaluation2016# cd SDK2016Production16.4.4/


root@4350:~/MediaServerStudioProfessionalEvaluation2016/SDK2016Production16.4.4# ls

CentOS Generic  media_server_studio_getting_started_guide.pdf media_server_studio_sdk_release_notes.pdf


root@4350:~/MediaServerStudioProfessionalEvaluation2016/SDK2016Production16.4.4# cd Generic/

root@4350:~/MediaServerStudioProfessionalEvaluation2016/SDK2016Production16.4.4/Generic# ls

intel-linux-media-ocl_generic_16.4.4-47109_64bit.tar.gz


# intel-linux-media-ocl_generic 파일 압축을 풉니다.

root@4350:~/MediaServerStudioProfessionalEvaluation2016/SDK2016Production16.4.4/Generic# tar xf intel-linux-media-ocl_generic_16.4.4-47109_64bit.tar.gz 

root@4350:~/MediaServerStudioProfessionalEvaluation2016/SDK2016Production16.4.4/Generic# ls

etc  install_media.sh  intel-linux-media-ocl_generic_16.4.4-47109_64bit.tar.gz intel-opencl-1.2-16.4.tar.gz  opt  usr


# 스크립트를 통해서 필요한 파일 설치를 합니다.

root@4350:~/MediaServerStudioProfessionalEvaluation2016/SDK2016Production16.4.4/Generic# ./install_media.sh

Error... You are about to install on a non supported linux distribution.

# 에러가 나지만 살포시 무시합니다. (실제로 CentOS 를 지원합니다.)

INFO... Install on Debian ...

INFO... Installing New Driver...

INFO... MediaSDK installed successfully in /opt/intel/mediasdk!

INFO... MDF Runtime installed successfully in /opt/intel/common/mdf!

INFO... Installing Config files...

INFO... The LIBVA_DRIVERS_PATH/LIBVA_DRIVER_NAME will be exported through /etc/profile.d/intel-mediasdk.sh for intel media solution. Please reboot to make it effective.

INFO... Calling ldconfig after all user-space drivers and config files are in place...

INFO... Calling to ldconfig is done.

INFO... Package installation Done.

root@4350:~/MediaServerStudioProfessionalEvaluation2016/SDK2016Production16.4.4/Generic# 




5. libdrm , libva , libmfx 설치


설치에 들어가기 전에 말씀 드립니다. 


아직 libmfx 설치를 정확하게 한 것인지 잘 모르겠습니다. 컴파일 할 때 libmfx 가 없다는 에러가 계속 뜹니다. 


덧글로 지적해주시길 바랍니다.


libdrm 을 설치하겠습니다.


# 경로와 버전명이 미디어 서버 스튜디오 버전마다 다르기 때문에 TAB 키로 자동완성 해주시길 바랍니다.

root@4350:~# cd /opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/

root@4350:/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109# ls

libdrm-2.4.54.tar.bz2


# libdrm 소스 압축을 풉니다.

root@4350:/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109# tar xf libdrm-2.4.54.tar.bz2

root@4350:/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109# cd libdrm-2.4.54/

build-aux/ freedreno/ intel/     m4/        nouveau/   radeon/

exynos/    include/   libkms/    man/       omap/      tests/

root@4350:/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109# cd libdrm-2.4.54/

root@4350:/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54# ls

aclocal.m4   configure.ac  intel           m4           nouveau  tests         xf86drmHash.c    xf86drmSL.c

build-aux    exynos        libdrm_lists.h  Makefile.am  omap     xf86atomic.h  xf86drmMode.c

config.h.in  freedreno     libdrm.pc.in    Makefile.in  radeon   xf86drm.c     xf86drmMode.h

configure    include       libkms          man          README   xf86drm.h     xf86drmRandom.c

root@4350:/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54#


# libdrm 소스를 컴파일 하고 설치합니다.

root@4350:/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54# ./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

............................................................................... (중략)

config.status: creating freedreno/libdrm_freedreno.pc

config.status: creating tests/Makefile

config.status: creating tests/modeprint/Makefile

config.status: creating tests/modetest/Makefile

config.status: creating tests/kmstest/Makefile

config.status: creating tests/radeon/Makefile

config.status: creating tests/vbltest/Makefile

config.status: creating tests/exynos/Makefile

config.status: creating include/Makefile

config.status: creating include/drm/Makefile

config.status: creating man/Makefile

config.status: creating libdrm.pc

config.status: creating config.h

config.status: executing depfiles commands

config.status: executing libtool commands


libdrm 2.4.54 will be compiled with:


  libkms         yes

  Intel API      yes

  vmwgfx API     yes

  Radeon API     yes

  Nouveau API    yes

  OMAP API       no

  EXYNOS API     no

  Freedreno API  no


root@4350:/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54#


# 폭풍 make && make install !!

root@4350:/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54# make && make install

make  all-recursive

make[1]: Entering directory '/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54'

Making all in .

make[2]: Entering directory '/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54'

  CC     libdrm_la-xf86drm.lo

  CC     libdrm_la-xf86drmHash.lo

  CC     libdrm_la-xf86drmRandom.lo

  CC     libdrm_la-xf86drmSL.lo

  CC     libdrm_la-xf86drmMode.lo

  CCLD   libdrm.la

make[2]: Leaving directory '/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54'

Making all in libkms

............................................................................................................................ (중략)

make[1]: Entering directory '/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54/man'

make[2]: Entering directory '/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54/man'

make[2]: Nothing to be done for 'install-exec-am'.

test -z "/usr/share/man/man3" || /bin/mkdir -p "/usr/share/man/man3"

test -z "/usr/share/man/man7" || /bin/mkdir -p "/usr/share/man/man7"

make[2]: Leaving directory '/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54/man'

make[1]: Leaving directory '/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54/man'

root@4350:/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54#


다음은 libva 를 설치해 보겠습니다.


# 상위폴더로 3번 빠꾸합니다.

root@4350:/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109/libdrm-2.4.54# cd ..

root@4350:/opt/intel/mediasdk/opensource/libdrm/2.4.54-47109# cd ..

root@4350:/opt/intel/mediasdk/opensource/libdrm# cd ..


# libva 폴더로 이동하고 압축풉니다.

root@4350:/opt/intel/mediasdk/opensource# cd libva/1.67.0.pre1-47109/

root@4350:/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109# tar xf libva-1.67.0.pre1.tar.bz2

root@4350:/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109# cd libva-1.67.0.pre1/

root@4350:/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1# ls

aclocal.m4  config.guess  config.sub  configure.ac  debian.upstream  doc         ltmain.sh    Makefile.in  NEWS       test

compile     config.h.in   configure   COPYING       depcomp          install-sh  Makefile.am  missing      pkgconfig  va

root@4350:/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1#


# configure -> make -> make install !!

root@4350:/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1# ./configure --enable-static --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for a thread-safe mkdir -p... /bin/mkdir -p

.....................................................(중략)

config.status: creating config.h

config.status: executing depfiles commands

config.status: executing libtool commands


libva - 1.67.0.pre1 (VA-API 0.99.0)


Installation prefix .............. : /usr

Default driver path .............. : /usr/lib/x86_64-linux-gnu/dri

Extra window systems ............. : wayland glx x11 drm

Build documentation .............. : no


root@4350:/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1#


root@4350:/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1# make && make install

make  all-recursive

make[1]: Entering directory '/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1'

Making all in va

make[2]: Entering directory '/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1/va'

Making all in drm

...................................................................................(중략)

make[2]: Nothing to be done for 'install-exec-am'.

make[2]: Nothing to be done for 'install-data-am'.

make[2]: Leaving directory '/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1/doc'

make[1]: Leaving directory '/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1/doc'

make[1]: Entering directory '/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1'

make[2]: Entering directory '/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1'

make[2]: Nothing to be done for 'install-exec-am'.

make[2]: Nothing to be done for 'install-data-am'.

make[2]: Leaving directory '/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1'

make[1]: Leaving directory '/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1'

root@4350:/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1#


다음으로 libmfx 를 설치해보겠습니다. 

(이 과정은 아직까지 정확하지 않습니다.)


# 3번 상위폴더 빠꾸!

root@4350:/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1# cd ..

root@4350:/opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109# cd ..

root@4350:/opt/intel/mediasdk/opensource/libva# cd ..

root@4350:/opt/intel/mediasdk/opensource# cd mfx_dispatch/

include/ src/

root@4350:/opt/intel/mediasdk/opensource/mfx_dispatch#


# 빌드 경로 생성 및 cmake 실행

root@4350:/opt/intel/mediasdk/opensource/mfx_dispatch# mkdir build

root@4350:/opt/intel/mediasdk/opensource/mfx_dispatch# cd build

root@4350:/opt/intel/mediasdk/opensource/mfx_dispatch/build# cmake –D__ARCH:STRING=intel64 ../

-- The C compiler identification is GNU 4.9.2

-- The CXX compiler identification is GNU 4.9.2

-- Check for working C compiler: /usr/bin/cc

-- Check for working C compiler: /usr/bin/cc -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Check for working CXX compiler: /usr/bin/c++

-- Check for working CXX compiler: /usr/bin/c++ -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Configuring done

-- Generating done

-- Build files have been written to: /opt/intel/mediasdk/opensource/mfx_dispatch/build

root@4350:/opt/intel/mediasdk/opensource/mfx_dispatch/build#


# make!!

root@4350:/opt/intel/mediasdk/opensource/mfx_dispatch/build# make

/usr/bin/cmake -H/opt/intel/mediasdk/opensource/mfx_dispatch -B/opt/intel/mediasdk/opensource/mfx_dispatch/build --check-build-system CMakeFiles/Makefile.cmake 0

/usr/bin/cmake -E cmake_progress_start /opt/intel/mediasdk/opensource/mfx_dispatch/build/CMakeFiles /opt/intel/mediasdk/opensource/mfx_dispatch/build/CMakeFiles/progress.marks

make -f CMakeFiles/Makefile2 all

make[1]: Entering directory '/opt/intel/mediasdk/opensource/mfx_dispatch/build'

make -f CMakeFiles/dispatch_shared.dir/build.make CMakeFiles/dispatch_shared.dir/depend

make[2]: Entering directory '/opt/intel/mediasdk/opensource/mfx_dispatch/build'

cd /opt/intel/mediasdk/opensource/mfx_dispatch/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /opt/intel/mediasdk/opensource/mfx_dispatch /opt/intel/mediasdk/opensource/mfx_dispatch /opt/intel/mediasdk/opensource/mfx_dispatch/build /opt/intel/mediasdk/opensource/mfx_dispatch/build /opt/intel/mediasdk/opensource/mfx_dispatch/build/CMakeFiles/dispatch_shared.dir/DependInfo.cmake --color=

Scanning dependencies of target dispatch_shared

make[2]: Leaving directory '/opt/intel/mediasdk/opensource/mfx_dispatch/build'

make -f CMakeFiles/dispatch_shared.dir/build.make CMakeFiles/dispatch_shared.dir/build

make[2]: Entering directory '/opt/intel/mediasdk/opensource/mfx_dispatch/build'

/usr/bin/cmake -E cmake_progress_report /opt/intel/mediasdk/opensource/mfx_dispatch/build/CMakeFiles 1

[  2%] Building CXX object CMakeFiles/dispatch_shared.dir/src/main.cpp.o

..........................................................(중략)

[100%] Building CXX object CMakeFiles/mfx.dir/src/mfx_load_plugin.cpp.o

/usr/bin/c++   -DLINUX -DLINUX32 -DUNIX -D_FILE_OFFSET_BITS=64 -D__USE_LARGEFILE64 -pipe -fPIC -I/opt/intel/mediasdk/opensource/mfx_dispatch/../../include -I/opt/intel/mediasdk/opensource/mfx_dispatch/include    -o CMakeFiles/mfx.dir/src/mfx_load_plugin.cpp.o -c /opt/intel/mediasdk/opensource/mfx_dispatch/src/mfx_load_plugin.cpp

Linking CXX static library __lib/libmfx.a

/usr/bin/cmake -P CMakeFiles/mfx.dir/cmake_clean_target.cmake

/usr/bin/cmake -E cmake_link_script CMakeFiles/mfx.dir/link.txt --verbose=1

/usr/bin/ar cr __lib/libmfx.a  CMakeFiles/mfx.dir/src/main.cpp.o CMakeFiles/mfx.dir/src/mfx_critical_section.cpp.o CMakeFiles/mfx.dir/src/mfx_critical_section_linux.cpp.o CMakeFiles/mfx.dir/src/mfx_dispatcher.cpp.o CMakeFiles/mfx.dir/src/mfx_function_table.cpp.o CMakeFiles/mfx.dir/src/mfx_library_iterator.cpp.o CMakeFiles/mfx.dir/src/mfx_library_iterator_linux.cpp.o CMakeFiles/mfx.dir/src/mfx_load_dll.cpp.o CMakeFiles/mfx.dir/src/mfx_load_dll_linux.cpp.o CMakeFiles/mfx.dir/src/mfx_win_reg_key.cpp.o CMakeFiles/mfx.dir/src/mfx_dxva2_device.cpp.o CMakeFiles/mfx.dir/src/mfx_plugin_hive.cpp.o CMakeFiles/mfx.dir/src/mfx_plugin_hive_linux.cpp.o CMakeFiles/mfx.dir/src/mfx_plugin_cfg_parser.cpp.o CMakeFiles/mfx.dir/src/mfx_load_plugin.cpp.o

/usr/bin/ranlib __lib/libmfx.a

make[2]: Leaving directory '/opt/intel/mediasdk/opensource/mfx_dispatch/build'

/usr/bin/cmake -E cmake_progress_report /opt/intel/mediasdk/opensource/mfx_dispatch/build/CMakeFiles  32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

[100%] Built target mfx

make[1]: Leaving directory '/opt/intel/mediasdk/opensource/mfx_dispatch/build'

/usr/bin/cmake -E cmake_progress_start /opt/intel/mediasdk/opensource/mfx_dispatch/build/CMakeFiles 0

root@4350:/opt/intel/mediasdk/opensource/mfx_dispatch/build#


# 빌드된 파일 연동?
root@4350:/opt/intel/mediasdk/opensource/mfx_dispatch/build# ln -s /opt/intel/mediasdk/include/ /usr/local/include/mfx
root@4350:/usr/local/lib# ln -sf /opt/intel/mediasdk/opensource/mfx_dispatch/build/__lib/libmfx.a
root@4350:/usr/local/lib# ln -sf /opt/intel/mediasdk/opensource/mfx_dispatch/build/__lib/libdispatch_trace.a
root@4350:/usr/local/lib# ln -sf /opt/intel/mediasdk/opensource/mfx_dispatch/build/__lib/libdispatch_shared.a
root@4350:/usr/local/lib# ln -sf /opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1/va/.libs/libva.a
root@4350:/usr/local/lib# ln -sf /opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1/va/.libs/libva-drm.a
root@4350:/usr/local/lib# ln -sf /opt/intel/mediasdk/opensource/libva/1.67.0.pre1-47109/libva-1.67.0.pre1/va/.libs/libva-tpi.a
root@4350:/usr/local/lib#

# pkg-config 파일 생성
root@4350:/usr/local/lib# nano /usr/lib/pkgconfig/libmfx.pc

prefix=/usr/local
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include

Name: libmfx
Description: Intel Media SDK Dispatched static library
Version: 2016
Requires:
Requires.private:
Conflicts:
Libs: -L${libdir} -lmfx -ldispatch_shared -lva -lva-drm -lsupc++ -lstdc++
-ldl
Libs.private:
Cflags: -I${includedir}
-I/opt/intel/mediasdk/opensource/mfx_dispatch/include

# 환경 변수 설정
root@4350:/usr/local/lib# nano /etc/environment

LD_LIBRARY_PATH="/usr/local/lib:/usr/lib64:/usr/lib/x86_64-linux-gnu"
LIBVA_DRIVER_NAME=iHD
LIBVA_DRIVERS_PATH=/opt/intel/mediasdk/lib64

# 모듈 연동 (심링크!)
# 이때 Too many levels of symbolic links 에러가 발생하지 않도록 해주세요.
root@4350:/usr/local/lib# cd /opt/intel/mediasdk/lib64
root@4350:/opt/intel/mediasdk/lib64# ls
iHD_drv_video.so  libmfxhw64-p.so.1.17  libmfxhw64.so  libmfxsw64-p.so.1.17  libmfxsw64.so
root@4350:/opt/intel/mediasdk/lib64# ln -s /opt/intel/mediasdk/lib64/libmfxhw64.so /usr/lib/x86_64-linux-gnu/
root@4350:/opt/intel/mediasdk/lib64# ln -s /opt/intel/mediasdk/lib64/libmfxhw64-p.so.1.17 /usr/lib/x86_64-linux-gnu/
root@4350:/opt/intel/mediasdk/lib64# ln -s /opt/intel/mediasdk/lib64/libmfxsw64.so /usr/lib/x86_64-linux-gnu/
root@4350:/opt/intel/mediasdk/lib64# ln -s /opt/intel/mediasdk/lib64/libmfxsw64-p.so.1.17 /usr/lib/x86_64-linux-gnu/

root@4350:/opt/intel/mediasdk/lib64# ldconfig -v | grep libmfx
/sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: /lib/x86_64-linux-gnu/ld-2.19.so is the dynamic linker, ignoring

        libmfxhw64.so -> libmfxhw64-p.so.1.17
        libmfxsw64.so -> libmfxsw64-p.so.1.17
root@4350:/opt/intel/mediasdk/lib64#


여기까지 설치가 끝났습니다. 


시원하게 리부팅 한번 해 줍니다.


root@4350:/opt/intel/mediasdk/lib64# reboot



6. 커널 패치 및 컴파일


(다음 기회에... ㅠㅠ)

5세대 이상은 백포트 설치하시면 해결됩니다.


7. FFMPEG 컴파일 및 설치


(다음 기회에... ㅠㅠ)


8. 작동 테스트


일단 vainfo 를 실행해 보시면 아래와 같이 vaapi 의 i965 드라이버가 아닌 iHD 드라이버를 사용합니다. (i915 driver)


root@4350:~# vainfo

error: XDG_RUNTIME_DIR not set in the environment.

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.4.4.47109-ubit

vainfo: Supported profile and entrypoints

      VAProfileH264Baseline           : VAEntrypointEncSlice

      VAProfileH264Baseline           : <unknown entrypoint>

      VAProfileH264Baseline           : <unknown entrypoint>

      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               : VAEntrypointEncSlice

      VAProfileVP9Profile0            : VAEntrypointEncSlice

      VAProfileVP9Profile0            : VAEntrypointVLD

      VAProfileVP9Profile0            : <unknown entrypoint>

      <unknown profile>               : VAEntrypointVideoProc

      VAProfileNone                   : VAEntrypointVideoProc

      VAProfileNone                   : <unknown entrypoint>

root@4350:~#


CPU , GPU 모니터링 툴 설치 


root@4350:~# apt-get install htop intel-gpu-tools

Reading package lists... Done

Building dependency tree

Reading state information... Done

htop is already the newest version.

intel-gpu-tools is already the newest version.

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

root@4350:~#


모니터링 툴 실행


root@4350:~# htop

root@4350:~# intel_gpu_top


인코딩 테스트를 해 보았습니다.


1. libx264 인코딩 (0.68x)


root@4350:~# ffmpeg -i test.mp4 -vcodec libx264 -an out.mp4



2. CPU -> h264_qsv 인코딩 (7.11x)


root@4350:~# ffmpeg -i test.mp4 -vcodec h264_qsv -an out.mp4



3. h264_qsv -> h264_qsv 인코딩 (8.74x)


root@4350:~# ffmpeg -vcodec h264_qsv -i test.mp4 -vcodec h264_qsv -an out.mp4




감사합니다. !!





댓글을 달아 주세요