Linux HOWTOs

About | Home | Search

HOWTO: x264
Description: Library for encoding H264/AVC video streams
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything

# x264
# ====
# Your choices for downloading it are a daily tarball snapshot or git.
# Daily snapshot tarballs won't work too well for an infrequently
# changing howto like this, so I'll only cover Subversion here.

# Prerequisites:
# git
# GPAC (optional; for mp4 output)
# nasm

mkdir -p -m 0700 ~/src
cd ~/src
test -d ./x264 && rm -r ./x264
test ! -d ./x264 &&
 git clone git://
cd x264
test $UID = 0 && chown -R root:root .
test -f config.mak && make distclean

# FYI, the configure script used here is not an autoconf one
# If you want mp4 output with GPAC, pass --enable-mp4-output to configure
# If you don't have GTK+ installed or just don't want the GTK+ interface,
#  leave off --enable-gtk
# If you don't want visualization, leave off --enable-visualize

## If you do pass --enable-mp4-output, you'll need to change this line
## in the configure script from this:
# MP4_LDFLAGS="-lgpac_static"
## to this:
# MP4_LDFLAGS="-lgpac"
## ...if you have a recent gpac that doesn't have a libgpac_static

# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
./configure --libdir=/usr/local/lib64 --enable-shared \
 --enable-mp4-output --enable-gtk --enable-visualize

# Configure the build for anything else
test $(uname -m) != 'x86_64' &&
./configure --enable-shared \
 --enable-mp4-output --enable-gtk --enable-visualize \

# Build it

# Become root to install it

# Remove old shared libraries
test -d /usr/local/lib &&
 ( cd /usr/local/lib* ; rm -f libx264.* libx264gtk.* )
test -d /usr/local/lib64 &&
 ( cd /usr/local/lib64 ; rm -f libx264.* libx264gtk.* )

# Install it
make install

# I'm in the US and only read/write English (well), so I don't need
# this/these:
find /usr/local/share/locale -type f -name -exec rm {} \;

# Become yourself again

mkdir -p -m 0700 installed
rm -f installed/x264-snapshot-*.tar.*
echo 'x264 was installed from Git in ~/src/x264' \
 > installed/x264.README
chmod 600 installed/x264.README

# If you ever want to uninstall x264, this should do it:
test -d src/x264-* && ( cd src/x264-* ; make uninstall )
( cd /usr/local/bin ; rm -f x264 x264_gtk_encode )
( cd /usr/local/include ; rm -f x264.h x264_gtk.h x264_gtk_enum.h )
test -d /usr/local/lib &&
 ( cd /usr/local/lib
   rm -f libx264.* libx264gtk.*
   test -d pkgconfig && rm pkgconfig/x264*.pc )
test -d /usr/local/lib64 &&
 ( cd /usr/local/lib64
   rm -f libx264.* libx264gtk.*
   test -d pkgconfig && rm pkgconfig/x264*.pc )
test -d /usr/local/share/x264 && rm -r /usr/local/share/x264
find /usr/local/share/locale -type f -name -exec rm {} \;
find ~/src -maxdepth 1 -type d -name "x264-*" -exec rm -r {} \;
rm -f ~/installed/x264-*.tar.*

Back to the list

Last updated: Wed, 29 Apr 2020 22:04:50 -0400
Jason Englander <jason at englanders dot us>