Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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.
#!/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 libass-dev libfreetype6-dev libgpac-dev \
libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \
libxcb-xfixes0-dev pkg-config texi2html zlib1g-dev
}
#install CUDA SDK
InstallCUDASDK(){
echo "Installing CUDA and the latest driver repositories from repositories"
cd ~/ffmpeg_sources
wget -c -v -nc https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.2.88-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1604_9.2.88-1_amd64.deb
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo apt-get -y update
sudo apt-get -y install cuda
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update && sudo apt-get -y upgrade
}
#Install nvidia SDK
installSDK(){
echo "Installing the nVidia NVENC SDK."
cd ~/ffmpeg_sources
cd ~/ffmpeg_sources
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers
make
sudo make install
}
#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 libopus
compileLibOpus(){
echo "Compiling libopus"
cd ~/ffmpeg_sources
wget http://downloads.xiph.org/releases/opus/opus-1.2.1.tar.gz
tar xzvf opus-1.2.1.tar.gz
cd opus-1.2.1
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean
}
#Compile libvpx
compileLibPvx(){
echo "Compiling libvpx"
cd ~/ffmpeg_sources
git clone https://chromium.googlesource.com/webm/libvpx
cd libvpx
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --enable-runtime-cpu-detect --enable-vp9 --enable-vp8 \
--enable-postproc --enable-vp9-postproc --enable-multi-res-encoding --enable-webm-io --enable-better-hw-compatibility --enable-vp9-highbitdepth --enable-onthefly-bitpacking --enable-realtime-only \
--cpu=native --as=nasm
PATH="$HOME/bin:$PATH" make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) clean
}
#Compile ffmpeg
compileFfmpeg(){
echo "Compiling ffmpeg"
cd ~/ffmpeg_sources
git clone https://github.com/FFmpeg/FFmpeg -b master
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-cuda-sdk \
--enable-cuvid \
--enable-libnpp \
--extra-cflags="-I/usr/local/cuda/include/" \
--extra-ldflags=-L/usr/local/cuda/lib64/ \
--enable-gpl \
--enable-libass \
--enable-libfdk-aac \
--enable-vaapi \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-nonfree \
--enable-nvenc
PATH="$HOME/bin:$PATH" make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean
hash -r
}
#The process
cd ~
mkdir ffmpeg_sources
installLibs
InstallCUDASDK
installSDK
compileNasm
compileLibX264
compileLibfdkcc
compileLibMP3Lame
compileLibOpus
compileLibPvx
compileFfmpeg
echo "Complete!"
@RicardoCapurro

This comment has been minimized.

Copy link

RicardoCapurro commented Apr 12, 2017

Note there is a bug while compiling vpx, the tar file and directory name is libvpx-1.6.0.tar.bz2 and libvpx-1.6.0 respectively without a v.

#Compile libvpx
...
wget storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.6.0.tar.bz2
tar xjvf libvpx-v1.6.0.tar.bz2
cd libvpx-v1.6.0
...

@Brainiarc7

This comment has been minimized.

Copy link
Owner Author

Brainiarc7 commented May 25, 2017

Okay, thanks for the correction.

@akuzia

This comment has been minimized.

Copy link

akuzia commented May 31, 2017

For 16.04 change:

sudo apt-get -y --force-yes install

to

sudo apt-get -y --allow install

@aptalca

This comment has been minimized.

Copy link

aptalca commented Jun 1, 2017

Just tried it and it seems libx264 requires nasm 2.13 https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu#nasm

and there are typos in the libvpx file and folder names

@Brainiarc7

This comment has been minimized.

Copy link
Owner Author

Brainiarc7 commented Jul 18, 2017

I'm planning to deprecate this script, as you should be using a newer version of NVENC SDK and NASM to handle the build.

@sven1011

This comment has been minimized.

Copy link

sven1011 commented Aug 26, 2017

that would be sad. I just used the script (step by step I admit) and was successful. I made a few changes:

  • use a prior downloaded Video_Codec_SDK_7.0.1 (the max version that is supported by my driver)
  • I used the usual 'sudo apt-get install' (to keep a list of newly installed stuff and be able to ok by hand)
  • added a section for compiling nasm-2.13.01 (looks very much like everything else)
  • fixed up compileLibPvx to compile libvpx-1.6.1.tar.bz2
    all pretty easy. Thus this script is still a big help to all of us who like to use nvenc. It just needs a bit of tlc.
@Brainiarc7

This comment has been minimized.

Copy link
Owner Author

Brainiarc7 commented Nov 23, 2017

Noted, @sven1011

@Brainiarc7

This comment has been minimized.

Copy link
Owner Author

Brainiarc7 commented Jun 8, 2018

Script updated.

@JezausTevas

This comment has been minimized.

Copy link

JezausTevas commented Jun 27, 2018

Does not work on Ubuntu 14.04, cuda installation failed as of missing (unsupported) packages.

@Brainiarc7

This comment has been minimized.

Copy link
Owner Author

Brainiarc7 commented Jun 29, 2018

Hmm, but why (and how) are you still on Ubuntu 14.04LTS?

Perhaps you could try installing CUDA with the binary installer, straight from NVIDIA?

@padams4

This comment has been minimized.

Copy link

padams4 commented Jul 3, 2018

I'm planning to deprecate this script, as you should be using a newer version of NVENC SDK and NASM to handle the build

Nooooooo! I struggled using the latest ffmpeg and NVIDIA documentation. This script works out of the box once "--enable-nonfree" is moved before -"-enable-cuda-sdk"

Dell with Xeon X5690, 16.04 LTS, GTX-1080.

@Brainiarc7

This comment has been minimized.

Copy link
Owner Author

Brainiarc7 commented Jul 31, 2018

The script should work out of the box (as at the present).

I'll commit resources to keep it up to date.

@pecheuy

This comment has been minimized.

Copy link

pecheuy commented Aug 31, 2018

thanks for this

@Brainiarc7

This comment has been minimized.

Copy link
Owner Author

Brainiarc7 commented Sep 17, 2018

You're welcome, @pecheuy.

Feel free to fork, make improvements, etc.

@kr105

This comment has been minimized.

Copy link

kr105 commented Oct 9, 2018

To make it work with Ubuntu 18.04 I had to modify the repository version on the script (plus file name and version of the .deb package too) and additionally install the nvidia-cuda-toolkit and git packages (This was a brand new machine which didn't have it installed). I had to remove the libopus option from the configure script as it also gave me problems. But at the end I got the compiled ffmpeg I was looking for. Thanks!

@ilyaevseev

This comment has been minimized.

Copy link

ilyaevseev commented Oct 15, 2018

I adopted your script to Ubuntu-18.04 and CentOS 7.
My script is here: https://github.com/ilyaevseev/ffmpeg-build

@Brainiarc7

This comment has been minimized.

Copy link
Owner Author

Brainiarc7 commented Dec 17, 2018

Thank you so much, @ilyaevseev

@nbd712

This comment has been minimized.

Copy link

nbd712 commented Jan 30, 2019

Not sure if this is due to the older version (14.04 LTS) that I'm using, but I had to add "--pkg-config-flags="--static" into the ffmpeg config options. Great script, thanks!

@Brainiarc7

This comment has been minimized.

Copy link
Owner Author

Brainiarc7 commented Feb 14, 2019

Thanks for the note, @nbd712.
I'll test that out and report back.

@eddiecsilva

This comment has been minimized.

Copy link

eddiecsilva commented Jul 26, 2019

Is this script compatible with Disco Dingo 19.04? My first run did not complete the installation, but I had already made many system changes. I will install a clean system and share the results.

Update 01:
Did a complete clean install and changed the release of Ubuntu to 18.10, but still not work. :-)

Update 02:
Here's a link to the output of the script: http://pasted.co/7d04d777
Machine: Ryzen 5 2600x, motherboard Asus Prime B450M, 8GB DDR4 3000Mhz, SSD sandisk 240GB, Ubuntu 19.04 full updated

@Brainiarc7

This comment has been minimized.

Copy link
Owner Author

Brainiarc7 commented Jul 26, 2019

@lucaszanella

This comment has been minimized.

