Skip to content

Instantly share code, notes, and snippets.

@trishmapow
Forked from feedsbrain/ffmpeg-qsv.sh
Last active May 12, 2023 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trishmapow/e1f019746c8fc41387458233afce6eff to your computer and use it in GitHub Desktop.
Save trishmapow/e1f019746c8fc41387458233afce6eff to your computer and use it in GitHub Desktop.
Compiling FFMpeg with Intel Quick Sync in Ubuntu 20.04
#!/bin/bash
# Taken from: https://red-full-moon.com/make-hevc-qsv-env-first-half/
sudo apt update
sudo apt dist-upgrade
sudo apt install cmake make autoconf automake libtool g++ bison libpcre3-dev pkg-config libtool libdrm-dev xorg xorg-dev openbox libx11-dev libgl1-mesa-glx libgl1-mesa-dev libpciaccess-dev libfdk-aac-dev libvorbis-dev libvpx-dev libx264-dev libx265-dev ocl-icd-opencl-dev pkg-config yasm libx11-xcb-dev libxcb-dri3-dev libxcb-present-dev libva-dev libmfx-dev intel-media-va-driver-non-free opencl-clhpp-headers
mkdir ~/git && cd ~/git
git clone https://github.com/intel/libva
cd libva
./autogen.sh
make
sudo make install
cd ~/git
git clone https://github.com/intel/libva-utils
cd libva-utils
./autogen.sh
make
sudo make install
cd ~/git
git clone https://github.com/intel/gmmlib
cd gmmlib
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE= Release -DARCH=64 ../
make -j4
sudo make install
cd ~/git
# smaller size: wget https://github.com/intel/media-driver/archive/refs/heads/master.zip; unzip master.zip
git clone https://github.com/intel/media-driver
mkdir build_media && cd build_media
cmake ../media-driver
make -j4
sudo make install
sudo mkdir -p /usr/local/lib/dri
sudo cp ~/git/build_media/media_driver/iHD_drv_video.so /usr/local/lib/dri/
cd ~/git
# smaller size: wget https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/heads/master.zip; unzip master.zip
git clone https://github.com/Intel-Media-SDK/MediaSDK msdk
cd msdk
git submodule init
git pull
mkdir -p ~/git/build_msdk && cd ~/git/build_msdk
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_WAYLAND=ON -DENABLE_X11_DRI3=ON -DENABLE_OPENCL=ON ../msdk
make -j4
sudo make install
sudo sh -c "echo '/opt/intel/mediasdk/lib' > /etc/ld.so.conf.d/imsdk.conf"
sudo ldconfig
cd ~/git
wget https://github.com/FFmpeg/FFmpeg/archive/refs/heads/master.zip -O FFmpeg.zip
unzip FFmpeg.zip
# git clone https://github.com/FFmpeg/FFmpeg
cd FFmpeg-master
PKG_CONFIG_PATH=/opt/intel/mediasdk/lib/pkgconfig ./configure --prefix=/usr/local/ffmpeg --extra-cflags="-I/opt/intel/mediasdk/include" --extra-ldflags="-L/opt/intel/mediasdk/lib" --extra-ldflags="-L/opt/intel/mediasdk/plugins" --enable-libmfx --enable-vaapi --enable-opencl --disable-debug --enable-libvorbis --enable-libvpx --enable-libdrm --enable-gpl --cpu=native --enable-libfdk-aac --enable-libx264 --enable-libx265 --extra-libs=-lpthread --enable-nonfree
make -j4
sudo make install
# check output
/usr/local/ffmpeg/bin/ffmpeg -hwaccels 2>/dev/null | grep vaapi
/usr/local/ffmpeg/bin/ffmpeg -encoders 2>/dev/null | grep vaapi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment