Ffmpeg快速安装
From Ffmpeg工程组
介绍如何获取源码,快速编译到安装整个命令过程
目录 |
[编辑] FFMPEG 和 FFMPEG-PHP 的安装
===软件下载===! FFmpeg 官方主页: http://ffmpeg.sourceforge.net http://ffmpeg.org/
cvs -z9 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg co ffmpeg
FFmpeg-php 官方主页 http://ffmpeg-php.sourceforge.net
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ffmpeg-php login
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ffmpeg-php co ffmpeg-php
Lame 下载地址:http:// www.linuxpackages.net/sea ... ;name=lame&ver=
Apache v2.0.54 官方主页: http://www.apache.org
http://www.apache.org/dist/httpd/httpd-2.0.54.tar.gz
PHP v4.3.11 官方主页: http://www.php.net
http://cn.php.net/distributions/php-5.0.4.tar.gz
GD Library v2.0.33 官方主页: http://www.boutell.com/gd/
http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
FreeType v2.1.10 官方主页: http://www.freetype.org
http:// savannah.nongnu.org/downl ... etype-2.1.10.tar.gz
Jpeg v6b 官方主页: http://www.ijg.org
http://www.ijg.org/files/jpegsrc.v6b.tar.gz
LibPNG v1.2.8 官方主页: http://sourceforge.net/project/showfiles.php?group_id=5624
http:// voxel.dl.sourceforge.net/ ... 1.2.8-config.tar.gz
zlib v1.2.2 官方主页: http://www.gzip.org/zlib/
http://www.zlib.net/zlib-1.2.2.tar.gz
[编辑] 开始安装
- 解压缩
把所有源码压缩包放在一个目录中,解压缩所有 .tar.gz 和 .tar.bz2压缩包
for i in `ls *.gz`;do tar zxvf $i; done;
for i in `ls *.bz2`;do tar jxvf $i; done;
- 安装
##### lame ##### lame-CVS20050706-i686-1jto.tgz解压后 复制lame中./usr/include ./usr/bin ./usr/lib 三个文件夹到服务器对应地方
##### ffmpeg ##### cd ffmpeg ./configure --prefix=/usr/local --enable-memalign-hack --enable-mp3lame --enable-shared make make install cd.. cp -r /usr/local/lib/libav*.so /usr/lib 注: --prefix=/usr/local不得修改,否则ffmpeg-php安装不上 运行/usr/local/bin/ffmpeg –v测试是否安装成功
##### Apache2 ##### cd httpd-2.0.54 ./configure --enable-so --prefix=/server/httpd --with-config-file-path=/server/httpd/conf make make install cd .. 注: 运行/server/httpd/bin/httpd –k start http://192.168.1.xxx测试是否安装成功 测试完后要关闭/server/httpd/bin/httpd –k stop
##### FreeType ##### cd freetype-2.1.10 ./configure --prefix=/usr/local/freetype make make install cd ..
##### LibPNG ##### cd libpng-1.2.8 ./configure --prefix=/usr/local/libpng --enable-shared --enable-static make test make install cd ..
##### Jpeg ##### cd jpeg-6b mkdir /usr/local/jpeg mkdir /usr/local/jpeg/bin mkdir /usr/local/jpeg/lib mkdir /usr/local/jpeg/include mkdir /usr/local/jpeg/man mkdir /usr/local/jpeg/man/man1 ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static make make install cd ..
##### zlib ##### cd zlib-1.2.2 ./configure make make install cd ..
##### GD Library ##### cd gd-2.0.33 ./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-png --with-zlib make make install cd ..
##### ffmpeg-php ##### 按照官方的说法,可以在装php前安装ffmpeg-php 但是我没成功 运行不了phpize 因此此步在装了php后再进行 有点傻
##### PHP ##### cd php-4.3.11 ./configure --prefix=/server/php --with-apxs2=/server/httpd/bin/apxs --with-gd=/usr/local/gd --enable-gd --enable-gd-native- ttf --with-jpeg-dir=/usr/local/jpeg --with-png --with-ttf --with-zlib --with-freetype-dir=/usr/local/freetype --with-config- file-path=/server/httpd/conf make make install cp php.ini-dist /server/httpd/conf/php.ini cd ..
##### ffmpeg-php ##### mv ffmpeg-php /path/to/php_sources/ext/ffmpeg cd /path/to/php_sources autoconf ./configure --prefix=/server/php --with-apxs2=/server/httpd/bin/apxs --with-gd=/usr/local/gd --enable-gd --enable-gd-native- ttf --with-jpeg-dir=/usr/local/jpeg --with-png --with-ttf --with-zlib --with-freetype-dir=/usr/local/freetype --with-config- file-path=/server/httpd/conf --with-ffmpeg=/user/local/include make make install
- 安装完毕
运行 /server/httpd/bin/httpd –k start 测试 <? phpinfo(); ?>
[编辑] 如何使PHP支持ffmpeg(ffmpeg-php模块的安装)
下载ffmpeg安装包地址: http://ffmpeg.mplayerhq.hu/download.html 使用该命令下载ffmpeg: svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg ./configure --enable-share --prefix=/usr make clean && make && make install 下载ffmpeg-php安装包地址: http://ffmpeg-php.sourceforge.net/ tar -xvf ffmpeg-php-0.4.9.tar mv ffmpeg-php-0.4.9 php-4.3.6/ext/ffmpeg cd php-4.3.6/ext/ffmpeg phpize cd /opt/software/php-4.3.6 rm configure ./buildconf –force
第二次编译php,让它支持ffmpeg-php
./configure --with-png-dir=/usr --with-gd --enable-gd-native-ttf --with-ttf --with-freetype --without-gdbm --with-gettext -- with-ncurses --with-gmp --with-iconv --with-jpeg-dir=/usr --with-png --enable-ftp --enable-sockets -with-xml --with-dom -- with-zlib --enable-track-vars --with-mysql --with-apxs2=/usr/local/apache2/bin/apxs --with-ffmpeg=/user/local/include make && make install
加粗为需要注意的地方,路径或参数不同会造成无法加载ffmpeg.so的错误. 错误提示如: Warning: dl(): Not supported in multithreaded Web servers - use extension statements in your php.ini 加粗为需要注意的地方,路径或参数不同会造成无法加载ffmpeg.so的错误. 错误提示如: Warning: dl(): Not supported in multithreaded Web servers - use extension statements in your php.ini
有关该问题的讨论帖可参考ffmpeg工程组论坛中的相关讨论:
FFMPEG 和 FFMPEG-PHP 的安装
[编辑] 获取ffmpeg源代码
This tutorial is about transcoding video fom one codec into another using FFMPEG. I got deeper into FFMPEG when I wanted to transcode into FLV (Flash Video) and it works very well. I developed the Riva FLV Encoder, a GUI for FFMPEG.
Update 26.10.2006: This tutorial is a little outdated as there were many changes in FFMPEG like the switch from CVS to Subversion and the workflow to compile FFMPEG under Windows has become more difficult. For the new tweaks check this tutorial.
- Download MinGW " MSYS current releases (Window Exe Binaries MSYS-1.0.10.exe & MinGW-3.1.0-1.exe)
- Install MinGW
- Install MSYS
- HINT: During the Postinstall be sure to set the right path to MinGW with a "/" instead of a Windows-"". If you did it wrong anyway re-install MSYS to the same directory and do the postinstall right (I missed it a few times)
- Download and compile Lame
- Extract Lame to your MSYS home-directory
- Open MSYS and change to your lame-directory (cd ../lame-XXX)
- Enter the following commands:
./configure //(takes a few minutes) make //(lame is being comiled; takes a few minutes, too) make install
- After installing you will recognize that there are new directories and files in MSYS/local which we will use while compiling ffmpeg with mp3-support
- Download Subversion Client like Tortoise SVN (http://http://tortoisesvn.tigris.org/) and install it
- Check out the sourcecode from svn://svn.mplayerhq.hu/ffmpeg
- Compile FFMPEG
- Change the directory in MSYS to your ffmpeg-directory (cd ../ffmpeg)
- Enter the command:
./configure --enable-memalign-hack --enable-mingw32 --enable-mp3lame --extra-cflags=-I/local/include --extra-ldflags=-L/local/lib
- HINT: you can paste into MSYS by pressing your center mouse-button
- 1. "--enabled-memalign-hack" is a Windows hack. Without this option ffmpeg always crashs with the message "removing common factors from framerate" when encoding AVIs.
- 2. "--enable-mingw32". I see no difference without it but we compile with MinGW and it would not do a harm when ffmpeg knows this
- 3. "--enable-mp3lame": Enable transcoding audio with the open-source mp3-lame-codec
- 4. "--extra-cflags=-I/local/include --extra-ldflags=-L/local/lib": The cflags- and ldflags-parameter sets the right path to your lame-installation which you did in step 3.d.
- Enter command: make (ffmpeg is being compiled; takes a few minutes) With "make install" you could now copy the ffmpeg.exe to c:Program Filesffmpeg. But there is no need to.
[编辑] Use FFMPEG
- Copy your compiled ffmpeg.exe from your MSYS directory to the directory where you like to transcode with ffmpeg
- Open the Dos-Shell and change to the directory where you copied the ffmpeg.exe
- Copy a test.mpg into your directory and enter the following command:
ffmpeg -i test.mpg -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 test.flv
- Your first FLV should be encoded now
[编辑] Render Images from a Video
Enter command:
ffmpeg -an -y -t 0:0:0.001 -i test.flv -f image2 test%d.jpg
- HINT: With -t you set the length of images to be extracted. Above we entered 1 millisecond the extract one image. If you miss this parameter all images of the video will be extracted
[编辑] ZLib Support
(e.g. for TSCC and Quicktime codecs). This should be compiled into FFMPEG. It is not an explicit compile in the configure statement. Do the following steps and after configure you should see that zlib is "on".
- Download and compile ZLib
- Extract the files to your mysys directory
- Change the directory in MSYS to that directory
- Enter command
./confugure make make install.
[编辑] AC3 Support
Add "--enable-a52 --enable-gpl" to your configure command
[编辑] 3GP Support
If you want to enable 3GP support you have to add the AMR audio codec. Download the TS26.104 REL-5 V5.1.0 26104-5??.zip here. Extract the codec into libavcodec/amr_float and add "--enable-amr_nb" to your configure command
[编辑] XVID Support
(thanks to garvin.thornten at datel.co.uk) Download and install the codec from www.xlib.org (see xvidcore-xxxx/doc/install). Add "--enable-xvid --enable-gpl" to your configure command. When compiling with xvid codec in MinGW or cygwin you will get a "mkstemp" error when compiling "xvidff.c". To fix this edit "libavcodec/xvidff.c" and add the following after the #includes. This will probably be fixed in a future ffmpeg release: ´
/* Added for windows compile ----------------- */
#include
int xvid_ff_2pass(void *ref, int opt, void *p1, void *p2); void xvid_correct_framerate(AVCodecContext *avctx);
int mkstemp(char* template)
char temppath[512];
if(GetTempPath(512,temppath)!=0)
{
if(GetTempFileName(temppath,"fil",0,template)!=0)
{
FILE *pFile;
pFile=fopen(template,"w+");
if(pFile!=NULL)
return (int)pFile;
}
}
return -1;
}
/* ------------------------------------------- */
Link about qscale removed "-f singlejpeg" as its identical to "-f mjpeg"
