(dv):Installing FFmpeg and FFmpeg-php
- This page was last modified on April 11, 2011, at 14:49.
From (mt) Community Wiki
Contents |
About FFmpeg and FFmpeg-PHP
FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library.
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...)
Requirements
This article assumes the user is comfortable with:
- Using SSH
- Editing files via SSH
- Root access is enabled
This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.
Installing FFmpeg
FFmpeg can be installed fairly easily on the (dv) 3.5 and 4.0 servers, through use of the third-party DAG RPM Repository.
- Connect to your server as root.
- Create and edit a new file in /etc/yum.repos.d/ called dag.repo and add the following lines:
/etc/yum.repos.d/dag.repo
[dag] name=DAG RPM Repository baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag gpgcheck=1 enabled=1
- Next, run the following commands to import the CentOS GPG key, then download and import the DAG Repository GPG key:
rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 wget http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt rpm --import RPM-GPG-KEY.dag.txt
If you want to verify the keys have been properly installed, enterrpm -q gpg-pubkey-*
Look for the following two gpg-pubkey entries from the command's output:
gpg-pubkey-6b8d79e6-3f49313d -- DAG Repository key
gpg-pubkey-e8562897-459f07a4 -- CentOS 5 key
- Now that yum has been properly configured with a new RPM repo, we can get FFmpeg installed. First, we want to update the yum package list with all the new packages the DAG Repository offers:
yum update
- Once yum has been updated with the new package list, we need to install ffmpeg and ffmpeg-devel:
yum install ffmpeg ffmpeg-devel
- Sit back and relax while yum downloads and installs the required packages for FFmpeg, you are done!
Installing FFmpeg-PHP
- Connect to your server as root.
- Download the latest FFmpeg-php source code:
wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download
- Run the following commands to unpack the archive and move into the ffmpeg-php directory:
tar -xjf ffmpeg-php-0.6.0.tbz2 cd ffmpeg-php-0.6.0
- Once you have fixed up the ffmpeg_frame.c file, run the following commands to compile and install the extension:
phpize ./configure && make make install
- Edit the /etc/php.ini file in your favorite text editor, and add the following line to any blank area underneath the "[PHP]" line:
/etc/php.ini
extension=ffmpeg.so
- Now, just restart Apache:
/etc/init.d/httpd restart
- If you want to make sure the extension is loaded and working, set up a PHP Info page, or copy test_ffmpeg.php and the contents of the tests/test_media/ directory into the document root of your website (normally httpdocs), then load test_ffmpeg.php from your browser.
- You are done!
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ffmpeg.so' – /usr/lib64/php/modules/ffmpeg.so: undefined symbol: _php_create_ffmpeg_frame in Unknown on line 0
External Links
FFmpeg.org website
FFmpeg-php site at Sourceforge
LinuxHostingSupport.net - a fix for "error: PIX_FMT_RGBA32 undeclared"