Build latest ffmpeg and all (generally) needed codecs from source

Jan 9, 2014, 3:53:21 PM

ffmpeg

In projects where you need to work with video data - converting video files or creating frame screenshot preview for a video, convert mp3 etc. it is very likely you will decide to use ffmpeg.
It is open source and free lib that is de-facto standard tool to operate with media files. But in Linux repositories it is often outdated version of ffmpeg and to get most recent features you'd better compile it from source. It is not a trivial things to get all needed dependencies, that's why I have gathered it all in one bash script.

Script to install ffmpeg + h264, AAC, MP3, Theora and other essential codecs in Ubuntu Linux from source codes.

#!/bin/bash

sudo apt-get update
sudo apt-get -y install autoconf automake build-essential git libass-dev libfaac-dev libgpac-dev libmp3lame-dev libopus-dev libtheora-dev libtool libvorbis-dev libvpx-dev pkg-config texi2html yasm zlib1g-dev

# YASM
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
make
make install
cd ..

# x264
git clone --depth 1 git://git.videolan.org/x264.git
cd x264
./configure --prefix="$HOME/ffmpeg_build" --bindir="/usr/bin" --enable-static
make
make install
cd ..

# fdk-aac
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
cd ..

# ffmpeg
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="/usr/bin" --enable-gpl --enable-libass \
  --enable-libfaac --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora \
  --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree
make 
make install
cd ..

just save this scipt to file e.g "ffmpeg_build.sh" and make

sudo chmod a+x ffmpeg_build.sh
sudo ./ffmpeg_build.sh

the most recent version of this script could be found in this Gist

comments powered by Disqus
Ievgen
Kuzminov "iJackUA"
Web Team Lead
at MobiDev (Kharkiv, Ukraine)
Code in Ruby and Elixir, but still love PHP. Explore ES6 and Vue.js. Explore databases, use Ubuntu and MacOS, think about IT people and management

Notes


Skaffold tool that facilitates continuous development for Kubernetes-native applications. Continuously deploys to your local or remote Kubernetes cluster.



DoItLive is a tool for live presentations in the terminal. It reads a file of shell commands and replays the commands in a fake terminal session as you type random characters.