ffmpeg – The upcoming tool for video conversion

ffmpeg [1] is the tool I have used locally for some time now [1]. It allows conversions of various video formats and video to image conversions. Over the last few months I started a collection of links to some helpful articles and discussions [2]. Recently, there has been started the development of a PHP extension [3]. I could imagine, that ffmpeg would be quite an interesting PHP5 standard extension 😉 I haven\’t checked the license for compatibility though.

Grabbing a frame out of a video is as simple as follows. It took me quite some time to figure out the appropriate options, since the web and the documentation did not yet satisfy my needs:

$ ffmpeg -i test.3gp -f singlejpeg -img jpeg -y test.jpg
Input #0, mov, from \’test.3gp\’:
Duration: 00:00:04.8, bitrate: 80 kb/s
Stream #0.0: Video: h263, 128×96, 10.00 fps
Stream #0.1: Audio: 0x726d6173, 8000 Hz, mono
Output #0, singlejpeg, to \’test.jpg\’:
Stream #0.0: Video: mjpeg, 128×96, 10.00 fps, q=2-31, 200 kb/s
Stream mapping:
Stream #0.0 -> #0.0
frame= 48 q=4.0 size= 117kB time=4.8 bitrate= 200.0kbits/s

I am sure this will boost video blogging enormously [4]. I first was heading for mplayer, but mplayer is IMHO kind of related to X and we do not really want X to be installed on a production server, do we?

Finally, I would like to talk about animated GIF files and provide an example. As with a combination of Imagemagick and ffmpeg, it is a matter of two command lines evtl. one (I am not a pipe specialist ;). As shown below, ffmpeg generates a set of 10 images and Imagemagick converts them to an animated GIF:

$ ffmpeg -i test.3gp -f image -img gif -t 1.0 test%03d.gif
Input #0, mov, from \’test.3gp\’:
Duration: 00:00:04.8, bitrate: 80 kb/s
Stream #0.0: Video: h263, 128×96, 10.00 fps
Stream #0.1: Audio: 0x726d6173, 8000 Hz, mono
Output #0, image, to \’test%03d.gif\’:
Stream #0.0: Video: rawvideo, pal8, 128×96, 10.00 fps, q=2-31, 200 kb/s
Stream mapping:
Stream #0.0 -> #0.0
frame= 10 q=0.0 size= 0kB time=1.0 bitrate= 0.0kbits/s

$ convert -delay 20 -loop 0 test*.gif animated.gif

Feeback always welcome 😉

[1] http://ffmpeg.sourceforge.net
[2] http://www.circle.ch/wiki/MpegToJpeg
[3] http://ffmpeg-php.sourceforge.net
[4] http://www.circle.ch/wiki/3gpVideo

Leave a Reply