Last active
June 14, 2021 23:15
-
-
Save EitanGoldfrad/88d5d2374cca000b4007d5520faf662c to your computer and use it in GitHub Desktop.
This bash script will compile a static Ffmpeg build with NVENC and VAAPI hardware-accelerated support on Ubuntu in your home directory. You can modify the script to customize the build options as you see fit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#This script will compile and install a static ffmpeg build with support for nvenc un ubuntu. | |
#See the prefix path and compile options if edits are needed to suit your needs. | |
#install required things from apt | |
installLibs(){ | |
echo "Installing prerequisites" | |
sudo apt-get update | |
sudo apt-get -y --force-yes install autoconf automake build-essential libfreetype6-dev libgpac-dev \ | |
libtool libva-dev pkg-config texi2html zlib1g-dev | |
} | |
#Compile nasm | |
compileNasm(){ | |
echo "Compiling nasm" | |
cd ~/ffmpeg_sources | |
wget http://www.nasm.us/pub/nasm/releasebuilds/2.14rc0/nasm-2.14rc0.tar.gz | |
tar xzvf nasm-2.14rc0.tar.gz | |
cd nasm-2.14rc0 | |
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" | |
make -j$(nproc) | |
make -j$(nproc) install | |
make -j$(nproc) distclean | |
} | |
#Compile libx264 | |
compileLibX264(){ | |
echo "Compiling libx264" | |
cd ~/ffmpeg_sources | |
wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2 | |
tar xjvf last_x264.tar.bz2 | |
cd x264-snapshot* | |
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static | |
PATH="$HOME/bin:$PATH" make -j$(nproc) | |
make -j$(nproc) install | |
make -j$(nproc) distclean | |
} | |
#Compile libfdk-acc | |
compileLibfdkcc(){ | |
echo "Compiling libfdk-cc" | |
sudo apt-get install unzip | |
cd ~/ffmpeg_sources | |
wget -O fdk-aac.zip https://github.com/mstorsjo/fdk-aac/zipball/master | |
unzip fdk-aac.zip | |
cd mstorsjo-fdk-aac* | |
autoreconf -fiv | |
./configure --prefix="$HOME/ffmpeg_build" --disable-shared | |
make -j$(nproc) | |
make -j$(nproc) install | |
make -j$(nproc) distclean | |
} | |
#Compile libmp3lame | |
compileLibMP3Lame(){ | |
echo "Compiling libmp3lame" | |
sudo apt-get install nasm | |
cd ~/ffmpeg_sources | |
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz | |
tar xzvf lame-3.99.5.tar.gz | |
cd lame-3.99.5 | |
./configure --prefix="$HOME/ffmpeg_build" --enable-nasm --disable-shared | |
make -j$(nproc) | |
make -j$(nproc) install | |
make -j$(nproc) distclean | |
} | |
#Compile ffmpeg | |
compileFfmpeg(){ | |
echo "Compiling ffmpeg" | |
cd ~/ffmpeg_sources | |
git clone --depth 1 --branch n4.3.2 https://github.com/FFmpeg/FFmpeg | |
cd FFmpeg | |
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \ | |
--prefix="$HOME/ffmpeg_build" \ | |
--extra-cflags="-I$HOME/ffmpeg_build/include" \ | |
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \ | |
--bindir="$HOME/bin" \ | |
--enable-gpl \ | |
--enable-libfdk-aac \ | |
--enable-libfreetype \ | |
--enable-libmp3lame \ | |
--enable-libvpx \ | |
--enable-libx264 \ | |
--enable-nonfree | |
PATH="$HOME/bin:$PATH" make -j$(nproc) | |
make -j$(nproc) install | |
make -j$(nproc) distclean | |
hash -r | |
} | |
#The process | |
cd ~ | |
mkdir ffmpeg_sources | |
installLibs | |
compileNasm | |
compileLibX264 | |
compileLibfdkcc | |
compileLibMP3Lame | |
compileFfmpeg | |
echo "Complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment