文章目录
- FFmpeg学习(2) 源码编译, 环境配置
- 1. 准备知识
- 1.1 linux基础命令
- 1.1.1 cd:切换目录
- 1.1.2 ls:列出目录下的文件 (List files)
- 1.1.3 mv:移动/重命名 文件或目录 (Move file)
- 1.1.4 mkdir:创建目录(Make directory )
- 1.1.5 cat:显示文件的内容 (Concatenate)
- 1.1.6 find:在指定目录下查找文件
- 1.1.7 pwd:以绝对路径的方式显示用户当前工作目录
- 1.1.8 rm -参数:删除N个文件或整个目录
- 1.1.9 touch:创建新的空文件
- 1.1.10 cp:复制文件/目录(Copy file)
- 1.1.11 vi:修改文件内容
- 1.1.12 echo:创建/覆盖文件
- 1.1.13 tar:文件打包、解压(Tape archive)
- 1.1.14 scp:远程拷贝文件(secure copy)
- 1.1.15 sudo: 管理员权限运行命令
- 1.1.16 pkg-config : 配置环境变量
- 1.2 Vim编辑器
- 2. FFmpeg源码下载
- 3. FFmpeg编译,安装
FFmpeg学习(2) 源码编译, 环境配置
上一篇博客“FFmpeg学习(一)开篇” 中讲解了FFmpeg的源码下载,以及简单的介绍了FFmpeg是什么,学习它的好处,本篇博客主要是针对FFmpeg源码编译,环境变量设置,常用命令进行讲解。
1. 准备知识
1.1 linux基础命令
由于FFmpeg的学习涉及到要在命令行下处理,如果连一下基本的shell命令都不会的话,后面的学习是很吃力的,所以这里简单介绍一下基本的shell命令
必备几个命令如下:
- ls 命令:列出目录下的文件(List files)
- cd 命令:切换目录(Change directory)
- pwd 命令:以绝对路径的方式显示用户当前工作目录
- mkdir 命令:创建目录(Make directory )
- cp 命令:复制文件/目录(Copy file)
- rm 命令:删除N个文件或整个目录
- sudo 命令:管理员权限运行命令
- pkg-config命令:配置环境变量
1.1.1 cd:切换目录
-
cd ~
和cd
:返回用户目录
-
cd .
:停留在当前目录
-
cd ..
:返回上一级目录:
例如我们先跳转到development目录,然后再返回上一级目录
cd ../..
:返回上两级目录:
例如我们先跳转到development/study 目录,然后再返回上两级目录
cd ../目录A
:先返回进入此目录之前所在的目录,然后再进入指定的目录A
下面演示一下 我们先进入development/study目录,然后cd …/projects目录
cd -
:返回进入此目录之前所在的目录
这个命令在我们来回切换两个目录时非常好用
上一步中我们先跳转到development/study
然后切换到了development/projects
目录,当我们输入cd -
命令时,会切换回到development/study
目录。如下图所示:
如果我们再输入cd -
命令时, 会切换回development/projects
目录:
cd 路径
:进入指定目录:
cd /
:返回到根目录:
1.1.2 ls:列出目录下的文件 (List files)
ls
:列出指定路径下的所有文件名、时间及读写权限(文件详细信息)
ls -a
:显示所有文件列表(含隐藏文件“.”和“…”)
ls -A
:显示除隐藏文件“.”和“…”以外的所有文件列表
ls -l
:以列表形式显示文件及文件夹的详细信息
如上图从左至右:文件类型、权限、数量、属主、属组、大小、修改/访问时间、文件名)
1.1.3 mv:移动/重命名 文件或目录 (Move file)
语法:mv 源文件 目标文件
- 目标文件不是目录,即重命名
- 单文件移动(mv 移动前文件 移动后文件路径)
- 多文件移动,使用 -t(含文件及文件夹)
1.1.4 mkdir:创建目录(Make directory )
- 在目录名前没有加任何路径名,则在当前目录下创建
- 在目录名前有一个已经存在的路径,将会在该目录下创建
- 创建多级目录及多文件夹,使用 -p(文件夹之间用空格隔开)
若上层目录没找到,则会一并创建
- 创建带权限的文件夹,使用 -m
如果目录不存在,创建失败,此时需要使用 -p-m
1.1.5 cat:显示文件的内容 (Concatenate)
- 输出多个文件内容
- 将2个文件合并新文件
注:若新文件有内容,则原数据会被清空,因此需要小心操作
- 将file1.txt追加到file2.txt的末尾(>> 表示将文本流追加到另一个文件的末位)
1.1.6 find:在指定目录下查找文件
语法为:find 目录 参数
-
单文件匹配
-
多文件匹配(目录下以.txt结尾的文件、含字母a的文件) : 使用
-o
-
查找除XX外的: **使用 “!” or “-not” **
例如,查找当前文件夹下文件名不含a
find ./ ! -name "*a*"
查找当前目录下 文件不含a的信息 使用 -not
find ./ -maxdepth 1 -not -name "*a*"
- 查找文件,忽略大小写 :使用
-i
- 只查找某层目录下含XX的文件(夹):使用
mindepth
和maxdepth
“-maxdepth 1” :限制只查找1层目录深度,当前目录即为1层
例如查找当前目录下,含test的文件及文件夹
find ./ -maxdepth 1 -name "*test*"
- 查找空文件(-empty)
只列出当前目录下的非隐藏空文件
- 查找指定文件类型的文件 (-type)
查找指定目录下的所有目录-type d
1.1.7 pwd:以绝对路径的方式显示用户当前工作目录
Print working directory
1.1.8 rm -参数:删除N个文件或整个目录
使用rm
命令要格外小心。因为一旦删除了一个文件,就无法再恢复。
建议用-i
选项,删除时会有提示
rm -r(或rm -R)
:删除当前目录下除隐含文件外的所有文件和子目录
rm -(r)f
:强制删除,f 可理解为force
结合find命令删除:
find 目录 -name "*file*" -exec rm -rf {} \;
语法解析
-exec
找到后执行命令
rm -rf {}
就是删除文件
\; 命令
属于格式要求的,没有具体含义
find /app1/ -name "*test*" -exec rm -rf {} \;
1.1.9 touch:创建新的空文件
-
创建单个文件
-
批量创建文件
1.1.10 cp:复制文件/目录(Copy file)
- 默认情况下,cp命令不能复制目录, 如果要复制目录,则必须使用-R选项
注意点:
- 目标目录存在,直接复制
- 目标目录不存在,先自动创建目标目录再复制源目录
- 复制文件
- 复制文件并重命名文件
1.1.11 vi:修改文件内容
先按键盘字母I,编辑内容后,保存(按esc键后输入:wq)
1.1.12 echo:创建/覆盖文件
-
若文件不存在则创建文件
-
若文件存在,覆盖文件原内容并重新输入内容
-
使用 >>,向文件追加内容,原内容不变
1.1.13 tar:文件打包、解压(Tape archive)
- 文件打包:
tar -zcvf 打包名 文件
例如:我们先进入到当前用户的Downloads目录下看看
现在我们要将红框里面的文件压缩成一个tar压缩包
- 文件解压:
tar -zxvf 文件名
1.1.13.1 zip unzip 命令
zip
命令
在mac上面我经常需要压缩成zip
包,命令如下:
zip -q -r -e -m -o file.zip tempFile
zip
后面的参数说明:
-q
:表示不显示压缩进度状态-r
:表示子目录子文件全部压缩为zip;这部分比较重要,不然的话只有tempFile这个文件夹被压缩,里面的没有被压缩进去-e
:表示你的压缩文件需要加密,终端会提示你输入密码的;还有种加密方法,这种是直接在命令行里做的,比如zip -r -P Password01! modudu.zip SomeDir
, 就直接用Password01!来加密modudu.zip了-m
:表示压缩完删除原文件-o
:表示设置所有被压缩文件的最后修改时间为当前压缩时间
当跨目录的时候是这么操作的
zip -q -r -e -m -o '\user\someone\someDir\someFile.zip' '\users\someDir'
下面来演示一下zip命令:
上面的操作将env文件夹压缩成了env_temp.zip并且压缩完成后删除了env文件夹。
-
unzip
命令
语法:unzip
[选项] 压缩文件名.zipunzip
各选项的含义分别为:-x
文件列表 解压缩文件,但不包括指定的file文件-v
查看压缩文件目录,但不解压。-t
测试文件有无损坏,但不解压。-d
目录 把压缩文件解到指定目录下。-z
只显示压缩文件的注解。-n
不覆盖已经存在的文件。-o
覆盖已存在的文件且不要求用户确认。-j
不重建文档的目录结构,把所有文件解压到同一目录下。
将压缩文件env_temp.zip
在当前目录下解压缩。
unzip env_temp.zip
将压缩文件env_temp.zip
在指定目录/tmp
下解压缩,如果已有相同的文件存在,要求unzip
命令不覆盖原先的文件。
$ unzip -n env_temp.zip -d /tmp
此外我们还可以只查看压缩文件目录,但不解压。
输入命令:
$ unzip -v env_temp.zip
1.1.14 scp:远程拷贝文件(secure copy)
- 将本地的文件上传到远程服务器上
相对路径下,scp 文件名 用户名@ip:服务器绝对路径目录 (分号后面无空格)
scp ffmpeg.tar.gz root@30.108.65.136:/app1/tools
绝对路径:
scp /app/software/tools/text.txt root@30.108.65.136:/app1/bak
若是上传目录,需要使用 -r
scp -r /app/software/tools root@30.108.65.136:/app1/bak
- 将远程服务器上的文件/目录拷贝到本地
scp -r 用户名@ip:服务器绝对路径目录 绝对路径本地目录
scp -r root@30.108.65.136:/app1/tools /app/software
scp root@30.108.65.136:/app1/tools/text.txt /app/software/tools
1.1.15 sudo: 管理员权限运行命令
- 简介:
sudo
是linux系统管理指令,是允许系统管理员让普通用户执行一些或者全部的root命令的一个工具,如halt,reboot,su等等。这样不仅减少了root用户的登录 和管理时间,同样也提高了安全性。sudo不是对shell的一个代替,它是面向每个命令的。
- 特性:
(1)
sudo
能够限制用户只在某台主机上运行某些命令。
(2)sudo
提供了丰富的日志,详细地记录了每个用户干了什么。它能够将日志传到中心主机或者日志服务器。
(3)sudo
使用时间戳文件来执行类似的“检票”系统。当用户调用sudo并且输入它的密码时,用户获得了一张存活期为5分钟的票(这个值可以在编译的时候改变)。
(4)sudo
的配置文件是sudoers文件,它允许系统管理员集中的管理用户的使用权限和使用的主机。它所存放的位置默认是在/etc/sudoers,属性必须为0440。
- 命令原理:
sudo
使一般用户不需要知道超级用户的密码即可获得权限。首先超级用户将普通用户的名字、可以执行的特定命令、按照哪种用户或用户组的身份执行等信息,登记在特殊的文件中(通常是/etc/sudoers),即完成对该用户的授权(此时该用户称为“sudoer”);在一般用户需要取得特殊权限时,其可在命令前加上“sudo”,此时sudo将会询问该用户自己的密码(以确认终端机前的是该用户本人),回答后系统即会将该命令的进程以超级用户的权限运行。之后的一段时间内(默认为5分钟,可在/etc/sudoers自定义),使用sudo不需要再次输入密码。
- 语法:
sudo [ -Vhl LvkKsHPSb ] │ [ -p prompt ] [ -c class│- ] [ -a auth_type ] [-u username│#uid ] command
- 参数:
可选参数 | 作用 |
---|---|
-V | 显示版本编号 |
-h | 会显示版本编号及指令的使用方式说明 |
-l | 显示出自己(执行 sudo 的使用者)的权限 |
-v | 因为 sudo 在第一次执行时或是在 N 分钟内没有执行(N 预设为五)会问密码,这个参数是重新做一次确认,如果超过 N 分钟,也会问密码 |
-k | 将会强迫使用者在下一次执行 sudo 时问密码(不论有没有超过 N 分钟) |
-b | 将要执行的指令放在背景执行 |
-p | prompt 可以更改问密码的提示语,其中 %u 会代换为使用者的帐号名称, %h 会显示主机名称 |
-u | username/#uid 不加此参数,代表要以 root 的身份执行指令,而加了此参数,可以以 username 的身份执行指令(#uid 为该 username 的使用者号码) |
-s | 执行环境变数中的 SHELL 所指定的 shell ,或是 /etc/passwd 里所指定的 shell |
-H | 将环境变数中的 HOME (家目录)指定为要变更身份的使用者家目录(如不加 -u 参数就是系统管理者 root ) |
command | 要以系统管理者身份(或以 -u 更改为其他人)执行的指令 |
sudo -i
切换用户身份到root
1.1.16 pkg-config : 配置环境变量
-
pkgconfig有什么用:
大家应该都知道用第三方库,就少不了要使用到第三方的头文件和库文件。我们在编译、链接的时候,必须要指定这些头文件和库文件的位置。
对于一个比较大第三方库,其头文件和库文件的数量是比较多的。如果我们一个个手动地写,那将是相当麻烦的。所以,pkg-config就应运而生了。pkg-config能够把这些头文件和库文件的位置指出来,给编译器使用。如果你的系统装有gtk,可以尝试一下下面的命令 p k g − c o n f i g − − c f l a g s g t k + − 2.0 。 可 以 看 到 其 输 出 是 g t k 的 头 文 件 的 路 径 。 我 们 平 常 都 是 这 样 用 p k g − c o n f i g 的 。 pkg-config --cflags gtk+-2.0。可以看到其输出是gtk的头文件的路径。 我们平常都是这样用pkg-config的。 pkg−config−−cflagsgtk+−2.0。可以看到其输出是gtk的头文件的路径。我们平常都是这样用pkg−config的。gcc main.cpkg-config --cflags --libs gtk+-2.0
-o main
上面的编译命令中,pkg-config --cflags --libs gtk+-2.0
的作用就如前面所说的,把gtk的头文件路径和库文件列出来,让编译去获取。–cflags和–libs分别指定头文件和库文件。
Ps:命令中的`不是引号,而是数字1左边那个键位的那个符号。
其实,pkg-config同其他命令一样,有很多选项,不过我们一般只会用到–libs和–cflags选项。更多的选项可以在这里查看。 -
配置环境变量
首先要明确一点,因为pkg-config也只是一个命令,所以不是你安装了一个第三方的库,pkg-config就能知道第三方库的头文件和库文件所在的位置。pkg-config命令是通过查询XXX.pc文件而知道这些的。我们所需要做的是,写一个属于自己的库的.pc文件。
但pkg-config又是如何找到所需的.pc文件呢?这就需要用到一个环境变量PKG_CONFIG_PATH了。这环境变量写明.pc文件的路径,pkg-config命令会读取这个环境变量的内容,这样就知道pc文件了。
对于Ubuntu系统,可以用root权限打开/etc/bash.bashrc文件。在最后输入下面的内容。
这样,pkg-config就会去/usr/local/lib/pkgconfig目录下,寻找.pc文件了。如果不是Ubuntu系统,那就没有/etc/bash.bashrc文件,可以参考我的一篇博文,来找到一个合适的文件,修改这个环境变量。输入bash命令使得配置生效。
现在pkg-config能找到我们的.pc文件。但如果有多个.pc文件,那么pkg-config又怎么能正确找到我想要的那个呢?这就需要我们在使用pkg-config命令的时候去指定。比如$gcc main.cpkg-config --cflags --libs gtk+-2.0
-o main就指定了要查找的.pc文件是gtk±2.0.pc。又比如,有第三方库OpenCV,而且其对应的pc文件为opencv.pc,那么我们在使用的时候,就要这样写pkg-config --cflags --libs opencv
。这样,pkg-config才会去找opencv.pc文件。
*.pc
文件的编写:
首先要明确一点,因为pkg-config也只是一个命令,所以不是你安装了一个第三方的库,pkg-config就能知道第三方库的头文件和库文件所在的位置。pkg-config命令是通过查询XXX.pc文件而知道这些的。我们所需要做的是,写一个属于自己的库的.pc文件。
如下展示hyperscan开源库中的libhs.pc文件的撰写:
[root@localhost pkgconfig]# ls
libhs.pc
[root@localhost pkgconfig]#
[root@localhost pkgconfig]#
[root@localhost pkgconfig]# cat libhs.pc
prefix=/usr/local
exec_prefix=/usr/local
libdir=/usr/local/lib
includedir=/usr/local/include
Name: libhs
Description: Intel(R) Hyperscan Library
Version: 4.5.0
Libs: -L${libdir} -lhs
Libs.private: -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
Cflags: -I${includedir}/hs
[root@localhost pkgconfig]#
- 设置
pkg-config
的环境变量:
pkg-config又是如何找到所需的.pc文件呢?这就需要用到一个环境变量PKG_CONFIG_PATH了。这环境变量写明.pc文件的路径,pkg-config命令会读取这个环境变量的内容,这样就知道pc文件了。
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
将环境变量增加到.bashrc脚本文件中:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib64/pkgconfig
export PKG_CONFIG_PATH
source .bashrc
- pkg-config的查询结果:
[root@localhost pkgconfig]# pkg-config --cflags --libs libhs
-I/usr/local/include/hs -L/usr/local/lib -lhs
[root@localhost pkgconfig]#
- 在脚本和编译的命令行中使用pkg-config的查询结果:
[root@localhost examples]# g++ -o simplegrep simplegrep.c $(pkg-config --cflags --libs libhs)
[root@localhost examples]#
[root@localhost examples]# echo $(pkg-config --cflags --libs libhs)
-I/usr/local/include/hs -L/usr/local/lib -lhs
[root@localhost examples]# ls
CMakeFiles CMakeLists.txt patbench.cc README.md simplegrep.c
cmake_install.cmake Makefile pcapscan.cc simplegrep
[root@localhost examples]#
1.2 Vim编辑器
Vim是从 vi 发展出来的一个文本编辑器。代码补完、编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用。
简单的来说, vi 是老式的字处理器,不过功能已经很齐全了,但是还是有可以进步的地方。 vim 则可以说是程序开发者的一项很好用的工具。
连 vim 的官方网站 (http://www.vim.org) 自己也说 vim 是一个程序开发工具而不是文字处理软件。
如果你熟练了Vim后,你的工作效率会大大提高,就像你学会了五笔去打汉字一样。
下面有一种业界广为流传的vim键盘图:
基本上 vi/vim 共分为三种模式,分别是命令模式(Command mode),输入模式(Insert mode)和底线命令模式(Last line mode)。 这三种模式的作用分别是:
esc
:切换到到命令模式i
: 切换到输入模式/编辑模式:
:切换到底线命令模式
q
退出程序w
保存文件qi
强制退出
这三种模式之间的关系如下图:
2. FFmpeg源码下载
FFmpeg源码下载肯定是优先去官网下载:官网 http://ffmpeg.org/download.html
打开官网如下:
可以选择直接下载,或者git命令直接克隆一份,作为开发人员一般都喜欢选择git克隆的方式,这样方便后续更新。
3. FFmpeg编译,安装
3.1 在Mac下编译安装FFmpeg
3.1.1 brew 方式安装
在mac下面可以很方便的使用brew install ffmpeg
命令直接安装ffmpeg,如果是新手这样安装比较方便快捷,但是这么安装有个弊端就是不能定制化,如果随着你对FFmpeg的深入,你需要使用一些其他的工具,就需要手动编译安装了,通过源码编译的方式,我们可以自己选择定制化。
我们可以先输入brew search ffmpeg
3.1.2 源码编译 方式安装
首先需要下载ffmpeg, 从官网http://ffmpeg.org/download.html下载
然后是编译ffmpeg 只需要执行下面3条命令即可:
./configure -prefix=/usr/local/ffmpeg -enable-debug=3
make -j 4
make install
接下来我们分别执行这3条语句:
- 执行
./configure --prefix=/usr/local/ffmpeg --enable-debug=3
一般我们默认安装在/usr/local/ffmpeg
路径下,这个路径可以自由设定,这里我们需要开启debug功能,后面要用到
我们下看看我们下载好的源码目录
你也可以使用./configure --help
来查看怎么配置
会打印如下所有选项:
Usage: configure [options]
Options: [defaults in brackets after descriptions]
Help options:
--help print this message
--quiet Suppress showing informative output
--list-decoders show all available decoders
--list-encoders show all available encoders
--list-hwaccels show all available hardware accelerators
--list-demuxers show all available demuxers
--list-muxers show all available muxers
--list-parsers show all available parsers
--list-protocols show all available protocols
--list-bsfs show all available bitstream filters
--list-indevs show all available input devices
--list-outdevs show all available output devices
--list-filters show all available filters
Standard options:
--logfile=FILE log tests and output to FILE [ffbuild/config.log]
--disable-logging do not log configure debug information
--fatal-warnings fail if any configure warning is generated
--prefix=PREFIX install in PREFIX [/usr/local]
--bindir=DIR install binaries in DIR [PREFIX/bin]
--datadir=DIR install data files in DIR [PREFIX/share/ffmpeg]
--docdir=DIR install documentation in DIR [PREFIX/share/doc/ffmpeg]
--libdir=DIR install libs in DIR [PREFIX/lib]
--shlibdir=DIR install shared libs in DIR [LIBDIR]
--incdir=DIR install includes in DIR [PREFIX/include]
--mandir=DIR install man page in DIR [PREFIX/share/man]
--pkgconfigdir=DIR install pkg-config files in DIR [LIBDIR/pkgconfig]
--enable-rpath use rpath to allow installing libraries in paths
not part of the dynamic linker search path
use rpath when linking programs (USE WITH CARE)
--install-name-dir=DIR Darwin directory name for installed targets
Licensing options:
--enable-gpl allow use of GPL code, the resulting libs
and binaries will be under GPL [no]
--enable-version3 upgrade (L)GPL to version 3 [no]
--enable-nonfree allow use of nonfree code, the resulting libs
and binaries will be unredistributable [no]
Configuration options:
--disable-static do not build static libraries [no]
--enable-shared build shared libraries [no]
--enable-small optimize for size instead of speed
--disable-runtime-cpudetect disable detecting CPU capabilities at runtime (smaller binary)
--enable-gray enable full grayscale support (slower color)
--disable-swscale-alpha disable alpha channel support in swscale
--disable-all disable building components, libraries and programs
--disable-autodetect disable automatically detected external libraries [no]
Program options:
--disable-programs do not build command line programs
--disable-ffmpeg disable ffmpeg build
--disable-ffplay disable ffplay build
--disable-ffprobe disable ffprobe build
Documentation options:
--disable-doc do not build documentation
--disable-htmlpages do not build HTML documentation pages
--disable-manpages do not build man documentation pages
--disable-podpages do not build POD documentation pages
--disable-txtpages do not build text documentation pages
Component options:
--disable-avdevice disable libavdevice build
--disable-avcodec disable libavcodec build
--disable-avformat disable libavformat build
--disable-swresample disable libswresample build
--disable-swscale disable libswscale build
--disable-postproc disable libpostproc build
--disable-avfilter disable libavfilter build
--enable-avresample enable libavresample build (deprecated) [no]
--disable-pthreads disable pthreads [autodetect]
--disable-w32threads disable Win32 threads [autodetect]
--disable-os2threads disable OS/2 threads [autodetect]
--disable-network disable network support [no]
--disable-dct disable DCT code
--disable-dwt disable DWT code
--disable-error-resilience disable error resilience code
--disable-lsp disable LSP code
--disable-lzo disable LZO decoder code
--disable-mdct disable MDCT code
--disable-rdft disable RDFT code
--disable-fft disable FFT code
--disable-faan disable floating point AAN (I)DCT code
--disable-pixelutils disable pixel utils in libavutil
Individual component options:
--disable-everything disable all components listed below
--disable-encoder=NAME disable encoder NAME
--enable-encoder=NAME enable encoder NAME
--disable-encoders disable all encoders
--disable-decoder=NAME disable decoder NAME
--enable-decoder=NAME enable decoder NAME
--disable-decoders disable all decoders
--disable-hwaccel=NAME disable hwaccel NAME
--enable-hwaccel=NAME enable hwaccel NAME
--disable-hwaccels disable all hwaccels
--disable-muxer=NAME disable muxer NAME
--enable-muxer=NAME enable muxer NAME
--disable-muxers disable all muxers
--disable-demuxer=NAME disable demuxer NAME
--enable-demuxer=NAME enable demuxer NAME
--disable-demuxers disable all demuxers
--enable-parser=NAME enable parser NAME
--disable-parser=NAME disable parser NAME
--disable-parsers disable all parsers
--enable-bsf=NAME enable bitstream filter NAME
--disable-bsf=NAME disable bitstream filter NAME
--disable-bsfs disable all bitstream filters
--enable-protocol=NAME enable protocol NAME
--disable-protocol=NAME disable protocol NAME
--disable-protocols disable all protocols
--enable-indev=NAME enable input device NAME
--disable-indev=NAME disable input device NAME
--disable-indevs disable input devices
--enable-outdev=NAME enable output device NAME
--disable-outdev=NAME disable output device NAME
--disable-outdevs disable output devices
--disable-devices disable all devices
--enable-filter=NAME enable filter NAME
--disable-filter=NAME disable filter NAME
--disable-filters disable all filters
External library support:
Using any of the following switches will allow FFmpeg to link to the
corresponding external library. All the components depending on that library
will become enabled, if all their other dependencies are met and they are not
explicitly disabled. E.g. --enable-libwavpack will enable linking to
libwavpack and allow the libwavpack encoder to be built, unless it is
specifically disabled with --disable-encoder=libwavpack.
Note that only the system libraries are auto-detected. All the other external
libraries must be explicitly enabled.
Also note that the following help text describes the purpose of the libraries
themselves, not all their features will necessarily be usable by FFmpeg.
--disable-alsa disable ALSA support [autodetect]
--disable-appkit disable Apple AppKit framework [autodetect]
--disable-avfoundation disable Apple AVFoundation framework [autodetect]
--enable-avisynth enable reading of AviSynth script files [no]
--disable-bzlib disable bzlib [autodetect]
--disable-coreimage disable Apple CoreImage framework [autodetect]
--enable-chromaprint enable audio fingerprinting with chromaprint [no]
--enable-frei0r enable frei0r video filtering [no]
--enable-gcrypt enable gcrypt, needed for rtmp(t)e support
if openssl, librtmp or gmp is not used [no]
--enable-gmp enable gmp, needed for rtmp(t)e support
if openssl or librtmp is not used [no]
--enable-gnutls enable gnutls, needed for https support
if openssl, libtls or mbedtls is not used [no]
--disable-iconv disable iconv [autodetect]
--enable-jni enable JNI support [no]
--enable-ladspa enable LADSPA audio filtering [no]
--enable-libaom enable AV1 video encoding/decoding via libaom [no]
--enable-libaribb24 enable ARIB text and caption decoding via libaribb24 [no]
--enable-libass enable libass subtitles rendering,
needed for subtitles and ass filter [no]
--enable-libbluray enable BluRay reading using libbluray [no]
--enable-libbs2b enable bs2b DSP library [no]
--enable-libcaca enable textual display using libcaca [no]
--enable-libcelt enable CELT decoding via libcelt [no]
--enable-libcdio enable audio CD grabbing with libcdio [no]
--enable-libcodec2 enable codec2 en/decoding using libcodec2 [no]
--enable-libdav1d enable AV1 decoding via libdav1d [no]
--enable-libdavs2 enable AVS2 decoding via libdavs2 [no]
--enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
and libraw1394 [no]
--enable-libfdk-aac enable AAC de/encoding via libfdk-aac [no]
--enable-libflite enable flite (voice synthesis) support via libflite [no]
--enable-libfontconfig enable libfontconfig, useful for drawtext filter [no]
--enable-libfreetype enable libfreetype, needed for drawtext filter [no]
--enable-libfribidi enable libfribidi, improves drawtext filter [no]
--enable-libglslang enable GLSL->SPIRV compilation via libglslang [no]
--enable-libgme enable Game Music Emu via libgme [no]
--enable-libgsm enable GSM de/encoding via libgsm [no]
--enable-libiec61883 enable iec61883 via libiec61883 [no]
--enable-libilbc enable iLBC de/encoding via libilbc [no]
--enable-libjack enable JACK audio sound server [no]
--enable-libklvanc enable Kernel Labs VANC processing [no]
--enable-libkvazaar enable HEVC encoding via libkvazaar [no]
--enable-liblensfun enable lensfun lens correction [no]
--enable-libmodplug enable ModPlug via libmodplug [no]
--enable-libmp3lame enable MP3 encoding via libmp3lame [no]
--enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
--enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
--enable-libopencv enable video filtering via libopencv [no]
--enable-libopenh264 enable H.264 encoding via OpenH264 [no]
--enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no]
--enable-libopenmpt enable decoding tracked files via libopenmpt [no]
--enable-libopus enable Opus de/encoding via libopus [no]
--enable-libpulse enable Pulseaudio input via libpulse [no]
--enable-librabbitmq enable RabbitMQ library [no]
--enable-librav1e enable AV1 encoding via rav1e [no]
--enable-librsvg enable SVG rasterization via librsvg [no]
--enable-librubberband enable rubberband needed for rubberband filter [no]
--enable-librtmp enable RTMP[E] support via librtmp [no]
--enable-libshine enable fixed-point MP3 encoding via libshine [no]
--enable-libsmbclient enable Samba protocol via libsmbclient [no]
--enable-libsnappy enable Snappy compression, needed for hap encoding [no]
--enable-libsoxr enable Include libsoxr resampling [no]
--enable-libspeex enable Speex de/encoding via libspeex [no]
--enable-libsrt enable Haivision SRT protocol via libsrt [no]
--enable-libssh enable SFTP protocol via libssh [no]
--enable-libtensorflow enable TensorFlow as a DNN module backend
for DNN based filters like sr [no]
--enable-libtesseract enable Tesseract, needed for ocr filter [no]
--enable-libtheora enable Theora encoding via libtheora [no]
--enable-libtls enable LibreSSL (via libtls), needed for https support
if openssl, gnutls or mbedtls is not used [no]
--enable-libtwolame enable MP2 encoding via libtwolame [no]
--enable-libv4l2 enable libv4l2/v4l-utils [no]
--enable-libvidstab enable video stabilization using vid.stab [no]
--enable-libvmaf enable vmaf filter via libvmaf [no]
--enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no]
--enable-libvorbis enable Vorbis en/decoding via libvorbis,
native implementation exists [no]
--enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no]
--enable-libwavpack enable wavpack encoding via libwavpack [no]
--enable-libwebp enable WebP encoding via libwebp [no]
--enable-libx264 enable H.264 encoding via x264 [no]
--enable-libx265 enable HEVC encoding via x265 [no]
--enable-libxavs enable AVS encoding via xavs [no]
--enable-libxavs2 enable AVS2 encoding via xavs2 [no]
--enable-libxcb enable X11 grabbing using XCB [autodetect]
--enable-libxcb-shm enable X11 grabbing shm communication [autodetect]
--enable-libxcb-xfixes enable X11 grabbing mouse rendering [autodetect]
--enable-libxcb-shape enable X11 grabbing shape rendering [autodetect]
--enable-libxvid enable Xvid encoding via xvidcore,
native MPEG-4/Xvid encoder exists [no]
--enable-libxml2 enable XML parsing using the C library libxml2, needed
for dash demuxing support [no]
--enable-libzimg enable z.lib, needed for zscale filter [no]
--enable-libzmq enable message passing via libzmq [no]
--enable-libzvbi enable teletext support via libzvbi [no]
--enable-lv2 enable LV2 audio filtering [no]
--disable-lzma disable lzma [autodetect]
--enable-decklink enable Blackmagic DeckLink I/O support [no]
--enable-mbedtls enable mbedTLS, needed for https support
if openssl, gnutls or libtls is not used [no]
--enable-mediacodec enable Android MediaCodec support [no]
--enable-libmysofa enable libmysofa, needed for sofalizer filter [no]
--enable-openal enable OpenAL 1.1 capture support [no]
--enable-opencl enable OpenCL processing [no]
--enable-opengl enable OpenGL rendering [no]
--enable-openssl enable openssl, needed for https support
if gnutls, libtls or mbedtls is not used [no]
--enable-pocketsphinx enable PocketSphinx, needed for asr filter [no]
--disable-sndio disable sndio support [autodetect]
--disable-schannel disable SChannel SSP, needed for TLS support on
Windows if openssl and gnutls are not used [autodetect]
--disable-sdl2 disable sdl2 [autodetect]
--disable-securetransport disable Secure Transport, needed for TLS support
on OSX if openssl and gnutls are not used [autodetect]
--enable-vapoursynth enable VapourSynth demuxer [no]
--enable-vulkan enable Vulkan code [no]
--disable-xlib disable xlib [autodetect]
--disable-zlib disable zlib [autodetect]
The following libraries provide various hardware acceleration features:
--disable-amf disable AMF video encoding code [autodetect]
--disable-audiotoolbox disable Apple AudioToolbox code [autodetect]
--enable-cuda-nvcc enable Nvidia CUDA compiler [no]
--disable-cuda-llvm disable CUDA compilation using clang [autodetect]
--disable-cuvid disable Nvidia CUVID support [autodetect]
--disable-d3d11va disable Microsoft Direct3D 11 video acceleration code [autodetect]
--disable-dxva2 disable Microsoft DirectX 9 video acceleration code [autodetect]
--disable-ffnvcodec disable dynamically linked Nvidia code [autodetect]
--enable-libdrm enable DRM code (Linux) [no]
--enable-libmfx enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no]
--enable-libnpp enable Nvidia Performance Primitives-based code [no]
--enable-mmal enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no]
--disable-nvdec disable Nvidia video decoding acceleration (via hwaccel) [autodetect]
--disable-nvenc disable Nvidia video encoding code [autodetect]
--enable-omx enable OpenMAX IL code [no]
--enable-omx-rpi enable OpenMAX IL code for Raspberry Pi [no]
--enable-rkmpp enable Rockchip Media Process Platform code [no]
--disable-v4l2-m2m disable V4L2 mem2mem code [autodetect]
--disable-vaapi disable Video Acceleration API (mainly Unix/Intel) code [autodetect]
--disable-vdpau disable Nvidia Video Decode and Presentation API for Unix code [autodetect]
--disable-videotoolbox disable VideoToolbox code [autodetect]
Toolchain options:
--arch=ARCH select architecture []
--cpu=CPU select the minimum required CPU (affects
instruction selection, may crash on older CPUs)
--cross-prefix=PREFIX use PREFIX for compilation tools []
--progs-suffix=SUFFIX program name suffix []
--enable-cross-compile assume a cross-compiler is used
--sysroot=PATH root of cross-build tree
--sysinclude=PATH location of cross-build system headers
--target-os=OS compiler targets OS []
--target-exec=CMD command to run executables on target
--target-path=DIR path to view of build directory on target
--target-samples=DIR path to samples directory on target
--tempprefix=PATH force fixed dir/prefix instead of mktemp for checks
--toolchain=NAME set tool defaults according to NAME
(gcc-asan, clang-asan, gcc-msan, clang-msan,
gcc-tsan, clang-tsan, gcc-usan, clang-usan,
valgrind-massif, valgrind-memcheck,
msvc, icl, gcov, llvm-cov, hardened)
--nm=NM use nm tool NM [nm -g]
--ar=AR use archive tool AR [ar]
--as=AS use assembler AS []
--ln_s=LN_S use symbolic link tool LN_S [ln -s -f]
--strip=STRIP use strip tool STRIP [strip]
--windres=WINDRES use windows resource compiler WINDRES [windres]
--x86asmexe=EXE use nasm-compatible assembler EXE [nasm]
--cc=CC use C compiler CC [gcc]
--cxx=CXX use C compiler CXX [g++]
--objcc=OCC use ObjC compiler OCC [gcc]
--dep-cc=DEPCC use dependency generator DEPCC [gcc]
--nvcc=NVCC use Nvidia CUDA compiler NVCC or clang []
--ld=LD use linker LD []
--pkg-config=PKGCONFIG use pkg-config tool PKGCONFIG [pkg-config]
--pkg-config-flags=FLAGS pass additional flags to pkgconf []
--ranlib=RANLIB use ranlib RANLIB [ranlib]
--doxygen=DOXYGEN use DOXYGEN to generate API doc [doxygen]
--host-cc=HOSTCC use host C compiler HOSTCC
--host-cflags=HCFLAGS use HCFLAGS when compiling for host
--host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host
--host-ld=HOSTLD use host linker HOSTLD
--host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
--host-extralibs=HLIBS use libs HLIBS when linking for host
--host-os=OS compiler host OS []
--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS []
--extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS []
--extra-objcflags=FLAGS add FLAGS to OBJCFLAGS []
--extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS []
--extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS []
--extra-ldsoflags=ELDFLAGS add ELDFLAGS to LDSOFLAGS []
--extra-libs=ELIBS add ELIBS []
--extra-version=STRING version string suffix []
--optflags=OPTFLAGS override optimization-related compiler flags
--nvccflags=NVCCFLAGS override nvcc flags []
--build-suffix=SUFFIX library name suffix []
--enable-pic build position-independent code
--enable-thumb compile for Thumb instruction set
--enable-lto use link-time optimization
--env="ENV=override" override the environment variables
Advanced options (experts only):
--malloc-prefix=PREFIX prefix malloc and related names with PREFIX
--custom-allocator=NAME use a supported custom allocator
--disable-symver disable symbol versioning
--enable-hardcoded-tables use hardcoded tables instead of runtime generation
--disable-safe-bitstream-reader
disable buffer boundary checking in bitreaders
(faster, but may crash)
--sws-max-filter-size=N the max filter size swscale uses [256]
Optimization options (experts only):
--disable-asm disable all assembly optimizations
--disable-altivec disable AltiVec optimizations
--disable-vsx disable VSX optimizations
--disable-power8 disable POWER8 optimizations
--disable-amd3dnow disable 3DNow! optimizations
--disable-amd3dnowext disable 3DNow! extended optimizations
--disable-mmx disable MMX optimizations
--disable-mmxext disable MMXEXT optimizations
--disable-sse disable SSE optimizations
--disable-sse2 disable SSE2 optimizations
--disable-sse3 disable SSE3 optimizations
--disable-ssse3 disable SSSE3 optimizations
--disable-sse4 disable SSE4 optimizations
--disable-sse42 disable SSE4.2 optimizations
--disable-avx disable AVX optimizations
--disable-xop disable XOP optimizations
--disable-fma3 disable FMA3 optimizations
--disable-fma4 disable FMA4 optimizations
--disable-avx2 disable AVX2 optimizations
--disable-avx512 disable AVX-512 optimizations
--disable-aesni disable AESNI optimizations
--disable-armv5te disable armv5te optimizations
--disable-armv6 disable armv6 optimizations
--disable-armv6t2 disable armv6t2 optimizations
--disable-vfp disable VFP optimizations
--disable-neon disable NEON optimizations
--disable-inline-asm disable use of inline assembly
--disable-x86asm disable use of standalone x86 assembly
--disable-mipsdsp disable MIPS DSP ASE R1 optimizations
--disable-mipsdspr2 disable MIPS DSP ASE R2 optimizations
--disable-msa disable MSA optimizations
--disable-msa2 disable MSA2 optimizations
--disable-mipsfpu disable floating point MIPS optimizations
--disable-mmi disable Loongson SIMD optimizations
--disable-fast-unaligned consider unaligned accesses slow
Developer options (useful when working on FFmpeg itself):
--disable-debug disable debugging symbols
--enable-debug=LEVEL set the debug level []
--disable-optimizations disable compiler optimizations
--enable-extra-warnings enable more compiler warnings
--disable-stripping disable stripping of executables and shared libraries
--assert-level=level 0(default), 1 or 2, amount of assertion testing,
2 causes a slowdown at runtime.
--enable-memory-poisoning fill heap uninitialized allocated space with arbitrary data
--valgrind=VALGRIND run "make fate" tests through valgrind to detect memory
leaks and errors, using the specified valgrind binary.
Cannot be combined with --target-exec
--enable-ftrapv Trap arithmetic overflows
--samples=PATH location of test samples for FATE, if not set use
$FATE_SAMPLES at make invocation time.
--enable-neon-clobber-test check NEON registers for clobbering (should be
used only for debugging purposes)
--enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
should be used only for debugging purposes)
--enable-random randomly enable/disable components
--disable-random
--enable-random=LIST randomly enable/disable specific components or
--disable-random=LIST component groups. LIST is a comma-separated list
of NAME[:PROB] entries where NAME is a component
(group) and PROB the probability associated with
NAME (default 0.5).
--random-seed=VALUE seed value for --enable/disable-random
--disable-valgrind-backtrace do not print a backtrace under Valgrind
(only applies to --disable-optimizations builds)
--enable-ossfuzz Enable building fuzzer tool
--libfuzzer=PATH path to libfuzzer
--ignore-tests=TESTS comma-separated list (without "fate-" prefix
in the name) of tests whose result is ignored
--enable-linux-perf enable Linux Performance Monitor API
--disable-large-tests disable tests that use a large amount of memory
NOTE: Object files are built at the place where configure is launched.
上面包括了很多配置参数,随着我们对ffmpeg的深入,我们也会慢慢了解这些配置参数,刚开始我们只需要知道我们关心的就好了。
例如我们不记得了禁止编译static怎么写的,我们这样查询一下:
./configure --help | grep static
同样我们可以查询一下share
相关的
./configure --help | grep share
这里我设置configure时禁止编译静态库,开启动态库,如下:
执行
./configure --prefix=/usr/local/ffmpeg --enable-debug=3 --enable-shared --disable-static
输入上面命令后回车,会等待一段时间,这个时候脚本在查询系统所有匹配的库,如果有不匹配的会有提示,如下图,我的配置会报一个错误:
由于我的电脑没有安装yasm库,所以需要先安装一下:
安装yasm编译器。安装方法如下:
- 下载:yasm的下载链接
- 解压:把下载下来的压缩包进行解压
- 切换路径: cd yasm-1.3.0
- 执行配置: ./configure
- 编译:make
- 安装:make install(提示:Permission denied,就执行sudo make install)
下面我们下来安装yasm编译器
(1)下载:yasm的下载链接
如果上面的链接下载比较慢,可以从我的百度云盘下载:
链接:https://pan.baidu.com/s/1oGMcX4HYg0ZzQ3TMKgaWfw 密码:m1k2
(2) 解压,这里需要用到本篇博客开篇的准备知识的解压命令tar -zxvf yasm-1.3.0.tar
tar -zxvf yasm-1.3.0.tar
(3)切换路径: cd yasm-1.3.0
(4)执行配置: ./configure
(5)编译:make
(6)安装:make install
(提示:Permission denied,就执行sudo make install)
安装了yasm编译器后,我们从新运行一下configure配置:
./configure --prefix=/usr/local/ffmpeg --enable-debug=3 --enable-shared --disable-static
如果没有报错,则会打印了下面信息:
✘ apple@kongyulu ~/development/study/ffmpeg/ffmpeg/ffmpeg master./configure --prefix=/usr/local/ffmpeg --enable-debug=3 --enable-shared --disable-static
install prefix /usr/local/ffmpeg
source path .
C compiler gcc
C library
ARCH x86 (generic)
big-endian no
runtime cpu detection yes
standalone assembly yes
x86 assembler yasm
MMX enabled yes
MMXEXT enabled yes
3DNow! enabled yes
3DNow! extended enabled yes
SSE enabled yes
SSSE3 enabled yes
AESNI enabled yes
AVX enabled yes
AVX2 enabled yes
AVX-512 enabled yes
XOP enabled yes
FMA3 enabled yes
FMA4 enabled yes
i686 features enabled yes
CMOV is fast yes
EBX available yes
EBP available yes
debug symbols yes
strip symbols yes
optimize for size no
optimizations yes
static no
shared yes
postprocessing support no
network support yes
threading support pthreads
safe bitstream reader yes
texi2html enabled no
perl enabled yes
pod2man enabled yes
makeinfo enabled yes
makeinfo supports HTML no
External libraries:
appkit bzlib iconv securetransport
avfoundation coreimage lzma zlib
External libraries providing hardware acceleration:
audiotoolbox videotoolbox
Libraries:
avcodec avfilter avutil swscale
avdevice avformat swresample
Programs:
ffmpeg ffprobe
Enabled decoders:
aac cscd mp1float rv40
aac_at cyuv mp2 s302m
aac_fixed dca mp2_at sami
aac_latm dds mp2float sanm
aasc derf_dpcm mp3 sbc
ac3 dfa mp3_at scpr
ac3_at dirac mp3adu screenpresso
ac3_fixed dnxhd mp3adufloat sdx2_dpcm
acelp_kelvin dolby_e mp3float sgi
adpcm_4xm dpx mp3on4 sgirle
adpcm_adx dsd_lsbf mp3on4float sheervideo
adpcm_afc dsd_lsbf_planar mpc7 shorten
adpcm_agm dsd_msbf mpc8 sipr
adpcm_aica dsd_msbf_planar mpeg1video siren
adpcm_argo dsicinaudio mpeg2video smackaud
adpcm_ct dsicinvideo mpeg4 smacker
adpcm_dtk dss_sp mpegvideo smc
adpcm_ea dst mpl2 smvjpeg
adpcm_ea_maxis_xa dvaudio msa1 snow
adpcm_ea_r1 dvbsub mscc sol_dpcm
adpcm_ea_r2 dvdsub msmpeg4v1 sonic
adpcm_ea_r3 dvvideo msmpeg4v2 sp5x
adpcm_ea_xas dxa msmpeg4v3 speedhq
adpcm_g722 dxtory msrle srgc
adpcm_g726 dxv mss1 srt
adpcm_g726le eac3 mss2 ssa
adpcm_ima_alp eac3_at msvideo1 stl
adpcm_ima_amv eacmv mszh subrip
adpcm_ima_apc eamad mts2 subviewer
adpcm_ima_apm eatgq mv30 subviewer1
adpcm_ima_cunning eatgv mvc1 sunrast
adpcm_ima_dat4 eatqi mvc2 svq1
adpcm_ima_dk3 eightbps mvdv svq3
adpcm_ima_dk4 eightsvx_exp mvha tak
adpcm_ima_ea_eacs eightsvx_fib mwsc targa
adpcm_ima_ea_sead escape124 mxpeg targa_y216
adpcm_ima_iss escape130 nellymoser tdsc
adpcm_ima_mtf evrc nuv text
adpcm_ima_oki exr on2avc theora
adpcm_ima_qt ffv1 opus thp
adpcm_ima_qt_at ffvhuff paf_audio tiertexseqvideo
adpcm_ima_rad ffwavesynth paf_video tiff
adpcm_ima_smjpeg fic pam tmv
adpcm_ima_ssi fits pbm truehd
adpcm_ima_wav flac pcm_alaw truemotion1
adpcm_ima_ws flashsv pcm_alaw_at truemotion2
adpcm_ms flashsv2 pcm_bluray truemotion2rt
adpcm_mtaf flic pcm_dvd truespeech
adpcm_psx flv pcm_f16le tscc
adpcm_sbpro_2 fmvc pcm_f24le tscc2
adpcm_sbpro_3 fourxm pcm_f32be tta
adpcm_sbpro_4 fraps pcm_f32le twinvq
adpcm_swf frwu pcm_f64be txd
adpcm_thp g2m pcm_f64le ulti
adpcm_thp_le g723_1 pcm_lxf utvideo
adpcm_vima g729 pcm_mulaw v210
adpcm_xa gdv pcm_mulaw_at v210x
adpcm_yamaha gif pcm_s16be v308
adpcm_zork gremlin_dpcm pcm_s16be_planar v408
agm gsm pcm_s16le v410
aic gsm_ms pcm_s16le_planar vb
alac gsm_ms_at pcm_s24be vble
alac_at h261 pcm_s24daud vc1
alias_pix h263 pcm_s24le vc1image
als h263i pcm_s24le_planar vcr1
amr_nb_at h263p pcm_s32be vmdaudio
amrnb h264 pcm_s32le vmdvideo
amrwb hap pcm_s32le_planar vmnc
amv hca pcm_s64be vorbis
anm hcom pcm_s64le vp3
ansi hevc pcm_s8 vp4
ape hnm4_video pcm_s8_planar vp5
apng hq_hqa pcm_u16be vp6
aptx hqx pcm_u16le vp6a
aptx_hd huffyuv pcm_u24be vp6f
arbc hymt pcm_u24le vp7
ass iac pcm_u32be vp8
asv1 idcin pcm_u32le vp9
asv2 idf pcm_u8 vplayer
atrac1 iff_ilbm pcm_vidc vqa
atrac3 ilbc pcx wavpack
atrac3al ilbc_at pgm wcmv
atrac3p imc pgmyuv webp
atrac3pal imm4 pgssub webvtt
atrac9 imm5 pictor wmalossless
aura indeo2 pixlet wmapro
aura2 indeo3 pjs wmav1
avrn indeo4 png wmav2
avrp indeo5 ppm wmavoice
avs interplay_acm prores wmv1
avui interplay_dpcm prosumer wmv2
ayuv interplay_video psd wmv3
bethsoftvid jacosub ptx wmv3image
bfi jpeg2000 qcelp wnv1
bink jpegls qdm2 wrapped_avframe
binkaudio_dct jv qdm2_at ws_snd1
binkaudio_rdft kgv1 qdmc xan_dpcm
bintext kmvc qdmc_at xan_wc3
bitpacked lagarith qdraw xan_wc4
bmp loco qpeg xbin
bmv_audio lscr qtrle xbm
bmv_video m101 r10k xface
brender_pix mace3 r210 xl
c93 mace6 ra_144 xma1
cavs magicyuv ra_288 xma2
ccaption mdec ralf xpm
cdgraphics metasound rasc xsub
cdtoons microdvd rawvideo xwd
cdxl mimic realtext y41p
cfhd mjpeg rl2 ylc
cinepak mjpegb roq yop
clearvideo mlp roq_dpcm yuv4
cljr mmvideo rpza zero12v
cllc motionpixels rscc zerocodec
comfortnoise movtext rv10 zlib
cook mp1 rv20 zmbv
cpia mp1_at rv30
Enabled encoders:
a64multi fits pcm_mulaw_at s302m
a64multi5 flac pcm_s16be sbc
aac flashsv pcm_s16be_planar sgi
aac_at flashsv2 pcm_s16le snow
ac3 flv pcm_s16le_planar sonic
ac3_fixed g723_1 pcm_s24be sonic_ls
adpcm_adx gif pcm_s24daud srt
adpcm_g722 h261 pcm_s24le ssa
adpcm_g726 h263 pcm_s24le_planar subrip
adpcm_g726le h263p pcm_s32be sunrast
adpcm_ima_qt h264_videotoolbox pcm_s32le svq1
adpcm_ima_wav hevc_videotoolbox pcm_s32le_planar targa
adpcm_ms huffyuv pcm_s64be text
adpcm_swf ilbc_at pcm_s64le tiff
adpcm_yamaha jpeg2000 pcm_s8 truehd
alac jpegls pcm_s8_planar tta
alac_at ljpeg pcm_u16be utvideo
alias_pix magicyuv pcm_u16le v210
amv mjpeg pcm_u24be v308
apng mlp pcm_u24le v408
aptx movtext pcm_u32be v410
aptx_hd mp2 pcm_u32le vc2
ass mp2fixed pcm_u8 vorbis
asv1 mpeg1video pcm_vidc wavpack
asv2 mpeg2video pcx webvtt
avrp mpeg4 pgm wmav1
avui msmpeg4v2 pgmyuv wmav2
ayuv msmpeg4v3 png wmv1
bmp msvideo1 ppm wmv2
cinepak nellymoser prores wrapped_avframe
cljr opus prores_aw xbm
comfortnoise pam prores_ks xface
dca pbm qtrle xsub
dnxhd pcm_alaw r10k xwd
dpx pcm_alaw_at r210 y41p
dvbsub pcm_dvd ra_144 yuv4
dvdsub pcm_f32be rawvideo zlib
dvvideo pcm_f32le roq zmbv
eac3 pcm_f64be roq_dpcm
ffv1 pcm_f64le rv10
ffvhuff pcm_mulaw rv20
Enabled hwaccels:
h263_videotoolbox hevc_videotoolbox mpeg2_videotoolbox
h264_videotoolbox mpeg1_videotoolbox mpeg4_videotoolbox
Enabled parsers:
aac dpx h264 sbc
aac_latm dvaudio hevc sipr
ac3 dvbsub mjpeg tak
adx dvd_nav mlp vc1
av1 dvdsub mpeg4video vorbis
avs2 flac mpegaudio vp3
bmp g723_1 mpegvideo vp8
cavsvideo g729 opus vp9
cook gif png webp
dca gsm pnm xma
dirac h261 rv30
dnxhd h263 rv40
Enabled demuxers:
aa filmstrip lrc rpl
aac fits lvf rsd
ac3 flac lxf rso
acm flic m4v rtp
act flv matroska rtsp
adf fourxm mgsts s337m
adp frm microdvd sami
ads fsb mjpeg sap
adx fwse mjpeg_2000 sbc
aea g722 mlp sbg
afc g723_1 mlv scc
aiff g726 mm sdp
aix g726le mmf sdr2
alp g729 mov sds
amr gdv mp3 sdx
amrnb genh mpc segafilm
amrwb gif mpc8 ser
anm gsm mpegps shorten
apc gxf mpegts siff
ape h261 mpegtsraw sln
apm h263 mpegvideo smacker
apng h264 mpjpeg smjpeg
aptx hca mpl2 smush
aptx_hd hcom mpsub sol
aqtitle hevc msf sox
argo_asf hls msnwc_tcp spdif
asf hnm mtaf srt
asf_o ico mtv stl
ass idcin musx str
ast idf mv subviewer
au iff mvi subviewer1
av1 ifv mxf sup
avi ilbc mxg svag
avr image2 nc swf
avs image2_alias_pix nistsphere tak
avs2 image2_brender_pix nsp tedcaptions
bethsoftvid image2pipe nsv thp
bfi image_bmp_pipe nut threedostr
bfstm image_dds_pipe nuv tiertexseq
bink image_dpx_pipe ogg tmv
bintext image_exr_pipe oma truehd
bit image_gif_pipe paf tta
bmv image_j2k_pipe pcm_alaw tty
boa image_jpeg_pipe pcm_f32be txd
brstm image_jpegls_pipe pcm_f32le ty
c93 image_pam_pipe pcm_f64be v210
caf image_pbm_pipe pcm_f64le v210x
cavsvideo image_pcx_pipe pcm_mulaw vag
cdg image_pgm_pipe pcm_s16be vc1
cdxl image_pgmyuv_pipe pcm_s16le vc1t
cine image_pictor_pipe pcm_s24be vividas
codec2 image_png_pipe pcm_s24le vivo
codec2raw image_ppm_pipe pcm_s32be vmd
concat image_psd_pipe pcm_s32le vobsub
data image_qdraw_pipe pcm_s8 voc
daud image_sgi_pipe pcm_u16be vpk
dcstr image_sunrast_pipe pcm_u16le vplayer
derf image_svg_pipe pcm_u24be vqf
dfa image_tiff_pipe pcm_u24le w64
dhav image_webp_pipe pcm_u32be wav
dirac image_xpm_pipe pcm_u32le wc3
dnxhd image_xwd_pipe pcm_u8 webm_dash_manifest
dsf ingenient pcm_vidc webvtt
dsicin ipmovie pjs wsaud
dss ircam pmp wsd
dts iss pp_bnk wsvqa
dtshd iv8 pva wtv
dv ivf pvf wv
dvbsub ivr qcp wve
dvbtxt jacosub r3d xa
dxa jv rawvideo xbin
ea kux realtext xmv
ea_cdata kvag redspark xvag
eac3 live_flv rl2 xwma
epaf lmlm4 rm yop
ffmetadata loas roq yuv4mpegpipe
Enabled muxers:
a64 framemd5 mpeg1video roq
ac3 g722 mpeg2dvd rso
adts g723_1 mpeg2svcd rtp
adx g726 mpeg2video rtp_mpegts
aiff g726le mpeg2vob rtsp
amr gif mpegts sap
apng gsm mpjpeg sbc
aptx gxf mxf scc
aptx_hd h261 mxf_d10 segafilm
asf h263 mxf_opatom segment
asf_stream h264 null singlejpeg
ass hash nut smjpeg
ast hds oga smoothstreaming
au hevc ogg sox
avi hls ogv spdif
avm2 ico oma spx
avs2 ilbc opus srt
bit image2 pcm_alaw stream_segment
caf image2pipe pcm_f32be streamhash
cavsvideo ipod pcm_f32le sup
codec2 ircam pcm_f64be swf
codec2raw ismv pcm_f64le tee
crc ivf pcm_mulaw tg2
dash jacosub pcm_s16be tgp
data latm pcm_s16le truehd
daud lrc pcm_s24be tta
dirac m4v pcm_s24le uncodedframecrc
dnxhd matroska pcm_s32be vc1
dts matroska_audio pcm_s32le vc1t
dv md5 pcm_s8 voc
eac3 microdvd pcm_u16be w64
f4v mjpeg pcm_u16le wav
ffmetadata mkvtimestamp_v2 pcm_u24be webm
fifo mlp pcm_u24le webm_chunk
fifo_test mmf pcm_u32be webm_dash_manifest
filmstrip mov pcm_u32le webp
fits mp2 pcm_u8 webvtt
flac mp3 pcm_vidc wtv
flv mp4 psp wv
framecrc mpeg1system rawvideo yuv4mpegpipe
framehash mpeg1vcd rm
Enabled protocols:
async gopher mmst srtp
cache hls pipe subfile
concat http prompeg tcp
crypto httpproxy rtmp tee
data https rtmps tls
ffrtmphttp icecast rtmpt udp
file md5 rtmpts udplite
ftp mmsh rtp unix
Enabled filters:
abench bwdif haldclutsrc scroll
abitscope cas hdcd select
acompressor cellauto headphone selectivecolor
acontrast channelmap hflip sendcmd
acopy channelsplit highpass separatefields
acrossfade chorus highshelf setdar
acrossover chromahold hilbert setfield
acrusher chromakey histogram setparams
acue chromashift hqx setpts
addroi ciescope hstack setrange
adeclick codecview hue setsar
adeclip color hwdownload settb
adelay colorbalance hwmap showcqt
aderivative colorchannelmixer hwupload showfreqs
adrawgraph colorhold hysteresis showinfo
aecho colorkey idet showpalette
aemphasis colorlevels il showspatial
aeval colorspace inflate showspectrum
aevalsrc compand interleave showspectrumpic
afade compensationdelay join showvolume
afftdn concat lagfun showwaves
afftfilt convolution lenscorrection showwavespic
afifo convolve life shuffleframes
afir copy limiter shuffleplanes
afirsrc coreimage loop sidechaincompress
aformat coreimagesrc loudnorm sidechaingate
agate crop lowpass sidedata
agraphmonitor crossfeed lowshelf sierpinski
ahistogram crystalizer lumakey signalstats
aiir cue lut silencedetect
aintegral curves lut1d silenceremove
ainterleave datascope lut2 sinc
alimiter dcshift lut3d sine
allpass dctdnoiz lutrgb smptebars
allrgb deband lutyuv smptehdbars
allyuv deblock mandelbrot sobel
aloop decimate maskedclamp spectrumsynth
alphaextract deconvolve maskedmax split
alphamerge dedot maskedmerge sr
amerge deesser maskedmin ssim
ametadata deflate maskedthreshold stereotools
amix deflicker maskfun stereowiden
amovie dejudder mcompand streamselect
amplify derain median superequalizer
amultiply deshake mergeplanes surround
anequalizer despill mestimate swaprect
anlmdn detelecine metadata swapuv
anlms dilation midequalizer tblend
anoisesrc displace minterpolate telecine
anull dnn_processing mix testsrc
anullsink doubleweave movie testsrc2
anullsrc drawbox negate thistogram
apad drawgraph nlmeans threshold
aperms drawgrid noformat thumbnail
aphasemeter drmeter noise tile
aphaser dynaudnorm normalize tlut2
apulsator earwax null tmedian
arealtime ebur128 nullsink tmix
aresample edgedetect nullsrc tonemap
areverse elbg oscilloscope tpad
arnndn entropy overlay transpose
aselect equalizer pad treble
asendcmd erosion pal100bars tremolo
asetnsamples extractplanes pal75bars trim
asetpts extrastereo palettegen unpremultiply
asetrate fade paletteuse unsharp
asettb fftdnoiz pan v360
ashowinfo fftfilt perms vectorscope
asidedata field photosensitivity vflip
asoftclip fieldhint pixdesctest vfrdet
asplit fieldmatch pixscope vibrance
astats fieldorder premultiply vibrato
astreamselect fifo prewitt vignette
asubboost fillborders pseudocolor vmafmotion
atadenoise firequalizer psnr volume
atempo flanger qp volumedetect
atrim floodfill random vstack
avectorscope format readeia608 w3fdif
avgblur fps readvitc waveform
axcorrelate framepack realtime weave
bandpass framerate remap xbr
bandreject framestep removegrain xfade
bass freezedetect removelogo xmedian
bbox freezeframes replaygain xstack
bench gblur reverse yadif
bilateral geq rgbashift yaepblur
biquad gradfun rgbtestsrc yuvtestsrc
bitplanenoise graphmonitor roberts zoompan
blackdetect greyedge rotate
blend haas scale
bm3d haldclut scale2ref
Enabled bsfs:
aac_adtstoasc filter_units mjpega_dump_header prores_metadata
av1_frame_merge h264_metadata mov2textsub remove_extradata
av1_frame_split h264_mp4toannexb mp3_header_decompress text2movsub
av1_metadata h264_redundant_pps mpeg2_metadata trace_headers
chomp hapqa_extract mpeg4_unpack_bframes truehd_core
dca_core hevc_metadata noise vp9_metadata
dump_extradata hevc_mp4toannexb null vp9_raw_reorder
eac3_core imx_dump_header opus_metadata vp9_superframe
extract_extradata mjpeg2jpeg pcm_rechunk vp9_superframe_split
Enabled indevs:
avfoundation lavfi
Enabled outdevs:
License: LGPL version 2.1 or later
libavutil/avconfig.h is unchanged
libavfilter/filter_list.c is unchanged
libavcodec/codec_list.c is unchanged
libavcodec/parser_list.c is unchanged
libavcodec/bsf_list.c is unchanged
libavformat/demuxer_list.c is unchanged
libavformat/muxer_list.c is unchanged
libavdevice/indev_list.c is unchanged
libavdevice/outdev_list.c is unchanged
libavformat/protocol_list.c is unchanged
ffbuild/config.sh is unchanged
apple@kongyulu ~/development/study/ffmpeg/ffmpeg/ffmpeg master
这样我们已经成功配置了FFmpeg,接下来执行编译
- 执行
make -j 4
这里命令的意思是增加4个内核,并行编译,这样提高编译速度
执行make命令后,接下来需要等待比较长的时间等编译完成,需要耐心
- 执行
make install
这里我执行make install
提示没有权限,所以需要用到开篇的基础命令sudo
增加执行权限
执行sudo make install
增加权限后,就可以安装成功了。
这样就成功安装到了/usr/local/ffmpeg
目录下面了,我们切换到这个目录查看一下
我们可以看到有四个子目录:bin, include, lib, share
- bin目录:存放所有ffmpeg的工具库
- include目录: 存放ffmpeg库的所有头文件
- lib目录:ffmepg生成的动态库或静态库
- share目录:存放文档相关内容和一些demo实例
我们接下来可以进入bin目录执行命令:
正常会有三个子目录,由于我这里没有安装ffplay所以少了一个ffplay
这是为什么呢?
因为ffplay实际上是客户端ffplay.c的C程序编译出来的,该ffplay.c需要依赖avdevice模块,而avdevice模块使用了sdl的API,如果你的PC上没有sdl(1.x版本,最常用的是1.2.0版本),那么ffplay就会编译不出来了,所以要想编译出命令行工具ffplay,首先的编译基础库 sdl
- Mac OS 安装sdl 库
如果没有安装brew的话,要先安装Homebrew
ruby -e "$(curl -fsSL \
https://raw.githubusercontent.com/Homebrew/install/master/install)”
等待一段时间,就安装好了,
然后执行命令:
brew install sdl
等待下载并且安装完毕之后,重新执行上述FFmpeg的配置和安装步骤,待make install
结束之后,再去bin目录下就可以找到命令行工具ffplay
了。
- 安装完成之后接下来一个很重要的事情就是配置环境变量,如果没有配置,你直接执行ffmpeg命令是会报错的
如果你配置环境变量,则需要每次带上全路径,如下:
/usr/local/ffmpeg/bin/ffmpeg -version
接下来配置环境变量
执行命令
vi ~/.bash_profile
在配置文件加入ffmpeg的bin文件夹路径:
export PATH=$PATH:/usr/local/ffmpeg/bin
然后输入:wq
保存退出,再执行下面命令让刚配置的环境变量生效:
source ~/.bash_profile
3.2 在Linux下编译安装FFmpeg
3.2.1 apt 命令安装
在ubuntu操作系统上可以很容易的跟Mac电脑上执行brew install ffmpeg
一样可以一行命令执行
通过执行apt 安装如下:
sudo apt install ffmpeg
这个的弊端也是无法定制化,如果要定制化还是要手动编译源码安装
安装完成后,我们可以执行ffmpeg -version
测试是否安装成功
Centos 操作系统下安装
- 需安装Nux Dextop Yum 源, 由于CentOS没有官方FFmpeg rpm软件包。但是,我们可以使用第三方YUM源(Nux Dextop)完成此工作。
CentOS 7下:
sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
然后
sudo yum install ffmpeg ffmpeg-devel -y
3.2.2 源码安装
- 官网下载:http://ffmpeg.org/download.html 这里下载最新版本
- 解压安装包
tar -xjvf ffmpeg-4.1.tar.bz2
cd ffmpeg-4.1/
- 跟上面mac源码安装类似,先进行configure配置,配置过程可能报错,如报下面错误:
[root@kongyulu ffmpeg-4.1]# ./configure
gcc is unable to create an executable file.
If gcc is a cross-compiler, use the --enable-cross-compile option.
Only do this if you know what cross compiling means.
C compiler test failed.
If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
则说明yasm编译器没有安装或者太老了,需要先安装新的yasm汇编器。
可以使用–disable-yasm禁用这个选项编译,yasm是一款汇编器,并且是完全重写了nasm的汇编环境,接收nasm和gas语法,支持x86和amd64指令集,所以这里安装一下yasm即可
- Linux下安装
yasm
跟Mac下安装相似,都是先下载源码,然后配置,编译,安装
官网下载:http://yasm.tortall.net/Download.html
下载后解压,安装
tar -xvzf yasm-1.3.0.tar.gz
cd yasm-1.3.0/
./configure
make
make install
- 安装成功后,还是和mac安装ffmpeg一样,需要重新配置FFmpeg:
./configure --enable-shared --prefix=/opt/ffmpeg
/opt/ffmpeg 是配置的安装目录,可以自己配置路径
- 然后make进行编译
make
- 安装
make install
make install
会把ffmpeg
相关执行程序、头文件、lib库安装在/opt/ffmpeg/
下
- 安装完成后可以进入
/opt/ffmpeg/
查看
发现有bin,include,lib,share
这4个目录
bin
是ffmpeg主程序二进制目录
include
是C/C++头文件目录
lib
是编译好的库文件目录
share
是文档目录
- 我们可以进入bin目录执行
./ffmpeg -version
, 查看当前版本的详细信息
可能会报错:
libavdevice.so.57: cannot open shared object file: No such file or directory
原因是lib
目录未加载到链接到系统库中
系统ld目录列表在/etc/ld.so.conf
中,打开文件会发现,
里面引用了/etc/ld.so.conf.d/
下面所有的.conf文件,比如mariadb-x86_64.conf
解决上面报错,需要创建一个文件并写入lib路径即可
- 执行命令:
vim /etc/ld.so.conf.d/ffmpeg.conf
- 然后添加一行内容:
/opt/ffmpeg/lib
- 之后保存并退出,然后执行 ldconfig使配置生效,
- 再次执行
./ffmpeg -version
显示就正常了
正常会打印如下信息
[root@kongyulu ffmpeg-4.1]# ffmpeg -ersion
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-28)
configuration: --enable-shared --prefix=/opt/ffmpeg-4
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
- 接下来需要配置环境变量
使用命令vim /etc/profile
:编辑写入↓
PATH=/opt/python364/bin/:/opt/ffmpeg-4/bin/:$PATH
然后执行命令source /etc/profile
:使修改后的配置文件生效
- 检测ffmpeg是否安装成功
执行which ffmpeg
查看安装路径
3.3 在Window下编译安装FFmpeg
3.3.1 Window编译工具介绍
window下编译FFmpeg相对复杂一下,需要借助Cygwin或MinGW来编译,可以通过MinGW+ MSYS2 或者 VS+ MSYS2来编译ffmpeg
Cygwin(Cygnus Windows)实际上相当于在window安装了一个软件来模拟linux系统
MinGW(Minimalist GNU for Windows)是完全模仿了linux的编译工具,相对于将linux的编译工具移植到 window,基于window系统api进行编译,需要提供额外的工具配合使用
VS就是 window开发很熟悉了
MSYS2(Minimal SYStem 2)
3.3.2 Window如何编译ffmpeg
Window编译ffmpeg主要有下面三种方式
- Cygwin直接安装使用:
Cygwin编译跟linux编译一模一样的,Cygwin完全就像一个虚拟机模拟了linux操作系统。Cygwin实际上是做了一层linux的api到windows 的api的转换。
但是这样编译出来的ffmpeg的exe程序需要挂在一个Cygwin.dll库才可以运行,因为它有一层转换,所以性能对比原始的window程序有一些损耗。
- MinGW + MSYS2 : 官方推荐的方式,这种编译出来的就是原生的window程序,不需要和Cygwin一样需要加载一个动态库了。
它的编译方式实际上和linux是一致的
- VS + MSYS2: 这种就是采用类linux的编译,只是把里面的工具链换成了VS的工具,但是这种方式生成ffplay比较麻烦。
所以一般都选择MinGW + MSYS2 : 官方推荐的方式
3.3.2.1 Cygwin 编译FFmpeg
在windows下安装 ffmpeg 的最好方式就是使用 Cygwin 。 Cygwin 是什么呢?简单的说,就是在 Windows上装了一个Linux模拟器。然后你可以在这个模拟器上按照Linux的方式操作 Windows系统。因此,Windows安装了 Cygwin 之后,你就把它当Linux用就可以了。
首先,到 Cygwin 官网下载 Cygwin 的可执行程序 setup-x86_64.exe。当然,它是 64位的,如果你现在还在用 32位的,那请在 Cygwin官网上找 32位对应的版本。
- 首先要安装Cygwin
下载软件后开始安装
选择系统的网络连接方式,跟虚拟机类似
选择镜像安装
选择镜像的对应包
然后选择我们需要的安装包安装,我这里选择 Debug, Devel这两个必须的
此外还需要选择网络
还需要添加wget
此外我们选择一个sdl的库
为了后面编译出ffplay库,最好把下面的红框里面都选上
以上就是一个最小的安装了
需要确保安装了下面这些工具
- gcc
- g++
- make
- cmake
- automake
- gdb
- nasm
- yasm
- wget
选好之后继续下一步
等待安装完成
然后点击图标打开
可以看到一个linux的控制台,如果在window下学习linux命名,就可以在这个控制台练习
这样你就可以敲入linux命令了
如果我们要访问window下的D:盘,可以像下面这样访问:
- 然后要安装apt-cyg: 这个实际就是Cygwin下的apt工具
apt-cyg与 Ubuntu系统中的 apt一样特别好用,而且使用的方式与 apt也是一个样子的。
我们可以在Cygwin下执行下面的命令就好了
wget -c https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg
然后执行命令
install apt-cyg /bin
安装好apt-cyg后,就可以用 apt-cyg instal xxx
这样来安装了我们的包了跟Mac下使用brew install xxx
一样爽歪歪。
- 接下来安装
pkg-config
工具
在Windows系统下,一般不会默认安装该工具,所以在Windows下做实验的同学大都会遇到明明已经装了某个库,但仍然找不到该库的情况。其原因就是没有安装 pkg-config这个工具。
首先确认是否已经将 pkg-config工具安装好了。可以执行下面的命令:
pkg-config
如果提示没有安装,则先将该工具安装好,安装命令如下:
apt-cyg install pkg-config
- 安装好了上面的工具后,接下来就是下载ffmpeg源码了,从官网:http://ffmpeg.org/download.html下载
然后就是安装了,安装方式跟mac,linux一样
- 输入命令:
./configure --prefix=/usr/local/ffmpeg
配置环境- 执行命令:
make -j 4
编译源码- 执行命令:
make install
安装
下载源码通过http直接下载或者git下载
这里我使用git方式,先创建一个ffmpeg目录,然后Git clone代码
下载好源码后,进入目录,然后配置configure
配置完成报告如下:
此时make文件已经生成好了,我们输入make -j 4
执行编译
这个编译过程比较长,耐心等待
最好执行make install
安装
安装好之后,我们可以进入/usr/local/ffmpeg
目录查看
我们可以看到四个目录:bin,include,lib,share
接下来,我们进入bin目录:
可以看到三个exe文件,ffmpeg.exe, ffplayer.exe, ffprobe.exe
我们可以执行ffmpeg.exe
- 接下来也需要配置环境变量,不然每次要带全路径
输入命令:vi ~/.bashrc
编辑配置文件
按快捷键“Shift+G”跳到文件末尾,在配置文件末尾插入:export PATH=/usr/local/ffmpeg/bin:$PATH
然后按esc键,退出编辑模式,输入:wq
保存退出
然后,我们输入source ~/.bashrc
使配置文件生效
最好我们输入env | grep PATH
来测试配置文件是否生效
配置好环境变量后,我们直接输入ffmpeg.exe就可以找到了
3.3.2.1.2 x264 安装
虽然有了apt-cyg这个神器,但它目前只能安装Linux下的一些常用命令,像我们编译时需要的 x264, x265
这些库它是无法找到的。
所以这些库需要我们自己来编译
- 编译yasm
- 下载源码:
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
- 解压:
tar zxvf yasm-1.3.0.tar.gz
- 切换到目录:
cd yasm-1.3.0
- 配置选项:
./configure
- 编译安装:
make && sudo make install
- 编译fdk-aac
- 下载源码:
wget https://jaist.dl.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-0.1.6.tar.gz
- 解压:
tar xvf fdk-aac-0.1.6.tar.gz
- 切换到目录:
cd fdk-aac-0.1.6
- 配置选项:
./configure
- 编译安装:
make && sudo make install
- 安装lame
- 下载源码:
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
- 解压:
tar -xzf lame-3.99.5.tar.gz
- 切换到目录:
cd lame-3.99.5
- 配置选项:
./configure
- 编译安装:
make && sudo make install
注:编译lame可能遇到的问题:
- 问题一:
在Cygwin下安装 lame的时候遇到执行 ./configure 失败的情况。如 “error: cannot guess build type; you must sepcify one”,对这个问题可以通过下面的步骤来解决:
安装automake。可以通过 which automake来确认automake 是否已经安装。如果没有安装,可以通使用 apt-cyg install automake进行安装。
确认automake当前版本。可执行automake --version获取当前automake的版本号。
将 lame目录下的 config.guess文件替换为 /usr/share/automake-version下的config.guess 文件。
此时,再执行./configure进就可以下成功了。- 问题二:
make时出现 "error: ‘_O_BINARY’ undeclared (first use in this function)"的错误,解决办法如下:
打开出错文件 vi ./frontend/lametime.c
将下面这段代码注释掉
/*
#elif defined __CYGWIN
setmod(fileno(fp), _O_BINARY);
*/
再执行make就可以成功了。
- 安装nasm
- 下载源码:
wget https://www.nasm.us/pub/nasm/releasebuilds/2.13.03/nasm-2.13.03.tar.gz
- 解压:
tar xvf nasm-2.13.03.tar.gz
- 切换到目录:
cd nasm-2.13.03
- 配置选项:
./configure
- 编译安装:
make && sudo make install
- 安装x264
- 下载源码: wget http://mirror.yandex.ru/mirrors/ftp.videolan.org/x264/snapshots/last_x264.tar.bz2
bunzip2 last_x264.tar.bz2- 解压:
tar -vxf last_x264.tar
- 切换到目录:
cd last_x264
- 配置选项:
./configure --enable-static --enable-shared --disable-asm --disable-avs
- 编译安装:
make && sudo make install
- 安装ffmpeg
- 下载源码:
wget -c https://ffmpeg.org/releases/ffmpeg-4.0.2.tar.bz2
- 解压:
bunzip2 ffmpeg-4.0.2.tar.bz2
- 切换到目录:
cd ffmpeg-4.0.2
- 配置选项:
./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-small --arch=x86_64 --enable-nonfree --enable-libfdk-aac --enable-libx264 --enable-filter=delogo --enable-debug --disable-optimizations --enable-shared
- 编译安装:
make && sudo make install
FFmpeg编译的问题:
- 问题一:找不到
fdk-aac
库
在编译ffmpeg时,有可能会报找不到fdk_aac库的错误。此时我们应该设置一下PKG_CONFIG_PATH
,指定ffmpeg到哪里找我们安装好的库。
上面通过源码安装的库,默认地址为/usr/local/lib
下面,当然你可以通过./configure
中的–prefix
参数改变这个目录。
如果使用默认路径的话,可以通过下面的命令来指定编译时去哪里找库export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
如果你改变了默认路径,则将后面的/usr/local/lib/pkgconfig
修改为你变更后的路径/xxx/.../lib/pkgconfig
即可。
3.3.2.2 MinGW + MSYS2 编译FFmpeg
3.3.2.3 VS + MSYS2 编译FFmpeg
参考:李超大神的博客和视频:https://www.imooc.com/article/247113