Ffmpeg

From ConShell
(Redirected from Ffmedia)
Jump to navigation Jump to search

This document will explain how to compile the latest and greatest version of ffmpeg. This library and the included command line utility will let you perform numerous batch operations including:

  • Converting from any supported media format to any other.
  • Gets screenschots of arbitary frame.
  • Insert a watermark into the media

Prerequisites

At the moment we are assuming you are using linux and, CentOS specifically. Go over to rpmforge, install the rpmform repo rpm for your repository (for CentOS we use RHEL) and type sudo yum install -y ffmpeg ffmpeg-devel . This is to install everythng that you will need to compile the latest version of ffmpeg.


Process

Getting the source

You can change the directory to suite your tastes. I prefer to make /usr/local/src readable by the developers group or wheel group.

cd /usr/local/src
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
cd ffmpeg
wget http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-510.zip
unzip 26104-510.zip
cd libavcodec
mkdir amr_float
cd libavcodec/amr_float
unzip ../../26104-510_ANSI_C_source_code.zip
cd ../../

./configure

The if you run the dag proviged ffmpeg binary, it tells you what its configure options were. They are:

./configure --prefix=/usr/ --libdir=/usr/lib --mandir=/usr/share/man --enable-libmp3lame --enable-libogg --enable-libvorbis --enable-libtheora --enable-libfaad --enable-libfaac --enable-libgsm --enable-xvid --enable-x264 --enable-liba52 --enable-liba52bin --enable-libdts --enable-pp --enable-shared --enable-pthreads --enable-gpl --disable-opts --disable-strip

This has no bearing on what configure options you should use in if you want to get the latest SVN repo to compile. The configure options I currently use are as follows:

./configure --prefix=/usr/ffmpeg/ --enable-libogg --enable-libvorbis --enable-liba52 --enable-libfaac --enable-libmp3lame --enable-pp --enable-gpl --enable-swscaler --disable-vhook --enable-libxvid --enable-libx264

A few notes about options:

--prefix= and --enable-shared

Make sure that your system knows to search in PREFIX/lib for libraries. If you want ffmpeg in its own place, consider just statically compiling it.

--enable-gpl --enable-pp

Some of the libraries that ffmpeg can optionally use are licensed under the GPL. In order to use these you need to enable this switch. --enable-pp enables some gpl licenses post prcessing filters.

--disable-opts

This disables optomizations. This is to prevent compile errors I have been getting. Proposed solutions to them live here

--disable-vhook

Not including this gets you the following:

In file included from vhook/imlib2.c:102:
/usr/local/src/ffmpeg/libavformat/framehook.h:25:2: warning: #warning VHOOK is deprecated. Please help porting libmpcodecs or a better filter system to FFmpeg instead of wasting your time writing new filters for this crappy one.
In file included from vhook/imlib2.c:114:
/usr/include/Imlib2.h:107: error: syntax error before '*' token
/usr/include/Imlib2.h:108: error: syntax error before '*' token
/usr/include/Imlib2.h:109: error: syntax error before "colormap"
/usr/include/Imlib2.h:110: error: syntax error before "drawable"
/usr/include/Imlib2.h:111: error: syntax error before "mask"
/usr/include/Imlib2.h:136: error: syntax error before '*' token
/usr/include/Imlib2.h:137: error: syntax error before '*' token
/usr/include/Imlib2.h:138: error: syntax error before "imlib_context_get_colormap"
/usr/include/Imlib2.h:139: error: syntax error before "imlib_context_get_drawable"
/usr/include/Imlib2.h:140: error: syntax error before "imlib_context_get_mask"
/usr/include/Imlib2.h:169: error: syntax error before '*' token
/usr/include/Imlib2.h:170: error: syntax error before '*' token
/usr/include/Imlib2.h:170: error: syntax error before '*' token
/usr/include/Imlib2.h:208: error: syntax error before '*' token
/usr/include/Imlib2.h:210: error: syntax error before '*' token
/usr/include/Imlib2.h:213: error: syntax error before "pixmap"
/usr/include/Imlib2.h:239: error: syntax error before "mask"
/usr/include/Imlib2.h:242: error: syntax error before '*' token
/usr/include/Imlib2.h:245: error: syntax error before "mask"
/usr/include/Imlib2.h:255: error: syntax error before "mask"
vhook/imlib2.c: In function `Configure':
vhook/imlib2.c:221: warning: suggest parentheses around assignment used as truth value
make: *** [vhook/imlib2.o] Error 1

Flags that cause compiler errors

The following flags caused compiler errors at one point in the past. They might in the future.:

  • --enable-x264
  • --disable-opts

A detailed treatment of compiler errors I get from these two flags and solutions.

make

Nothing special here

make && make install

using ffmpeg

Making Flash Video files

Ok somewhere along the line Flash developed this FLV format that has several advantages:

  • Can be embedded into Flash 7 SWFs, therefore working in most browsers, including Firefox on Linux.
  • Good compression
  • ffmpeg can convert media to this format.

Anyway say you have a media file foo.mpg that you want to save in FLV format the command to do this is:

ffmpeg -i foo.mpg -ar 44100 foo.flv

A few notes:

The -ar flag must be specified after the -i flag. This is the audio sample rate. For FLV files it must be set to 44100, 22050, 11025. If not ffmpeg
There are many other flags you can pass. I'll be furthert documenting them as time goes on, or feel free to do so yourself.

Play the FLV in your favorite media player. If it doesn't play something is wrong.