1、首先vm安装 ubuntu 10 i386 desktop,然后安装一下开发环境和vim:点击打开链接。
2、下载 ffmpeg 源码,这里提供下载地址:点击打开链接
3、这里我放到/opt/目录下,并且解压:# tar xvfj ffmpeg-3.0.tar.bz2,然后进入解压后的文件夹。
4、执行配置信息 # ./configure --enable-shared --prefix=/usr/local/ffmpeg 首先是静态编译,然后是编译之后生成的文件夹路径,这里并没有直接放到 /usr 目录下,是因为方便整体打包。
5、然后编译:# make,再安装:# make install,之后就会在 /usr/local/ffmpeg目录下生成几个文件夹:
其中 bin 目录是ffmpeg的可执行程序,include是头文件,lib 是静态连接时用到的库文件,这时我们可以在当前目录下测试一下:
# bin/ffmpeg -i 2.mp3 -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 a.flv 这里我们把mp3格式转成 flv 格式,成功的话会有如下提示:
ffmpeg version 3.0 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1) configuration: --enable-shared --prefix=/usr/local/ffmpeg libavutil 55. 17.103 / 55. 17.103 libavcodec 57. 24.102 / 57. 24.102 libavformat 57. 25.100 / 57. 25.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 31.100 / 6. 31.100 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 [mp3 @ 0x9f5d280] Skipping 0 bytes of junk at 36866. [mjpeg @ 0x9f64ba0] Changing bps to 8 Input #0, mp3, from '2.mp3': Metadata: title : As Long As You Love Me artist : Backstreet Boys album : Pure... Love album_artist : Various Tagging time : 2011-12-08T17:18:05 TYER : 2011-10-10 Duration: 00:03:31.98, start: 0.025056, bitrate: 321 kb/s Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s Metadata: encoder : LAME3.97 Side data: replaygain: track gain - -6.500000, track peak - unknown, album gain - unknown, album peak - unknown, Stream #0:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 240x240 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn, 90k tbc Metadata: title : e comment : Cover (front) Please use -b:a or -b:v, -b is ambiguous [swscaler @ 0x9f8eba0] deprecated pixel format used, make sure you did set range correctly [flv @ 0x9f83760] Bitrate 500 is extremely low, maybe you mean 500k The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s [adpcm_swf @ 0x9f841e0] Bitrate 56 is extremely low, maybe you mean 56k The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s Output #0, flv, to 'a.flv': Metadata: title : As Long As You Love Me artist : Backstreet Boys album : Pure... Love album_artist : Various Tagging time : 2011-12-08T17:18:05 TYER : 2011-10-10 encoder : Lavf57.25.100 Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 320x240 [SAR 3:4 DAR 1:1], q=2-31, 0 kb/s, 15 fps, 1k tbn, 15 tbc Metadata: title : e comment : Cover (front) encoder : Lavc57.24.102 flv Side data: unknown side data type 10 (24 bytes) Stream #0:1: Audio: adpcm_swf ([1][0][0][0] / 0x0001), 22050 Hz, stereo, s16, 176 kb/s Metadata: encoder : Lavc57.24.102 adpcm_swf Stream mapping: Stream #0:1 -> #0:0 (mjpeg (native) -> flv1 (flv)) Stream #0:0 -> #0:1 (mp3 (native) -> adpcm_swf (native)) Press [q] to stop, [?] for help frame= 1 fps=0.5 q=3.4 Lsize= 4669kB time=00:03:31.95 bitrate= 180.4kbits/s speed= 115x video:11kB audio:4586kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.561890%
6、如果我们要把编译好的程序放到其他版本的linux上使用,我们首先打包这几个文件夹:# tar -zcvf ./ffmpeg.tar.gz ./ffmpeg/ ,然后拷贝到其他机器,解压之后,我们要指定一下静态库文件的路径,添加 # vim /etc/ld.so.conf,如下:
然后再更新一下文件 # ldconfig 。
如果是 用这个32 位操作系统编译生成的 ffmpeg 在64 位的程序上执行,还需要安装一个程序 :yum install glibc.i686,当然ubuntu的就用 apt-get。
7、这里为什么要用ubuntu 10 的32位操作系统来编译,是为了保险起见,这样低版本(ubuntu 8又太低了,就只能用更低版本的 ffmpeg 才行,这里是 3.0 )的程序能在高版本的系统下运行,并且 32 位的程序能在 64 位的操作系统下运行,而反之则不行。(对于已经搭建了复杂环境的系统还是建议配置32位和64位两个版本的,因为软件依赖太多,也会有冲突)