Skip to content

Instantly share code, notes, and snippets.

@xdamman
Created July 2, 2014 21:03
Show Gist options
  • Save xdamman/e4f713c8cd1a389a5917 to your computer and use it in GitHub Desktop.
Save xdamman/e4f713c8cd1a389a5917 to your computer and use it in GitHub Desktop.
Install latest ffmpeg on ubuntu 12.04 or 14.04
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
sudo apt-get -y install build-essential checkinstall git libfaac-dev libgpac-dev \
libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev librtmp-dev libtheora-dev \
libvorbis-dev pkg-config texi2html yasm zlib1g-dev
# Install x264
sudo apt-get -y install libx264-dev
cd
git clone --depth 1 git://git.videolan.org/x264
cd x264
./configure --enable-static
make
sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
--fstrans=no --default
# Install AAC audio decoder
cd
wget http://downloads.sourceforge.net/opencore-amr/fdk-aac-0.1.0.tar.gz
tar xzvf fdk-aac-0.1.0.tar.gz
cd fdk-aac-0.1.0
./configure
make
sudo checkinstall --pkgname=fdk-aac --pkgversion="0.1.0" --backup=no \
--deldoc=yes --fstrans=no --default
# Install VP8 video encoder and decoder.
cd
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx
cd libvpx
./configure
make
sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default
# Add lavf support to x264
# This allows x264 to accept just about any input that FFmpeg can handle and is useful if you want to use x264 directly. See a more detailed explanation of what this means.
cd ~/x264
make distclean
./configure --enable-static
make
sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
--fstrans=no --default
# Installing FFmpeg
cd
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb \
--enable-libopencore-amrwb --enable-librtmp --enable-libtheora --enable-libvorbis \
--enable-libvpx --enable-libx264 --enable-nonfree --enable-version3
make
sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default
hash x264 ffmpeg ffplay ffprobe
# Optional: install qt-faststart
# This is a useful tool if you're showing your H.264 in MP4 videos on the web. It relocates some data in the video to allow playback to begin before the file is completely downloaded. Usage: qt-faststart input.mp4 output.mp4.
cd ~/ffmpeg
make tools/qt-faststart
sudo checkinstall --pkgname=qt-faststart --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \
--deldoc=yes --fstrans=no --default install -Dm755 tools/qt-faststart \
/usr/local/bin/qt-faststart
@edantonio505
Copy link

This helped me solve a problem I was having with ffmpeg. I was ripping my face off! Thanks a lot man!

@CGTKamlesh
Copy link

Thanks Bro :)

@FooBarQuaxx
Copy link

Another Thank you.

@arifje
Copy link

arifje commented Nov 24, 2016

on my 14.04 installation it breaks because of "--enable-libfaac"

after removing it, it ran ok.

@azri445
Copy link

azri445 commented Dec 10, 2016

ok.... its been nearly a year... im trying to install ffmpeg on my dedicated server from dreamhost. as they told me that i need to install ffmpeg by myself. while i got no knowledge on installing it.

my dedicated server ubunut 12.04 code name precise.... and my ffmpeg version 0.8

how to achieve a successful ffmpeg installation... been looking long time already.. didnt find the solution. try solution given here... but none is working.

Hope i can get answer from you all.... thanks in advanced

@hohaidang
Copy link

hohaidang commented Mar 17, 2017

It's really really good. Thanks a lot :D I spent 3 days try to install this package to my development board. It helped me a lot

@crclayton
Copy link

Maybe I'm missing something here, but I install ffmpeg with just this:

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ffmpeg

@franciskim
Copy link

@crclayton this script seems to build from source, the repo u point out is an unofficial one as far as I'm aware.

@kevinashaw
Copy link

Outstanding!

@CGTKamlesh
Copy link

command: sudo add-apt-repository ppa:mc3man/trusty-media

"And confirm the following message by pressing :"

"Also note that with apt-get a sudo apt-get dist-upgrade is needed for initial setup & with some package upgrades
More info: https://launchpad.net/~mc3man/+archive/ubuntu/trusty-media
Press [ENTER] to continue or ctrl-c to cancel adding it"

Update the package list.

command: sudo apt-get update
command: sudo apt-get dist-upgrade

"Now FFmpeg is available to be installed with apt:"

command: sudo apt-get install ffmpeg

That's it. Enjoy 👍 :)

@lispc
Copy link

lispc commented May 24, 2017

nasm should be installed before running the script. And nasm cannot be installed by 'apt-get' because a new version is required while nasm in apt-get is too old. I compiled nasm from source.

@slhck
Copy link

slhck commented Jun 19, 2017

Please find an always up-to-date guide here:

http://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

This one also has proper instructions for nasm.

@yongsukjo93
Copy link

Thanks! You are my HERO.

@shirsub
Copy link

shirsub commented Feb 26, 2018

Thanks!

@lhrotk
Copy link

lhrotk commented Feb 7, 2019

Thanks bro. I think it will be even more awesome if you add "libsdl2-dev" to the dependencies, since 'ffplay' will not be compiled without it. I am using 16.04.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment