svn co https://ffmpeg-php.svn.sourceforge.net/svnroot/ffmpeg-php ffmpeg-php
ffmpeg-php is an extension for PHP that adds an easy to use, object-oriented API for accessing and retrieving information from video and audio files. It has methods for returning frames from movie files as images that can be manipulated using PHP's image functions. This works well for automatically creating thumbnail images from movies. ffmpeg-php is also useful for reporting the duration and bitrate of audio files (mp3, wma...). ffmpeg-php can access many of the video formats supported by ffmpeg (mov, avi, mpg, wmv...)
09/21/07 - Offical Gentoo package available! Gentoo users can now install using 'emerge ffmpeg-php'.
07/16/07 - Offical Debian package available! Debian users can now install using 'apt-get install php5-ffmpeg'. A big thanks to Raphael Geissert for all his work on this, and for all the tips on getting ffmpeg-php to play well with Debian's packaging system. A unoffical package for PHP4 is available at his personal repository.
05/24/07 - Ffmpeg and ffmpeg-php installation services available. For $75 USD (via Paypal) I will install ffmpeg and ffmpeg on your Linux server. Email email@example.com for more info.
08/15/06 - The ffmpeg-php sources have been migrated from CVS to Subversion. CVS is still available from the command line but will no longer be updated.
gd-2.0 or higher (the version of GD bundled with PHP works too)
ffmpeg-php is not compatible with ffmpeg's swscaler. Enabling swscaler in ffmpeg disables the img_convert functions that ffmpeg-php needs to do its thing. Ffmpeg must be configured and compiled without the '--enable-swscale' flag.
Some users have posted Windows builds to the ffmpeg-php google group. I hear from folks that they work great but I haven't had time to test them personally yet.
Apparently there is some sort of conflict between the php IMAP extension and ffmpeg-php in certain cases. The IMAP extension seems to conflict with a few other extensions so for now I am assuming it is a problem with IMAP.
Simple object oriented interface.
Ability to grab frames from movie files and return them as images that can be manipulated using PHP's built-in image functions. This is great for automatically creating thumbnails for movie files.
Can create animated GIFs from a series of movie frames or GD images.
Has the ability to use ffmpeg's excellent re-sampling and cropping features on returned frames.
Provides access to data from mp3 files such as duration, bit rate and track meta information.
Sites Using ffmpeg-php
Here's a list of some of my favorite sites using ffmpeg-php.
Opusphp.com - Opus php CMS is a great alternative to hastily designed CMS/Social Networking software on the market today, and another great example of how you can use ffmpeg/ffmpeg-php!
Vimeo.com - Vimeo.com is a super cool site for organizing and sharing video clips. Think del.icio.us meets Flickr for video! ffmpeg-php is used for automatic thumbnailing of movies uploaded to the site. Thanks to Vimeo's creator, Jakob Lodwick for the link and encouragement!
Trainorders.com - Trainorders is a popular rail enthusiast website with some unique features. My favorite is the new motion activated camera systems that automatically record passing trains at various popular rail junctions. Once recording is complete, the movies are uploaded to the Trainorders.com website where they are thumbnailed using ffmpeg-php and presented to subscribers. A big thanks to Todd Clark, the webmaster of Trainorders.com, for the opportunity to help develop this.
patricksaviation.com - This is my son's favorite site on the internet. It's a video sharing website for aviation enthusiasts. Fun! If there's a better use for the internet, I haven't found it.
half-lime.com - An excellent video sharing website with a great interface. Thanks to Aleksander Kuprikov for the link.
Change to the ffmpeg-php extension directory and run phpize (included with your PHP installation) to build configuration files. NOTE: if your php installation does not include phpize, you may have to install a php-dev package for your distro (usually named: php-dev, php-devel or similar)
Configure and build the extension.
./configure && make
Install the shared extension.
sudo make install
If everything went as planned, ffmpeg-php is now installed as a shared extension.
If you've built ffmpeg-php as a shared extension but want to make it available to all scripts
by default, add extension=ffmpeg.so to your php.ini file to load ffmpeg-php at PHP startup. Make sure to restart apache when you are done to reload php.ini.
Testing the Installation
Put the directory test_media and test_ffmpeg.php script under your web root somewhere (put both in the same directory).
Load test_ffmpeg.php into your browser.
RESULTS: You should get a listing of the methods provided by the ffmpeg-php
module as well as some test output from the methods.
If you've the installed ffmpeg-php extension as a shared library but haven't set it to auto-load in your php.ini file, you'll need to use the PHP dl() function to make ffmpeg-php available to your scripts. Add the following PHP code to the beginning of scripts you want to call ffmpeg-php methods in.
Q: How come it doesn't work with some Quicktime movies?
A: ffmpeg must be compiled with zlib support to read Quicktime movies with compressed headers.
Q: How come it doesn't work with <myfavoritetype> movies?
A: The ffmpeg-php extension uses ffmpeg libraries for access to video info. Some movie types have limited support in ffmpeg. Some encoders create non-standard movies which may cause problems for ffmpeg. If the movie can't be read correctly by ffmpeg then it won't work with ffmpeg-php. Consult the ffmpeg documentation for more info on supported formats. If ffmpeg-php won't read a movie, try using the ffmpeg command line program to convert the movie to another type. If it fails, then ffmpeg (and thus ffmpeg-php) don't support your movie type. If ffmpeg converts it correctly then the problem is most likely in ffmpeg-php, in which case you can bug me about it.
Q: ffmpeg-php doesn't do the one freakin' thing I absolutely need! Can you add it to the program?
Ffmpeg-php was written specifically for a project I was working on and have now finished. There is no ongoing development at all beyond just keeping it compatible with the ever changing ffmpeg API (and even then I just wait for someone to complain). That said, I am available for hire if you need further development or customization as long as the resulting code is made open source also.
Q: I can't get it to install. What's the deal?
Ffmpeg-php can sometimes be a pain to install. This is mostly due to the strange voodoo it has to do to detect if GD is available in PHP. Sometimes this fails for no apparent reason. Add to that the ever changing ffmpeg SVN and it can get even more tricky. If you get stuck, ask on the Google group and someone can probably talk you through it.
If you get really stuck I'd be happy to install ffmpeg and ffmpeg-php (and any other videoshare prerequisites) on your server for $75 bucks. I'll need ssh root access to the machine and about 45 minutes. (Linux only, I'm not a Windows dude) Feel free to contact me for the details: firstname.lastname@example.org
If you find ffmpeg-php useful, want to report a bug, or want to request a feature, please use the SourceForge project page.