Android-音视频学习系列-(四)-一键编译-32-64-位-FFmpeg-4-2-2

  • libavfilter:

音视频滤镜库,该模块包含了音频特效和视频特效的处理,在使用 FFmpeg 的 API 进行编解码的过程中,可以使用该模块高效的为音视频数据做特效处理

  • libavdevice:

输入输出设备库,比如需要编译出播放声音或者视频的工具 ffplay,就需要确保该模块是打开的,同事也需要 libsdl 的预先编译,该设备模块播放声音和视频都又是使用libsdl 库

  • libavutil:

核心工具库,最基础模块之一,其他模块都会依赖该库做一些基本的音视频处理操作

  • libswresample:

用于音频重采样,可以对数字音频进行声道数、数据格式、采样率等多种基本信息的转换

  • libswscale

该模块用于图像格式转换,可以将 YUV 的数据转换为 RGB 的数据

  • libpostproc

该模块用于进行后期处理,当我们使用filter的时候,需要打开这个模块,filter会用到这个模块的一些基础函数

比较老的 ffmpeg 还会编译出 avresamle 模块,也是用于对音频原始出具进行重采样的,但是已经被废弃,推荐使用 libswresample 替代

另外,库里还可以包含对 H.264/MPEG-4 AVC 视频编码的 X264 库,是最常用的有损视频编码器,支持 CBR、VBR 模式,可以在编码的过程中直接改变码率的设置,在直播的场景中非常适用!可以做码率自适应的功能。

下载 FFmpeg

FFmpeg 官网 直接下载源码方式

在 linux 环境中,命令下载:

//1. 命令下载
wget https://ffmpeg.org/releases/ffmpeg-4.2.2.tar.bz2
//2. 安装解压缩工具
yum -y install bzip2
//3. 解压 FFmpeg
tar -jxvf ffmpeg-4.2.2.tar.bz2

编译 FFmpeg

编译环境

  • ffmpeg-4.2.2
  • Centos 7
  • android-ndk-r17c-linux-x86_64.zip

configure 脚本介绍

#!/bin/sh

#帮组选项
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

#标准选项
#–disable 代表关闭状态 ;–enable 代表开启状态
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 [$prefix_default]

–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:
#我们不需要使用程序,不需要在Windows中执行,某.exe程序,我们只需要在代码中使用 [此命令操作的是下面三项]
–disable-programs do not build command line programs
#使用FFmpeg命令
–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:
#可以操控我们的摄像头-(Android中是不支持))
–disable-avdevice disable libavdevice build
#audio video codec(编码 和 解码)
–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
#混合封装(音视频等于 一段音频 一段视频 合并在一起 就是.mp4,不想这样就可以关闭)
–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

编写 32/64 位 FFmpeg4.2.2 shell 脚本

ndk20b+ffmpeg4.2.2 clang 编译脚本

#!/bin/bash

echo “>>>>>>>>> 编译硬件解码版本 <<<<<<<<”
echo “>>>>>>>>> 注意:该编译环境目前只在 NDK20b + ffmpeg4.2.2 测试过 <<<<<<<<”
echo “>>>>>>>>> 注意:该编译环境目前只在 NDK20b + ffmpeg4.2.2 测试过 <<<<<<<<”

#你自己的NDK路径.
export NDK=/root/android/ndk/android-ndk-r20b
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64

function build_android
{

echo “开始编译 $CPU”

./configure
–prefix= P R E F I X   − − e n a b l e − n e o n   − − e n a b l e − h w a c c e l s   − − e n a b l e − g p l   − − e n a b l e − p o s t p r o c   − − e n a b l e − s h a r e d   − − d i s a b l e − d e b u g   − − e n a b l e − s m a l l   − − e n a b l e − j n i   − − e n a b l e − m e d i a c o d e c   − − e n a b l e − d e c o d e r = h 26 4 m e d i a c o d e c   − − d i s a b l e − s t a t i c   − − d i s a b l e − d o c   − − e n a b l e − f f m p e g   − − d i s a b l e − f f p l a y   − − d i s a b l e − f f p r o b e   − − d i s a b l e − a v d e v i c e   − − d i s a b l e − d o c   − − d i s a b l e − s y m v e r   − − c r o s s − p r e f i x = PREFIX \ --enable-neon \ --enable-hwaccels \ --enable-gpl \ --enable-postproc \ --enable-shared \ --disable-debug \ --enable-small \ --enable-jni \ --enable-mediacodec \ --enable-decoder=h264_mediacodec \ --disable-static \ --disable-doc \ --enable-ffmpeg \ --disable-ffplay \ --disable-ffprobe \ --disable-avdevice \ --disable-doc \ --disable-symver \ --cross-prefix= PREFIX enableneon enablehwaccels enablegpl 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值