I was randomly browsing the internet and reading about making a website look better and I encountered ffmpeg-php. ffmpeg is a very powerful tool to record, convert and stream audio and video. Its a very rich tool almost supporting every format out there in the world. It can convert any format to any other format provided the codec. ffmpeg-php is an extension for PHP that provides a rich library to access info about audio and video files. The good thing about ffmpeg-php is that it can retrieve all info about any audio/video file subjected to the condition that the particular audio/video format is supported by your ffmpeg installation. So, now you have a clear idea that you can do wonders with audio/videos while showing them on your site :)

I tried some of the functionalities and they worked out of the box. Here’s is complete how to on installing ffmpeg and ffmpeg-php.

FFMPEG:

I tried installing ffmpeg from rpms provided by several Fedora repositories but after installation ffmpeg doesn’t seem to work. After several tries, I installed ffmpeg from source rpms and it worked. Below, I will describe how to install ffmpeg from source rpm.

Step 1:

Make sure that you have ‘rpmbuild’ installed by issuing

[root@bordeaux saini]# rpm -q rpmbuild [Enter]

command. If the above says that rpmbuild is not installed, then install it using yum as given below

[root@bordeaux saini]# yum install rpmbuild [Enter] (do as root)

Step 2:

Download the latest src rpm of ffmpeg from rpmfind.net. Issue the command given below

[root@bordeaux saini]# rpm -hiv ffmpeg-x.x.x.xx-xxx.src.rpm [Enter] (do as root)

Step 3:

Go to ‘/usr/src/redhat/SPECS/’ directory and issue the command given below

1
2
[root@bordeaux saini]# cd /usr/src/redhat/SPECS/ [Enter]
[root@bordeaux SPECS]# rpmbuild -ba ffmpeg.spec [Enter] (do as root)

If it gives an error like package ‘xyz’ is need by ffmpeg. Then install the package ‘xyz’ using yum as

[root@bordeaux SPECS]# yum install xyz [Enter] (do as root)

After installing the dependencies, issue the rpmbuild command ‘rpmbuild -ba ffmpeg.spec’. Now ffmpeg rpms will be build and they will be stored in ‘/usr/src/redhat/RPMS/i386/’.

Step 4:

Go the ‘/usr/src/redhat/RPMS/i386/’ (x86_64 instead of i386 if your OS is 64 bit). Install all the rpms that were built by rpmbuild.

[root@bordeaux saini]# rpm -hiv *.rpm [Enter] (do as root)

Thats it. ffmpeg is now successfully installed on your computer. Half the job is done. Now lets proceed with ffmpeg-php installation.

FFMPEG-PHP:

We will install ffmpeg-php from source bundle.

Step 1:

Make sure that ‘php-devel’ installed on your machine by issuing

[root@bordeaux saini]# rpm -q php-devel [Enter]

command. If the above command says the ‘php-devel’ is not installed, then install it using the following command.

[root@bordeaux saini]# yum install php-devel [Enter] (do as root)

Step 2:

Download the latest version of ffmpeg-php from here. Unpack the file you have downloaded.

1
2
[root@bordeaux saini]# bunzip2 -d ffmpeg-php-0.5.1.tbz2 [Enter]
[root@bordeaux saini]# tar -xvf ffmpeg-php-0.5.1.tar [Enter]

Step 3:

Issue the following command in sequence if everything goes fine.

1
2
3
4
5
[root@bordeaux saini]# cd ffmpeg-php-0.5.1 [Enter]
[root@bordeaux ffmpeg-php-0.5.1]# phpize [Enter]
[root@bordeaux ffmpeg-php-0.5.1]# ./configure [Enter]
[root@bordeaux ffmpeg-php-0.5.1]# make [Enter]
[root@bordeaux ffmpeg-php-0.5.1]# make install [Enter] (do as root)

Step 4:

Open ‘/etc/php.ini’ and add a line ‘extension=ffmpeg.so’ in the category ‘Dynamic Extensions’. For help see the image below.
FFMPEG PHP PHPini Module

