MPlayer下载
http://www.mplayerhq.hu/design7/dload.html
目前版本MPlayer v1.0rc2

MPlayer编译
tar -xjvf MPlayer-1.0rc2.tar.bz2
cd MPlayer-1.0rc2
./configure
make
make install

如果出现以下错误
cabac.h: In function `get_cabac_noinline’:
cabac.h:525: error: can’t find a register in class `GENERAL_REGS’ while reloading `asm’
make[1]: *** [h264.o] 错误 1
在make前加入
export CFLAGS=-fomit-frame-pointer
make clean

ffmpeg的编译大全

1. 首先获取ffmpeg

很多人找不到怎么下载,其实之前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的目录,就是你下载的源代码。

官网:http://ffmpeg.mplayerhq.hu/download.html

我们还不能这么快编译ffmpeg,应该如果要让ffmpeg支持更多格式的转换,还需做一些前期工作

2. 支持mp3,linux当然是lame,下载解压
http://sourceforge.net/projects/lame

lame-3.97.tar.gz Mirror

cd lame-3.97
./configure –enable-shared –prefix=/usr
./make
./make install
这里推荐尽量装在/usr下,默认是装在/usr/local下。这样ffmpeg编译都能顺利的找到库文件

3.支持Ogg Vorbis:
as4自带相应的rpm包,你可以安装一下如下rpm包
libvorbis, libvorbis-devel,libogg, libogg-devel

FC3和FC4應該是預設安裝了有關的library的,實際上要安裝的套件有4個:libvorbis、libvorbis-devel、libogg和libogg-devel。您可以用以下指令檢查一下有沒有。
#rpm -qa | grep libogg
#rpm -qa | grep libvorbis
如果沒有的話,用yum安裝就可以了。
4.支持xvid x264,现在最流行的两种高质量的压缩格式
xvid的编译安装
Get the latest version on http://www.xvid.org/, and uncompress it on
your disk. Let’s name the resulting source directory ${xvidcore}.
wget http://downloads.xvid.org/downloads/xvidcore-1.1.3.tar.gz

The next step allows you to configure the xvid sources.
# cd ${xvidcore}/build/generic
# ./configure

Some building options can be tuned thanks to the ./configure tool. You
can use your own CC and CFLAGS variables in order to override xvid’s
default ones. To have a list of known options:
# ./configure –help

Now xvidcore is configured according to your specific platform. You
can still handwrite the platform.inc file in order to add/remove
specific flags that ./configure may have set them wrong.

It is time to build xvidcore:
# make

That creates a =build directory where all object files go, and where
the build targets are linked. If no error was reported by the build
process, then you can install it on your system:
# make install

This copies the shared and static libraries to the prefix location
passed to the ./configure tool (/usr/local by default). The xvid.h
include file is also copied during the “make install” run.

Voila, xvidcore is installed on your system, make sure your runtime
linker knows about the xvidcore prefix lib dir where it is
installed. And make also sure that it generates a symlink to its
SONAME. In case it would do not take care of the symlink itself:
# cd ${prefix}/lib
# ls libxvidcore.so.*
    ls should list at least one libxvidcore.so.MAJOR.MINOR file
# ln -s libxvidcore.so.MAJOR.MINOR libxvidcore.so.MAJOR

You may also add a .so link to .so.MAJOR, so that applications linked
against .so are in fact linked to .so.MAJOR and thus ensures better
binary compatibility as we take care not changing the MAJOR number
until there is an incompatible ABI change.
# ln -s libxvidcore.so.MAJOR libxvidcore.so

#tar zvxf xvidcore-1.1.2.tar.gz
#cd xvidcore-1.1.2/build/generic/
#./configure –prefix=/usr
#make
#make install
H264/AVC 支援:x264

要壓HQ1080、iPod和PSP的影片,x264是少不了的。不過要安裝x264,就需要用yasm來編譯。那就先裝個yasm吧。
yasm下載網址:http://www.tortall.net/projects/yasm/releases/yasm-0.6.0.tar.gz
最新的 下载:     Source .tar.gz 0.6.2

#tar xzvf yasm-0.6.0.tar.gz
#cd yasm-0.6.0
#./configure –prefix=/usr/local/yasm
#make
#make install
#export PATH=”$PATH:/usr/local/yasm/bin”
#vi /etc/profile
–[在最後,插入]–
export PATH=”$PATH:/usr/local/yasm/bin”
–[存檔並關閉]–

跟ffmpeg一樣,x264的官網也是鼓勵大家 checkout SVN來取得最新版本。但據SupeSite在2007年5月16日的說明指出官網的x264最新版有Bug,無法正常在一些Intel的CPU上編譯安 裝(甚麼雙至強、四至強CPU嘛,是指雙核和四核嗎?)。不過起碼米奇在公司的P4 2.8GHz CPU安裝沒有問題啦,所以…管它。如果您遇上問題的話,就去下載SupeSite的開發公司Comsenz的版本吧,不過先旨聲明,那個改版的授權還是 不是原來的GPL就不知道了。如果您在意於授權的話,那就用SVN checkout吧,我想那問題可能在您安裝時已經修正好了。

x264的获取同样是采用svn方式,看来svn取代cvs不远了
svn co svn://svn.videolan.org/x264/trunk x264
cd x264
./configure –prefix=/usr –enable-shared
make
make install

5.AC3和dts编码的支持
as4系统似乎已经支持ac3编码,编译的时候只要加–enable-a52 –enable-gpl参数就行
現在的ffmpeg又沒附有liba52了,所以,還是自己動手裝吧…
下載網站:http://liba52.sourceforge.net/

# tar zxvf a52dec-0.7.4.tar.gz
# cd a52dec-0.7.4
# ./configure –enable-shared –prefix=/usr
# make
# make install

6.mpg4 aac格式支持,由于服务器还针对手机用户服务,所以,类似aac,mpg4铃声格式的支持,我们也得做。这里我们安装faad2和faac就行
faac是用來壓製AAC音軌的,而faad2就是AAC音軌的解碼器。手機鈴聲和MP4影片都是使用AAC作聲音編碼的,所以要裝這個。
另外,faac和faad2都可以配合libmp4v2來安裝,有些網站說需要先安裝libmp4v2,( http://mpeg4ip.net/)不過米奇就發覺只要編譯faac和faad2時加入適當參數,就可以連同libmp4v2一同安裝了。
下载请到http://www.audiocoding.com/downloads.html

FAAD2的编译
cd faad2
autoreconf -vif
./configure –prefix=/usr –with-mp4v2 –enable-shared
make
make install

faac的编译
cd faac
chmod +x bootstrap
./bootstrap
./configure –prefix=/usr –with-mp4v2 –enable-shared
make
make install
Comsenz版下載網址:http://download.discuz.net/env/video/faac-1.25-Comsenz.tar.bz2

#tar xjvf faac-1.25-Comsenz.tar.bz2
#cd faac-Comsenz
#autoreconf -vif
#./configure –prefix=/usr –with-mp4v2 –enable-shared
#make
#make install

要知道安裝了faac和faad2之後有沒有安裝好libmp4v的話,只要找一找/usr/lib目錄裡有沒有libmp4v2.so等一系列檔案就可以了。找不到的話,就到這裡去下載,安裝好之後再重頭安裝faac和faad2了。

7.支持3gp格式,这也是现在好多手机支持的格式,因为手机用户是我们的主要用户,所以也得支持编译

编译的时候加上–enable-amr_nb –enable-amr_wb参数就行,根据编译系统的提示,所以我们得下载一

些编译3gp所需得文件。

wget http://www.3gpp.org/ftp/Specs/ar … 6.204/26204-510.zip
解压以后把里面的文件都拷贝到libavcodec/amrwb_float

wget http://www.3gpp.org/ftp/Specs/ar … 6.104/26104-510.zip
解压以后把里面的文件都拷贝到libavcodec/amr_float

3GPP AMR Floating point 和 AMR-Wideband支援:libamrnb、libamrwb
3GP影片的影像是h263編碼,而聲音就用AMR-NB或AMR-WB編碼,所以要轉換手機影片,就要安裝AMR程式庫。最初坊間的 安裝方式都是到3GPP官網去下載那些連名字也搞不懂的檔案來,放在ffmpeg裡的指定目錄去跟ffmpeg一同編譯的,但現在已經有人抽取了出來而成 為獨立的程式庫,安裝起來就簡單得多了。
下載網址:http://www.penguin.cz/~utx/amr

libamrnb
#tar xjvf amrnb-7.0.0.0.tar.tar
#cd amrnb-7.0.0.0
#./configure –prefix=/usr –enable-shared
#make
#make install

libamrwb
#tar xjvf amrwb-7.0.0.2.tar.tar
#cd amrwb-7.0.0.2
#./configure –prefix=/usr –enable-shared
#make
#make install

8. DTS 支援:libdca
ffmpeg已經內含了用來解碼DTS的libdca,所以不用安裝,也沒有要入加的參數。

9. 安裝ffmpeg
安裝完成必要的程式庫之後,終於可以動手安裝ffmpeg本體了。如果您先前曾經安裝過ffmpeg的話,就先把ffmpeg的源碼目錄刪掉,再次checkout個新版本回來安裝吧。

#svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk /usr/local/src/ffmpeg
#cd /usr/local/src/ffmpeg
#./configure –prefix=/usr –enable-gpl –enable-shared –enable-libmp3lame –enable-libvorbis –enable-libamr-nb –enable-libamr-wb –enable-libxvid –enable-libx264 –enable-liba52 –enable-liba52bin –enable-libfaac –enable-libfaad –enable-libfaadbin –enable-pp –enable-pthreads –disable-ffserver –disable-ffplay
#make clean && make
#make install

經過可以去看一節動畫的時間編譯之後,你應該可以在/usr/bin目錄裡找到ffmpeg程式。輸入ffmpeg便會列出用了甚麼參數來編譯這個 ffmpeg和它的版本。米奇試過用以這程序來安裝的ffmpeg來編製和解壓3GP、Xvid、mov、wmv9、msmpeg4、MPEG2+AC3 音源、h264+aac音源的mkv、PSP用的MP4和FLV影片,都沒有問題,只有wmv7的影片無法解碼,相信已經對應得到大部份現時流行的影音格 式了。

可以用 ffmpeg -threads [thread_count] -deinterlace -i [input_file] -ac 2 -ab [audio_bitrate] -acodec libfaac -vcodec libx264 -b [video_bitrate] [output_file] 來產生 H.264+AAC 的 mp4 檔案了。