Copy link

lucaszanella commented Jul 28, 2019

I'm gonna dockerize this soon :)

@Brainiarc7

This comment has been minimized.

Copy link
Owner Author

Brainiarc7 commented Jul 28, 2019

@deisi

This comment has been minimized.

Copy link

deisi commented Sep 2, 2019

on a quite fresh ubu 19.04 it ended with this:

rm -f y4minput.c.o vpx/src/vpx_image.c.o vpx_mem/vpx_mem.c.o tools/tiny_ssim.c.o y4minput.c.d vpx/src/vpx_image.c.d vpx_mem/vpx_mem.c.d tools/tiny_ssim.c.d y4minput.c.o vpx/src/vpx_image.c.o vpx_mem/vpx_mem.c.o tools/tiny_ssim.c.o
rm -f tools.doxy tools.dox tools/tiny_ssim.dox
rm -f .docs .install-docs 
rm -f .bins .install-bins tools/tiny_ssim
rm -f .libs .install-libs 
rm -f .install-srcs
rm -f   
rm -f doxyfile 
rm -f .docs .install-docs 
rm -f .bins .install-bins 
rm -f .libs .install-libs 
rm -f .install-srcs
rm -f   
rm -f 
rm -f .docs .install-docs 
rm -f .bins .install-bins 
rm -f .libs .install-libs 
rm -f .install-srcs
Compiling ffmpeg
fatal: destination path 'FFmpeg' already exists and is not an empty directory.
ERROR: failed checking for nvcc.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target '/tests/Makefile'.  Stop.
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target '/tests/Makefile'.  Stop.
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target '/tests/Makefile'.  Stop.
Complete!

@bootrino

This comment has been minimized.

Copy link

bootrino commented Sep 11, 2019

On Ubuntu 18.04 I get:

remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 572802 (delta 5), reused 8 (delta 3), pack-reused 572781
Receiving objects: 100% (572802/572802), 224.59 MiB | 32.71 MiB/s, done.
Resolving deltas: 100% (447059/447059), done.
ERROR: failed checking for nvcc.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.

@RileyMShea

This comment has been minimized.

Copy link

RileyMShea commented Sep 15, 2019

I was getting opus errors on 19.04. I needed to add the --pkg-config-flags="--static". I also changed the ffmpeg source to the official release which may have done something.

#Compile ffmpeg
compileFfmpeg(){
cd ~/ffmpeg_sources &&
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 &&
tar xjvf ffmpeg-snapshot.tar.bz2 &&
cd ffmpeg &&
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure
--prefix="$HOME/ffmpeg_build"
--pkg-config-flags="--static"
--extra-cflags="-I$HOME/ffmpeg_build/include"
--extra-ldflags="-L$HOME/ffmpeg_build/lib"
--bindir="$HOME/bin"
--enable-cuda-sdk
--enable-cuvid
--enable-libnpp
--extra-cflags="-I/usr/local/cuda/include/"
--extra-ldflags=-L/usr/local/cuda/lib64/
--enable-gpl
--enable-libass
--enable-libfdk-aac
--enable-vaapi
--enable-libfreetype
--enable-libmp3lame
--enable-libopus
--enable-libtheora
--enable-libvorbis
--enable-libvpx
--enable-libx264
--enable-nonfree
--enable-nvenc
PATH="$HOME/bin:$PATH" make -j$(nproc)
make -j$(nproc) install
make -j$(nproc) distclean
hash -r
}

@Hulkaveli

This comment has been minimized.

Copy link

Hulkaveli commented Oct 8, 2019

You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 cuda-drivers : Depends: nvidia-418 (>= 418.87.01) but it is not installed
 libcuda1-418 : Depends: nvidia-418 (>= 418.87.01) but it is not installed
 nvidia-418-dev : Depends: nvidia-418 (>= 418.87.01) but it is not installed
 nvidia-opencl-icd-418 : Depends: nvidia-418 (>= 418.87.01) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

the --fix-broken install doesnt work & i cant figure out how to just undo everything this script did.

please help. spent 3 days setting ubuntu server up with everything configured and the only thing left was to get handbrake-cli or ffpmeg nvenc encoding going.