Step 5:

Restart apache web server aka ‘httpd’ service by issuing the command.

[root@bordeaux saini]# service httpd restart [Enter] (do as root)

Step 6:

Write a test php file and test your ffmpeg-php installation.

phpinfo();

Save the above code in ‘info.php’ and save the file in ‘/var/www/html/’ and browse http://localhost/info.php . If you see something like this.
FFMPEG PHP Linux
Then the ffmpeg-php is successfully installed on your machine. Now you can jump into the world of video manipulation via your website.

Related Posts

{ 1 trackback }

Android KTV development process 2
June 9, 2011 at 2:40 PM

{ 15 comments }

1 pkj December 21, 2007 at 10:21 PM

i have posted the comic .. check it out.

btw, awesome by-line in your blog title.

2 Tom April 12, 2008 at 8:43 AM

We have released a new script that does ffmpeg, ffmpeg-php install. It covers everything that is required for the youtube clones and is made user friendly.

http://admin-ahead.com/software_development.html

Success stories @:

http://www.webhostingtalk.com/showthread.php?t=685218

Hope you will have great use of it.

-T

3 visitor November 6, 2008 at 4:44 PM

There are many automated scripts available which install these but its better to do it manually as in case of an error occuring during the installation process, we can stop the installation and fix them.
closets

4 kulbirsaini November 6, 2008 at 5:48 PM

Totally agreed.

5 Janet Houser December 15, 2008 at 9:03 AM

This covers everything that is required for the youtube clones and is made user friendly. I belive the ffmpeg.so was created inside a folder no-debug-non-zts-20050922, and phpinfo() did not show it when I restarted apache after editing php.ini.

6 Rima February 21, 2009 at 3:35 PM

I installed ffmpeg successfuly and I am able to convert and do all tasks from command line as root user.
but I can not convert anything from php script.

my php.ini says ffmpeg-php enabled ..

any suggestions :(

7 Dependencies of ffmeg | Alec's Notes April 26, 2009 at 7:15 PM

[...] See also this link. [Share/Save] April 26th, 2009 in Site Updates [...]

8 WebTenet Solutions July 23, 2008 at 3:15 AM

Hi,

Can I give 6 out of 5 ;)

I just installed the ffmpeg-php extension on my development server. I have my PHP compiled from source so I skipped yum installing the php-devel package. In the first go, I got the error “unable to find ffmpeg headers” while doing the ./configure. I re-checked and found that I missed to yum nstall the ffmpeg-devel package. All worked like a charm!

By the way, the ffmpeg.so was created inside a folder no-debug-non-zts-20050922, and phpinfo() did not show it when I restarted apache after editing php.ini. (I have Zend Optimizer installed too). I just copied the ffmpeg.so file from that folder to /usr/local/lib/php/extensions, restarted apache and yeehaw…. it now shows in phpinfo().

Your article was of great help kulbirsaini….
Thanks a lot.

9 EHCanadian September 29, 2009 at 10:50 AM

@ Rima

Its a permission issue. Apache is trying to access something that root installed. Change the permissions on the binary file

10 dan paluska January 20, 2010 at 5:10 PM

i get this error:
> yum install rpmbuild
Loaded plugins: refresh-packagekit
Setting up Install Process
No package rpmbuild available.
Nothing to do

11 Lion February 2, 2010 at 5:54 PM

Hi! Great documentation, thanks!

12 Jose Melendez September 9, 2010 at 7:58 PM

I get the same error as Dan:

“No package rpmbuild available.”

13 darka October 7, 2010 at 11:19 AM

yum install rpm-build

14 Pankaj Dangi October 27, 2010 at 3:25 PM
15 Roberto October 16, 2011 at 11:28 AM

install rpmbuild [sic]
learn to spell!
when it’s a command it’s a B.M.
(Big Mistake)

Comments on this entry are closed.

Previous post:

Next post: