Linux HOWTOs

About | Home | Search


HOWTO: ffmpeg
Description: Record, covert, play and stream audio and video
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


# FFmpeg 4.1
# ==========
# Prerequisites:
# SDL (optional)
# OpenCL (optional)
# texi2html
# Perl
# texinfo's makeinfo
# bzip's bzlib
# iconv
# zlib

# Mailing lists

# Get it
cd
test -f installed/ffmpeg-4.1.tar.xz && mv -f installed/ffmpeg-4.1.tar.xz .
test ! -f ffmpeg-4.1.tar.xz &&
 wget http://ffmpeg.org/releases/ffmpeg-4.1.tar.xz

# Verify tarball w/ sha256sum:
# (this came from my gpg-verified tarball)
echo "a38ec4d026efb58506a99ad5cd23d5a9793b4bf415f2c4c2e9c1bb444acd19\
94  ffmpeg-4.1.tar.xz" | sha256sum -c

# Verify tarball w/ GnuPG:
( gpg --list-keys D67658D8 > /dev/null 2>&1 || gpg --recv-keys D67658D8 ) &&
 wget -nc http://ffmpeg.org/releases/ffmpeg-4.1.tar.xz.asc &&
  gpg --verify ffmpeg-4.1.tar.xz.asc && rm ffmpeg-4.1.tar.xz.asc

# Extract it
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "ffmpeg-*" -exec rm -r {} \;
tar xJvf ~/ffmpeg-4.1.tar.xz
cd ffmpeg-4.1
test $UID = 0 && chown -R root:root .

# Read README.md and INSTALL.md, and if upgrading, ChangeLog

# Docs are available in ./doc/ and at http://ffmpeg.org/documentation.html

# Configure the build
LDIR=/usr/local/lib
test $(uname -m) = "x86_64" && LDIR="${LDIR}64"
./configure --enable-gpl --enable-nonfree --enable-shared \
--docdir=/usr/local/doc/ffmpeg --libdir=${LDIR} \
--mandir=/usr/local/man --shlibdir=${LDIR}
unset LDIR

# Build it
make

# Become root to install it
su

# Remove old version shared library files and .so.* symlinks - if you're
# _positive_ that nothing else is still using them
LIBSTOCLEAN="avcodec avdevice avfilter avformat avutil postproc \
swresample swscale"
for ldir in /usr/local/lib /usr/local/lib64; do
  for libtoclean in $LIBSTOCLEAN; do
    find $ldir -type f -name "lib${libtoclean}.so.*" -exec rm {} \;
    find $ldir -type l -name "lib${libtoclean}.so.*" -exec rm {} \;
  done
done
unset LIBSTOCLEAN

# Install it
make install
ldconfig

# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .

# Become your non-root user again
exit

# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/ffmpeg-*.tar.*
mv ffmpeg-4.1.tar.xz installed/


# If you ever want to uninstall FFmpeg, this should do it:
cd
su
test -d src/ffmpeg-* && ( cd src/ffmpeg-* ; make uninstall )
( /usr/local/bin ; rm -f ffmpeg ffprobe ffserver )
test -d /usr/local/doc/ffmpeg && rm -r /usr/local/doc/ffmpeg
test -d /usr/local/include/libavcodec && rm -r /usr/local/include/libavcodec
test -d /usr/local/include/libavdevice &&
 rm -r /usr/local/include/libavdevice
test -d /usr/local/include/libavfilter &&
 rm -r /usr/local/include/libavfilter
test -d /usr/local/include/libavformat &&
 rm -r /usr/local/include/libavformat
test -d /usr/local/include/libavutil && rm -r /usr/local/include/libavutil
test -d /usr/local/include/libpostproc &&
 rm -r /usr/local/include/libpostproc
test -d /usr/local/include/libswresample &&
 rm -r /usr/local/include/libswresample
test -d /usr/local/include/libswscale && rm -r /usr/local/include/libswscale
( cd /usr/local/lib
  rm -f libavcodec.* libavdevice.* libavfilter.* libavformat.*\
   libavutil.* libpostproc.* libswresample.* libswscale.* )
( cd /usr/local/lib/pkgconfig
  libavcodec.pc libavdevice.pc libavfilter.pc libavformat.pc\
   libavutil.pc libpostproc.pc libswresample.pc libswscale.pc )
( cd /usr/local/lib64
  rm -f libavcodec.* libavdevice.* libavfilter.* libavformat.*\
   libavutil.* libpostproc.* libswresample.* libswscale.* )
( cd /usr/local/lib64/pkgconfig
  libavcodec.pc libavdevice.pc libavfilter.pc libavformat.pc\
   libavutil.pc libpostproc.pc libswresample.pc libswscale.pc )
( cd /usr/local/man/man1
  rm -f ffmpeg.1 ffmpeg-*.1 ffprobe.1 ffprobe-*.1 ffserver.1\
   ffserver-*.1 )
( cd /usr/local/man/man3
  rm -f libavcodec.3 libavdevice.3 libavfilter.3 libavformat.3\
   libavutil.3 libswresample.3 libswscale.3 )
test -d /usr/local/share/doc/ffmpeg && rm -r /usr/local/share/doc/ffmpeg
test -d /usr/local/share/ffmpeg && rm -r /usr/local/share/ffmpeg
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "ffmpeg-*" -exec rm -r {} \;
rm -f ~/installed/ffmpeg-*.tar.*

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>