Gstreamer

GstreamerとVAAPI

18日からトライしているGStreamerのVAAPIエンコード環境整備。

/srcからソースコードをダウンロードし、gstreamer-1.10.2gstreamer-vaapi-1.10.2をbuildしてみたものの、

yano@haswell:~/gstreamer/gstreamer-vaapi-1.10.2$ gst-inspect-1.0 vaapi
Plugin Details:
  Name                     vaapi
  Description              VA-API based elements
  Filename                 /usr/local/lib/gstreamer-1.0/libgstvaapi.so
  Version                  1.10.2
  License                  LGPL
  Source module            gstreamer-vaapi
  Source release date      2016-11-29
  Binary package           gstreamer-vaapi
  Origin URL               http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer
  **0 features**:
  +-- **0 elements**
yano@haswell:~/gstreamer/gstreamer-vaapi-1.10.2$

と、なかなかVAAPIのフィルタが有効にならない。他にもいろいろと足りないものがあったので、gst-plugins-base-1.10.2gst-plugins-bad-1.10.2gst-plugins-good-1.10.2gst-plugins-ugly-1.10.2vo-aacenc-0.1.3libmpeg2-0.5.1gst-libav-1.10.2libva-1.7.3libva-intel-driver-1.7.3をbuildしていくもののダメで、結局のところ

yano@haswell:~$ sudo apt-get install libdrm-dev libudev-dev libva-dev

が効いたようで、ようやく

yano@haswell:~/gstreamer/gstreamer-vaapi-1.10.2$ gst-inspect-1.0 vaapi
Plugin Details:
  Name                     vaapi
  Description              VA-API based elements
  Filename                 /usr/local/lib/gstreamer-1.0/libgstvaapi.so
  Version                  1.10.2
  License                  LGPL
  Source module            gstreamer-vaapi
  Source release date      2016-11-29
  Binary package           gstreamer-vaapi
  Origin URL               http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer
  vaapijpegdec: VA-API JPEG decoder
  vaapimpeg2dec: VA-API MPEG2 decoder
  vaapih264dec: VA-API H264 decoder
  vaapivc1dec: VA-API VC1 decoder
  vaapipostproc: VA-API video postprocessing
  vaapidecodebin: VA-API Decode Bin
  vaapisink: VA-API sink
  vaapimpeg2enc: VA-API MPEG-2 encoder
  vaapih264enc: VA-API H264 encoder
  9 features:
  +-- 9 elements
yano@haswell:~/gstreamer/gstreamer-vaapi-1.10.2$

となった。

GstreamerとVAAPI

宿題を残したQSVハードウェアエンコード環境。

Intel VAAPI h264 encoding: gstreamer vs ffmpeg\avconvなどによるとVAAPI対応の選択肢としてGStreamerもあるようなので、試してみた。

yano@haswell:~/gst-test$ sudo apt-get install gstreamer1.0-vaapi*
yano@haswell:~/gst-test$ gst-inspect-1.0 vaapi
Plugin Details:
  Name                     vaapi
  Description              VA-API based elements
  Filename                 /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvaapi.so
  Version                  0.5.7
  License                  LGPL
  Source module            gstreamer-vaapi
  Binary package           gstreamer-vaapi
  Origin URL               gwenole.beauchesne@intel.com
  vaapidecode: VA-API decoder
  vaapipostproc: VA-API video postprocessing
  vaapisink: VA-API sink
  3 features:
  +-- 3 elements
yano@haswell:~/gst-test$

との事。GStreamer VA-API Plugins 1.0 Plugins Reference Manualを見る限り「VA-API based H.264 video encoder」がありそうなのだが、どうやらubuntu 14.04の公式パッケージはデコーダ未対応の旧版な雰囲気だ。

というわけで、必然的に最新版をソースコードからbuildする方向にハンドルを切るわけだが、その前にGstreamerの独特な作法に馴染むべく、取り敢えずx264で試行錯誤してmp4のファイル出力にトライ。

yano@haswell:~/gst-test$ ffmpeg -i ~/20161210_2313_28_GRhd.ts -map 0:0 -map 0:1 \
  -vcodec copy -acodec copy ./input.ts
yano@haswell:~/gst-test$ gst-launch-1.0 \
  filesrc location=./input.ts ! progressreport ! tsdemux name=demuxer demuxer. ! queue ! \
  aacparse ! avdec_aac ! audioresample ! audioconvert dithering=0 ! voaacenc bitrate=25800 ! mux. \
  mp4mux name=mux ! filesink location=./gst-x264-`date +%Y%m%d_%H%M`.mp4 demuxer. ! queue ! mpegvideoparse ! mpeg2dec ! \
  videoconvert ! x264enc pass=quant ! video/x-h264,stream-format=byte-stream,profile=high ! h264parse ! mux.
Got EOS from element "pipeline0".
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
progressreport0 (00:00:05): 4869200 / 250449088 bytes ( 1.9 %)
progressreport0 (00:00:10): 8648000 / 250449088 bytes ( 3.5 %)
~中略~
progressreport0 (00:04:15): 241937200 / 250449088 bytes (96.6 %)
progressreport0 (00:04:20): 246054400 / 250449088 bytes (98.2 %)
Execution ended after 0:04:27.257661620
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
yano@haswell:~/gst-test$

ちなみに生のTSをそのまま喰わせると