现在的位置: 首页 > 操作系统 > 正文

ffmpeg 在ubuntu下的编译安装

2019年03月08日 操作系统 ⁄ 共 2057字 ⁄ 字号 评论关闭

转自:http://shanewfx.github.com/blog/2012/09/24/compile-ffmpeg-on-ubuntu/

登陆ffmpeg官网的下载页面可以得到使用git克隆ffmpeg源代码的地址:

<span class="line-number" style="font-family:inherit;color:#586e75;margin:0px; padding:0px; border:0px;font-size:undefined; font-style:inherit; font-variant:inherit; line-height:inherit; vertical-align:baseline;">1</span>
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg

在ubuntu的shell下,使用上述git命令来下载ffmpeg,下载所需的时间会有点长。

等ffmpeg下载完成,ubuntu上就已经存在了一份完整的ffmpeg源代码了。

下面就可以进行编译ffmpeg了。

编译前我们可以使用下面命令对ffmpeg的源代码进行备份:

<span class="line-number" style="font-family:inherit;color:#586e75;margin:0px; padding:0px; border:0px;font-size:undefined; font-style:inherit; font-variant:inherit; line-height:inherit; vertical-align:baseline;">1</span>
tar czf ffmpeg.tar.gz ffmpeg/

这样就在当前目录下产生一个ffmpeg.tar.gz文件。

在以后需要的时候可以通过下面的命令提取出ffmpeg源代码:

<span class="line-number" style="font-family:inherit;color:#586e75;margin:0px; padding:0px; border:0px;font-size:undefined; font-style:inherit; font-variant:inherit; line-height:inherit; vertical-align:baseline;">1</span>
tar xzf ffmpeg.tar.gz

在编译ffmpeg之前,请先安装好基本的C/C++的编译开发环境,请参考上篇文章

另外,ffmpeg编译时需要使用yasm,如果系统中没有安装,可以通过下面的命令来安装:

<span class="line-number" style="font-family:inherit;color:#586e75;margin:0px; padding:0px; border:0px;font-size:undefined; font-style:inherit; font-variant:inherit; line-height:inherit; vertical-align:baseline;">1</span>
sudo apt-get install yasm

上述的编译工具安装好后,就可开始编译ffmpeg了。

ffmpeg是采用autoconfig和automake等工具自动生成makefile,然后再通过make进行编译,具体的编译的过程如下:

  • 使用./configure产生makefile文件

  • 使用make进行编译

  • 使用make
    install
    将ffmpeg安装到系统中

安装ffmpeg到系统中,需要root权限,在shell下执行下面的命令切换到root账户下:

<span class="line-number" style="font-family:inherit;color:#586e75;margin:0px; padding:0px; border:0px;font-size:undefined; font-style:inherit; font-variant:inherit; line-height:inherit; vertical-align:baseline;">1</span>
sudo -i

根据提示输入root密码,然后还需再次进入到ffmpeg源代码目录中,再执行make
install
即可。

默认是安装在/user/local下,其中:

  • 头文件放在/user/local/include目录下

  • 编译好的libs放在/user/local/lib目录下,其中,在该目录下还有一个pkgconfig目录,里面存放着每个lib的配置文件

  • 编译好的可执行文件(ffmpeg、ffprobe、ffserver)放在/user/local/bin目录下

  • 文档在/user/local/share/man/man1目录下,同时在/user/local有一个指向此目录的链接

抱歉!评论已关闭.