TAG:
2008年5月22日的安装过程记录,修正了网上安装过程的bug
主要参考网址:
http://blog.tianya.cn/blogger/view_blog.asp?BlogID=311462&CategoryID=830616&idWriter=0&Key=0
http://hi.baidu.com/liushui05/blog/item/577f19d83bb3e83432fa1c60.html
http://www.mplayerhq.hu/
这两个软件的安装配置是实现视频网站(flv转码、截图)的关键技术,由于涉及到很多编码库,网上的安装方法都不全面或存在错误,以下是我实验找出的正确安装方法:
安装apache的runtime模块apr和apr-util,这样才能安装svn:
http://apr.apache.org/
先装apr,再装apr-util的时候要用 --with-apr=apr源码路径
安装subversion,这样才能装接下来的软件。
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=apr的源码路径 --with-apr-util=apr-util的源码路径
svn是一个类似cvs的版本管理工具,主要用来从服务器上获取源代码。如果已经有以下软件则不必装svn
subversion 编译时 也可以不必安装apr
安装faad2包:
http://www.audiocoding.com/modules/mydownloads/
解压后如果configure出错,需要如下修改
echo > plugins/Makefile.am
echo > plugins/xmms/src/Makefile.am
sed -i '/E_B/d' configure.in
autoreconf -vif
./configure --prefix=/usr --with-mp4v2 --enable-shared
make
make install
安装faac:
下载地址同上,如果bootstrap出错,需要如下修改(因为Unix格式问题)
sed -i 's/\r//' bootstrap
sed -i 's/\r//' configure.in
./bootstrap
./configure --prefix=/usr --with-mp4v2 --enable-shared
make
make install
安装mp3lame:
http://lame.sourceforge.net/download.php
./configure --enable-shared --prefix=/usr
make
make install
安装xvid,ffmpeg貌似带了的,实际是个wrap
wget 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
make
make install
安装x264
svn co svn://svn.videolan.org/x264/trunk x264
./configure --prefix=/usr --enable-shared
make
make install
安装liba52:
./configure --prefix=/usr --enable-shared
make
make install
http://download.chinaunix.net/download/0006000/5785.shtml
./configure --prefix=/usr --enable-shared
make
make install
3gp支持:在编译ffmpeg加入--enable-amr_nb --enable-amr_wb的时候,会有提示,下载:http://www.3gpp.org/ftp/Sp...,解压的源代码文件以后把里面的文件都拷贝到ffmpeg的源代码目录下libavcodec/amrwb_float;然后下载:http://www.3gpp.org/ftp/Sp...,解压得源代码文件以后把里面的文件都拷贝到ffmpeg解包目录下的libavcodec/amr_float,然后交给ffmpeg编译去做了.
也可以在这里下载这两个包:amrwb_float下载,amr_float下载. 在编译时要加上相应的选项
这个我没有测试通过
最新的办法:
3GP影片的影像是h263編碼,而聲音就用AMR-NB或AMR-WB編碼,所以要轉換手機影片,就要安裝AMR程式庫。最初坊間的安裝方式都是到3GPP官網去下載那些連名字也搞不懂的檔案來,放在ffmpeg裡的指定目錄去跟ffmpeg一同編譯的,但現在已經有人抽取了出來而成為獨立的程式庫,安裝起來就簡單得多了。
下载一个新的amr-nb,amr-wb包,是库文件,不是源码.
amr-wb:http://ftp.penguin.cz/pub/users/utx/amr/amrwb-7.0.0.1.tar.bz2 amr-nb:http://ftp.penguin.cz/pub/users/utx/amr/amrnb-6.1.0.4.tar.bz2 libamrnb
#tar xjvf amrnb-6.1.0.3.tar.bz2 #cd amrnb-6.1.0.3 #./configure --prefix=/usr --enable-shared #make #make install libamrwb
#tar xjvf amrwb-7.0.0.0.tar.bz2 #cd amrwb-7.0.0.0 #./configure --prefix=/usr --enable-shared #make #make install 都装齐了就可以编译ffmpeg:
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
基于2008年5月22日星期四下载 的svn版本 SVN-r13233
./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-pthreads --enable-nonfree
./configure --prefix=/opt/ffmpeg --enable-gpl --enable-shared --enable-libmp3lame --enable-libogg --enable-libvorbis --enable-libxvid --enable-liba52 --enable-liba52bin --enable-pp --enable-libfaad --enable-libfaadbin --enable-libfaac --enable-libx264 --enable-pthreads --disable-ffserver --disable-ffplay
注意:
错误libavformat.so.51: cannot open shared object file的解决方法,
如果没有装在、usr(--prefix=/usr),此错误一般都会出现 > >>Error: h1124192:~/src/ffmpeg_20061208# ffmpeg
> >>ffmpeg: error while loading shared libraries:
> >>libavformat.so.51: cannot
> >>open shared object file: No such file or directory
> >>
#ldconfig -v
查看libs文件的位置,发现没有包括/opt/ffmpeg/lib #vi /etc/ld.so.conf
加入/opt/ffmpeg/lib就是你安装ffmpeg lib的位置 使用的时候很方便,一般来说:
ffmpeg -i 源文件 -o 目标文件 [-codec 编码方式] [-b 码率]就可以了,码率默认200k,编码默认为目标扩展名类型。
下面安装mplayer/mencoder:
注意如果编译安装图像界面需要装Xwindows和gnome开发库,要不通不过编译
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
tar xjvf MPlayer-1.0rc2.tar.bz2
cd MPlayer-1.0rc2
./configure --prefix=/usr/local --enable-gui --enable-largefiles --enable-gif --enable-png --enable-jpeg --language=zh_CN --codecsdir=/usr/lib/codecs/
make make install 安装mencoder需要的codecs:
http://www1.mplayerhq.hu/MPlayer/releases/codecs/
安装到usr/local/lib/codecs
安装Helix DNA Producer
https://helix-producer.helixcommunity.org/downloads
转flv的参数:
mencoder zhou.rm -o ps2.flv -of lavf -oac mp3lame -lameopts abr:br=32:mode=3 -ovc lavc -lavcopts vcodec=flv:vbitrate=150:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -srate 22050 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -vf scale=350:-3 -sws 2
由于producer for Linux只认识uncompress的视频文件,所以转rm要先中转:
mencoder ps2.mpeg -ovc raw -oac pcm -o ps2.avi
producer -i ps2.avi -o ps2.rm
对于ffmpeg,可以将除swf,rmvb,wmav9以外的视频/音频格式转换成flv/mp3,同时可以截取这些视频文件中的某个时间的该帧图片.这些实际上就是一个视频播客显示的部分.对于mencoder,支持各种常见格式的视频/音频转换成flv/mp3.或者转换成avi.
1)ffmpeg篇: ffmpeg的命令行参数因为太多,这里不列出,可以用ffpmeg -h可以查看到.列出非高级参数如下: 引用
Main options:
-L show license -h show help -version show version -formats show available formats, codecs, protocols, ... -f fmt force format -i filename input file name -y overwrite output files -t duration set the recording time -fs limit_size set the limit file size -ss time_off set the start time offset -itsoffset time_off set the input ts offset -title string set the title -timestamp time set the timestamp -author string set the author -copyright string set the copyright -comment string set the comment -album string set the album -v verbose control amount of logging -target type specify target file type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd", "ntsc-svcd", ...) -dframes number set the number of data frames to record -scodec codec force subtitle codec ('copy' to copy stream) -newsubtitle add a new subtitle stream to the current output stream -slang code set the ISO 639 language code (3 letters) of the current subtitle stream Video options: -vframes number set the number of video frames to record -r rate set frame rate (Hz value, fraction or abbreviation) -s size set frame size (WxH or abbreviation) -aspect aspect set aspect ratio (4:3, 16:9 or 1.3333, 1.7777) -croptop size set top crop band size (in pixels) -cropbottom size set bottom crop band size (in pixels) -cropleft size set left crop band size (in pixels) -cropright size set right crop band size (in pixels) -padtop size set top pad band size (in pixels) -padbottom size set bottom pad band size (in pixels) -padleft size set left pad band size (in pixels) -padright size set right pad band size (in pixels) -padcolor color set color of pad bands (Hex 000000 thru FFFFFF) -vn disable video -vcodec codec force video codec ('copy' to copy stream) -sameq use same video quality as source (implies VBR) -pass n select the pass number (1 or 2) -passlogfile file select two pass log file name -newvideo add a new video stream to the current output stream Subtitle options: -scodec codec force subtitle codec ('copy' to copy stream) -newsubtitle add a new subtitle stream to the current output stream -slang code set the ISO 639 language code (3 letters) of the current subtitle stream Audio/Video grab options: -vd device set video grab device -vc channel set video grab channel (DV1394 only) -tvstd standard set television standard (NTSC, PAL (SECAM)) -ad device set audio device -grab format request grabbing using -gd device set grab device Advanced options: -map file :stream[:syncfile :syncstream] set input stream mapping -map_meta_data outfile :infile set meta data information of outfile from infile -benchmark add timings for benchmarking -dump dump each input packet -hex when dumping packets, also dump the payload -re read input at native frame rate -loop_input loop (current only works with images) -loop_output number of times to loop output in formats that support looping (0 loops forever) -threads count thread count -vsync video sync method -async audio sync method -vglobal video global header storage type -copyts copy timestamps -shortest finish encoding within shortest input -dts_delta_threshold timestamp discontinuity delta threshold -ps size set packet size in bits -muxdelay seconds set the maximum demux-decode delay -muxpreload seconds set the initial demux-decode delay 如果这些都明白了,并且有编程基础,你就可以去参与ffmpeg开发了.其实这些堆积起来的命令95%一般是用不上的.这里介绍一些简单的常见的命令: -fromats 显示可用的格式 -f fmt 强迫采用格式fmt -I filename 输入文件 -y 覆盖输出文件 -t duration 设置纪录时间 hh:mm:ss[.xxx]格式的记录时间也支持(截图需要) -ss position 搜索到指定的时间 [-]hh:mm:ss[.xxx]的格式也支持 -title string 设置标题 -author string 设置作者 -copyright string 设置版权 -comment string 设置评论 -target type 设置目标文件类型(vcd,svcd,dvd),所有的格式选项(比特率,编解码以及缓冲区大小)自动设置,只需要输入如下的就可以了:ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg -hq 激活高质量设置 -b bitrate 设置比特率,缺省200kb/s -r fps 设置帧频,缺省25 -s size 设置帧大小,格式为WXH,缺省160X128.下面的简写也可以直接使用:Sqcif 128X96 qcif 176X144 cif 252X288 4cif 704X576 -aspect aspect 设置横纵比 4:3 16:9 或 1.3333 1.7777 -croptop/botton/left/right size 设置顶部切除带大小,像素单位 -padtop/botton/left/right size 设置顶部补齐的大小,像素单位 -padcolor color 设置补齐条颜色(hex,6个16进制的数,红:绿:蓝排列,比如 000000代表黑色) -vn 不做视频记录 -bt tolerance 设置视频码率容忍度kbit/s -maxrate bitrate设置最大视频码率容忍度 -minrate bitreate 设置最小视频码率容忍度 -bufsize size 设置码率控制缓冲区大小 -vcodec codec 强制使用codec编解码方式. 如果用copy表示原始编解码数据必须被拷贝.(很重要) -ab bitrate 设置音频码率 -ar freq 设置音频采样率 -ac channels 设置通道,缺省为1 -an 不使能音频纪录 -acodec codec 使用codec编解码 -vd device 设置视频捕获设备,比如/dev/video0 -vc channel 设置视频捕获通道 DV1394专用 -tvstd standard 设置电视标准 NTSC PAL(SECAM) -dv1394 设置DV1394捕获 -av device 设置音频设备 比如/dev/dsp -map file :stream 设置输入流映射 -debug 打印特定调试信息 -benchmark 为基准测试加入时间 -hex 倾倒每一个输入包 -bitexact 仅使用位精确算法 用于编解码测试 -ps size 设置包大小,以bits为单位 -re 以本地帧频读数据,主要用于模拟捕获设备 -loop 循环输入流。只工作于图像流,用于ffserver测试 |