paazmaya.fi

The Website of Juga Paazmaya | Stories about Web Development, Japanese Martial Arts, Hardware prototyping and travelling

Best quality video for Flash with FFmpeg and friends

A quick list of commands needed to build the best tools available for creating the best quality video to be played in the Flash player.

In case your system has not been used before to build applications from sources, there might be several tools and packages missing. In many cases even the required libraries are available, their devel packages are missing. ATrpms is a good source if your original distribution does not offer enough of multimedia related packages.

The sources are fetched with git, subversion and cvs.

git clone git://git.videolan.org/x264.git
cd x264
./configure --prefix=/usr/local/encoding \
--enable-shared \
--enable-visualize \
--extra-cflags="-I/usr/local/encoding/include" \
--extra-ldflags="-L/usr/local/encoding/lib"

FFmpeg is one of the most important piece of software needed to encode audio and video freely, without any licenses or royalties. It is hyper fast.

svn co svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd ffmpeg
./configure --prefix=/usr/local/encoding \
--enable-frei0r \
--enable-gpl \
--enable-libdc1394 \
--enable-libdirac \
--enable-libfaac \
--enable-libgsm \
--enable-libmp3lame \
--enable-libnut \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-libopencv \
--enable-libopenjpeg \
--enable-libschroedinger \
--enable-libspeex \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libxvid \
--enable-nonfree \
--enable-postproc \
--enable-pthreads \
--enable-shared \
--enable-version3 \
--extra-cflags="-I/usr/local/encoding/include" \
--extra-libs="-L/usr/local/encoding/lib"

Mencoder, which comes with Mplayer, is here as a bonus, as it is not needed necessarily. On the other hand it offers the best media player known to the free software community.

wget https://www.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
tar jxf essential-20071007.tar.bz2
sudo mv essential-20071007 /usr/local/encoding/lib/codecs
svn co svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd mplayer
./configure --prefix=/usr/local/encoding \
--enable-gui \
--enable-dynamic-plugins \
--extra-cflags="-I/usr/local/encoding/include" \
--extra-libs="-L/usr/local/encoding/lib"

Gpac has a tool called MP4Box, which is used to create the mp4 file containing the streams of video, audio and possible subtitles.

Fetch the source and compile accordingly

svn co https://gpac.svn.sourceforge.net/svnroot/gpac/trunk/gpac gpac
cd gpac
./configure --prefix=/usr/local/encoding \
--extra-cflags="-I/usr/local/encoding/include" \
--extra-libs="-L/usr/local/encoding/lib"

The actual compiling and installation could be done for all the items above by using the following commands:

make -j4
sudo make install
make distclean

On Mac OS you could substitute make with gmake in order to make the use of the correct tools. The last command is for cleaning the sources in case you decide to update and recompile them later.

The encoding commands I must leave to another post.