@bobsingh1

This comment has been minimized.

Copy link

bobsingh1 commented Oct 30, 2019

My build goes through fine on Ubuntu 16.04 but when I take the binary and try to run it on a newly installed Ubuntu 16.04 server I get the following error
ffmpeg: error while loading shared libraries: libxcb-shm.so.0: cannot open shared object file: No such file or directory

It runs fine on the server where compiled and see this output
ffmpeg version git-2019-10-30-881f083 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9 (Ubuntu 9.2.1-9ubuntu2~16.04.1)
configuration: --pkg-config-flags=--static --prefix=/home/bob/ffmpeg-build-static-binaries --bindir=/home/bob/ffmpeg-build-static-binaries/bin --extra-cflags='-I /home/bob/ffmpeg-build-static-binaries/include -I /usr/local/cuda/include/' --extra-ldflags='-L /home/bob/ffmpeg-build-static-binaries/lib -L /usr/local/cuda/lib64/' --extra-libs=-lpthread --enable-cuda --disable-cuda-sdk --enable-cuvid --enable-libnpp --enable-gpl --enable-libass --enable-libfdk-aac --enable-vaapi --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libaom --enable-nvenc

@DwarfFighterCleric

This comment has been minimized.

Copy link

DwarfFighterCleric commented Nov 11, 2019

