FFMEPG安装

下载源包目录自定义,不一定按照文档中的路径放置
一、FFMEPG安装前的支持软件包
1、lame 支持mp3
Url:http://sourceforge.net/project/showfiles.php?group_id=290&package_id=309
#####################################
tar -zxvf lame-398.tar.gz
cd lame-398
./configure –enable-shared –prefix=/usr
make && make install
#####################################

2、libogg
Url:http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
###################################
tar xvfz libogg-1.1.3.tar.gz
cd libogg-1.1.3
./configure –prefix=/usr
make && make install
###################################

3、libvorbis
Url:http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz
#####################################
tar xvfz libvorbis-1.1.2.tar.gz
cd libvorbis-1.1.2
./configure –prefix=/usr
make && make install
#####################################

4、xvid 高质量的压缩格式
Url:http://downloads.xvid.org/downloads/xvidcore-1.1.3.tar.gz
#####################################
tar zvxf xvidcore-1.1.3.tar.gz
cd xvidcore-1.1.3/build/generic
./configure –prefix=/usr
make && make install
#####################################

(补充)安裝 yasm yasm-0.7.1.tar.gz
# cd /usr/local/src/video
# wget http://www.tortall.net/projects/yasm/releases/yasm-0.7.1.tar.gz
# tar xzvf yasm-0.7.1.tar.gz
# cd yasm-0.7.1
# ./configure –prefix=/usr
# make && make install

#####################################

5、x264 高质量的压缩格式
x264-snapshot-20080401-2245.tar.bz2 (PS:最新包无法编译成功)
Url:http://www.videolan.org/developers/x264.html
wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20100330-2245.tar.bz2
#####################################
tar xvfj x264-snapshot-20080401-2245.tar.bz2
cd x264-snapshot-20080401-2245
./configure –prefix=/usr –enable-shared
make && make install
#####################################

支持AC3和DTS
6、libdts dts编码的支持

http://download.videolan.org/pub/videolan/libdca/0.0.2/libdca-0.0.2.tar.gz

#####################################
tar zxvf libdca-0.0.2.tar.gz
cd libdts-0.0.2
./configure –prefix=/usr
make && make install
#####################################

7、a52
a52dec-0.7.4.tar.gz

http://liba52.sourceforge.net/downloads.html

Wget http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz
#####################################
tar xvfz a52dec-0.7.4.tar.gz
cd a52dec-0.7.4
./configure –prefix=/usr
make && make install
#####################################

支持MPEG4和AAC
8、faad2
faad2-2.6.1.tar.gz

http://www.audiocoding.com/downloads.html

Wget http://downloads.sourceforge.net/faac/faad2-2.7.tar.gz
#####################################
tar xvfz faad2-2.6.1.tar.gz
cd faad2
autoreconf -vif
./configure –prefix=/usr –with-mp4v2 –enable-shared
make && make install
#####################################

9、faac
faac-1.26.tar.gz

http://linux.softpedia.com/progDownload/FAAC-Download-554.html

wget http://sourceforge.net/projects/faac/files/faac-src/faac-1.28.tar.bz2
#####################################
tar zxvf faac-1.26.tar.gz
cd faac
./bootstrap
./configure –prefix=/usr –with-mp4v2 –enable-shared
make && make install

注: faac在编译过程中或许会遇到以下错误:

make[3]: Entering directory `/root/Downloads/faac-1.28/common/mp4v2'
g++ -DHAVE_CONFIG_H -I. -I../.. -I../../include   -Wall -g -O2 -MT 3gp.o -MD -MP -MF .deps/3gp.Tpo -c -o 3gp.o 3gp.cpp
In file included from mp4common.h:29,
                 from 3gp.cpp:28:
mpeg4ip.h:126: error: new declaration ‘char* strcasestr(const char*, const char*)’
/usr/include/string.h:369: error: ambiguates old declaration ‘const char* strcasestr(const char*, const char*)’
make[3]: *** [3gp.o] Error 1

此时,可以修改文件faac-1.28/common/mp4v2/mpeg4ip.h,如下所示:

修改 extern "C" {

为:extern "C++" {

修改 char *strcasestr(const char *haystack, const char *needle);

为:const char *strcasestr(const char *haystack, const char *needle);

#####################################

支持3gp格式
10、amr-nb
amrnb-6.1.0.4.tar.bz2

http://ftp.penguin.cz/pub/users/utx/amr/amrnb-6.1.0.4.tar.bz2

#####################################
tar xvfj amrnb-6.1.0.4.tar.bz2
cd amrnb-6.1.0.4
./configure –prefix=/usr
make && make install
#####################################

11、amr-wb
amrwb-7.0.0.1.tar.bz2

http://ftp.penguin.cz/pub/users/utx/amr/amrwb-7.0.0.1.tar.bz2

#####################################
tar xvfj amrwb-7.0.0.1.tar.bz2
cd amrwb-7.0.0.1
./configure –prefix=/usr
make && make install
#####################################

二、安装FFMEPG包

http://www.ffmpeg.org/releases/ffmpeg-0.6.tar.gz

tar zxvf ffmpeg-0.6.tar.gz
cd ffmpeg-0.6
./configure –prefix=/usr –enable-gpl –enable-shared –enable-libmp3lame –enable-libvorbis –enable-libx264 –enable-liba52 –enable-liba52bin –enable-libfaac –enable-libfaad –enable-libfaadbin –enable-pthreads –enable-nonfree –disable-ffserver –disable-ffplay

Make && make install

Ldconfig 加载以下动态库,要不可能会抱错

三、转换MP4视频脚本,

01#!/bin/sh
02  
03  infile="test.flv"
04  outfile="test.mp4"
05  options="-vcodec libx264 -b 512k -flags +loop+mv4 -cmp 256 /
06           -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 /
07           -me_method hex -subq 7 -trellis 1 -refs 5 -bf 3 /
08           -flags2 +bpyramid+wpred+mixed_refs+dct8x8 -coder 1 -me_range 16 /
09           -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10/
10           -qmax 51 -qdiff 4"
11  
12  ffmpeg -y -i "$infile" -acodec libfaac -ar 44100 -ab 96k -pass 2 -threads 2 $options "$outfile"

接下来介绍视频选项:
• -b 指定码率注意单位是bit/s,所以我们一般要加k,比如 -b 1000k 就是1000kb/s
• -g 设置组的大小
• -vframes 指定要编码的帧数,比如-vframes 1 就是编码1帧,截图的时候就这样写.
• -r 指定帧率,默认是25
• -s 指定图像分辨率,用wxh的格式,比如320×240
• -aspect 指定宽高比 可以些16:9这种,也可以写小数比如1.3333
• -croptop 指定顶部裁减多少像素,类似的还有-cropleft -cropright -cropbuttom
• -bt 设置比特率容许的误差,默认4000k,在第一阶段时使用这个参数会告诉码率控制器能够偏移平均码率多远,这个选项和最大最小码率无关.设太小了不利于质量
• -maxrate 和-minrate 指定允许的最大和最小码率,一般如果要用cbr模式编码的话会用这个:
ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
否则用处不大
• -vcodec 强制使用某种编码器
• -sameq 使用和源文件相同的质量,这个选项是动态码率的
• -pass 指定编码阶段,这个只有1和2,第一阶段的时候应该不处理音频,并且把输出导向空,比如
音频部分:

• -ar 设置采样频率,默认44100hz
• -ab 设置比特率,默认64k
• -an 禁用音频录制
• -acodec 指定音频编码器
对应解释参照http://www.php-oa.com/2009/03/09/ffmpeg_x264.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值