Tuesday, November 04, 2008

Converting any video into flv or anyother formate ffmpeg, ffmpeg-php, php

How to get FFMPEG working on Fedora


Installing FFMPEG
-----------------

Step 1. Update yum "yum update"
Step 2. Install GD "yum install php-gd" - it will install latest version
Step 3. "yum install ffmpeg ffmpeg-devel"

If you get "No package ffmpeg available."

Then download Livna repository for Fedora 7 (which ever version you are using) (http://rpm.livna.org/rlowiki/).

For 7: http://rpm.livna.org/livna-release-7.rpm

Install livna-release-7.rpm using the following command: rpm -Uvh livna-release-7.rpm

Now try, yum install ffmpeg ffmpeg-devel

it should install it without any problem.


To check the FFmpeg working:

Finally, check the ffmpeg whether it is working or not.

> ffmpeg
> ffmpeg -formats
> ffmpeg --help
// This lists path of mpeg, its modules and other path information


ffmpeg -i Input.file Output.file
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


Installing FFMPEG-PHP
--------------------------

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. You

can download the lastest source tarball : http://ffmpeg-php.sourceforge.net/

Run the following commands..

Step 1: wget http://nchc.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.6.0.tbz2

Step 2: tar -xjf ffmpeg-php-0.6.0.tbz2

Step 3: cd ffmpeg-php-0.6.0

Step 4: phpize

Step 5: ./configure

Step 6: make

Step 7: make install

Step 8: Edit PHP.ini

The best way to find php.ini in used to use this command.

# php -i | grep php.ini
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini


Before we edit the file, let's make a backup.

cp /etc/php.ini /etc/php.ini.bak (replace path/to with actual dir)

now let's edit it

vi /etc/php.ini (replace path/to with the actual dir)


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

[ffmpeg]
extension=ffmpeg.so


Step 10: 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()

?>



Installing Mplayer + Mencoder
-----------------------------

Step 1: yum install mplayer mencoder


Installing FlvTool2
--------------------

For this you need ruby, if you dont have then install it..

Step 1: yum install ruby

Get the latest FLVtool from http://rubyforge.org/projects/flvtool2/

Step 2: wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz

Step 3: tar zxvf flvtool2-1.0.6.tgz

Step 4: cd flvtool2-1.0.6/

Step 5: ruby setup.rb config

Step 6: ruby setup.rb setup

Step 7: ruby setup.rb install


HELPFULL LINKS:
---------------

http://www.mysql-apache-php.com/ffmpeg-install.htm

http://forums.fedoraforum.org/archive/index.php/t-176767.html


http://linux.justinhartman.com/FFmpeg,_FFmpeg-PHP,_Lame,_Libogg,_Libvorbis,_FLVtool2,_Mplayer,_Mencoder,_AMR_Installation#Install_flvtool2

http://blog.gwikzone.org/2006/09/25/flv-encoding-with-ffmpeg

No comments: