php在线处理视频 (在线视频转码,取得视频信息)
时间:2010-10-20 来源:liushan
1.创建文件夹
mkdir ~/ffmpeg
cd ~/ffmpeg
2.取得基本要求的源文件
wget http://www.mplayerhq.hu/MPlayer/releases/codecs/all-20100303.tar.bz2
or
wget http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
or
wget http://ftp.de.debian.org/debian/pool/main/f/flvtool2/flvtool2_1.0.6-4.tar.gz
wget http://downloads.sourceforge.net/project/lame/lame/3.98.4/lame-3.98.4.tar.gz
wget http://downloads.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2
wget http://downloads.xiph.org/releases/ogg/libogg-1.2.0.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.1.tar.gz
wget http://www.tortall.net/projects/yasm/releases/yasm-1.1.0.tar.gz
3.解压源文件
bunzip2 all-20100303.tar.bz2; tar xvf all-20100303.tar
or
bunzip2 essential-20071007.tar.bz2; tar xvf essential-20071007.tar.bz2
tar zfvx flvtool2_1.0.6-4.tar.gz
tar zxvf lame-3.98.4.tar.gz
bunzip2 ffmpeg-php-0.6.0.tbz2 ;tar vxf ffmpeg-php-0.6.0.tar
tar zvxf libogg-1.2.0.tar.gz
tar zxvf libvorbis-1.3.1.tar.gz
bunzip2 rpl-4.0.19.tar.bz2; tar vfx rpl-4.0.19.tar
4.创建codecs文件夹并导入
mkdir /usr/local/lib/codecs/
mv all-20100303/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/
5.取得FFMPEG和Mplayer
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
6.编译lame
cd lame-3.98.4
./configure
make
make install
cd ..
7编译libOGG
cd cd libogg-1.2.0
./configure
make
make install
Cd ..
8. 编译libVorbis
cd libvorbis-1.3.1
./configure
make
make install
cd ..
9 编译 flvtool2
cd flvtool2/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
cd ..
10.编译yasm(安装mplayer必须)
tar zfvx yasm-1.1.0.tar.gz
cd yasm-1.1.0
./configure
make
make install
11. 编译mplayer
MPlayer
cd mplayer
./configure
make
make install
cd ..
12. 编译ffmpeg
cd ffmpeg
./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared --enable-yasm
echo '#define HAVE_LRINTF 1' >> config.h
make
make install
cd ..
13.建立链接
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.编译PHP的FFmpeg扩展
cd ffmpeg-php-0.6.0
/usr/local/php/bin/phpize #我的PHPIZE在这里
./configure --with-php-config=/usr/local/php/bin/php-config #我的php-config在这里
make
#可能出现错误:error: ‘PIX_FMT_RGBA32′ undeclared (first use in this function)
#make: *** [ffmpeg_frame.lo] Error 1
#打开文件 “/ffmpeg-php-0.5.0/ffmpeg_frame.c”
# 替换所欲的 PIX_FMT_RGBA32 为 PIX_FMT_RGB32 #vi 命令 :%s/PIX_FMT_RGBA32/PIX_FMT_RGB32/
make install
cd ..
vi /usr/local/php/etc/php.ini
往结尾添加
extension=/usr/local/lib/php/extensions/ no-debug-non-zts-20020429/ffmpeg.so #这个SO的地址根据你的实际的写
#注:根据PHP的配置不同.部分可能直接会自动添加而无需手动
16 重启web 服务,检查是否有ffmpeg 扩展出现
传张我配置完后得到的效果图:
明天把PHP端如何处理补上.