Pengen Punya WebSite instan kualitas intan ?

Sunday, May 16, 2010

Install FFMPEG and PHP-FFMPEG Youtube Like Script

If you have a site like Youtube site or any other tube site, and you want to configure your PHP to support FFMPEG. Here is a detail how to compile and configure FFMPEG and PHP-FFMPEG so your php will support any script like flvtool, mplayer, libogg, libvorbis, libmp3lame, xvidcore, libtheora, faac, faad2 and libmp4v2

In this tutorial, all my configuration is running in OpenSUSE server. I also confirmed that this tutorial also working with Fedora/Centos/RHEL server.

I assume you already have apache, php and mysql up and running in your server. Please follow up the apache, php and mysql installation from this URL below http://www.idprayoga.com/?p=47 and you already have Subversion up and running in your server too. Please follow up the Subversion installation from this URL below http://www.idprayoga.com/?p=205

Download any packages to support ffmpeg and php-ffmpeg

first check on your server, there are Ncurses, autoconf or not, in my case Ncurses, autoconf was build in my server. if there are nothing, follow in line bellow.

#cd /root
#wget ftp://invisible-island.net/ncurses/ncurses-5.7.tar.gz
#wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.64.tar.gz
#wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz

Compiling Ncurses, autoconf, and Ruby

#cd root
#tar -zxvf ncurses-5.7.tar.gz
#cd ncurses-5.7
#./configure
#make && make install

#cd root
#tar -zxvf autoconf-2.64.tar.gz
#cd autoconf-2.64
#./configure && make && make install

#cd /root
#wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz
#tar -zxvf ruby-1.9.1-p243.tar.gz
#./configure
#make && make install

Download all ffmpeg dependency packages
#cd /root
#mkdir ffmpeg
#cd ffmpeg
#wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
#wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
#wget ftp://ftp.uni-hannover.de/pub/mirror/bsd/NetBSD/packages/distfiles/lame-398-2.tar.gz
#wget http://downloads.xiph.org/releases/ogg/libogg-1.1.4.tar.gz
#wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.3.tar.gz
#wget http://dfn.dl.sourceforge.net/sourceforge/faac/faad2-2.0-rc3.tar.gz
#wget http://downloads.xiph.org/releases/theora/libtheora-1.0.zip
#wget ftp://ftp.uni-frankfurt.de/pub/Mirrors2/gentoo.org/distfiles/faac-1.24.tar.gz
#wget http://resare.com/libmp4v2/dist/libmp4v2-1.5.0.1.tar.bz2
#wget http://www.libsdl.org/release/SDL-1.2.13.tar.gz
#wget http://downloads.xvid.org/downloads/xvidcore-1.1.2.tar.gz

Extract all packages
#bunzip2 essential-20071007.tar.bz2; tar xvf essential-20071007.tar
#tar zxvf flvtool2-1.0.6.tgz
#tar zxvf lame-398-2.tar.gz
#tar zxvf faac-1.24.tar.gz
#tar zxvf faad2-2.0-rc3.tar.gz
#tar zxvf libogg-1.1.4.tar.gz
#tar zxvf libvorbis-1.2.3.tar.gz
#bunzip2 libmp4v2-1.5.0.1.tar.bz2; tar xvf libmp4v2-1.5.0.1.tar
#unzip libtheora-1.0.zip
#tar zxvf SDL-1.2.13.tar.gz
#tar zxvf xvidcore-1.1.2.tar.gz

Create the codecs dir and import them

#mkdir /usr/local/lib/codecs
#mv essential-20071007/* /usr/local/lib/codecs/
#chmod -R 755 /usr/local/lib/codecs/

Get the latest FFMPEG/MPlayer from the subversion
#/usr/local/subversion/svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
#/usr/local/subversion/svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

Compile LAME
#cd /root/ffmpeg/lame-398-2
#./configure && make && make install

Compile libOGG
#cd /root/ffmpeg/libogg-1.1.4
#./configure && make && make install

Compile libVorbis
#cd /root/ffmpeg/libvorbis-1.2.3
#./configure && make && make install

Compile flvtool2
#cd /root/ffmpeg/flvtool2-1.0.6
#ruby setup.rb config
#ruby setup.rb setup
#ruby setup.rb install

Compile MPlayer
#cd /root/ffmpeg/mplayer
#./configure && make && make install

Compile Libtheora

#cd /root/ffmpeg/
#cd libtheora-1.0
#./configure && make && make install

Compile FAAC
#cd /root/ffmpeg
#cd faac
#sh bootstrap
#./configure && make && make install

Compile libmp4v2
#cd /root/ffmpeg
#cd libmp4v2-1.5.0.1
#./configure && make && make install

Compile SDL
#cd /root/ffmpeg
#./configure && make && make install

Compile FAAD2
#cd /root/ffmpeg
#cd faad2
#sh bootstrap
#./configure && make && make install

Compile Xvid
#cd /root/ffmpeg
#cd xvidcore-1.1.2
#cd build
#cd generic
#./configure && make && make install

Compile FFMPEG
#cd  /root/ffmpeg/ffmpeg
# ./configure --enable-libmp3lame --enable-libtheora --enable-libvorbis \
--enable-libfaac --enable-libfaad --disable-mmx --enable-shared \
--enable-libxvid --enable-gpl --enable-nonfree
#make && make install

Export LD Library
#export  LD_LIBRARY_PATH=/usr/local/lib/

Compile FFMPEG-PHP
#cd /root/ffmpeg
#svn co https://ffmpeg-php.svn.sourceforge.net/svnroot/ffmpeg-php ffmpeg-php
#cd /root/ffmpeg/ffmpeg-php/trunk/ffmpeg-php
#/usr/local/bin/phpize
#./configure && make && make install

FFMPEG Result :
# ffmpeg
FFmpeg version SVN-r23145, Copyright (c) 2000-2010 the FFmpeg developers
built on May 16 2010 15:34:44 with gcc 4.3.2 [gcc-4_3-branch revision 141291]
configuration: --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libfaac --enable-libfaad --disable-mmx --enable-shared --enable-libxvid --enable-gpl --enable-nonfree
libavutil     50.15. 2 / 50.15. 2
libavcodec    52.67. 0 / 52.67. 0
libavformat   52.62. 0 / 52.62. 0
libavdevice   52. 2. 0 / 52. 2. 0
libavfilter    1.20. 0 /  1.20. 0
libswscale     0.10. 0 /  0.10. 0
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

# php -i |grep ffmpeg
ffmpeg
ffmpeg-php version => 0.6.3
ffmpeg-php built on => May 16 2010 15:37:44
ffmpeg-php gd support  => enabled
ffmpeg libavcodec version => Lavc52.67.0
ffmpeg libavformat version => Lavf52.62.0
ffmpeg swscaler version => SwS0.10.0
ffmpeg.allow_persistent => 0 => 0
ffmpeg.show_warnings => 0 => 0
OLDPWD => /root/ffmpeg
PWD => /root/ffmpeg/ffmpeg-php/trunk/ffmpeg-php
_SERVER["OLDPWD"] => /root/ffmpeg
_SERVER["PWD"] => /root/ffmpeg/ffmpeg-php/trunk/ffmpeg-php

Configure PHP.ini
#vi /usr/local/lib/php.ini
### add this line below in the end of the php.ini file ###
extension="ffmpeg.so"

Restart Apache Services
#/usr/local/apache2/bin/apachectl stop
#/usr/local/apache2/bin/apachectl start

Result from PHPINFO

.:: ffmpeg result from phpinfo() ::.

source:http://www.wowtutorial.org/tutorial/224.html

0 comments:

Post a Comment