How to fix build ffmpeg enable-jni error "jni not found", support for hard decoding

本文详细介绍如何使用Android NDK静态编译FFmpeg,包括配置环境变量、选择目标平台、指定架构和交叉编译工具链,以及启用各种编解码器和硬件加速选项。

See configure file

enabled jni               && { [ $target_os = "android" ] && check_header jni.h && enabled pthreads &&
                                check_lib "dlfcn.h" dlopen -ldl || die "ERROR: jni not found"; }

You can see target_os must android.

#!/bin/bash  
NDK=~/android-ndk-r14b/
SYSROOT=$NDK/platforms/android-14/arch-arm/  
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64  
CPU=armv7-a
PREFIX=$(pwd)/$CPU  
ADDI_CFLAGS="-marm -march=$CPU"  

./configure \
    --prefix=$PREFIX \
    --enable-static \
    --disable-shared \
    --disable-ffserver \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-doc \
    --disable-symver \
    --enable-small \
    --enable-gpl \
    --enable-asm \
    --enable-jni \
    --enable-mediacodec \
    --enable-decoder=h264_mediacodec \
    --enable-hwaccel=h264_mediacodec \
    --enable-decoder=hevc_mediacodec \
    --enable-decoder=mpeg4_mediacodec \
    --enable-decoder=vp8_mediacodec \
    --enable-decoder=vp9_mediacodec \
    --enable-nonfree \
    --enable-version3 \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    --target-os=android \
    --arch=arm \
    --sysroot=$SYSROOT \
    --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
    --extra-ldflags="$ADDI_LDFLAGS" \
    $ADDITIONAL_CONFIGURE_FLAG  
FFmpeg decoder module The FFmpeg module provides , which uses FFmpeg for decoding and can render audio encoded in a variety of formats.FfmpegAudioRenderer License note Please note that whilst the code in this repository is licensed under Apache 2.0, using this module also requires building and including one or more external libraries as described below. These are licensed separately. Build instructions (Linux, macOS) To use the module you need to clone this GitHub project and depend on its modules locally. Instructions for doing this can be found in the top level README. The module is not provided via Google's Maven repository (see ExoPlayer issue 2781 for more information). In addition, it's necessary to manually build the FFmpeg library, so that gradle can bundle the FFmpeg binaries in the APK: Set the following shell variable: cd "<path to project checkout>" FFMPEG_MODULE_PATH="$(pwd)/libraries/decoder_ffmpeg/src/main" Download the Android NDK and set its location in a shell variable. This build configuration has been tested on NDK r26b (r23c if ANDROID_ABI is less than 21). NDK_PATH="<path to Android NDK>" Set the host platform (use "darwin-x86_64" for Mac OS X): HOST_PLATFORM="linux-x86_64" Set the ABI version for native code (typically it's equal to minSdk and must not exceed it): ANDROID_ABI=21 Fetch FFmpeg and checkout an appropriate branch. We cannot guarantee compatibility with all versions of FFmpeg. We currently recommend version 6.0: cd "<preferred location for ffmpeg>" && \ git clone git://source.ffmpeg.org/ffmpeg && \ cd ffmpeg && \ git checkout release/6.0 && \ FFMPEG_PATH="$(pwd)" Configure the decoders to include. See the Supported formats page for details of the available decoders, and which formats they support. ENABLED_DECODERS=(vorbis opus flac) Add a link to the FFmpeg source code in the FFmpeg module directory.jni cd "${FFMPEG_MODULE_PATH}/jni" && \ ln -s "$FFMPEG_PATH" ffmpeg Execute to build FFmpeg for , , and . The script can be edited if you need to build for different architectures:build_ffmpeg.sharmeabi-v7aarm64-v8ax86x86_64 cd "${FFMPEG_MODULE_PATH}/jni" && \ ./build_ffmpeg.sh \ "${FFMPEG_MODULE_PATH}" "${NDK_PATH}" "${HOST_PLATFORM}" "${ANDROID_ABI}" "${ENABLED_DECODERS[@]}" Install CMake Having followed these steps, gradle will build the module automatically when run on the command line or via Android Studio, using CMake and Ninja to configure and build the module's JNI wrapper library. Build instructions (Windows) We do not provide support for building this module on Windows, however it should be possible to follow the Linux instructions in Windows PowerShell. Using the module with ExoPlayer Once you've followed the instructions above to check out, build and depend on the module, the next step is to tell ExoPlayer to use . How you do this depends on which player API you're using:FfmpegAudioRenderer If you're passing a to , you can enable using the module by setting the parameter of the constructor to . This will use for playback if doesn't support the input format. Pass to give priority over .DefaultRenderersFactoryExoPlayer.BuilderextensionRendererModeDefaultRenderersFactoryEXTENSION_RENDERER_MODE_ONFfmpegAudioRendererMediaCodecAudioRendererEXTENSION_RENDERER_MODE_PREFERFfmpegAudioRendererMediaCodecAudioRenderer If you've subclassed , add an to the output list in . ExoPlayer will use the first in the list that supports the input media format.DefaultRenderersFactoryFfmpegAudioRendererbuildAudioRenderersRenderer If you've implemented your own , return an instance from . ExoPlayer will use the first in the returned array that supports the input media format.RenderersFactoryFfmpegAudioRenderercreateRenderersRenderer If you're using , pass an in the array of s. ExoPlayer will use the first in the list that supports the input media format.ExoPlayer.BuilderFfmpegAudioRendererRendererRenderer Note: These instructions assume you're using . If you have a custom track selector the choice of is up to your implementation, so you need to make sure you are passing an to the player, then implement your own logic to use the renderer for a given track.DefaultTrackSelectorRendererFfmpegAudioRenderer 根据以上内容帮我写一份github action工作流
最新发布
01-01
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值