简体   繁体   English

Android NDK 在 2021 年构建 FFMPEG

[英]Android NDK Build FFMPEG in 2021

I'm working on an android app, and I have to convert webm files to mp3 .我正在开发 android 应用程序,我必须将webm文件转换为mp3 I really want to make a custom ffmpeg build, because it reduces the ffmpeg executable size to only 2MB.我真的很想制作一个自定义的 ffmpeg 构建,因为它将 ffmpeg 可执行文件的大小减少到只有 2MB。

My library works absolutely fine when running on my PC , but i'm struggling to build it for android... It seems like NDK architecture has changed and tutorials are outdated, and I can't find a proper and recent guide for android compiling...我的库在我的 PC 上运行时工作得非常好,但我正在努力为 android 构建它......似乎 NDK 架构已经改变并且教程已经过时,我找不到合适的和最新的 android 编译指南...

I also would like to target all architectures ( aarch64 , armv7 , i686 , and x86_64 )...我还想针对所有架构( aarch64armv7i686x86_64 )...

I've been on this for hours, fixed many errors, but still nothing has worked ><.我已经研究了好几个小时,修复了很多错误,但仍然没有任何效果><。 Please help me: :\请帮我: :\

PS.附言。 I'm compiling on Linux, here is my configuration script:我在 Linux 上编译,这是我的配置脚本:

#!/bin/bash

API=31 # target android api

OUTPUT=/home/romain/dev/android/ffmpeg_build

NDK=/home/romain/android-sdk/ndk/23.0.7599858
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
SYSROOT=$TOOLCHAIN/sysroot

TOOL_PREFIX="$TOOLCHAIN/bin/aarch64-linux-android"

CC="$TOOL_PREFIX$API-clang"
CXX="$TOOL_PREFIX$API-clang++"

./configure \
    --prefix=$OUTPUT \
    --target-os=android \
    --arch=$ARCH \
    --cpu=$CPU \
    --disable-everything \
    --disable-everything \
    --disable-network \
    --disable-autodetect \
    --enable-small \
    --enable-decoder=opus,vorbis \
    --enable-demuxer=matroska \
    --enable-muxer=mp3 \
    --enable-protocol=file \
    --enable-filter=aresample \
    --enable-libshine \
    --enable-encoder=libshine \
    --cc=$CC \
    --cxx=$CXX \
    --sysroot=$SYSROOT \
    --extra-cflags="-0s -fpic"

make
make install

The prefix should point to $SYSROOT/usr/ and you misunderstood what --prefix mean.前缀应该指向$SYSROOT/usr/并且您误解了--prefix意思。 Its not output directory.它不是输出目录。 Other than that i think nothing problematic than that (if it still happen please provide ffbuild/config.log )除此之外,我认为没有什么比这有问题的(如果它仍然发生,请提供ffbuild/config.log

The repository pointed to by the previous answer is no longer being maintained.不再维护先前答案指向的存储库。 Here is an updated one.是一个更新的。

This is the android branch: https://github.com/arthenica/ffmpeg-kit/tree/main/android这是 android 分支: https://github.com/arthenica/ffmpeg-kit/tree/main/android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM