Powered By

FFMPEG Installation Step by step guide in centos

                               FFMPEG Installation Guide

            FFMPEG is an open source application and developed under Linux  that allows you to convert video and audio files easily between a variety of different formats. It supports most industry-standard codec and can convert from one file format to another quickly and easily.It includes libavcodec, a leading audio/video codec  library.  FFmpeg  can compile under most Operating Systems, including Windows.  
     You can use this powerfull tool using any scripting language server side execute functions once you installed in your server.
   In php
      shell_exec(“command, parameters”);
the following flow chart explain you how it works with php




This article will guide you to installing FFMPEG and other codec on Linux(centos 5).

FFMPEG Installation Requirements
·      LAME Mp3 Audio Codec (Requred for mpg, flv, avi, wmv etc files)
·      FFMPEG ,mplayer,mencoder, flvtool2
·      FFMPEG-PHP
More Advantage When you installed these components
·      AMR Audio Codec (Required for 3gp video files)
·      XVID Audio Codec

Note :
 You need to know how to use yum,rpm,wget commands well and these commands should be configured in the server in which you are going to install ffmpeg.
·         Make a note of what you are doing for future reference when ever you are facing problems
·         These steps are worked well for me and and am not sure how about for you, so please make some backup when ever you modifying your system files.
Go ahead.....

Installation Steps

    It is a good practice to install all the external audio codec libraries first and then install the FFMPEG.   
   So now you need to connect to your server using any ssh tool like putty by giving server name , username, password.



    cd /usr/
    Create a directory for all the further steps
    mkdir downloads
    Move into downloads directory
    cd downloads    


 

  
Installing LAME MP3 Encoder

          Download LAME Mp3 Codec download URL : Lame Mp3 Codec
·      Untar the lame file by using tar zxvf lametarfile
·      Assign 777 permission rights to the lame folder by typing chmod 777 lamefolder -R
·      Traverse to the root of lame folder and type
          wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
Extract the archive:
tar -xjf lame-3.97.tar.gz
 cd  lame-3.97
./configure
make
make install



Installing – Ffmpeg


Adding the DAG repository is simple. I’m using yum, so I did the following to add the repository:

1.    Create and open a new file called /etc/yum.repos.d/dag.repo.
vi /etc/yum.repos.d/dag.repo
   2. Add the following text to the file:
      [dag]
      name=DAG RPM Repository
      baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
      gpgcheck=1
      enabled=1
   3. Finally, save and close the file.
            In order to successfully use the DAG repository with tools such as yum, you need to add DAG’s GPG key. Failure to do so will result in an error like the following:
            warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
            Public key for faac.x86_64.1.26-1.el5.rf.rpm is not installed



            In order to add the GPG key for DAG, run the following:
            rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

            Or if you dont need key validation just make gpgcheck=0 in the above dag.repo file     
            So Now that DAG is setup, it’s a good idea to update all your packages.
           
            # yum update
Now you are ready to install FFmpeg with yum. I wanted to install all the available FFmpeg packages, so I first asked yum what was available.
# yum search ffmpeg

Searching through the results, I found that three packages need to be installed: ffmpeg, ffmpeg-devel, and ffmpeg-libpostproc.

# yum install ffmpeg ffmpeg-devel ffmpeg-libpostproc
install supporting packages – mplayer,mencoder, flvtool2
yum -y install mplayer mencoder flvtool2

  Preparing for ffmpeg-php

I often work with programs through command line calls in code, but I wanted something more robust this time, so I looked around and found ffmpeg-php. Based on the API, it looks to be a great tool to interface PHP and FFmpeg.
There are four things that are required to successfully install and run ffmpeg-php; they are:
·                                          ffmpeg-0.4.9_pre1 or higher
·                                          php-4.3.0 or higher
·                                          gd-2.0 or higher
·                                          php-devel
 Run the following

yum install php-gd
In case you are wondering what php-devel is for, it installs the phpize program which is used to install ffmpeg-php.

    Installing ffmpeg-php

Now we are ready to install ffmpeg-php.
This can be done in six easy steps:
1.                                      Download the  latestet ffmpeg-php from http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/
        wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download

2.                   Extract the archive:
             tar -xjf ffmpeg-php-X.x.x.tbz2
3.                   cd ffmpeg-php-X.x.x/
4.                   phpize
5.                   ./configure && make
6.                   sudo make install

It will copy the ffmpeg.so module in php default module location. Now you have to edit php.ini file to enable ffmpeg-php support in it by using ffmpeg.so module.
vi /etc/php.ini
and append following line
extension=ffmpeg.so

Restart apache service to take effect of php.ini
/etc/init.d/httpd restart
Run following command to ffmpeg module listing in php.
php -m | grep ffmpeg
For more about ffmpeg-php functions –  documentation

Now you should be ready to convert any video to any video format and still more, Have a nice streaming. 

Test it out using
ffmpeg -i videofilename.extension
          You will be getting some message and info about the input file


Installing advanced ffmpeg supporting components
AMR Audio Download URL   AMR Audio Codec
To install the AMR codec you will require both AMR-WB and AMR-NB files.
XVID Audio Download URL: XVID Audio Codec

Installing AMR Codec
For installing the AMR codec there are two separate files that needs to be installed are AMR-WB and AMR-NB.
·  Untar the AMR file by using tar zxvf tarfile
·  Assign 777 permission rights to the amr folder by typing chmod 777 amrfolder -R
·  Traverse to the root of amr folder and type
./configure
make
make install
Note on Installing AMR:
You might get errors installing AMR codec on Autoconf utility of linux. To resolve this problem will have to install the latest version of Autoconf utility
Dwonload  AutoConf  from  Here
Installing Xvid Codec
·  Untar the xvid file bu using tar zxvf tarfilename
·  Assign 777 permission rights to the lame folder by typing chmod 777 xvidfolder -R
·  Traverse to the root of xvid folder
·  Goto Build/generic folder and type
./configure
make
make install 


Leave A comment If you are facing any problem.  Have a happy encoding and streaming, we will see set of streaming tutorials in next tutors.



Related Posts by Categories