1. 首先安装系统编译环境
1 yum install -y automake autoconf libtool gcc gcc-c++ #CentOS
编译所需源码包
1 #yasm:汇编器,新版本的ffmpeg增加了汇编代码
2
3 wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
4
5 tar -xzvf yasm-1.3.0.tar.gz
6
7 cd yasm-1.3.0
8
9 ./configure
10
11 make
12
13 make install
14
15
16
17 #lame:Mp3音频解码
18
19 wget http://jaist.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
20
21 tar -xzvf lame-3.99.5.tar.gz
22
23 cd lame-3.99.5
24
25 ./configure
26
27 make
28
29 make install
30
31
32
33 #amr支持
34
35 wget http://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz
36
37 tar -xzvf opencore-amr-0.1.3.tar.gz
38
39 cd opencore-amr-0.1.3
40
41 ./configure
42
43 make
44
45 make install
46
47
48
49 #amrnb支持
50
51 wget http://www.penguin.cz/~utx/ftp/amr/amrnb-11.0.0.0.tar.bz2
52
53 tar -xjvf amrnb-11.0.0.0.tar.bz2
54
55 cd amrnb-11.0.0.0
56
57 ./configure
58
59 make
60
61 make install
62
63
64
65 #amrwb支持
66
67 wget http://www.penguin.cz/~utx/ftp/amr/amrwb-11.0.0.0.tar.bz2
68
69 tar -xjvf amrwb-11.0.0.0.tar.bz2
70
71 cd amrwb-11.0.0.0
72
73 ./configure
74
75 make
76
77 make install
78
79
80
81 #ffmpeg
82
83 wget http://ffmpeg.org/releases/ffmpeg-2.5.3.tar.bz2
84
85 tar -xjvf ffmpeg-2.5.3.tar.bz2
86
87 cd ffmpeg-2.5.3
88
89 ./configure --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-shared
90
91 make
92
93 make install
94
95
96
97 #加载配置
98
99 #最后写入config后,终端运行ffmpeg命令,出现success和已安装的扩展,则运行成功。
100
101 ldconfig
使用方法
ffmpeg -i 1.mp3 -ac 1 -ar 8000 1.amr #MP3转换AMR
2
3 ffmpeg -i 1.amr 1.mp3 #AMR转换MP3
附录:
附录1. ffmpeg默认安装目录为“/usr/local/lib”,有些64位系统下软件目录则为“/usr/lib64”,编译过程中可能会出现
“ffmpeg: error while loading shared libraries: libmp3lame.so.0: cannot open shared object file: No such file or directory”等类似的错误,解决办法是建立软链接:
ln -s /usr/local/lib/libmp3lame.so.0.0.0 /usr/lib64/libmp3lame.so.0
附录2. 如果出现以下提示:ffmpeg: error while loading shared libraries: libavdevice.so.54: cannot open shared object file: No such file or directory
可以通过如下方式查看ffmpeg的动态链接库哪些没有找到:
1 ldd which ffmpeg
2
3 libavdevice.so.54 => not found
4
5 libavfilter.so.3 => not found
6
7 libavformat.so.54 => not found
8
9 libavcodec.so.54 => not found
10
11 libswresample.so.0 => not found
12
13 libswscale.so.2 => not found
14
15 libavutil.so.51 => not found
16
17 libm.so.6 => /lib64/libm.so.6 (0x00002ab7c0eb6000)
18
19 libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ab7c100b000)
20
21 libc.so.6 => /lib64/libc.so.6 (0x00002ab7c1125000)
22
23 /lib64/ld-linux-x86-64.so.2 (0x00002ab7c0d9a000)
24
25 #如果类似于上面的输出内容,查找以上类库,会发现全部在/usr/local/lib/下
26
27 find /usr/local/lib/ | grep -E “libavdevice.so.54|libavfilter.so.3|libavcodec.so.54”
28
29 /usr/local/lib/libavfilter.so.3.17.100
30
31 /usr/local/lib/libavcodec.so.54.59.100
32
33 /usr/local/lib/libavdevice.so.54
34
35 /usr/local/lib/libavcodec.so.54
36
37 /usr/local/lib/libavfilter.so.3
38
39 /usr/local/lib/libavdevice.so.54.2.101
40
41
42
43 #查看链接库配置文件
44
45 more /etc/ld.so.conf | grep /usr/local/lib
46
47 #如果不包含的话,需要编辑此文添加:
48
49 vi /etc/ld.so.conf
50
51 /usr/local/lib
52
53 /usr/local/lib64
54
55 #运行配置命令
56
57 ldconfig