Transcoder setup

VideoPress transcoder stack

The VideoPress software stack standardizes contributed videos for playback across a wide variety of web browsers, plugins and consumer electronics devices. This document will help you install a fresh copy of FFmpeg and other associated libraries on your system of choice.

This document focuses on Debian and its package management system. We assume a basic knowledge of aptitude and the advanced packaging tool (APT) for systems management, subversion and git source code repositories, and build tools such as autoconf, automake, and scons.

Update your system libraries

You should make sure your package management system and its base libraries are up-to-date before getting started. Run update and upgrade to create a stable base platform with up-to-date package references.

  1. apt-get update
  2. apt-get upgrade

Install build basics

Install system packages needed to compile, build, and install source code.

apt-get install yasm build-essential autoconf scons libtool zlib1g-dev libbz2-dev libcurl4-openssl-dev libxml2-dev

Package Description
yasm Modular assembler
build-essential List of essential build tools.
autoconf Configure script builder
scons Code compiler
libtool Build static libraries
zlib1g-dev gzip compression
libbz2-dev File compression library
libcurl4-openssl-dev cURL transfer support with OpenSSL support
libxml2-dev GNOME XML support

Version control systems

Install package management system clients to download the latest version of source repositories.

apt-get install subversion git-core

Package Description
subversion Subversion client
git-core Git client

Software libraries

VideoPress relies on open-source demuxers, video decoders and encoders, audio decoders and encoders, and muxers to properly pull apart and put back together again each new video file. Order matters, as some libraries depend on a previous compile to assemble supporting pieces. Add an --enable-shared compile flag for shared library support.

First install the FFmpeg video postprocessing library to establish the correct processing hooks on compile.

apt-get install libpostproc-dev

You can install all packages supported by the main repository at once before working your way through individual source compilations.

apt-get install libpostproc-dev libgsm1 libgsm1-dev libspeex1 libspeex-dev libopencore-amrnb0 libopencore-amrwb0 libfreetype6 libfreetype6-dev libjpeg62 libpng12-0 libpng12-dev liba52-0.7.4 liba52-0.7.4-dev libopenjpeg2 libopenjpeg-dev libmad0 libmad0-dev

Library Description Source Revision (stable) Configuration
freetype Subtitle overlay support libfreetype6 libfreetype6-dev
libjpeg JPEG handling libjpeg62 libjpeg62-dev
libopenjpeg Motion JPEG 2000 libopenjpeg2 libopenjpeg-dev
libpng MotionPNG libpng12-0 libpng12-dev
libkate Subtitles in Ogg git://git.xiph.org/users/oggk/kate.git 0.3.7
libogg Ogg container format http://svn.xiph.org/trunk/ogg 16745 (1.1.4)
libvorbis Vorbis audio http://svn.xiph.org/trunk/vorbis 16745 (1.2.3)
theora Theora video http://svn.xiph.org/trunk/theora 16745 (1.1.1)
libgsm GSM speech compressor libgsm1 libgsm1-dev
liba52 AC-3 audio liba52-0.7.4 liba52-0.7.4-dev
libmad MPEG audio decoder libmad0 libmad0-dev
libmp3lame MP3 audio lame.cvs.sourceforge.net:/cvsroot/lame (3.98.3)
libfaad MPEG-4 and AAC audio decoder http://www.audiocoding.com/downloads.html 2.7
mp4v2 MP4 file format manipulator http://mp4v2.googlecode.com/svn/trunk/ 368 (1.9.1) --disable-debug
libfaac MPEG-4 and AAC audio encoder http://www.audiocoding.com/downloads.html (1.2.8) --with-mp4v2
libspeex Speex audio libspeex1 libspeex-dev
libopencore-amrnb 3GPP AMR speech NB libopencore-amrnb0 libopencore-amrnb-dev (git) 627 (2.07)
libopencore-amrwb 3GPP AMR speech WB libopencore-amrwb0 libopencore-amrwb-dev (git) 627 (2.07)
xvidcore MPEG-4 Visual cvs.xvid.org:/xvid co xvidcore (http) 1.2.2
x264 H.264 video git://git.videolan.org/x264.git 1368

Typically the configure, compile and install process follows standard GNU commands.

  1. ./configure
  2. make
  3. sudo make install

Installing FFmpeg

FFmpeg and its component libraries, libavcodec and libavformat, are the main workhorses of the transcode process. FFmpeg connects to the additional format libraries you have installed above to improve its demuxer, decode, encode, and muxer functionalities.

