Wednesday, April 29, 2009

How to Install FFmpeg in Linux

                    FFmpeg is a very fast video and audio converter. It can also grab from a live audio/video source. FFmpeg is so important if you are planning to run a video website with streaming with conversion of video files to different video formats. This blog is intended for Centos/Redhat versions of Linux where any novice user can install ffmpeg without compiling the source which is a more traditional way of installing the FFmpeg software on linux servers. In this blog i will show you the easy way to install ffmpeg and ffmpeg-php (php extension) with just yum rather than compiling ffmpeg from source files.

Installation

First you need to add a file in yum repository directory for dag packages installation. For this edit the following file: 


Vi /etc/yum.repos.d/dag.repo 

add the following contents to the file, 

[dag] 
name=Dag RPM Repository for Red Hat Enterprise Linux 
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag 
gpgcheck=0 
enabled=1 

Then enter the command, 

yum install ffmpeg ffmpeg-devel 

To check what audi/video formats are supported 

ffmpeg -formats > ffmpeg-format.txt 

Open the ffmpeg-formats.txt to see the ooutput 

D means decode 
E means encode 
V means video 
A means audio 
T = Truncated

Installation of FFMPEG-PHP Extension

  FFmpeg-php is a very good extension and wrapper for PHP which can pull useful information about video through API interface. Inorder to install it you will need to download the source file and then compile and install extension in your server. 

For downloading the source tarball click here

or 

wget http://sourceforge.net/project/downloading.php?group_id=122353&filename=ffmpeg-php-0.6.0.tbz2&a=55737530 

Extract the souce tarball.

tar -xjf ffmpeg-php-0.6.0.tbz2 

cd ffmpeg-php-0.6.0/

 phpize 

./configure 

make 

make install

Editing PHP.INI

 Once you have done that without any problems then you will see the php extension file /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so and you will need mention that extension in php.ini file 

vi /usr/local/lib/php.ini 

Put the below two lines at the end of the php.ini file 

[ffmpeg] 
extension=ffmpeg.so 

Then restart the server
 
service httpd restart 

To check whether ffmpeg enabled with php, point your browser to test.php file. It should show the confirmation of installed ffmpeg php extension 

// #test.php


phpinfo();

?>

              

If any case the ffmpeg does not show in the phpinfo() test make sure that php.ini path to ffmpeg.so is correct. Still the problem occures, the reason could be you might be using older version of ffmpeg-php which is buggy. just download the latest version of ffmpeg-php sourse then complile it.

Common Errors

1. If you get command not found error for phpize, then you will need to do yum install php-devel

2. If you get error like "ffmpeg headers not found" while configuring the source.

configure: error: ffmpeg headers not found. Make sure ffmpeg is compiled as shared libraries using the --enable-shared option

then it means you have not installed ffmpeg-devel packages.

To Fix: Just install ffmpeg-devel using

yum install ffmpeg-devel

3. If you get an error like shared libraries not found problem and the program halts in the middle, then you must specify the ffmpeg installed path explicitly to the ./configure.

configure: error: ffmpeg shared libraries not found. Make sure ffmpeg is compiled as shared libraries using the --enable-shared option

To Fix:

1. First find out the ffmpeg path with ffmpeg --help command. The prefix default path should be like /usr/local/cpffmpeg
2. Configure the FFmpeg-php with --with-ffmpeg option

./configure --with-ffmpeg=/usr/local/cpffmpeg

That should resolve the problem!


No comments:

Post a Comment