Clipshare'den alınma(ben daha ayrıntılı buldum)
PHP- Kodu:
The following is a guide on how to setup the required modules on your dedicated Linux server. Note that there may be newer versions of the required modules available, than the ones mentioned here.You can check for newer version of the modules at these sites:
Mencoder – Mplayer: http://www3.mplayerhq.hu
FFMPeg-PHP: http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php
LAME: http://easynews.dl.sourceforge.net/sourceforge/lame
Libogg: http://downloads.xiph.org/releases/ogg
LibVorbis: http://downloads.xiph.org/releases/vorbis
1. Login to your server via SSH as the “root” user, using Putty or any other SSH client.
2. Create a directory to download the sources and work in:
mkdir ~/ffmpeg
cd ~/ffmpeg
3. Get all the source files (you may want to check for newer versions, at the URLs mentioned above):
Note: If your "wget" doesn't work, for any reason, you can login to your server as root, with SSH/FTP, using Filezilla or any other FTP client, download the files to your PC and then FTP them to the working directory.
wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/all-20061022.tar.bz2
wget http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget http://downloads.xiph.org/releases/ vorbis/libvorbis-1.1.2.tar.gz
Note: There are other libraries you can get and install, such as libfaad and libxvid, which you can then configure for support in ffmpeg,using the same "--" switches, as in the examples shown below ,for libogg and libvorbis. These libraries will add sound and video support for additional sound formats of the original uploaded videos, when converting.
4. Extract all the source files:
bunzip2 all-20061022.tar.bz2; tar xvf all-20061022.tar
tar zxvf flvtool2_1.0.5_rc6.tgz
tar zxvf lame-3.97.tar.gz
bunzip2 ffmpeg-php-0.5.0.tbz2; tar xvf ffmpeg-php-0.5.0.tar
tar zxvf libogg-1.1.3.tar.gz
tar zxvf libvorbis-1.1.2.tar.gz
5. Create the codecs directory & import them:
mkdir /usr/local/lib/codecs/
mv all-20061022
6. Install SVN/Ruby, using yum. Ruby is needed for the FLVTool2 to run:
yum install subversion
yum install ruby
yum install ncurses-devel
Note: If the installation fails (you will notice that if the compilation of flvtool2 fails), you can check at your /scripts directory for a Cpanel script to install ruby or your Cpanel WHM “Modules" section, for an installation module.
7. Get the latest FFMPEG/MPlayer from the subversion. We need to do that, because any SVN version of this software is always more secure to use, than any other, “unofficial" release (in fact, there are no official releases).
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
8. Compile LAME (LAME is needed to add audio extraction support for FFMpeg, when convering videos). This may take a while:
cd ~/ffmpeg/lame-3.97
./configure
make
make install
9. Compile libOGG. This may take a while:
cd ~/ffmpeg/libogg-1.1.3
./configure
make
make install
10. Compile libVorbis. This may take a while:
cd ~/ffmpeg/libvorbis-1.1.2
./configure
make
make install
11. Compile flvtool2. This may take a while:
cd ~/ffmpeg/flvtool2_1.0.5_rc6
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
12. Compile Mencoder – Mplayer. This may take a while:
cd ~/ffmpeg/mplayer
./configure
make
make install
13. Compile FFMPEG
Before compiling FFmpeg, we need to add the patch for proper sound support in .3gp files:
cd ~/ffmpeg/ffmpeg
Get the amr patch:
wget http://blogger.rukker.org/dl/ffmpeg-0.cvs20060823_enable_amr.patch.bz2
Apply the patch:
bzcat /full_path_to_ffmpeg_and_patch_file_directory/ffmpeg-0.cvs20060823_enable_amr.patch.bz2 | patch -p1
Compile FFmpeg:
./configure --enable-libmp3lame --enable-libogg --enable-libvorbis --disable-mmx --enable-shared
echo '#define HAVE_LRINTF 1' >> config.h
make
make install
14. Finalize the codec setups
ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50
ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51
ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
15. Compile FFMPEG-PHP
cd ~/ffmpeg/ffmpeg-php-0.5.0
phpize
./configure
make
make install 16. Link FFMPEG-PHP to your server's PHP installation. Find your php.ini file (normally located at /urs/local/lib/php) and, at the end, add the line:
extension=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ffmpeg.so
Also remember to edit the extension dir line, in php.ini, to:
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20020429"
Note: This directory may be differnet, you might need to check if the “ffmpeg.so" file exists in that directory.
17. Restart your Apache http server, to load FFMPEG-PHP (Depends on OS, this is for RHEL/CentOS):
service httpd stop
service httpd start
18. Upload a .php file with the code <?php phpinfo(); ?> , in your public_html directory, to check for references to ffmpeg. Visit this file, using your browser. You should see the ffmpeg mentioned and the ligogg and ligvorbis libraries versions installed.
After these, the paths you should get for the modules, to set them up in your site's Administration Area, are:
FFMpeg: /usr/local/bin/ffmpeg
Mplayer: /usr/local/bin/mplayer
Mencoder: /usr/local/bin/mencoder
FLVTool: /usr/bin/flvtool2
You may need to login as root via FTP/SSH, to check for the location of these binaries, using the commands:
which ffmpeg
which mplayer
which mencoder
which flvtool2