ffmpeg编译

一、准备工作

1.1、ffmpeg源码下载
官网下载

1.2、linux 系统

1.3、linux ndk下载
官网下载

二、编译脚本编写

#!/bin/bash

ARCHS="armv7 arm64"
PREFIX=out/lib
ANDROID_VERSION=android-21
NDK_PATH=/studySourceCode/android-ndk-r21b
TOOLCHAIN=$NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
CROSS_COMPILE=$TOOLCHAN/bin/arm-linux-androideabi-
SYSROOT=$NDK_PATH/platforms/$ANDROID_VERSION/arch-$ARCH

for ARCH in $ARCHS; do
	echo "************ START *************"
	echo "NDK_PATH=$NDK_PATH ANDROID_VERSION=$ANDROID_VERSION"
	./configure --disable-x86asm	\
	--target-os=linux	\
	--arch=$ARCH		\
	--prefix=$PREFIX/$ARCH	\
	--enable-shared	\
	--disable-static	\
	--disable-doc	\
	--disable-ffmpeg	\
	--disable-ffplay	\
	--disable-ffprobe	\
	--disable-fferver	\
	--disable-doc	\
	--disable-symver	\
	--enable-cross-compile	\
	--cross-prefix=$CROSS_COMPILE	\
	--sysroot=$SYSROOT	\
	--extra-cflags="-fpic"

	make clean
	make -j8
	make install

	echo "PREFIX=$PREFIX/$ARCH"
	echo "TOOLCHAIN=${TOOLCHAIN}"
	echo "CROSS_COMPILE=${CROSS_COMPILE}"
	echo "SYSROOT=${SYSROOT}"
	echo "************* END ************"
done

2.1、
这里首先要注意的一行是:
./configure --disable-x86asm 生成编译相关的配置
因为如今网络上很多编译脚本中都是写的
./configure
如今使用不带参执行这个命令会发现其实压根不会执行任何操作去生成配置,后面如果去执行ffmpeg_build.sh 编译会引发 No such file or directory(没有那个文件或目录) 的问题
在这里插入图片描述
2.2 编译参数

参数说明
--arch指定cpu位数
--prefix指定安装路径(但是我用这个无法指定路径,还是生成在默认路径/usr/local)
--disable-encoders禁止所有的编码
--enable-encoder=NAME 开启名字为NAME的编码,例如--enable-encoder=h264,mp3,m4a,wav,aac
--disable-encoder=NAME 禁止名字为NAME的编码,例如--enable-encoder=h264,mp3,m4a,wav,aac
--disable-decoders禁止所有的解码
--enable-decoder=NAME 开启名字为NAME的解码,例如--enable-decoder=h264,mp3,m4a,wav,aac
--disable-decoder=NAME 禁止名字为NAME的解码,例如--disable-decoder=h264,mp3,m4a,wav,aac

更多配置参数参考
./configure --help

三、开始编译

3.1、生成相关配置

./configure --disable-x86asm

3.2、执行编译脚本

. ffmpeg_build.sh

这里单独拿出了./configure --disable-x86asm,因为怕有些读者不是从笔者这里复制的脚本,./configure --disable-x86asm的作用读者可以参考第二节
最后等待编译完成即可。

四、常见错误

4.1、./configure 权限不够

chmod 777  /.configure

4.2

-bash: --prefix=out/lib: 没有那个文件或目录
Makefile:2: ffbuild/config.mak: 没有那个文件或目录
Makefile:40: /tools/Makefile: 没有那个文件或目录
Makefile:41: /ffbuild/common.mak: 没有那个文件或目录
Makefile:97: /libavutil/Makefile: 没有那个文件或目录
Makefile:97: /ffbuild/library.mak: 没有那个文件或目录
Makefile:99: /fftools/Makefile: 没有那个文件或目录
Makefile:100: /doc/Makefile: 没有那个文件或目录
Makefile:101: /doc/examples/Makefile: 没有那个文件或目录
Makefile:167: /tests/Makefile: 没有那个文件或目录
make: *** 没有规则可以创建目标“/tests/Makefile”。 停止。
Makefile:2: ffbuild/config.mak: 没有那个文件或目录
Makefile:40: /tools/Makefile: 没有那个文件或目录
Makefile:41: /ffbuild/common.mak: 没有那个文件或目录
Makefile:97: /libavutil/Makefile: 没有那个文件或目录
Makefile:97: /ffbuild/library.mak: 没有那个文件或目录
Makefile:99: /fftools/Makefile: 没有那个文件或目录
Makefile:100: /doc/Makefile: 没有那个文件或目录
Makefile:101: /doc/examples/Makefile: 没有那个文件或目录
Makefile:167: /tests/Makefile: 没有那个文件或目录
make: *** 没有规则可以创建目标“/tests/Makefile”。 停止。
Makefile:2: ffbuild/config.mak: 没有那个文件或目录
Makefile:40: /tools/Makefile: 没有那个文件或目录
Makefile:41: /ffbuild/common.mak: 没有那个文件或目录
Makefile:97: /libavutil/Makefile: 没有那个文件或目录
Makefile:97: /ffbuild/library.mak: 没有那个文件或目录
Makefile:99: /fftools/Makefile: 没有那个文件或目录
Makefile:100: /doc/Makefile: 没有那个文件或目录
Makefile:101: /doc/examples/Makefile: 没有那个文件或目录
Makefile:167: /tests/Makefile: 没有那个文件或目录
make: *** 没有规则可以创建目标“/tests/Makefile”。 停止。

./configure --disable-x86asm 生成相关配置

如果是相关参数中的文件没有找到,检查脚本中的反斜杠 \ 换行符是否都有,像笔者这里之前测试就马虎忘记写了一行,所以有了如下错误:
在这里插入图片描述

 --prefix=out/lib: 没有那个文件或目录
  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

有头发的猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值