Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Build GStreamer MSDK

Dmitry Rogozhkin edited this page Oct 7, 2020 · 1 revision

This build documentation was tested under clear Ubuntu 18.04 (with gcc-7.4.0) and Ubuntu 19.04 (gcc-8.3.0) but it should work on another OS distributions with various versions of gcc and clang.

Prepare environment and dependencies

Install all required common packages:

You can get it in two ways:

  • Build from sources:

    do not forget to export environment variables:

    export LIBVA_DRIVERS_PATH=/path/to/iHD_driver
    export LIBVA_DRIVER_NAME=iHD
    export LD_LIBRARY_PATH=/path/to/msdk/lib
    export PKG_CONFIG_PATH=/path/to/msdk/lib/pkgconfig
    
  • Starting from Ubuntu 19.04 Intel media stack components are available for installation via apt-get (see: Intel media stack on Ubuntu).

    sudo apt-get install libva-dev libmfx-dev intel-media-va-driver-non-free
    export LIBVA_DRIVER_NAME=iHD
    

Install Gstreamer & plugins

Currently (on 23 Aug 2019) GStreamer package which installs via apt-get does not contain msdk plugin, so we need to build & install this from sources.

For build gstreamer uses meson and ninja packages.

You can get meson through your package manager or using

pip3 install --user meson

This will install meson into ~/.local/bin which may or may not be included automatically in your PATH by default.

You should get ninja using your package manager or download the official release and put the ninja binary in your PATH.

Build Gstreamer

git clone https://gitlab.freedesktop.org/gstreamer/gstreamer
cd gstreamer
meson build
ninja -C build
ninja -C build install

Build gstreamer-plugins-base

git clone https://gitlab.freedesktop.org/gstreamer/gst-plugins-base
cd gst-plugins-base
meson build
ninja -C build
ninja -C build install

Build gstreamer-plugins-bad

git clone https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad
cd gst-plugins-bad
meson build

After configure log must contains:

Run-time dependency libmfx found: YES 1.28
Has header "mfx/mfxdefs.h" : YES 
Has header "mfxvp9.h" : YES 

Or can check why msdk will not be built. Example of error log:

sys/msdk/meson.build:91:2: ERROR: Dependency "gudev-1.0" not found, tried pkgconfig

For build & install plugins to you machine:

ninja -C build
ninja -C build install

for check that plugins install:

gst-inspect-1.0 | grep msdk

output:

msdk:  msdkvpp: MSDK Video Postprocessor
msdk:  msdkvp9enc: Intel MSDK VP9 encoder
msdk:  msdkvp9dec: Intel MSDK VP9 decoder
msdk:  msdkvc1dec: Intel MSDK VC1 decoder
msdk:  msdkvp8enc: Intel MSDK VP8 encoder
msdk:  msdkvp8dec: Intel MSDK VP8 decoder
msdk:  msdkmpeg2enc: Intel MSDK MPEG2 encoder
msdk:  msdkmpeg2dec: Intel MSDK MPEG2 decoder
msdk:  msdkmjpegenc: Intel MSDK MJPEG encoder
msdk:  msdkmjpegdec: Intel MSDK MJPEG decoder
msdk:  msdkh265enc: Intel MSDK H265 encoder
msdk:  msdkh265dec: Intel MSDK H265 decoder
msdk:  msdkh264enc: Intel MSDK H264 encoder
msdk:  msdkh264dec: Intel MSDK H264 decoder

Usage examples

GStreamer has built-in debug facilities contolled by --gst-debug-level=* option.

Debug levels:

  • 0 - no logging
  • 7 - maximum level
gst-launch-1.0 --gst-debug-no-color --gst-debug-level=7 filesrc location=in.file ! filesink location=out.file

Download stream

wget https://fate-suite.libav.org/h264-conformance/AUD_MW_E.264

Decode

H264 video decode and save as a raw file

gst-launch-1.0 filesrc location=AUD_MW_E.264 \
   ! h264parse ! msdkh264dec                 \
   ! filesink location=aud_mw_e176x144.yuv

Encode

Encode raw video as H265

gst-launch-1.0 filesrc location=aud_mw_e176x144.yuv \
   ! videoparse width=176 height=144                \
   ! msdkh265enc ! filesink location=aud_mw_e176x144.hevc

Transcode

Transcode h264 to h265

gst-launch-1.0 \
    filesrc location=AUD_MW_E.264      \
    ! h264parse ! msdkh264dec          \
    ! videoparse width=176 height=144  \
    ! msdkh265enc ! filesink location=AUD_h264_to_h265.hevc

Decode -> VPP -> Encode

gst-launch-1.0 \
    filesrc location=AUD_MW_E.264 ! h264parse ! msdkh264dec \                   
    ! msdkvpp ! video/x-raw, width=352, height=288          \
    ! videoparse width=352 height=288 !  msdkh265enc        \
    ! filesink location=h264d_VPPresize_h265e.hevc

Deprecated build method

Since GStreamer 1.17.x development series removed autotools support and switched to meson. This section contains information how-to build Gstreamer with autotools.

Build Gstreamer

git clone https://gitlab.freedesktop.org/gstreamer/gstreamer
cd gstreamer
./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
make
sudo make install

Build gstreamer-plugins-base

git clone https://gitlab.freedesktop.org/gstreamer/gst-plugins-base
cd gst-plugins-base
./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
make
sudo make install

Build gstreamer-plugins-bad

git clone https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad
cd gst-plugins-bad
./autogen.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
make
sudo make install

Useful links

Clone this wiki locally