FFmpeg入门(1)-Ubuntu 安装 ffmpeg , 支持MP3,H264编码

本文介绍了如何在Ubuntu上安装FFmpeg,并通过配置支持MP3和H264编码。首先从源码安装libmp3lame和libx264,然后通过配置选项`--enable-libmp3lame`和`--enable-libx264`编译FFmpeg,最后解决依赖问题和设置系统变量,成功实现FFmpeg的编译和转码功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

借用了前人经验,谢谢

http://blog.chinaunix.net/uid-11344913-id-3930867.html


编译支持MP3,H264编码的ffmpeg

ffmpeg原有的系统中支持mp3和h264的解码,但是编码并不支持,所以,需要是应用第三方插件进行支持;

从configure --help可以看出:


点击(此处)折叠或打开

  1. [StevenLiu@liudeMacBook-Pro ffmpeg]$ ./configure --help 
  2.   --enable-libstagefright-h264 enable H.264 decoding via libstagefright [no]
  3.   --enable-libx264 enable H.264 encoding via x264 [no]
  4.  --enable-libmp3lame enable MP3 encoding via libmp3lame [no]


首先系统中需要包含libx264与libmp3lame,这两个lib能够从对应的git中下载得到

MP3编码对应web: http://lame.sourceforge.net/download.php

libx264对应Web: http://www.videolan.org/developers/x264.html

安装mp3编码库


点击(此处)折叠或打开

  1. ./configure
  2. make
  3. make install


安装libx264编码库


点击(此处)折叠或打开

  1. ./configure
  2. make
  3. make install

此处可以改为 ./configure --prefix=/usr/local/x264

以修改安装目录,之后在 /etc/profile 中加入 export PATH="/usr/local/x264/bin:$PATH"

再运行 source /etc/profile

把x264的路径加入到 系统变量里

可以用命令 which x264 测试一下

x264, FFmpeg 的安装都需要yasm支持, 当安装的过程中遇到需要yasm的时候,可以--disabled-yasm,当然,并不建议disabled调,还是安装yasm更好一些

x264需要最新的yasm支持,apt安装的不可用,所以要去官网 http://yasm.tortall.net/Download.html 下载安装


如果需要支持h264与mp3的话,可以使用如下参数进行支持

./configure --enable-libmp3lame --enable-libx264 --enable-gpl

由于libx264的code有GPL信息,所以,支持libx264时,需要--enable-gpl,ffmpeg在license方面还是比我们国内的人更重视

然后make&&make install即编译安装ffmpeg

接下来可以试一下

ok,生成完毕


我使用的配置是

./configure --enable-memalign-hack --enable-ffserver --enable-network --enable-protocols --enable-muxers --disable-yasm --enable-shared --enable-w32threads --enable-libx264 --enable-gpl --extra-cflags=-I/usr/local/x264/include --extra-ldflags=-L/usr/local/x264/lib --prefix=/slq/local/ffmpeg

可以编译,但是没加上--enable-libmp3lame,加上后重新配置编译,我安装了yasm,把这个也打开

./configure--enable-libmp3lame --enable-memalign-hack --enable-ffserver --enable-network --enable-protocols --enable-muxers --enable-yasm --enable-shared --enable-w32threads --enable-libx264 --enable-gpl --extra-cflags=-I/usr/local/x264/include --extra-ldflags=-L/usr/local/x264/lib --prefix=

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值