**************ffmpeg的编译****************
1。首先获取ffmpeg 如果已经获取了ffmpeg的tar包那第一步可以跳过
很多人找不到怎么下载,其实之前ffmpeg可以通过cvs下载,不过最近他已经换成了更加强大的svn
如何使用SVN我这里不再介绍,网上还有大量的安装和使用的文章可以借鉴,这里简单罗列几个SVN辅助的软件:
SubVersion,从 http://subversion.tigris.org/ 下载,支持linux,我们这里就装这个
TortoiseSVN,从 http://tortoisesvn.tigris.org/ 下载,是很不错的SVN客户端程序,为windows外壳程序集成到windows资源管理器和文件管理系统的Subversion客户端,用起来很方便,commit动作变得就像Winrar右键压缩一样方便。
ok,先装subversion,记住最好之前装过apr和apr-util,在apache.org网站能下到
wget http://subversion.tigris.org/downloads/subversion-1.3.2.tar.gz
tar zvxf subversion-1.3.2.tar.gz
cd subversion-1.3.2
./configure --with-apr=/usr/local/apr-httpd --with-apr-util=/usr/local/apr-util-httpd/
make
make install
到此,我们就可以通过svn命令获取最新的ffmpeg了
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
你会发现在你所在的目录,自动出现一个ffmpeg的目录,就是你下载的源代码。
我们还不能这么快编译ffmpeg,应该如果要让ffmpeg支持更多格式的转换,还需做一些前期工作
2.支持mp3,linux当然是lame,下载解压
tar zxvf lame-3.97b3_.tar.gz
cd lame-3.97.1
./configure --prefix=/usr --enable-shared
make
make install
这里推荐尽量装在/usr下,默认是装在/usr/local下。这样ffmpeg编译都能顺利的找到库文件
3.支持Ogg和Vorbis:
as4你可以安装一下如下tar包
libvorbis, libvorbis-devel,libogg, libogg-devel
tar jxvf libvorbis-1.1.1-1-src.tar.bz2
cd libvorbis-1.1.1-1
./configure --prefix=/usr --enable-shared
make
make install
其他的(libvorbis-devel,libogg, libogg-devel这三个tar直接解压就可以了用tar jxvf libvorbis-devel.........)
4.支持xvid x264,现在最流行的两种高质量的压缩格式
xvid的编译安装
下载 http://downloads.xvid.org/downloads/xvidcore-1.1.0.tar.gz
tar zvxf xvidcore-1.1.0.tar.gz
cd xvidcore-1.1.0/build/generic/
./configure --prefix=/usr --enable-shared
make
make install
***在安装X264之前必须安装nasm-0.98.39.tar.bz2 不然X264装不上去***
下载nasm-0.98.39.tar.bz2
tar jxvf nasm-0.98.39.tar.bz2
cd nams-0.98.39
./configure --prefix=/usr --enable-shared
make
make install
下载 x264-snapshot.tar.bz2
tar jxvf x264-snapshot.tar.bz2
cd x264-snapshot.tar.bz2
./configure --prefix=/usr --enable-shared
make
make install
5.AC3和dts编码的支持
as4系统似乎已经支持ac3编码,编译的时候只要加--enable-a52 --enable-gpl参数就行
libdts-0.0.2.tar.gz编译参数
tar zxvf libdts-0.0.2.tar.gz
cd libdts-0.0.2
./configure --prefix=/usr --enable-shared
make
make install
6.mpg4 aac格式支持,由于服务器还针对手机用户服务,所以,类似aac,mpg4铃声格式的支持,我们也得做。这里我们安装faad2和faac就行
下载请到http://www.audiocoding.com/modules/mydownloads/
***先编译FAAD2,然后在编译FAAC。有个先后顺序的***
//////////////////////////FAAD2的编译\\\\\\\\\\\\\\\\\\\\\\\\\\\\
tar zxvf faad2-2.5.tar.gz
cd faad2
在编译FAAD2时可能出现的错误,参照你的错误现象去修改
错误现象:
cd faad2
[root@TServer faad2]# autoreconf -ivf
autoreconf: Entering directory `.'
autoreconf: configure.in: not using Gettext
autoreconf: running: aclocal --force
autoreconf: configure.in: tracing
autoreconf: running: libtoolize --copy --force
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
configure.in: installing `./install-sh'
configure.in: installing `./missing'
common/mp4ff/Makefile.am: installing `./compile'
common/mp4ff/Makefile.am: installing `./depcomp'
plugins/Makefile.am:12: required directory plugins/bmp does not exist
plugins/xmms/src/Makefile.am:2: libdir was already defined in condition TRUE, which includes condition HAVE_BMP ...
configure.in:10: ... `libdir' previously defined here
plugins/xmms/src/Makefile.am:8: libdir was already defined in condition TRUE, which includes condition !HAVE_BMP ...
configure.in:10: ... `libdir' previously defined here
Makefile.am: installing `./INSTALL'
autoreconf: automake failed with exit status: 1
解决方案:
只要把BMP相关的编译条件(一般都是以if-else形式存在的,注意要把整个块都删除)都remove,就好了。
操作如下:
[root@TServer faad2]# cd plugins/
[root@TServer plugins]# grep -lr BMP *
Makefile.am
xmms/src/libmp4.c
xmms/src/Makefile.am
[root@TServer plugins]# vi Makefile.am
if HAVE_MPEG4IP_PLUG
if HAVE_XMMS
SUBDIRS = xmms mpeg4ip
else
SUBDIRS = mpeg4ip
endif #HAVE_XMMS
else
if HAVE_XMMS
SUBDIRS = xmms
else
SUBDIRS =
endif #HAVE_XMMS
endif #HAVE_MPEG4IP_PLUG
~
~
~
~
~
~
~
"Makefile.am" [dos] 13L, 200C 已写入
[root@TServer plugins]# grep -lr BMP *
xmms/src/libmp4.c
xmms/src/Makefile.am
[root@TServer plugins]# vi xmms/src/libmp4.c
/*
* MP4/AAC decoder for xmms
*
* OPTIONNAL need
* --------------
* libid3 (3.8.x - www.id3.org)
*/
#include <pthread.h>
#include <gtk/gtk.h>
#include <stdio.h>
#include <string.h>
#include "neaacdec.h"
#include "mp4ff.h"
#define MP4_DESCRIPTION "MP4 & MPEG2/4-AAC audio player - 1.2.x"
#define MP4_VERSION "ver. 0.5-faad2-version - 22 August 2004"
#define MP4_ABOUT "Written by ciberfred"
#define BUFFER_SIZE FAAD_MIN_STREAMSIZE*64
static void mp4_init(void);
static void mp4_about(void);
static void mp4_play(char *);
static void mp4_stop(void);
"xmms/src/libmp4.c" [dos] 574L, 15762C 已写入
[root@TServer plugins]# ls
in_mp4 Makefile.am mpeg4ip QCD QCDMp4 xmms
[root@TServer plugins]# grep -lr BMP *
xmms/src/Makefile.am
[root@TServer plugins]# vi xmms/src/Makefile.am
if HAVE_BMP
libdir=$(shell pkg-config --variable=input-plugin-dir bmp)
local_CFLAGS=$(shell pkg-config --cflags bmp)
local_LDFLAGS=$(shell pkg-config --libs bmp)
else
local_CFLAGS=`$(XMMS_CONFIG) --cflags` -Wall
local_LDFLAGS=`$(XMMS_CONFIG) --libs`
libdir = `$(XMMS_CONFIG) --input-plugin-dir`
endif #HAVE_BMP
lib_LTLIBRARIES = libmp4.la
libmp4_la_CFLAGS = $(local_CFLAGS) -Wall \
-I$(top_srcdir)/include -I$(top_srcdir)/common/mp4ff
libmp4_la_LIBADD = $(top_builddir)/libfaad/libfaad.la \
$(top_builddir)/common/mp4ff/libmp4ff.la
libmp4_la_LDFLAGS = -module -avoid-version $(local_LDFLAGS) -lpthread
libmp4_la_SOURCES = libmp4.c mp4_utils.c aac_utils.c
~
~
"xmms/src/Makefile.am" [dos] 11L, 373C 已写入
[root@TServer plugins]# cd ..
[root@TServer faad2]# grep -lr BMP *
configure.in
[root@TServer faad2]# vi configure.in
AM_CONDITIONAL([HAVE_BMP], true)
fi
if test x$WITHDRM = xyes; then
AC_DEFINE(DRM, 1, [Define if you want to use libfaad together with Digital Radio Mondiale (DRM)])
AC_DEFINE(DRM_PS, 1, [Define if you want support for Digital Radio Mondiale (DRM) parametric stereo])
fi
AC_CONFIG_FILES(libfaad/Makefile)
AC_CONFIG_FILES(common/Makefile)
AC_CONFIG_FILES(common/mp4ff/Makefile)
AC_CONFIG_FILES(plugins/Makefile)
AC_CONFIG_FILES(plugins/xmms/Makefile)
AC_CONFIG_FILES(plugins/xmms/src/Makefile)
AC_CONFIG_FILES(plugins/mpeg4ip/Makefile)
AC_CONFIG_FILES(faad2.spec)
AC_CONFIG_FILES(frontend/Makefile)
AC_CONFIG_FILES(Makefile)
已查找到文件结尾;再从开头继续查找
AC_PROG_MAKE_SET
AC_CHECK_PROGS(RPMBUILD, rpmbuild, rpm)
AM_CONFIG_HEADER(config.h)
AC_ARG_WITH(xmms,[ --with-xmms compile XMMS-1 plugin],
WITHXMMS=$withval, WITHXMMS=no)
AC_ARG_WITH(drm,[ --with-drm compile libfaad with DRM support],
WITHDRM=$withval, WITHDRM=no)
AC_ARG_WITH(mpeg4ip, [ --with-mpeg4ip compile mpeg4ip plugin],
WITHMPEG4IP=$withval, WITHMPEG4IP=no)
dnl Checks for header files required for mp4.h
AC_HEADER_STDC
AC_CHECK_HEADERS(stdint.h inttypes.h)
AC_CHECK_HEADERS(mathf.h)
AC_CHECK_HEADERS(float.h)
/BMP
fi
AM_CONDITIONAL(HAVE_XMMS, true)
else
AC_MSG_NOTICE(no xmms build configured)
AM_CONDITIONAL(HAVE_XMMS, false)
fi
if test x$WITHDRM = xyes; then
AC_DEFINE(DRM, 1, [Define if you want to use libfaad together with Digital Radio Mondiale (DRM)])
AC_DEFINE(DRM_PS, 1, [Define if you want support for Digital Radio Mondiale (DRM) parametric stereo])
fi
AC_CONFIG_FILES(libfaad/Makefile)AC_CONFIG_FILES(common/Makefile)AC_CONFIG_FILES(common/mp4ff/Makefile)AC_CONFIG_FILES(plugins/Makefile)
AC_CONFIG_FILES(plugins/xmms/Makefile)
"configure.in" [dos] 131L, 3776C 已写入
[root@TServer faad2]# grep -lr BMP *
[root@TServer faad2]# ls
aacDECdrop common faad2.spec.in libfaad README
AUTHORS configure.in frontend Makefile.am README.linux
bootstrap COPYING include NEWS TODO
ChangeLog docs in_mpeg4aac.nsi plugins
[root@TServer faad2]# autoreconf -vir
/usr/bin/autoreconf: unrecognized option `-r'
Try `/usr/bin/autoreconf --help' for more information.
[root@TServer faad2]# autoreconf -vif
autoreconf: Entering directory `.'
autoreconf: configure.in: not using Gettext
autoreconf: running: aclocal --force
autoreconf: configure.in: tracing
autoreconf: running: libtoolize --copy --force
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
configure.in: installing `./install-sh'
configure.in: installing `./missing'
common/mp4ff/Makefile.am: installing `./compile'
common/mp4ff/Makefile.am: installing `./depcomp'
Makefile.am: installing `./INSTALL'
autoreconf: Leaving directory `.'
cd faad2
autoreconf -vif
./configure --prefix=/usr --with-mp4v2 --enable-shared
make
make install
////////////////faac的编译\\\\\\\\\\\\\\\\\\\\\\\\
cd faac
faac-1.25,有两个地方需要修改,一是m4 macro文件,另外一个是需要对文件的格式及权限作一下处理:
错误现象 1:
[root@TServer faac]# autoreconf -vif
autoreconf: Entering directory `.'
autoreconf: configure.in: not using Gettext
autoreconf: running: aclocal --force
configure.in:10: warning: underquoted definition of MY_DEFINE
run info '(automake)Extending aclocal'
or see http://sources.redhat.com/automake/automake.html#Extending-aclocal
autoreconf: configure.in: tracing
autoreconf: running: libtoolize --copy --force
configure.in:10: warning: underquoted definition of MY_DEFINE
run info '(automake)Extending aclocal'
or see http://sources.redhat.com/automake/automake.html#Extending-aclocal
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
autoreconf: Leaving directory `.'
[root@TServer faac]# grep MY_DEFINE *
configure.in:AC_DEFUN(MY_DEFINE, [ AC_DEFINE($1, 1, [define if needed]) ])
configure.in:AC_CHECK_DECL(strcasecmp, MY_DEFINE(HAVE_STRCASECMP))
configure.in: MY_DEFINE(HAVE_LIBMP4V2)
configure.in:AC_CHECK_DECL(strchr, MY_DEFINE(HAVE_STRCHR))
configure.in:AC_CHECK_DECL(memcpy, MY_DEFINE(HAVE_MEMCPY))
configure.in:AC_CHECK_DECL(strsep, MY_DEFINE(HAVE_STRSEP))
解决方案1:
[root@TServer faac]# grep MY_DEFINE *
configure.in:AC_DEFUN(MY_DEFINE, [ AC_DEFINE($1, 1, [define if needed]) ])
configure.in:AC_CHECK_DECL(strcasecmp, MY_DEFINE(HAVE_STRCASECMP))
configure.in: MY_DEFINE(HAVE_LIBMP4V2)
configure.in:AC_CHECK_DECL(strchr, MY_DEFINE(HAVE_STRCHR))
configure.in:AC_CHECK_DECL(memcpy, MY_DEFINE(HAVE_MEMCPY))
configure.in:AC_CHECK_DECL(strsep, MY_DEFINE(HAVE_STRSEP))
把configure.in文件中的AC_DEFUN(MY_DEFINE, [ AC_DEFINE($1, 1, [define if needed]) ])
修改为 AC_DEFUN([MY_DEFINE], [ AC_DEFINE($1, 1, [define if needed]) ])
然后就可以autoreconf -ivf了。
错误现象2:
./configure的时候,会出现以下错误:
configure: creating ./config.status
config.status: creating common/Makefile
config.status: creating common/mp4v2/Makefile
config.status: creating \
.infig.status: error: cannot find input file: \
这个问题是文件的格式问题造成的,可以用一下方法处理:
[root@TServer faac]#find . -type f | xargs dos2unix
[root@TServer faac]#chmod * 777 -R
处理之后,就可以安装了。
chmod +x bootstrap
./bootstrap
./configure --prefix=/usr --with-mp4v2 --enable-shared
make
make install
7.支持3gp格式,这也是现在好多手机支持的格式,所以也得支持编译
编译的时候加上--enable-amr_nb --enable-amr_wb参数就行,根据编译系统的提示,所以我们得下载一
些编译3gp所需得文件。
先在ffmpeg-0.4.9-p20051120/libavcoder/建三个目录
mkdir -p amr
mkdir -p amr_float
mkdir -p amrwb_float
下载http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26073-530_ANSI_C_source_code.zip
解压以后把里面的文件都拷贝到libavcodec/amr
下载http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-530_ANSI-C_source_code.zip
解压以后把里面的文件都拷贝到libavcodec/amrwb_float
下载http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-540_ANSI_C_source_code.zip
解压以后把里面的文件都拷贝到libavcodec/amr_float
修改libavcodec/amr/makefile 找到CFLAGS = -Wall -pedantic-errors -I. $(CFLAGS_$(MODE)) -D$(VAD) 换成CFLAGS = -Wall -I. $(CFLAGS_$(MODE)) -D$(VAD) -DMMS_IO
8.编译ffmpeg-0.4.9-p20051120
tar xvf ffmpeg-0.4.9-p20051120.tar
cd ffmpeg-0.4.9-p20051120
./configure --prefix=/usr --enable-gpl --enable-shared --enable-mp3lame --enable-amr_nb --enable-amr_nb-fixed --enable-amr_wb --enable-amr_if2 --enable-libogg --enable-vorbis --enable-xvid --enable-a52 --enable-a52bin --enable-dts --enable-pp --enable-faad --enable-faadbin --enable-faac --enable-x264 --enable-pthreads --disable-ffserver --disable-ffplay --cpu=CPU
make
make install
小修正一下,如果上面的configure不行,在我的机器上得这样,可能由于版本的关系,
./configure --enable-gpl --enable-nonfree --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-x11grab --prefix=/usr --enable-shared
补充1:
要是说在当在cpu是x86的情况下,不能编译过去,如果你真编译不过去,可以试着加上--cpu=CPU
补充2:
当遇到编译ffmpeg出错时,找到vi ffmpeg/libavcodec/x264.c删除x4->params.rc.b_cbr = 1;这一行
到此,一个ffmpeg编译好了,不过目前管方的ffmpeg还不支持wma9和rmvb,不过网上有很多解决方法。
ffmpeg的转换参数:
ffmpeg -y -i test.mpeg -ac 1 -acodec amr_nb -ar 8000 -s 320x240 -b 128 -r 15 test.3gp
*************************mencoder的编译********************************
mencoder安装篇
1、下载主程序: MPlayer-1.0rc1.tar.bz2
2、下载essential-20061022.tar.bz2,安装:
tar vjxf essential-20061022.tar.bz2
mv essential-20061022 /usr/lib/codes
chmod 644 /usr/lib/codes/*
chown root.root /usr/lib/codes/*
3、下载windows-essential-20061022.zip,安装:
unzip windows-essential-20061022.zip
mv windows-essential-20061022 /usr/lib/wincodes
chmod 644 /usr/lib/wincodes/*
chown root.root /usr/lib/wincodes/*
4、安装mplayer
tar vjxf MPlayer-1.0rc1.tar.bz2
cd MPlayer-1.0rc1
./configure --prefix=/usr --with-codecsdir=/usr/lib/codecs/ --language=zh_CN
make
make install
如果你需要使用mplayer在linux下播放视频,还需要加上--enable-gui(图形界面),不过这样就要安装多很多东西了,这里我们只使用它的mencoder,所以--enable-gui可以省略
mencoder的配置参数:
./configure --prefix=/usr --with-codecsdir=/usr/lib/codecs/ --language=zh_CN
mencoder转换参数:
mencoder /var/www/woyo/image.woyo.com/%inputfile% -o /var/www/woyo/image.woyo.com/%outputfile% -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=300:mbd=2:last_pred=3:dia=2:cmp=3:vb_strategy=1 -sws 3 -vf scale=400:300 -ofps 30 -srate 22050 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames