以前の記事:
BRIX s (i3-6100U) + CentOS7 + Intel Media Server Studio 2017 R3 で QSV を使ってみた。でQSV環境とPLEXドライバーが共存できない問題が解決したようなので早速構築してみました。


Intel Media Server Studio 2018 R1 のリリースをコメントで教えて頂きました。
なんと CentOS7.4に対応したとのことです。
まさに渡りに船!
What's New in Intel® Media Server Studio 2018 を見てみると
「New Features in Intel Media Server Studio for Linux」に
「Supports CentOS* 7.4 - providing new features, security updates」とありました!
CPU対応は第5世代 Broadwell、第6世代 Skylake と変わらずのようです。
Media Server Studio 2018 R1 インストール
CentOS-7-x86_64-Everything-1708.iso を使用しました。
前回同様、「開発およびクリエイティブワークステーション」でインストールしました。
「プラットホーム開発」、「開発ツール」、「python」を選びました。
# usermod -a -G video $USER
# lspci -nn -s 00:02.0
00:02.0 VGA compatible controller [0300]: Intel Corporation HD Graphics 520 [8086:1916] (rev 07)
# tar zxvf MediaServerStudioEssentials2018R1.tar.gz
# cd MediaServerStudioEssentials2018R1
# tar zxvf SDK2018Production16.8.tar.gz
# cd SDK2018Production16.8
# cd CentOS7.4
# tar zxvf install_scripts_centos_16.8-69021.tar.gz
# ./install_sdk_CentOS.sh
再起動後、確認…、libva-utilsが入ってないようです。
# vainfo
bash: vainfo: コマンドが見つかりませんでした...
# yum install epel-release yum-utils
# yum --enablerepo=epel install libva-utils
(省略)
エラー
まぁいいか(笑)
サンプル実行がパスするかを確認します。
# cd MediaServerStudioEssentials2018R1
# tar zxvf MediaSamples_Linux_2018R1_b982.tar.gz
# cd MediaSamples_Linux_2018R1_b982/samples/_bin/x64
# ./sample_multi_transcode -i::h264 ../content/test_stream.264 -o::h264 test_out.h264 -hw -la
Multi Transcoding Sample Version 8.2.25.982
libva info: VA-API version 1.0.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_1_0
libva info: va_openDriver() returns 0
Pipeline surfaces number (DecPool): 59
MFX HARDWARE Session 0 API ver 1.25 parameters:
Input video: AVC
Output video: AVC
Session 0 was NOT joined with other sessions
Transcoding started
..
Transcoding finished
Common transcoding time is 0.139144 sec
-------------------------------------------------------------------------------
*** session 0 PASSED (MFX_ERR_NONE) 0.138996 sec, 101 frames
-i::h264 ../content/test_stream.264 -o::h264 test_out.h264 -hw -la
-------------------------------------------------------------------------------
The test PASSED
libmfx を設定します。
# mkdir /opt/intel/mediasdk/include/mfx
# cp /opt/intel/mediasdk/include/*.h /opt/intel/mediasdk/include/mfx
# nano /usr/lib64/pkgconfig/libmfx.pc
書き込んで終了。
prefix=/opt/intel/mediasdk
exec_prefix=${prefix}
libdir=${prefix}/lib/lin_x64
includedir=${prefix}/include
Name: libmfx
Description: Intel Media SDK
Version: 16.8
Libs: -L${libdir} -lmfx -lva -lstdc++ -ldl -lva-drm -ldrm
Cflags: -I${includedir} -I/usr/include/libdrm
ffmpegは3.4.2を使用しました。
cd /tmp && \
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz && \
tar zxvf yasm-1.3.0.tar.gz && \
cd yasm-1.3.0 && \
./configure && \
make -j$(nproc) && \
sudo make install && \
sudo ldconfig
cd /tmp && \
wget http://ffmpeg.org/releases/ffmpeg-3.4.2.tar.bz2 && \
tar jxvf ffmpeg-3.4.2.tar.bz2 && \
cd ffmpeg-3.4.2 && \
./configure --enable-libmfx && \
make -j$(nproc) && \
sudo make install
バージョン確認して完了。
$ ffmpeg -version
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
configuration: --enable-libmfx
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
トランスコード
う、動いたー。
H264_sqv speed=3.7x 前回と同じくらいなのでこんなものなのでしょう。
2018/04/21 追記
DDR3L 1600 8GB 1.35Vを1枚追加してデュアルチャネルにすると
H264_sqv が speed=6.02x になりました。
メモリ速度が影響するとは聞いていましたがちょっとビックリです。
hevc_qsv は微増で speed=2.69x でした。
$ ffmpeg -i in.mp4 -vcodec h264_qsv -init_hw_device qsv:hw out_qsv.mp4
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
configuration: --enable-libmfx
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mp4':
…
Output #0, mp4, to 'out_qsv.mp4':
…
Stream #0:0(und): Video: h264 (h264_qsv) (avc1 / 0x31637661), nv12, 1920x1080, q=2-31, 1000 kb/s, 24 fps, 12288 tbn, 24 tbc (default)
…
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
…
speed= 3.7x
…
H.265 (hevc_qsv) も試します。
こっちも無事動きました。
hevc_qsv speed=2.14x でした。こちらも前回とほぼ同じですね。
$ ffmpeg -i in.mp4 -vcodec hevc_qsv -init_hw_device qsv:hw -load_plugin hevc_hw -maxrate 10000k out_qsv.mp4
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
configuration: --enable-libmfx
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mp4':
…
Output #0, mp4, to 'out_qsv.mp4':
…
Stream #0:0(und): Video: hevc (hevc_qsv) (hev1 / 0x31766568), nv12, 1920x1080, q=2-31, 1000 kb/s, 24 fps, 12288 tbn, 24 tbc (default)
…
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
…
speed=2.14x
…
PLEX PX-Q3U4 セットアップ
とりあえずドライバーインストールです。
PLEX から CentOS7-1708_64bit_kernel3.10.0-693.zip をダウンロードしてきました。
ドライバはもちろん問題なく、機器も正しく認識されました。
# unzip CentOS7-1708_64bit_kernel3.10.0-693.zip
# cd CentOS7-1708_64bit_kernel3.10.0-693
# insmod tty_Virtual.ko
# insmod usb-px4.ko
# lsmod | grep px4
usb_px4 446056 0
tty_Virtual 22223 1 usb_px4
# ls /dev/px4*
/dev/px4-DTV0 /dev/px4-DTV2 /dev/px4-DTV4 /dev/px4-DTV6
/dev/px4-DTV1 /dev/px4-DTV3 /dev/px4-DTV5 /dev/px4-DTV7
# cp -p *.ko /lib/modules/`uname -r`/kernel/drivers/video
# depmod
アクセス設定を追加。
# nano /etc/udev/rules.d/99-px4.rules
KERNEL=="px4*" GROUP="video", MODE="0666"
再起動後、デバイスファイルを確認。
$ ls -l /dev/px4*
crw-rw-rw-. 1 root video 180, 192 4月 16 23:39 /dev/px4-DTV0
crw-rw-rw-. 1 root video 180, 193 4月 16 23:39 /dev/px4-DTV1
crw-rw-rw-. 1 root video 180, 194 4月 16 23:39 /dev/px4-DTV2
crw-rw-rw-. 1 root video 180, 195 4月 16 23:39 /dev/px4-DTV3
crw-rw-rw-. 1 root video 180, 196 4月 16 23:39 /dev/px4-DTV4
crw-rw-rw-. 1 root video 180, 197 4月 16 23:39 /dev/px4-DTV5
crw-rw-rw-. 1 root video 180, 198 4月 16 23:39 /dev/px4-DTV6
crw-rw-rw-. 1 root video 180, 199 4月 16 23:39 /dev/px4-DTV7
カードリーダーには SCR3310-NTTCom を接続しました。
録画ソフトまでセットアップしていきます。
$ sudo yum -y install ccid pcsc-lite pcsc-lite-devel pcsc-lite-libs
$ wget http://ludovic.rousseau.free.fr/softwares/pcsc-perl/pcsc-perl-1.4.14.tar.bz2
$ tar xf pcsc-perl-1.4.14.tar.bz2
$ cd pcsc-perl-1.4.14
$ perl Makefile.PL
$ make
$ sudo make install
$ wget http://ludovic.rousseau.free.fr/softwares/pcsc-tools/pcsc-tools-1.5.3.tar.bz2
$ tar xf pcsc-tools-1.5.3.tar.bz2
$ cd pcsc-tools-1.5.3
$ ./configure
$ make
$ sudo make install
$ sudo systemctl enable pcscd
$ sudo systemctl start pcscd
$ pcsc_scan
Using reader plug'n play mechanism
Scanning present readers...
0: NTT Communications Corp. SCR3310-NTTCom USB SmartCard Reader [Vendor Interface] 00 00
…
$ sudo yum -y install ld-linux.so.2
$ wget http://hg.honeyplanet.jp/pt1/archive/c44e16dbb0e2.zip
$ unzip c44e16dbb0e2.zip
$ cd pt1-c44e16dbb0e2/arib25
$ make
$ sudo make install
$ sudo echo /usr/local/lib > /etc/ld.so.conf.d/usr-local-lib.conf
$ sudo ldconfig
$ wget http://plex-net.co.jp/download/linux/Linux_Driver.zip
$ unzip Linux_Driver.zip
$ cd Linux_Driver/MyRecpt1/MyRecpt1/recpt1/
$ make clean
$ sh ./configure --enable-b25
$ make
$ sudo make install
あとは適当にテスト。
セットアップ直後、px4-DTV2,3がレベルはあるのに
ファイルサイズゼロな状況に遭遇しましたが、
USBを抜き差ししたら正常に掃き出すようになりました。
再現しないのでよくわかりません。
その後はとりあえず特に問題もなく終了です。
$ recpt1 --device /dev/px4-DTV2 --b25 --strip 25 10 ~/test.ts
所感
とりあえず、セットアップだけ通してやってみました。
これで録画してQSVで圧縮という環境は整いました。
後日つづきで Chinachu γ との QSV連携 をやってみようかなというところです。
foltia Anime Locker も CentOS7.4 に対応すればいいのになーと。
さて、QSVに関してですが、正直H264の速度が出ていないので
H265のほうを採用しようかなとかおもっています。
小さい動画で試しただけですが、サイズ的にざっくりH264が2分の1、H265が3分の1という感じでした。
XPERIA XZ Premium で確認しているのですが、どちらも再生に問題はなかったです。
画質的には見れるなーというくらいしかわかりませんでしたが。
色々試してみないとなんともです。
ともあれまた一歩前進したのでよかったです!
- 関連記事
-