Today we will explain how you can install ‘ffmpeg’ and ‘ffmpeg-php’ on a Debian 6 (Squeeze) VPS. The installation instructions apply to any other Debian 6 based box too.
What is FFMPEG?
It is a complete, cross-platform solution to record, convert and stream audio and video files. FFMPEG ships ‘libavcodec‘ which is one of the leading audio/video codec libraries.
Ok, but then what is FFMPEG-PHP?
It is an extension for PHP that adds an easy to use, object-oriented application programming interface for accessing and retrieving information from video and audio files.
1. First, make sure your Debian VPS is fully up-to-date by executing the following:
# apt-get update && apt-get -y upgrade --show-upgraded
2. Next, we need to include the DotDeb repository to your sources so we can easily install PHP ffmpeg extension from it:
# echo -e "deb http://packages.dotdeb.org squeeze all" >> /etc/apt/sources.list
3. Now as we have added the repo to the sources, we need to import its GPG key. To do that execute the following statement:
# gpg --keyserver keys.gnupg.net --recv-key 89DF5277 && gpg -a --export 89DF5277 | apt-key add -
– You should get something like the output below:
gpg: requesting key 89DF5277 from hkp server keys.gnupg.net
gpg: key 89DF5277: public key “Guillaume Plessis ” imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
4. Now, the DotDeb repo is fully setup so we need to refresh the sources by running:
# apt-get update
5. With all that in place we’re ready to actually install the FFMPEG and FFMPEG-PHP packages, so do it by executing the following command:
# apt-get install ffmpeg php5-ffmpeg -y
Once the installation is completed, test if ffmpeg is installed and loaded appropriately by running:
# ffmpeg -version
# php -m | grep ffmpeg
If everything is OK as a final test you can use the following PHP script to test whether FFMPEG is available in your PHP:
$command = 'ffmpeg -version'; $path = '/tmp'; exec($command, $path, $returncode); if ($returncode == 127) { echo 'ffmpeg is NOT available'; die(); } else { echo 'ffmpeg is available'; }
I have installed this successfully, but have and error “ffmpeg is NOT available” :(
What should I do to fix this?
Anyway, Thank you.
Did you restart your web server for the changes to take effect?
where i create php file ?
Hi Qosim,
you can create the test PHP script anywhere within your document root, so you can access it via your favorite browser.
Let us know how it goes.