栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

ffmpeg 4.1.7编译arm64-v8a流程

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ffmpeg 4.1.7编译arm64-v8a流程

1、概述

这次编译的是ffmpeg 4.1.7 arm64-vba版本
下载地址:https://ffmpeg.org/download.html

【前置条件】:

  • 已经部署好ndk, 使用:android-ndk-r21e
  • 编译环境:Ubuntu 16.04.2 LTS
2、环境变量配置
export NDK=/home/share/ide/android-ndk-r21e
export SYSROOT=$NDK/platforms/android-21/arch-arm64/
export TOOLCHAIN=/home/share/ide/my-android-toolchain64
export PATH=$TOOLCHAIN/bin:$PATH
export CC=aarch64-linux-android-gcc
export CPP=aarch64-linux-android-g++
export LD=aarch64-linux-android-ld
export AR=aarch64-linux-android-ar
export STRIP=aarch64-linux-android-strip
3、配置文件

创建sh脚本执行:build_android.sh

#!/bin/bash

#!/bin/bash

CFLAGS="-O3 -Wall -marm -pipe -fpic -fasm 
  -finline-limit=300 -ffast-math 
  -fstrict-aliasing -Werror=strict-aliasing 
  -fmodulo-sched -fmodulo-sched-allow-regmoves 
  -Wno-psabi -Wa,--noexecstack 
  -DANDROID -DNDEBUG"

EXTRA_CFLAGS="-mfpu=neon -mfloat-abi=softfp"

FFMPEG_FLAGS="--prefix=./android-ffmpeg-install 
  --target-os=linux 
  --arch=arm64 
  --enable-cross-compile 
  --cross-prefix=$TOOLCHAIN/bin/aarch64-linux-android- 
  --enable-static 
  --disable-ffplay 
  --disable-ffprobe 
  --enable-shared 
  --disable-symver 
  --disable-doc 
  --disable-encoders  
  --disable-devices 
  --enable-protocols  
  --enable-parsers 
  --enable-demuxers 
  --disable-demuxer=sbg 
  --enable-decoders 
  --enable-bsfs 
  --enable-network 
  --enable-swscale  
  --enable-neon 
  --enable-asm 
  --enable-gpl 
  --enable-pthreads 
  --disable-linux-perf 
  --enable-version3"

./configure $FFMPEG_FLAGS --extra-cflags="$CFLAGS $EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS"
4、执行

make -j8

5、合成输出 ffmpeg.so

创建sh脚本执行: combine.sh

#!/bin/bash

EXTRA_CFLAGS="-march=arm64-v8a -mfpu=neon -mfloat-abi=softfp -mvectorize-with-neon-quad"

#rm libavutil/log2_tab.o
#rm libavcodec/log2_tab.o
#rm libavformat/golomb_tab.o
#rm libavformat/log2_tab.o
#rm libswresample/log2_tab.o
#rm libswscale/log2_tab.o
#rm libavfilter/log2_tab.o
#rm -rf libavcodec/reverse.o

$CC -lm -lz -shared --sysroot=$SYSROOT -Wl,--no-undefined 
   -Wl,-z,noexecstack $EXTRA_LDFLAGS libavutil/log2_tab.c libavutil/*.o libavutil/aarch64/*.o 
   libavcodec/*.o libavcodec/aarch64/*.o libavcodec/neon/*.o libavformat/*.o libswresample/*.o libswresample/aarch64/*.o 
   libswscale/*.o libswscale/libswscale.a compat/*.o -o libffmpeg.so

$STRIP -g libffmpeg.so
6、错误记录 6.1、64位报错
报错:
aarch64-linux-android-gcc is unable to create an executable file.
C compiler test failed.


ffbuild/config.log查看报错:
clang90: error: unknown argument: '-mvectorize-with-neon-quad'
clang90: error: the clang compiler does not support '-march=arm64-v8a'

解决:64位编译不要设置以下两个参数

-mvectorize-with-neon-quad:由于GCC 4.4只对双字自动向量化,加了这个就可以对四字了
-march=xxxx
6.2、64位报错
libavcodec/hevc_mvs.c:368:23: error: use of undeclared   identifier 'y0000000'
    is_available_b0 = AVAILABLE(cand_up_right, B0) &&
                      ^
libavcodec/hevc_mvs.c:274:16: note: expanded from macro 'AVAILABLE'
    (cand && !(TAB_MVF_PU(v).pred_flag == PF_INTRA))
               ^
libavcodec/hevc_mvs.c:208:15: note: expanded from macro 'TAB_MVF_PU'
            ((y ## v) >> s->ps.sps->log2_min_pu_size))
              ^
:332:1: note: expanded from here y0000000
^
libavcodec/hevc_mvs.c:368:23: error: use of undeclared identifier 'x0000000'
libavcodec/hevc_mvs.c:274:16: note: expanded from macro 'AVAILABLE'
    (cand && !(TAB_MVF_PU(v).pred_flag == PF_INTRA))
               ^
libavcodec/hevc_mvs.c:207:15: note: expanded from macro 'TAB_MVF_PU'
    TAB_MVF(((x ## v) >> s->ps.sps->log2_min_pu_size),

解决:配置文件传参

--disable-linux-perf

解决参考:
https://github.com/android/ndk/issues/630

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/276868.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号