How To: Install FFMPEG and FFMPEG-PHP

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.

 

How To: Install WordPress on LAMP

Recently, I bought this domain name and shifted all my blogs here on saini.co.in . As I chose wordpress as the software to blog. So, just installed it and started using it right away. Installing wordpress is one of the most easiest things that you’ll ever do. Below is a step by step howto on installing wordpress and importing your current wordpress.com blog to your domain.

Step 1:

Download latest version of wordpress from here.

Step 2:

Go to the directory where you want to install it. Here I am taking gofedora.com as reference website where we want to install the wordpress and ~/htdocs/ as the web directory for gofedora.com . Modify above details in accordance with your needs.

If you downloaded .zip format then do this

[saini@bordeaux htdocs]# unzip wordpress-X.X.X.zip [Enter]

If you download .tar.gz format then do this

[saini@bordeaux htdocs]# tar -xvzf wordpress-X.X.X.zip [Enter]

Step 3:

[saini@bordeaux htdocs]# mv wordpress/* . [Enter]

If you visit http://gofedora.com now, you’ll get an error as shown in the image below …

Wordpress Error Without wp-config

Step 4:

Open the file wp-config-sample.php in your favorite text editor and edit the things shown in the image below.

Sample wp-config

Enter your database name, database username, database password and the table prefix for the wordpress database. e.g. one can use linux_ as table prefix. If you have the database on the same system, then there is no need to change the database host otherwise change it accordingly.

Step 5:

[saini@bordeaux htdocs]# mv wp-config-sample.php wp-config.php [Enter]

Step 6:

Go to http://gofedora.com/ and you’ll see a welcome page if you gave correct setting in wp-config.php . The page is like in the image below.

Wordpress Blog Config

Fill the settings properly. Anyway you can change them afterwards. Fill the blog name and email id and click Install WordPress.

Step 7:

You’ll see a web-page like in the image below, if everything goes fine. Copy the password on the page and paste at some temporary place and click login.

Wordpress Copy Password

Step 8:

You’ll be presented with a login page. Enter ‘admin’ as username and the password you copied from the previous page.

Wordpress Admin Login

Step 9:

Congratulations ! You have successfully installed wordpress and created the admin login. Go to Users -> Authors & Users and click Edit in the row with admin as author. Change the password on the next page as below ..

Wordpress Change Password

This is all you have to do to install wordpress. Below is how you import wordpress.com blog to your domain.

Step 1:

Login as admin on you wordpress.com blog and go to Manage -> Export and download the exported blog to your system as show in the image below.

Wordpress Export Blog

Step 2:

Create directory named ‘uploads’ in ~/htdocs/wp-content/ and change permissions to 777 so that wordpress can upload your blog there.

1
2
3
[saini@bordeaux htdocs]# cd wp-content [Enter]
[saini@bordeaux wp-content]# mkdir uploads [Enter]
[saini@bordeaux wp-content]# chmod 777 uploads [Enter]

Step 3:

Go to Manager -> Import section and click on ‘wordpress’ . Upload the .xml file that you download from your wordpress.com blog in step 1 on the page as shown in the image below ..

Wordpress Import Blog

Step 4:

If uploading goes successful, then all your posts will be imported from your wordpress.com blog and will be stored in the database as gofedora.com . Now it will ask you for the author of the new blog posts at gofedora.com as show below …

Choose New Author

Step 5:

Change the permission of uploads back to normal as show below

[saini@bordeaux wp-content]# chmod 744 uploads [Enter]

Everything is done. Now you blog has been shifted to your domain and you can go on with the new blog. But keep in the mind the the images you used in wordpress.com blog posts are not stored in your local database, they are still linked back to your wordpress.com blog images. So, don’t just go and delete your wordpress.com blog. That would be fatal.

The steps for installing wordpress on a windows system are the same, but you have to use some notepads and whatever to edit files 🙂

Enjoy blogging at your domain. Hope the above howto helps.