Even that ffmpeg is included in most distributions, is a good idea to build it from scratch in order to get the maximum functionality.
How to build FFmpeg from sources
Get the code from svn, also available from git repository.
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
# ./configure --prefix=/usr/local --arch=i686 --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom \ -fasynchronous-unwind-tables' --extra-version=rpmfusion --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libopenjpeg \ --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avfilter-lavf --enable-postproc \ --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib --cpu=i686 --enable-runtime-cpudetect
# ./configure --prefix=/usr/local --enable-bzlib --enable-libdc1394 --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libschroedinger --enable-libspeex \ --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avfilter-lavf --enable-postproc --enable-pthreads --enable-shared \ --enable-gpl --disable-debug --disable-stripping --enable-runtime-cpudetect
Then build the sources and install them.
# make & make install
How to trans-code video files with FFmpeg
Trans-coding could happens in different ways, video, audio, a mix of them and could be done in 1-pass or 2-pass, each one of them has its pro and cons.
Generally speaking, I prefer this method if, and only if, the following criteria is meet:
- The source file is relative small compared with the system capabilities (CPU and RAM)
- If many files need to be processed, then batch them one by one
The advantage of this method is that the input file is recognized in the first step, so is enough to use any "fast" preset in order to accomplish successfully the pass 1, then the second pass must be faster than 1-pass only. But some things to consider when work with 2-pass are:
- ffmpeg will generate a series of log files, they are necessary for second pass
- When multiple files are processed in parallel, this might generate trouble since must of the log files will be overwritten, a workaround to deal with is to process each file in separate folder.
When transcoded files are going to be played online, they will be played only when the movie is completely loaded, a workaround to this is apply the qt-faststart to the resultant file from any of the above methods of processing.
# qt-faststart ffmpg_out.mp4 my_video.mp4