Checkout a fresh copy of FFmpeg from the project’s source repository.

svn co svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg

The most recent stable release at time of writing is 0.5 from March 2009. FFmpeg trunk is fast moving, with more recent releases supporting the new FFmpeg API and x264 API. We therefore recommend trunk. VideoPress EC2 AMI uses r20787 as of December 2009.

Configuration parameters

Configuration parameters will depend on which software libraries you have installed above. If you installed everything and follow the VideoPress standard setup your configure line will look like:

--enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-postproc --disable-doc --disable-ffplay --disable-ffserver --enable-pthreads --disable-network --disable-ipv6 --disable-devices --disable-filters --enable-zlib --enable-bzlib --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libspeex --enable-libmp3lame --enable-libfaac --enable-libfaad --enable-libopenjpeg --enable-libxvid --enable-libx264

Parameter Description
--enable-gpl Include code licensed under GPL
--enable-version3 Include code licensed under GPL version 3
--enable-nonfree Establish your own definitions of freedoms and patents
--enable-shared Build shared libraries
--enable-postproc Enable postprocessing support
--disable-doc Do not include documentation
--disable-ffplay No playback libraries
--disable-ffserver No streaming server capabilities
--enable-pthreads Threading support
--disable-network File inputs are local, not over a network
--disable-ipv6 No IPv6 addressing needed
--disable-devices No connected camera or streaming device support needed.
--disable-filters No transforms, just straight transcoding.

You can of course run ./configure --help to print an up-to-date list of configure choices.

See FFmpeg license and legal considerations for more information on the open-source and non-free flags. File formats, audio compression and video compression are typically patent-encumbered and may require paying protection money (IP license) to appropriate stakeholders. Codec libraries and the open-source programs touching encoding files struggle with definitions of freedom. Projects work around complex issues by not distributing binaries and letting individuals set their own compile flags based on their own legal concerns.

make and sudo make install to complete the process.

Check library support

FFmpeg will display a list of libraries coupled with your main FFmpeg install. Check the list to make sure you have configured and installed all decoding and encoding libraries to your satisfaction.

Example:

Component Installed?
libdc1394 support no
libdirac enabled no
libfaac enabled yes
libfaad enabled yes
libfaad dlopened no
libgsm enabled yes
libmp3lame enabled yes
libnut enabled no
libopencore-amrnb support yes
libopencore-amrwb support yes
libopenjpeg enabled yes
libschroedinger enabled no
libspeex enabled yes
libtheora enabled yes
libvorbis enabled yes
libx264 enabled yes
libxvid enabled yes
zlib enabled yes
bzlib enabled yes

FFmpeg-PHP

FFmpeg-PHP is an extension for PHP providing an object-oriented API for movie information (codecs, frame size, frame count, duration, etc.) and frame access tools.

svn co https://ffmpeg-php.svn.sourceforge.net/svnroot/ffmpeg-php ffmpeg-php

The latest FFmpeg-PHP stable release is 0.6.0, released in October 2008. We recommend installing trunk to match the new FFmpeg API and component libraries. Latest revision at time of writing is 677.

Configure, make, install.

We prefer to build FFmpeg-PHP alongside PHP, not inside the full binary.

qt-faststart

The qt-faststart utility prepares MP4 files for progressive playback by moving essential structural box types (also known as atoms) to the beginning of the file, allowing descriptive data to be loaded in the correct load order before any video or audio data. If your transcode process uses a 2-pass muxer you may not need qt-faststart to perform yet another pass and rewrite boxes. We include the utility here, and in VideoPress source code, for completeness.

The qt-faststart utility is included in the FFmpeg source under the /tools subdirectory. Run make tools/qt-faststart and copy the resulting qt-faststart program to your system’s binary path (preferably alongside ffmpeg).

ffmpeg2theora

The ffmpeg2theora utility is a muxer and encoding front-end used to standardize Ogg file creation and its Theora and Vorbis component tracks across encoding setups. We recommend installing ffmpeg2theora for your Ogg creation needs.

Checkout a fresh copy of ffmpeg2theora from the project’s source repository:

svn co http://svn.xiph.org/trunk/ffmpeg2theora

The latest stable version of ffmpeg2theora at time of writing is 0.25. As with previous Xiph repo examples, we used revision 16745.

The ffmpeg2theora source is built using scons, which you should have already installed in the build tools section above.

  1. scons
  2. sudo scons install