What a pain in the lower rear all of this stuff is, my god... What is the point of compiling an executable that will not run on another system other than the one you compiled it on? (I'm having the same issues stated above...) Wouldn't we be better compiling Windows EXE's to run in Wine then? Wouldn't that be more portable and cross-platform than any of this? Or maybe AppImages are the way to go? FFmpeg is such a cool project to be doomed by this :(

@DwarfFighterCleric

This comment has been minimized.

Copy link

DwarfFighterCleric commented Nov 11, 2019

Tried to use RileyMShea's updated script on stock Xubuntu 16.04.3 ("stock" meaning I never run sudo apt-get upgrade or dist upgrade, only sudo apt-get update)
Doesn't work, up until the last steps, which are for building the ffmpeg executable itself.
Here are the last output lines of the terminal, can you perhaps guess where it is failing? (I don't have experience with compiling)

`ffmpeg/presets/libvpx-720p.ffpreset
ffmpeg/presets/libvpx-720p50_60.ffpreset
ffmpeg/presets/libvpx-360p.ffpreset
ffmpeg/VERSION
ffmpeg/libpostproc/
ffmpeg/libpostproc/Makefile
ffmpeg/libpostproc/libpostproc.v
ffmpeg/libpostproc/postprocess_altivec_template.c
ffmpeg/libpostproc/postprocess_internal.h
ffmpeg/libpostproc/postprocess.c
ffmpeg/libpostproc/postprocess_template.c
ffmpeg/libpostproc/postprocess.h
ffmpeg/libpostproc/postprocres.rc
ffmpeg/libpostproc/version.h
ERROR: failed checking for nvcc.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:94: /libavutil/Makefile: No such file or directory
Makefile:94: /ffbuild/library.mak: No such file or directory
Makefile:96: /fftools/Makefile: No such file or directory
Makefile:97: /doc/Makefile: No such file or directory
Makefile:98: /doc/examples/Makefile: No such file or directory
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target '/tests/Makefile'. Stop.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:94: /libavutil/Makefile: No such file or directory
Makefile:94: /ffbuild/library.mak: No such file or directory
Makefile:96: /fftools/Makefile: No such file or directory
Makefile:97: /doc/Makefile: No such file or directory
Makefile:98: /doc/examples/Makefile: No such file or directory
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target '/tests/Makefile'. Stop.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:94: /libavutil/Makefile: No such file or directory
Makefile:94: /ffbuild/library.mak: No such file or directory
Makefile:96: /fftools/Makefile: No such file or directory
Makefile:97: /doc/Makefile: No such file or directory
Makefile:98: /doc/examples/Makefile: No such file or directory
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target '/tests/Makefile'. Stop.
Complete!
$

$ sudo find /bin /lib /lib64 /usr /etc /var /opt /sbin /snap /srv /tmp -name "ffmpeg"
/usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.so.56
/usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.so.56.60.100
/usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5
/usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5.40.101
/usr/lib/x86_64-linux-gnu/libavformat-ffmpeg.so.56
/usr/lib/x86_64-linux-gnu/libavformat-ffmpeg.so.56.40.101
/usr/lib/x86_64-linux-gnu/libavresample-ffmpeg.so.2
/usr/lib/x86_64-linux-gnu/libavresample-ffmpeg.so.2.1.0
/usr/lib/x86_64-linux-gnu/libavutil-ffmpeg.so.54
/usr/lib/x86_64-linux-gnu/libavutil-ffmpeg.so.54.31.100
/usr/lib/x86_64-linux-gnu/libpostproc-ffmpeg.so.53
/usr/lib/x86_64-linux-gnu/libpostproc-ffmpeg.so.53.3.100
/usr/lib/x86_64-linux-gnu/libswresample-ffmpeg.so.1
/usr/lib/x86_64-linux-gnu/libswresample-ffmpeg.so.1.2.101
/usr/lib/x86_64-linux-gnu/libswscale-ffmpeg.so.3
/usr/lib/x86_64-linux-gnu/libswscale-ffmpeg.so.3.1.101
/usr/share/lintian/overrides/libavcodec-ffmpeg56
/usr/share/lintian/overrides/libavfilter-ffmpeg5
/usr/share/lintian/overrides/libavformat-ffmpeg56
/usr/share/lintian/overrides/libavresample-ffmpeg2
/usr/share/lintian/overrides/libavutil-ffmpeg54
/usr/share/lintian/overrides/libpostproc-ffmpeg53
/usr/share/lintian/overrides/libswresample-ffmpeg1
/usr/share/lintian/overrides/libswscale-ffmpeg3
/usr/share/doc/libavcodec-ffmpeg56
/usr/share/doc/libavfilter-ffmpeg5
/usr/share/doc/libavformat-ffmpeg56
/usr/share/doc/libavresample-ffmpeg2
/usr/share/doc/libavutil-ffmpeg54
/usr/share/doc/libpostproc-ffmpeg53
/usr/share/doc/libswresample-ffmpeg1
/usr/share/doc/libswscale-ffmpeg3
/var/lib/dpkg/info/libavcodec-ffmpeg56:amd64.list
/var/lib/dpkg/info/libavcodec-ffmpeg56:amd64.md5sums
/var/lib/dpkg/info/libavcodec-ffmpeg56:amd64.shlibs
/var/lib/dpkg/info/libavcodec-ffmpeg56:amd64.symbols
/var/lib/dpkg/info/libavcodec-ffmpeg56:amd64.triggers
/var/lib/dpkg/info/libavfilter-ffmpeg5:amd64.list
/var/lib/dpkg/info/libavfilter-ffmpeg5:amd64.md5sums
/var/lib/dpkg/info/libavfilter-ffmpeg5:amd64.shlibs
/var/lib/dpkg/info/libavfilter-ffmpeg5:amd64.symbols
/var/lib/dpkg/info/libavfilter-ffmpeg5:amd64.triggers
/var/lib/dpkg/info/libavformat-ffmpeg56:amd64.list
/var/lib/dpkg/info/libavformat-ffmpeg56:amd64.md5sums
/var/lib/dpkg/info/libavformat-ffmpeg56:amd64.shlibs
/var/lib/dpkg/info/libavformat-ffmpeg56:amd64.symbols
/var/lib/dpkg/info/libavformat-ffmpeg56:amd64.triggers
/var/lib/dpkg/info/libavresample-ffmpeg2:amd64.list
/var/lib/dpkg/info/libavresample-ffmpeg2:amd64.md5sums
/var/lib/dpkg/info/libavresample-ffmpeg2:amd64.shlibs
/var/lib/dpkg/info/libavresample-ffmpeg2:amd64.symbols
/var/lib/dpkg/info/libavresample-ffmpeg2:amd64.triggers
/var/lib/dpkg/info/libavutil-ffmpeg54:amd64.list
/var/lib/dpkg/info/libavutil-ffmpeg54:amd64.md5sums
/var/lib/dpkg/info/libavutil-ffmpeg54:amd64.shlibs
/var/lib/dpkg/info/libavutil-ffmpeg54:amd64.symbols
/var/lib/dpkg/info/libavutil-ffmpeg54:amd64.triggers
/var/lib/dpkg/info/libpostproc-ffmpeg53:amd64.list
/var/lib/dpkg/info/libpostproc-ffmpeg53:amd64.md5sums
/var/lib/dpkg/info/libpostproc-ffmpeg53:amd64.shlibs
/var/lib/dpkg/info/libpostproc-ffmpeg53:amd64.symbols
/var/lib/dpkg/info/libpostproc-ffmpeg53:amd64.triggers
/var/lib/dpkg/info/libswresample-ffmpeg1:amd64.list
/var/lib/dpkg/info/libswresample-ffmpeg1:amd64.md5sums
/var/lib/dpkg/info/libswresample-ffmpeg1:amd64.shlibs
/var/lib/dpkg/info/libswresample-ffmpeg1:amd64.symbols
/var/lib/dpkg/info/libswresample-ffmpeg1:amd64.triggers
/var/lib/dpkg/info/libswscale-ffmpeg3:amd64.list
/var/lib/dpkg/info/libswscale-ffmpeg3:amd64.md5sums
/var/lib/dpkg/info/libswscale-ffmpeg3:amd64.shlibs
/var/lib/dpkg/info/libswscale-ffmpeg3:amd64.symbols
/var/lib/dpkg/info/libswscale-ffmpeg3:amd64.triggers
$

@ransagy

This comment has been minimized.

Copy link

ransagy commented Jan 19, 2020

Oddly enough, while it works (in compiling a binary with the needed parts. do you need a machine with an nvidia gpu even to build?), It doesn't compile staticly linked. ldd ~/bin/ffmpeg gives a long list of libraries being dynamically linked when inspecting this binary.

@lucaszanella

This comment has been minimized.

Copy link

lucaszanella commented Jan 19, 2020

Hey @ransagy, I've had the same problem and couldn't find a solution. I want to support computers with different drivers, like NVIDIA, Intel... If I compile ffmpeg for both of these at the same time, then I must install NVIDIA and Intel drivers on the machine, otherwise an NVIDIA machine will complain that Intel libs for ffmpeg are missing, and for Intel, NVIDIA ones are missing.

I found no way of solving this, it seems that it's impossible to compile a totally static library? I've seen another project that compiles ffmpeg and it compiles a separate ffmpeg for each computer (one for NVIDIA, one for Intel, etc). This suggest that it's indeed possible to statically link everything.

But if you find a way, please tell me! It'd be a pain to release a version of my app to each platform.

However, a question remains: does ffmpeg binary in Ubuntu support hardware decoding/encoding? If so, how? Which dependencies it uses?

@ransagy

This comment has been minimized.

Copy link

ransagy commented Jan 26, 2020

@lucasszanella I made a fork of a fork of this gist that worked for me - https://gist.github.com/ransagy/3f6f1a9e5ede6212425f3b36b136216e
Specifically see the linked ffmpeg issue in the opening comment in the script.

However, the caveat here is that i only needed nVidia so this doesn't solve your issue explicitly. This also leaves the C runtime/lib dynamically linked to avoid a host of issues; which means you need to compile against the lowest common glibc version of your set of machines and hope that both works AND doesn't hurt performance too much. Not perfect, But it's something.

@theonlycure

This comment has been minimized.

Copy link

theonlycure commented Feb 1, 2020

ransagy yours didn't work at all

solve the problem.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:97: /libavutil/Makefile: No such file or directory
Makefile:97: /ffbuild/library.mak: No such file or directory
Makefile:99: /fftools/Makefile: No such file or directory
Makefile💯 /doc/Makefile: No such file or directory
Makefile:101: /doc/examples/Makefile: No such file or directory
Makefile:166: /tests/Makefile: No such file or directory
make: *** No rule to make target '/tests/Makefile'. Stop.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:97: /libavutil/Makefile: No such file or directory
Makefile:97: /ffbuild/library.mak: No such file or directory
Makefile:99: /fftools/Makefile: No such file or directory
Makefile💯 /doc/Makefile: No such file or directory
Makefile:101: /doc/examples/Makefile: No such file or directory
Makefile:166: /tests/Makefile: No such file or directory
make: *** No rule to make target '/tests/Makefile'. Stop.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:97: /libavutil/Makefile: No such file or directory
Makefile:97: /ffbuild/library.mak: No such file or directory
Makefile:99: /fftools/Makefile: No such file or directory
Makefile💯 /doc/Makefile: No such file or directory
Makefile:101: /doc/examples/Makefile: No such file or directory
Makefile:166: /tests/Makefile: No such file or directory
make: *** No rule to make target '/tests/Makefile'. Stop.

@theonlycure

This comment has been minimized.

Copy link

theonlycure commented Feb 1, 2020

Neither one works for me. Ubuntu 18.04. Same errors "no such files or directory"

@theonlycure

This comment has been minimized.

Copy link

theonlycure commented Feb 1, 2020

of other note the snap version of ffmpeg worked great up until non snap ffmpeg was installed by another package and could never figure out how to get path right to use the snap version it without failing.
update: dang all I had to do to run the snap version after another ffmpeg was installed /snap/bin/ffmpeg Back to HW encoding

@ransagy

This comment has been minimized.

Copy link

ransagy commented Feb 1, 2020

As the note says, you have to edit the configure script in the ffmpeg sources dir. I tried it on a clean Ubuntu VM in Azure and had no issues.
I imagine the snap version wouldn't have nvidia support, though.

@theonlycure

This comment has been minimized.

Copy link

theonlycure commented Feb 8, 2020

@ransagy

This comment has been minimized.

Copy link

ransagy commented Feb 8, 2020

Huh, That's good to know. Weird, considering that non-free shouldn't be legally allowed redistribution but..
Thanks :)

@ajgentile

This comment has been minimized.

Copy link

ajgentile commented Mar 9, 2020

I adopted your script to Ubuntu-18.04 and CentOS 7.
My script is here: https://github.com/ilyaevseev/ffmpeg-build

Awesome.

@Brainiarc7

This comment has been minimized.

Copy link
Owner Author

Brainiarc7 commented Mar 9, 2020

@mercster

This comment has been minimized.

Copy link

mercster commented Mar 27, 2020

Hey, thanks for this... if not already brought up, the script calls 'git', which the script does not install with apt-get. Might wanna add that.

Also getting "ERROR: failed checking for nvcc." and script fails, but I'll see if I can't figure it out...

@theonlycure

This comment has been minimized.

Copy link

theonlycure commented Apr 16, 2020

@sotiris-bos

This comment has been minimized.

Copy link

sotiris-bos commented May 15, 2020

You have to change the videolan x264 source to use git. The wget link just gives a 404 error, resulting in ffmpeg being compiled without x264.

@DwarfFighterCleric

This comment has been minimized.

Copy link

DwarfFighterCleric commented May 29, 2020

I'm still being restricted to use a FFmpeg binary that uses outdated Libavcodec and Libavformat from back in Feb-2017 because these are what the Xenial 16.04 repositories have to install. This means that I'm potentially relying on outdated aac codec (less audio quality) and outdated x264 (possibly less performance or compression rate when encoding video)
It seems like this difficulty to build from source happens across the board.
Do you guys know a place where updated Linux builds are made available? I could only find one Windows EXE build and it was from 2018, it came with HE-AAC included with it. (and even harder: any place to find Xenial 16.04 builds?)
It seems like some people from the Linux community really have a source of satisfaction from gatekeeping these things so other people can't benefit from it.
Even an Appimage release once a year would provide solution for this.
Is there a way to manually update the binary and the libs? Will that work if I simply copy the files manually? How can I manually update the AAC and the x264 codecs?

@mercster

This comment has been minimized.

Copy link

mercster commented May 29, 2020

Debian is usually quite out of date... I can only suggest you install a more up-to-date distro (Ubuntu? Fedora?) ; I don't know the answer for Debian.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.