-
Notifications
You must be signed in to change notification settings - Fork 460
Intel media stack on Ubuntu
Starting from Ubuntu 19.04 the following Intel media stack components are available for the installation:
- Intel Media SDK
- Intel Media Driver for VAAPI (aka iHD driver)
- Intel C for Media Runtime (hosted within Intel Media Driver for VAAPI)
To install Intel Media SDK runtime use the following commands:
sudo apt-get install libmfx1 libmfx-tools
This will install Intel Media SDK and a set of VAAPI drivers. Additionally to that make sure to install at least one of VAAPI backends for DRM, X Server, Wayland, etc.:
sudo apt-get install libva-drm2 libva-x11-2 libva-wayland2 libva-glx2
As of now default driver for Intel GPU is i965 driver which is not supported by Media SDK. To enable iHD media driver export the following environment variable:
export LIBVA_DRIVER_NAME=iHD
The basic test whether VAAPI driver is functional would be to run vainfo
tool. The tool prints basic information about the loaded driver and features it supports (entrypoints and profiles) which depend on the actual hardware you are running on:
$ sudo apt-get install vainfo
$ vainfo # running on SKL
libva info: VA-API version 1.4.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_4
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.4 (libva 2.4.0)
vainfo: Driver version: Intel iHD driver - 1.0.0
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSliceLP
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSliceLP
VAProfileJPEGBaseline : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointEncPicture
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
VAProfileVP8Version0_3 : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointVLD
After that you can try to run the following command lines to verify that media stack is functional:
export LIBVA_DRIVER_NAME=iHD
wget https://github.com/lu-zero/fate-samples/raw/master/h264-conformance/AUD_MW_E.264
# Decode H.264 video stream w/ maximum speed
/usr/share/mfx/samples/sample_decode h264 -i AUD_MW_E.264
# Decode H.264 video stream and dump output YUV
/usr/share/mfx/samples/sample_decode h264 -i AUD_MW_E.264 -o AUD_MW_E.yuv -i420
# You can verify the result comparing with the following checksum:
# sha1sum AUD_MW_E.yuv
e17a3f8cfeeeb1cc46218c3c797d24dd84e82b59 AUD_MW_E.yuv
# Encode H.264 stream w/ Low Power encoder on gen9+ (skl+)
/usr/share/mfx/samples/sample_encode h264 \
-w 176 -h 144 -f 30 -cqp -qpi 30 -qpp 30 -qpb 30 -qsv-ff \
-i AUD_MW_E.yuv -o encoded_AUD_MW_E.264
Above command lines don't require running graphical server (for example, X server).
There are few drivers available for Intel GPUs under Ubuntu. The table below provides a quick summary.
Driver | Package | Supported platforms | Supported by mediasdk? |
---|---|---|---|
i965 "free" | i965-va-driver | pre-gen11 | No |
i965 "non-free" | i965-va-driver-shaders | pre-gen11 | No |
iHD "free" | intel-media-va-driver | gen8+ | Yes |
iHD "non-free" | intel-media-va-driver-non-free | gen8+ | Yes |
By default "free" versions are installed which have limited number of available features. For the purpose of this article we will focus on the iHD media driver. As was just mentioned "free" version is installed by default which comes via intel-media-va-driver
package). To install full feature driver (aka "non-free") execute:
sudo apt-get install intel-media-va-driver-non-free
Both drivers are available under the same License. The difference between them is that the "non-free" one contains closed source EU binary shaders. For the details on which features are actually supported in each driver, refer to the driver documentation starting from README. Basically, "free" driver build corresponds to -DENABLE_NONFREE_KERNELS=OFF
configuration option.
To verify that full feature driver works fine you can run all the commands you've executed on the limited driver (see above) plus the following commands corresponding to the extended set of features (mind bigger list of supported profiles and entrypoints reported by vainfo
):
$ sudo apt-get install intel-media-va-driver-non-free
$ vainfo # running on SKL
libva info: VA-API version 1.4.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_4
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.4 (libva 2.4.0)
vainfo: Driver version: Intel iHD driver - 1.0.0
vainfo: Supported profile and entrypoints
VAProfileNone : VAEntrypointVideoProc
VAProfileNone : VAEntrypointStats
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Simple : VAEntrypointEncSlice
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointFEI
VAProfileH264Main : VAEntrypointEncSliceLP
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointFEI
VAProfileH264High : VAEntrypointEncSliceLP
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointEncPicture
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264ConstrainedBaseline: VAEntrypointFEI
VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
VAProfileVP8Version0_3 : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointFEI
# Encode H.264 stream w/ Dual Pipe encoder on gen8+ (bdw+):
$ /usr/share/mfx/samples/sample_encode h264 \
-w 176 -h 144 -f 30 -b 3000 \
-i AUD_MW_E.yuv -o encoded_AUD_MW_E.264
To switch back to the limited free driver execute:
sudo apt-get install intel-media-va-driver
To install Intel media stack development environment run:
sudo apt-get install libva-dev libmfx-dev
To try on-screen rendering under X Server via sample decode, execute:
# Decode H.264 video stream and render output on the screen under X Server
/usr/share/mfx/samples/sample_decode h264 -i AUD_MW_E.264 -r -rgb4 -f 30
Mind, please, that this command line requires NV12 to RGB4 color space conversion which might not be available for your particular platform under default free driver (intel-media-va-driver
), but should be available for non-free one (intel-media-va-driver-non-free
)
- MediaSDK#1735: Different AVC low power encoding quality on free and non-free media drivers
- MediaSDK#1736: Sample decode crashes if X server can't be initialized
Issues addressed with Ubuntu 19.10:
- Fixed failures of AVC low power encoding, MediaSDK#1398, media-driver#613
- Improved error reporting in sample decode for on-screen rendering, see MediaSDK#1396
- Media SDK for Linux
- Media SDK for Windows
- FFmpeg QSV
- GStreamer MSDK
- Docker
- Usage guides
- Building Media SDK
- Running Media SDK CI tests
- Additional information
- Multi-Frame Encode