Code Monkey home page Code Monkey logo

ffmpeg-android-maker's Introduction

ffmpeg-android-maker

Codacy Badge Compilability check Android Weekly #378 Android Weekly #396

Here is a script that downloads the source code of FFmpeg library and assembles it for Android. The script produces shared libraries (*.so files) as well as header files (*.h files). The output structure is represented in the image.

The script also produces ffmpeg and ffprobe executables that can be used in Android's terminal directly or can even be embedded into an Android app. They can be found in build directory after the successful build.

The main focus of ffmpeg-android-maker is to prepare shared libraries for seamless integration into an Android project. The script prepares the output directory that is meant to be used. And it's not the only thing this project does.

By default this script downloads and builds the FFmpeg 7.0, but the version can be overridden.

The details of how this script is implemented are described in this series of posts:

The WIKI contains a lot of useful information.

Customization

The actual content of output directory depends on how the FFmpeg was configured before assembling. The master branch of ffmpeg-android-maker builds 'vanilla' version of FFmpeg. This means all default components and shared libraries are built (according to the image).

The media-file branch contains certain customizations in build scripts of FFmpeg and certain external libraries. These customizations are meant to be an example of how this project can be tuned to obtain the only functionality that is actually needed. What is actually customized can be seen here.

The MediaFile Android library uses only a subset of FFmpeg's functionality, so the redundant parts are not even compiled. This gives much smaller output binaries.

Also there are a lot of arguments that you can pass to the ffmpeg-android-maker.sh script for tuning certain features. Check this WIKI page out for more info.

Supported Android ABIs

  • armeabi-v7a (with NEON)
  • arm64-v8a
  • x86
  • x86_64

If you need to build only some of these ABIs, you can do so by specifying a flag.

The default Android API version used to compile these binaries is 19, as the minimum supported by the Android NDK r24. However, with NDK r23 it is still possible to have it 16. Some external libraries (like libvpx) require to use higher API - 21. This is explained at this WIKI page in more details.

Supported host OS

Regardless of the OS you use, you need to setup it before executing the script. Please follow the instructions in Requirements section.

On macOS and Linux the script is supported natively. Just execute it script in the terminal.

On Windows 10 you can use WSL technology to install Ubuntu 20.04 LTS app. Then follow the Linux way of executing the script. Note that you will need to manually install exactly Linux versions of Android SDK and NDK into your Linux subsystem. The Dockerfile may help to understand how to do the setup.

Also on any OS you can use Docker tool to execute the script. Check this WIKI page out to understand benefits of this approach.

Requirements

The script assumes you have Android SDK and NDK already installed. In order to tell the script their locations you have to define 2 environment variables:

  • ANDROID_SDK_HOME - absolute path to your Android SDK
  • ANDROID_NDK_HOME - absolute path to your Android NDK

The script expects to use at least Android NDK r23. It doesn't matter if you use other version of NDK for you actual Android project.

Certain external libraries require additional software to be installed. Check this WIKI page out for more info. Note that if you don't need these external libraries then you also don't need to install the additional software. These external libraries are not built by default.

Features

Add an arbitrary external library that FFMpeg supports to the building process. Just specify how the source code needs to be downloaded and how to perform the build operation. More about this is here.

Setting your own FFmpeg version and origin. You can actually override the version of FFmpeg used by the script. See details here.

Test your script in a cloud. This repository has CI integration and you can use it too for your own configurations. See details here.

Text relocations monitoring. After an assembling is finished you can look into stats/text-relocations.txt file. This file lists all *.so files that were built and reports if any of them has text relocations. If you don't see any mentioning of 'TEXTREL' in the file, you are good. Otherwise, you will see exact binaries that have this problem. The Github Actions' Compilability check build will automatically fail if text relocations occur.

License

The ffmpeg-android-maker's source code is available under the MIT license. See the LICENSE.txt file for more details.

However, the binaries that are produced have different license. The FFmpeg itself is under LGPL 2.1. Enabling certain external libraries (like libx264) changes the license to be GPL 2 or later.

ffmpeg-android-maker's People

Contributors

a2va avatar bugparty avatar codacy-badger avatar javernaut avatar mdrokz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ffmpeg-android-maker's Issues

libavcodec.so: error: undefined reference to 'log2'

libavcodec/libavcodec.so: error: undefined reference to 'log2'
libavcodec/libavcodec.so: error: undefined reference to 'log2'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [ffprobe_g] Error 1
make: *** Waiting for unfinished jobs....
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [ffmpeg_g] Error 1

How to solve this problem?
NDK:21.3
What's the reason I haven't found the problem for a long time..

x86 headers actually differ from others

In libavutil/avconfig.h the constant AV_HAVE_FAST_UNALIGNED is defined as 0, while for all other architectures it is defined as 1.

Having a single /include folder is a priority, and this tiny difference isn't a reason to separate /include folders for all architectures.

It is actually possible to set AV_HAVE_FAST_UNALIGNED to 1 for x86 arch (as for all other) by passing --enable-fast-unaligned flag to configure script. I wouldn't like to override the default behavior of configure here.

So the issue does take place, but it isn't harmful for now.

Problem with building external gnutls library

Hi,
I am having problems with adding --enable-gnutls to the build. I cannot reconcile dependencies and have installed GnuTls subdependency Libnettle. Have any one succeeded in adding GnuTLS support to the ffmpeg?

Regards
Patryk

ffmpeg binary not getting built

Hello! First off thanks for this great project! I tried running the script so I can build the ffmpeg binary for android, however it doesn't appear that is getting generated. I modified the configure settings by removing the --disable-programs and disabled the other binaries I'm not interested in such as ffprobe and ffplay. In fact, this is what the modified configure options look like inside ffmpeg-android-maker.sh

  ./configure \
    --prefix=${BUILD_DIR}/${ABI} \
    --enable-cross-compile \
    --target-os=android \
    --arch=${TARGET_TRIPLE_MACHINE_BINUTILS} \
    --sysroot=${SYSROOT} \
    --cross-prefix=${CROSS_PREFIX} \
    --cc=${CC} \
    --extra-cflags="-O3 -fPIC" \
    --enable-shared \
    --disable-static \
    ${EXTRA_BUILD_CONFIGURATION_FLAGS} \
    --disable-runtime-cpudetect \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-avdevice \
    --disable-postproc \
    --disable-swresample \
    --disable-avfilter \
    --disable-doc \
    --disable-debug \
    --disable-pthreads \
    --disable-network \
    --disable-bsfs

Any reason?

c compiler test failed

WARNING: /toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-pkg-config not found, library detection may fail.
mktemp -u XXXXXX
A0Quav
test_ld cc
test_cc
BEGIN /var/folders/gq/s_z1gl311m35t0lfbpd88h59yz5bw5/T//ffconf.OX3pcfIE/test.c
1 int main(void){ return 0; }
END /var/folders/gq/s_z1gl311m35t0lfbpd88h59yz5bw5/T//ffconf.OX3pcfIE/test.c
/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang --sysroot=/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -O3 -fPIC -I/Users/rakesh-3121/repositories/ffmpeg-samples/ffmpeg-android-maker/build/external/arm64-v8a/include -c -o /var/folders/gq/s_z1gl311m35t0lfbpd88h59yz5bw5/T//ffconf.OX3pcfIE/test.o /var/folders/gq/s_z1gl311m35t0lfbpd88h59yz5bw5/T//ffconf.OX3pcfIE/test.c
./configure: line 974: /toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang: No such file or directory
C compiler test failed.

Any help on this error

Docker support to fix Windows builds (and Linux/Mac)

Hi,

Firstly, thanks for this project - it makes building ffmpeg far easier!

I wanted to be able to easily build this on Windows but noticed that's now not possible in v2.0.0, and last time I did try and build it on Windows using MSYS2 pre v2.0.0 I ended up with a whole range of strange build problems and just ended up installing an Ubuntu VM where it was quite straight forward.

I'd like to avoid having to use a Linux VM so I figured the best way would be to be able to build it in Docker. I've created pull request 21 which will build a Docker image that does all the work for you. You can mount /build/build from the Docker container to a path on your host to access to the built files.

I've updated the readme in the pull request which explains how to use it.

Can't build the .so files

Hello,
I've tried to build the .so files using terminal, but i get some errors. I'm not so sure where is the problem, but i think is from my NDK.
The NDK comes from Android Studio.
Here is the logs (can't format logs, sorry):


Using FFmpeg 4.2
/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi16-clang is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
[email protected] mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:94: /libavutil/Makefile: No such file or directory
Makefile:94: /ffbuild/library.mak: No such file or directory
Makefile:96: /fftools/Makefile: No such file or directory
Makefile:97: /doc/Makefile: No such file or directory
Makefile:98: /doc/examples/Makefile: No such file or directory
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target /tests/Makefile'. Stop. Makefile:2: ffbuild/config.mak: No such file or directory Makefile:40: /tools/Makefile: No such file or directory Makefile:41: /ffbuild/common.mak: No such file or directory Makefile:94: /libavutil/Makefile: No such file or directory Makefile:94: /ffbuild/library.mak: No such file or directory Makefile:96: /fftools/Makefile: No such file or directory Makefile:97: /doc/Makefile: No such file or directory Makefile:98: /doc/examples/Makefile: No such file or directory Makefile:163: /tests/Makefile: No such file or directory make: *** No rule to make target /tests/Makefile'. Stop.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:94: /libavutil/Makefile: No such file or directory
Makefile:94: /ffbuild/library.mak: No such file or directory
Makefile:96: /fftools/Makefile: No such file or directory
Makefile:97: /doc/Makefile: No such file or directory
Makefile:98: /doc/examples/Makefile: No such file or directory
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target `/tests/Makefile'. Stop.
./ffmpeg-android-maker.sh: line 197: /toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-readelf: No such file or directory
cp: /Users/catalin/Downloads/ffmpeg-android-maker-master/build/armeabi-v7a/lib/*.so: No such file or directory
/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
[email protected] mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:94: /libavutil/Makefile: No such file or directory
Makefile:94: /ffbuild/library.mak: No such file or directory
Makefile:96: /fftools/Makefile: No such file or directory
Makefile:97: /doc/Makefile: No such file or directory
Makefile:98: /doc/examples/Makefile: No such file or directory
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target /tests/Makefile'. Stop. Makefile:2: ffbuild/config.mak: No such file or directory Makefile:40: /tools/Makefile: No such file or directory Makefile:41: /ffbuild/common.mak: No such file or directory Makefile:94: /libavutil/Makefile: No such file or directory Makefile:94: /ffbuild/library.mak: No such file or directory Makefile:96: /fftools/Makefile: No such file or directory Makefile:97: /doc/Makefile: No such file or directory Makefile:98: /doc/examples/Makefile: No such file or directory Makefile:163: /tests/Makefile: No such file or directory make: *** No rule to make target /tests/Makefile'. Stop.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:94: /libavutil/Makefile: No such file or directory
Makefile:94: /ffbuild/library.mak: No such file or directory
Makefile:96: /fftools/Makefile: No such file or directory
Makefile:97: /doc/Makefile: No such file or directory
Makefile:98: /doc/examples/Makefile: No such file or directory
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target `/tests/Makefile'. Stop.
./ffmpeg-android-maker.sh: line 197: /toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-readelf: No such file or directory
cp: /Users/catalin/Downloads/ffmpeg-android-maker-master/build/arm64-v8a/lib/*.so: No such file or directory
/toolchains/llvm/prebuilt/darwin-x86_64/bin/i686-linux-android16-clang is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
[email protected] mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:94: /libavutil/Makefile: No such file or directory
Makefile:94: /ffbuild/library.mak: No such file or directory
Makefile:96: /fftools/Makefile: No such file or directory
Makefile:97: /doc/Makefile: No such file or directory
Makefile:98: /doc/examples/Makefile: No such file or directory
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target /tests/Makefile'. Stop. Makefile:2: ffbuild/config.mak: No such file or directory Makefile:40: /tools/Makefile: No such file or directory Makefile:41: /ffbuild/common.mak: No such file or directory Makefile:94: /libavutil/Makefile: No such file or directory Makefile:94: /ffbuild/library.mak: No such file or directory Makefile:96: /fftools/Makefile: No such file or directory Makefile:97: /doc/Makefile: No such file or directory Makefile:98: /doc/examples/Makefile: No such file or directory Makefile:163: /tests/Makefile: No such file or directory make: *** No rule to make target /tests/Makefile'. Stop.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:94: /libavutil/Makefile: No such file or directory
Makefile:94: /ffbuild/library.mak: No such file or directory
Makefile:96: /fftools/Makefile: No such file or directory
Makefile:97: /doc/Makefile: No such file or directory
Makefile:98: /doc/examples/Makefile: No such file or directory
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target `/tests/Makefile'. Stop.
./ffmpeg-android-maker.sh: line 197: /toolchains/llvm/prebuilt/darwin-x86_64/bin/i686-linux-android-readelf: No such file or directory
cp: /Users/catalin/Downloads/ffmpeg-android-maker-master/build/x86/lib/*.so: No such file or directory
/toolchains/llvm/prebuilt/darwin-x86_64/bin/x86_64-linux-android21-clang is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
[email protected] mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:94: /libavutil/Makefile: No such file or directory
Makefile:94: /ffbuild/library.mak: No such file or directory
Makefile:96: /fftools/Makefile: No such file or directory
Makefile:97: /doc/Makefile: No such file or directory
Makefile:98: /doc/examples/Makefile: No such file or directory
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target /tests/Makefile'. Stop. Makefile:2: ffbuild/config.mak: No such file or directory Makefile:40: /tools/Makefile: No such file or directory Makefile:41: /ffbuild/common.mak: No such file or directory Makefile:94: /libavutil/Makefile: No such file or directory Makefile:94: /ffbuild/library.mak: No such file or directory Makefile:96: /fftools/Makefile: No such file or directory Makefile:97: /doc/Makefile: No such file or directory Makefile:98: /doc/examples/Makefile: No such file or directory Makefile:163: /tests/Makefile: No such file or directory make: *** No rule to make target /tests/Makefile'. Stop.
Makefile:2: ffbuild/config.mak: No such file or directory
Makefile:40: /tools/Makefile: No such file or directory
Makefile:41: /ffbuild/common.mak: No such file or directory
Makefile:94: /libavutil/Makefile: No such file or directory
Makefile:94: /ffbuild/library.mak: No such file or directory
Makefile:96: /fftools/Makefile: No such file or directory
Makefile:97: /doc/Makefile: No such file or directory
Makefile:98: /doc/examples/Makefile: No such file or directory
Makefile:163: /tests/Makefile: No such file or directory
make: *** No rule to make target `/tests/Makefile'. Stop.
./ffmpeg-android-maker.sh: line 197: /toolchains/llvm/prebuilt/darwin-x86_64/bin/x86_64-linux-android-readelf: No such file or directory
cp: /Users/catalin/Downloads/ffmpeg-android-maker-master/build/x86_64/lib/*.so: No such file or directory
./ffmpeg-android-maker.sh: line 225: cd: /Users/catalin/Downloads/ffmpeg-android-maker-master/build: No such file or directory
./ffmpeg-android-maker.sh: line 226: cd: .DS_Store: Not a directory
cp: include: No such file or directory

Thanks.

Libvpx isn't compilable with LLVM

Hi,

It seems that this project does not currently support Android NDK 23. As the NDK changelog states, GNU binutils have been removed from the NDK. As such, the scripts in this repo to build ffmpeg fail due to missing utils like arm-linux-androideabi-strip.

How to run FFMPEG command using cpp Android?

We build whole library as per your script and suggestion, but what after that. We need to run our all complex command on it! Than how we can write cpp code for Android? What is the code to run FFMPEG command? Your example is only contains how to get video frames, but what if we need execute our command like other libraries built by popular tanersener, bravobit etc...

Doesnt compile

/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi16-clang is unable to create an executable file.
C compiler test failed.

I need help configuring ffmpeg in my application.

Sorry to submit this as an issue. But I had no way to contact you outside github.
Here is my problem,

2020-06-07 18:19:15.686 29697-29697/com.bini.bee.studio E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.bini.bee.studio, PID: 29697
java.lang.UnsatisfiedLinkError: dlopen failed: library "libavutil.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
at java.lang.System.loadLibrary(System.java:1667)
at com.bini.bee.studio.javaBee.(javaBee.java:6)
at com.bini.bee.studio.VideoEditorActivity.onClick(VideoEditorActivity.java:102)
at android.view.View.performClick(View.java:7140)
at android.view.View.performClickInternal(View.java:7117)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27355)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7397)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
2020-06-07 18:19:15.693 29697-29697/com.bini.bee.studio I/Process: Sending signal. PID: 29697 SIG: 9

My CMake :

cmake_minimum_required(VERSION 3.4.1)

set(ffmpeg_dir ${CMAKE_SOURCE_DIR}/src/main/nativeLibs)
set(ffmpeg_libs ${ffmpeg_dir}/lib/${ANDROID_ABI})

include_directories(${ffmpeg_dir}/include/${ANDROID_ABI})

set(
# List variable name
ffmpeg_libs_names
# Values in the list
avutil avformat avcodec swscale)

foreach (ffmpeg_lib_name ${ffmpeg_libs_names})
add_library(
${ffmpeg_lib_name}
SHARED
IMPORTED)
set_target_properties(
${ffmpeg_lib_name}
PROPERTIES
IMPORTED_LOCATION
${ffmpeg_libs}/lib${ffmpeg_lib_name}.so)
endforeach ()

add_library(
# Name for a library to build
nativeLib
# Type of a library
SHARED
# All cpp files to compile
src/main/nativeLibs/nativeBee.cpp)

target_link_libraries(
# Library to link
nativeLib
# List of libraries to link against:
# Library for writing messages in LogCat
log
# Library for processing Bitmap objects
jnigraphics
# FFmpeg libraries
${ffmpeg_libs_names})

I have analysed the apk , it is only 1.85 mb.
my library nativeLib is present inside the apk. I don't know if the ffmpeg libraries are linked to it.

Undefined reference to 'main'

Hello. Thank you for the awesome script, It was such a pleasure after all to just see how ffmpeg is simply being compiled)

I have a question that is not related to this repository, but I will be very happy if you could take a look at it:

I am trying to build static libs of ffmpeg 4.0.2 ver to use it with JNI in my Android Studio project.
Configuration:

ffmpeg:
    $(TBZUNPACK) $(FFMPEG)
    # include/binder,cutils,utils,multimedia/stagefright
    cd $(FFMPEGDIR); cat ../patches/android-ffmpeg-*.diff | patch -p1
    #tar -C $(DEPENDENCIES)/ -xjf $(STAGEFRIGHT).tbz
  
    cd $(FFMPEGDIR); ./configure 
        --prefix=$(DEPENDENCIES) \
        --enable-pic \
        --enable-libmp3lame \
        --enable-libtheora --enable-libvorbis \
        --enable-libx264 --enable-libvpx \
        --enable-libopus \
        --enable-gpl --enable-nonfree --disable-outdev=sdl \
        --disable-doc \
        --enable-cross-compile 
        --enable-shared --cross-prefix=$(CCPREFIX) \
        --target-os=linux $(FFMPEG_ANDROID) \
        --extra-cflags="$(ANDROID_CFLAGS) -I$(DEPENDENCIES)/include   $(ANDROID_EXTRA_HEADERS)" \
        --extra-cxxflags="$(ANDROID_CFLAGS) -I$(DEPENDENCIES)/include $(ANDROID_EXTRA_HEADERS)"\
        --extra-ldflags="$(ANDROID_LDFLAGS) -L$(DEPENDENCIES)/lib -Wl,--allow-shlib-undefined -Wl,-rpath-link=$(DEPENDENCIES)/lib"
    make -C $(FFMPEGDIR) $(PARALLEL_MAKE)
    make -C $(FFMPEGDIR) install
    rm -rf $(FFMPEGDIR)

and I am getting my build failed with this error:

 /home/android-ndk/./platforms/android-16/arch-arm/usr/lib/crtbegin_dynamic.o:crtbrand.c:function _start: error: undefined reference to 'main'
collect2: error: ld returned 1 exit status
Makefile:107: recipe for target 'ffplay_g' failed
make[1]: *** [ffplay_g] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/ffmpeg-4.0.2'
Makefile.android:180: recipe for target 'ffmpeg' failed
make: *** [ffmpeg] Error 2

I can't understand what function main is doing there, because I thought I am compiling libraries, not executables.

Also, I tried to implement this configuration into your script. Script worked out ok, but no files were generated =(

Question / Feature - download files from Travis CI

First, the Travis CI integration works fine on branches, too - I just had to do a 'dummy commit & push' as already described. Great !

However, I was wondering if it is possible to download the files generated by Travis Ci ? E.g. the .so and header files.

why replace LD with CC?

your scripts:
export FAM_LD=${FAM_CC}
export FAM_AS=${FAM_CC}

usually:
export LD=$TOOLCHAIN/bin/$TARGET-ld
export AS=$TOOLCHAIN/bin/$TARGET-as

when I change FAM_LD and FAM_AS to real path to ld and as, can not build!
What's wrong and why?

Can't open libavfilter/libavfilter.version

./ffbuild/pkgconfig_generate.sh: 21: .: Can't open libavfilter/libavfilter.version
make: *** [ffbuild/library.mak:102: libavdevice/libavdevice.pc] Error 127

My OS: ubuntu 20

x86 binary doesn't have assembler optimizations

The configuration for x86 binary explicitly disables assembler optimizations, since they bring text relocations. This stuff is forbidden in the latest versions of Android OS.

So it should be investigated further and ideally those optimizations should be enabled back with dropping of text relocations themselves.

How to build a debug version of ffmpeg libraries?

Sir,

Your tool help me a lot, thank you very much!

I have encountered some difficult problems on Android and need to debug into ffmpeg. Is there a way for your tool to build a debug version of the ffmpeg library? Or can you provide some hints for me to do this manually?

Best Regards,
Peter

Problems with ffmpeg build on docker

I run docker run --rm ^ -v C:\path\to\ffmpeg-android-maker:/mnt/ffmpeg-android-maker ^ javernaut/ffmpeg-android-maker

But Docker return this:/usr/bin/env: 'bash\r': No such file or directory

I saw the CRLF line ending cause problems on Windows and I tried to use LF but it will return the same error.

ffmpeg with mp3 codec

Hello!
Thanks for this script. Im desperate trying to build ffmpeg for android. so far i can build a naked instance now with our script. But i need to add lame (mp3) to it because i need to decode MPEG2-L2 streams.

im running the script and added --enable-libmp3lame to the configure part.
when im trying to build this now it shows the following:

ERROR: libmp3lame >= 3.98.3 not found

On my system i installed lame:
janeichhorn@Jans-MBP sources % lame LAME 64bits version 3.99.5 (http://lame.sf.net)

also it seems like the libs are placed in the correct directories:

for lib:

janeichhorn@Jans-MBP sources % ls /usr/local/lib/libmp3lame.a /usr/local/lib/libmp3lame.a

for include:

janeichhorn@Jans-MBP include % ls /usr/local/include/lame lame.h

Also i added
--extra-cflags="-I/usr/local/include -O3 -fPIC" \ --extra-ldflags="-L/usr/local/lib" \

do you know or does anyone knows how this is working? I am using mac OSX 10.15.1.

this is the output of the build log:

test_ld cc -lmp3lame -lm test_cc BEGIN /var/folders/p_/yz6grx197198g3q41x22hxk40000gn/T//ffconf.B1MgsdwI/test.c 1 #include <lame/lame.h> 2 #include <stdint.h> 3 long check_lame_set_VBR_quality(void) { return (long) lame_set_VBR_quality; } 4 int main(void) { int ret = 0; 5 ret |= ((intptr_t)check_lame_set_VBR_quality) & 0xFFFF; 6 return ret; } END /var/folders/p_/yz6grx197198g3q41x22hxk40000gn/T//ffconf.B1MgsdwI/test.c /Users/janeichhorn/Library/Android/sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi16-clang --sysroot=/Users/janeichhorn/Library/Android/sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -I/usr/local/include -O3 -fPIC -march=armv7-a -std=c11 -fPIE -fomit-frame-pointer -fPIC -marm -c -o /var/folders/p_/yz6grx197198g3q41x22hxk40000gn/T//ffconf.B1MgsdwI/test.o /var/folders/p_/yz6grx197198g3q41x22hxk40000gn/T//ffconf.B1MgsdwI/test.c /Users/janeichhorn/Library/Android/sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi16-clang -L/usr/local/lib --sysroot=/Users/janeichhorn/Library/Android/sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -march=armv7-a -Wl,--as-needed -Wl,-z,noexecstack -fPIE -pie -o /var/folders/p_/yz6grx197198g3q41x22hxk40000gn/T//ffconf.B1MgsdwI/test /var/folders/p_/yz6grx197198g3q41x22hxk40000gn/T//ffconf.B1MgsdwI/test.o -lmp3lame -lm /Users/janeichhorn/Library/Android/sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: mp3lame: no archive symbol table (run ranlib) /var/folders/p_/yz6grx197198g3q41x22hxk40000gn/T//ffconf.B1MgsdwI/test.o:test.c:function check_lame_set_VBR_quality: error: undefined reference to 'lame_set_VBR_quality' clang: error: linker command failed with exit code 1 (use -v to see invocation) ERROR: libmp3lame >= 3.98.3 not found

Would be so nice if someone can help me out here.

got a UnsatisfiedLinkError while running on Android 5.1 devices.

compiled and running is fine on device Android 9.0, but failed on android device 5.1, here is the error message:

  • java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "av_audio_fifo_peek_at" referenced by "libavfilter.so"...
    at java.lang.Runtime.loadLibrary(Runtime.java:371)
    at java.lang.System.loadLibrary(System.java:988)
    at com.joygames.joyplayer.MainActivity.(MainActivity.java:30)
    at java.lang.reflect.Constructor.newInstance(Native Method)
    at java.lang.Class.newInstance(Class.java:1606)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
    at android.app.ActivityThread.access$800(ActivityThread.java:151)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:893)
    06-08 11:32:29.482 5336-5336/? I/Process: Sending signal. PID: 5336 SIG: 9

Its really wired for me. cause it all working fine on high version devices. and the abi using is v7a.

[Developer Note] You can use this to build Release 3.4 by ...

You can use this to build ffmpeg 3.4 (needed by QtAv) by editing
ffmpeg-android-maker/scripts/ffmpeg/build.sh

and adding the following line below ./configure
--disable-indev=v4l2
and changing this line:
--extra-cflags="-O3 -fPIC $DEP_CFLAGS"
to this:
--extra-cflags="-fno-integrated-as -O3 -fPIC $DEP_CFLAGS" \

And finally calling the script with
./ffmpeg-android-maker.sh --source-git-branch=release/3.4

The extra flag -fno-integrated-as, keeps LLVM from messing with ffmpeg assembly code.

This will disable video4linux2 that breaks with the current ndk compiler.
There is a way to enable it, but then there are runtime errors, more info here:

tanersener/mobile-ffmpeg#48 (comment)

I was able to successfully build everything this way and it is working as intended

jni not found

I add --enabl-jni:

./configure \
--prefix=${BUILD_DIR_FFMPEG}/${ANDROID_ABI}
--enable-cross-compile
--target-os=android
--arch=${TARGET_TRIPLE_MACHINE_BINUTILS}
--sysroot=${SYSROOT_PATH}
--cc=${FAM_CC}
--cxx=${FAM_CXX}
--ld=${FAM_LD}
--ar=${FAM_AR}
--as=${FAM_CC}
--nm=${FAM_NM}
--ranlib=${FAM_RANLIB}
--strip=${FAM_STRIP}
--extra-cflags="-O3 -fPIC $DEP_CFLAGS"
--extra-ldflags="$DEP_LD_FLAGS"
--enable-shared
--disable-static
--pkg-config=${PKG_CONFIG_EXECUTABLE}
${EXTRA_BUILD_CONFIGURATION_FLAGS}
--disable-runtime-cpudetect
--disable-programs
--disable-avdevice
--disable-postproc
--disable-doc
--disable-debug
--disable-pthreads
--disable-network
--disable-bsfs
--enable-neon
--enable-jni
--enable-mediacodec
--enable-decoder=h264_mediacodec
$ADDITIONAL_COMPONENTS || exit 1

but ERROR:jni not found

config.log:
check_headers jni.h test_cpp BEGIN /var/folders/t1/c81wp_td7rlgq6f5jdnpy1f40000gp/T//ffconf.1ChaJAA1/test.c 1 #include <jni.h> 2 int x; END /var/folders/t1/c81wp_td7rlgq6f5jdnpy1f40000gp/T//ffconf.1ChaJAA1/test.c /Users/rain/Library/Android/sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi28-clang --sysroot=/Users/rain/Library/Android/sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -O3 -fPIC -I/Users/rain/apus/ffmpeg/ffmpeg-android-custom/build/external/armeabi-v7a/include -march=armv7-a -std=c11 -fPIE -fomit-frame-pointer -fPIC -mthumb -E -o /var/folders/t1/c81wp_td7rlgq6f5jdnpy1f40000gp/T//ffconf.1ChaJAA1/test.o /var/folders/t1/c81wp_td7rlgq6f5jdnpy1f40000gp/T//ffconf.1ChaJAA1/test.c ERROR: jni not found

I am sure ANDROID_SDK_HOME,ANDROID_NDK_HOME,SYSROOT_PATH is right!

libmp3lame not packaged when building static executable?

ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
      built with Android (7019983 based on r365631c3) clang version 9.0.9 (https://android.googlesource.com/toolchain/llvm-project a2a1e703c0edb03ba29944e529ccbf457742737b) (based on LLVM 9.0.9svn)
      configuration: --disable-everything --disable-network --enable-small --prefix=/mnt/c/Users/mrsha/AndroidStudioProjects/spotiflyer/ffmpeg/ffmpeg-android-maker/build/ffmpeg/arm64-v8a --enable-cross-compile --target-os=android --arch=aarch64 --sysroot=/home/shabinder/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot --cc=/home/shabinder/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang --cxx=/home/shabinder/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++ --ld=/home/shabinder/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang --ar=/home/shabinder/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar --as=/home/shabinder/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang --nm=/home/shabinder/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-nm --ranlib=/home/shabinder/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ranlib --strip=/home/shabinder/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip --extra-cflags='-O3 -fPIC -I/mnt/c/Users/mrsha/AndroidStudioProjects/spotiflyer/ffmpeg/ffmpeg-android-maker/build/external/arm64-v8a/include' --extra-ldflags='-L/mnt/c/Users/mrsha/AndroidStudioProjects/spotiflyer/ffmpeg/ffmpeg-android-maker/build/external/arm64-v8a/lib ' --enable-filter=aresample --enable-decoder='aac*,ac3*' --enable-demuxer=mov --enable-muxer=mp3 --enable-protocol=file --pkg-config=/usr/bin/pkg-config --x86asmexe=/home/shabinder/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/yasm --enable-libmp3lame
      libavutil      56. 70.100 / 56. 70.100
      libavcodec     58.134.100 / 58.134.100
      libavformat    58. 76.100 / 58. 76.100
      libavdevice    58. 13.100 / 58. 13.100
      libavfilter     7.110.100 /  7.110.100
      libswscale      5.  9.100 /  5.  9.100
      libswresample   3.  9.100 /  3.  9.100

As you can see conf does have --enable-libmp3lame

Build Cmd: ./ffmpeg-android-maker.sh --android-api-level=21 -lame

If I specify -acodec libmp3lame, then I get Unknown encoder 'libmp3lame'
and when I simply don't mention codec manually, I get

Automatic encoder selection failed for output stream #0:0. Default encoder for format mp3 (codec mp3) is probably disabled. Please choose an encoder manually.
    Error selecting an encoder for stream 0:0

Instructions Followed to Build Static Executable: #49 (comment)

C compiler test failed.

I am using Mac MOnterey

home/name/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/i686-linux-android19-clang is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
[email protected] mailing list or IRC #ffmpeg on irc.libera.chat.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.

ffmpeg cannot executable at android

I tried to exex ffmpeg at android cmd. but I got follow error.
Enviorment:
Ubuntu 16.04
NDK version: r22b
ffmpeg version: 4.4

05-27 00:43:59.098 +0000 22178 22178 W linker : /data/data/com/files/ffmpeg: unsupported flags DT_FLAGS_1=0x8000001
--------- beginning of crash
05-27 00:43:59.098 +0000 22178 22178 F libc : CANNOT LINK EXECUTABLE "/data/user/0/com/files/ffmpeg": library "libavdevice.so" not found
05-27 00:43:59.098 +0000 22178 22178 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 22178 (ffmpeg)

Licence free build

Using the --enable-all-free argument produces builds that do not include GPL2 code, but the resulting builds still include encoders/decoders and muxers/demuxers that require licences (ex. aac). Would you consider adding an option to generate builds that do not include components that require licences (ex. --exclude-licenced-encoders, --exclude-licenced-decoders, --exclude-licenced-muxers, --exclude-licenced-demuxers).
Thanks

Maintaining prebuilt libraries with maven central?

I stumbled across this because I have a need for libswscale in an Android app. Have you thought about maintaining pre-built libraries for this in maven central? You seem to have done most of the work done already, and that would simplify the approach so that other people could more easily benefit from this.

Thanks for the blog posts and tutorials. It's helpful :)

Enable static builds

Hello, thank you for providing these convenient scripts.

I would like to know if you would be willing to consider adding an option to specify whether the binaries are built as static or as shared. I am able to build static binaries if I disable the shared flag and enable the static flag in the script scripts/ffmpeg/build.sh and do not provide any arguments to the script. But if I provide the --enable-all-free argument to the script then the build fails with a number of errors.

andidate function has type mismatch at 2nd parameter

Hi, while building n4.1.4 as shown in example, I get the following error

/22.1.7171670/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/bits/ioctl.h:60:5: note: candidate function has type mismatch at 2nd parameter (expected 'unsigned long' but has 'unsigned int')

My ndk version is 22.1.7171670. If I understand correctly, it has got something to do with the fact that gcc isn't supported by ndk anymore.

Hence, I downloaded an older version of ndk (r13b) and tried to run the script.

Then I got the following error

Library/Android/sdk/ndk/android-ndk-r13b/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang is unable to create an executable file

Library not found

java.lang.UnsatisfiedLinkError: dlopen failed: library "libswresample.so" not found
file_not_found

Couldn't compile ffmpeg for android using ubuntu

binishmathew@VirtualUbuntu:/ffmpeg-android-maker-master$ sudo ./ffmpeg-android-maker.sh
[sudo] password for binishmathew:
Getting source code of the component: ffmpeg
Using FFmpeg source archive: 4.2.3
Ensuring sources of ffmpeg in ffmpeg-4.2.3
/home/binishmathew/ffmpeg-android-maker-master/scripts/common-functions.sh: line 20: curl: command not found
tar: ffmpeg-4.2.3.tar.bz2: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
rm: cannot remove 'ffmpeg-4.2.3.tar.bz2': No such file or directory
Building the component: ffmpeg
./ffmpeg-android-maker.sh: line 112: cd: /home/binishmathew/ffmpeg-android-maker-master/sources/ffmpeg/ffmpeg-4.2.3: No such file or directory
/home/binishmathew/ffmpeg-android-maker-master/scripts/ffmpeg/build.sh: line 25: ./configure: No such file or directory
binishmathew@VirtualUbuntu:~/ffmpeg-android-maker-master$

Are --disable-avfilter and disable-avdevice necessary?

I took these off and got compiler errors, is it why you disabled?. Than I putted back and took --disable-static off, and it still tries to build avdevice and avfilter, is that why you disabled static?

Why can't those be built? Also, is swresample not suitable for android too?

Compilation on Windows - Issues

Hello,
The info how to compile on windows is a bit sparse, here is what I did:
a) Install msys2
b) Open the msys2 console and update first,
pacman -Syu
then install the mentioned libraries:
pacman -S make git diffutils tar
c) change directory to where you cloned the ffmpge-android-maker, e.g.
cd /c/mydir
d) execute the script via
./ffmpeg-android-maker.sh

When doing so, the script runs for ~1 min and then fails with
/toolchains/llvm/prebuilt/windows-x86_64/bin/armv7a-linux-androideabi16-clang is unable to create an executable file.
C compiler test failed.

It creates
output\lib\armeabi-v7a
folder but nothing is in it.

Can't build

Hello, I've tried to build the .so files using Android Studio and terminal, but i get some errors.
I set in check-host-machine.sh

export ANDROID_SDK_HOME=$HOME/Android/sdk
export ANDROID_NDK_HOME=$ANDROID_SDK_HOME/ndk/21.3.6528147

FFmpeg downloads, but after getting
from terminal =

Getting source code of the component: ffmpeg
Using FFmpeg source archive: 4.3.1
Ensuring sources of ffmpeg in ffmpeg-4.3.1
Building the component: ffmpeg
/toolchains/llvm/prebuilt/darwin-x86_64/bin/i686-linux-android16-clang is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
[email protected] mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.

from android studio =
ffmpeg-android-maker/ffmpeg-android-maker.sh:92: bad substitution

Can you help?

c compiler test failed

#17

Hello,
I am using Ubuntu 19.10 in a VM and cannot get the build script to work.

I have installed android studio, then using the sdk manager from android studio I installed the ndk and cmake.
After that, I set the environment variables like this:
export ANDROID_SDK_HOME=$HOME/android-sdk and
export ANDROID_NDK_HOME=$ANDROID_SDK_HOME/ndk/21.0.6113669

Both folders exist. E.g. ANDROID_NDK_HOME contains the ndk-build.sh file and more.

However, when executing the script I get

Building the component: ffmpeg
/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android16-clang is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
[email protected] mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help

I also tried executing the commands from the travis.yml file one after another but It crashes in
installAndroidComponent "ndk;21.0.6113669" with an error that seems to link to the wrong jdk (which is 9 on ubuntu 19.10, and in the travis.yml it says jdk8 explicitly)

Any ideas ?

Problem adding libopus to build

I'm trying to build ffmpeg with libopus 1.3.1 without success. I created the download and build scripts et added an argument to parse_arguments.sh but I get a weird error while building :

ERROR: opus not found using pkg-config

Which is weird since I get this :

> echo $PKG_CONFIG_PATH
/home/guiyom/ffmpeg-android-maker/build/external/arm64-v8a/lib/pkgconfig
> echo $(pkg-config --libs opus)
-L/home/guiyom/ffmpeg-android-maker/build/external/arm64-v8a/lib -lopus

My libopus/download.sh :

#!/usr/bin/env bash

# Script to download opus source code

# Exports SOURCES_DIR_libopus - path where actual sources are stored

OPUS_VERSION=1.3.1
echo "Using libopus $OPUS_VERSION"
OPUS_SOURCES=opus-${OPUS_VERSION}

if [[ ! -d "$OPUS_SOURCES" ]]; then
  TARGET_FILE_NAME=${OPUS_SOURCES}.tar.gz

  curl https://archive.mozilla.org/pub/opus/${TARGET_FILE_NAME} -o ${TARGET_FILE_NAME}
  tar xf ${TARGET_FILE_NAME} -C .
  rm ${TARGET_FILE_NAME}
fi

export SOURCES_DIR_libopus=$(pwd)/${OPUS_SOURCES}

My libopus/build.sh :

#!/usr/bin/env bash

#autogen.sh
./configure \
  --prefix=${INSTALL_DIR} \
  --host=${TARGET} \
  --with-sysroot=${SYSROOT_PATH} \
  --with-pic \
  --with-sysroot=${SYSROOT_PATH} \
  --disable-shared \
  --enable-static \
  --disable-extra-programs \
  --disable-doc \
  --disable-maintainer-mode \
  --disable-fast-install\
  --enable-rtcd \
  --enable-asm \
  --enable-check-asm \
  --enable-custom-modes \
  CC=${FAM_CC} \
  CFLAGS=-O3 \
  AR=${FAM_AR} \
  RANLIB=${FAM_RANLIB}

export FFMPEG_EXTRA_LD_FLAGS+="${FFMPEG_EXTRA_LD_FLAGS} -lopus"

${MAKE_EXECUTABLE} clean
${MAKE_EXECUTABLE} -j${HOST_NPROC}
${MAKE_EXECUTABLE} install

After checking into the build directory, I do have files in my build directory :

In build/external/arm64-v8a : 
./lib
./lib/libaom.a
./lib/libopus.a
./lib/pkgconfig
./lib/pkgconfig/aom.pc
./lib/pkgconfig/dav1d.pc
./lib/pkgconfig/opus.pc
./lib/libdav1d.a
./lib/libopus.la
./share
./share/aclocal
./share/aclocal/opus.m4
./include
./include/opus
./include/opus/opus_defines.h
./include/opus/opus.h
./include/opus/opus_projection.h
./include/opus/opus_types.h
./include/opus/opus_custom.h
./include/opus/opus_multistream.h
./include/dav1d
./include/dav1d/headers.h
./include/dav1d/data.h
./include/dav1d/picture.h
./include/dav1d/common.h
./include/dav1d/dav1d.h
./include/dav1d/version.h
./include/aom
./include/aom/aom.h
./include/aom/aom_encoder.h
./include/aom/aom_frame_buffer.h
./include/aom/aom_decoder.h
./include/aom/aom_codec.h
./include/aom/aom_integer.h
./include/aom/aomcx.h
./include/aom/aomdx.h
./include/aom/aom_image.h

A bit of help would be much appreciated on this one as I'm not very familiar with C/C++ builds.

Android ffmpeg binary and other .so files execution error

Firstly, Thanks for simplifying all the steps in single script..
Have executed script and got ffmpeg/ffprobe binary and other .so files i.e. libavcodec.so, libavdevice.so, libavfilter.so, libavformat.so, libavutil.so, libswresample.so, libswscale.so.

Now when applying to android project using below process:
I have put all these .so files in jniLibs->arm64-v8a->... and same for other 3 CPU architecture like x86 and x86_64.

I have put binary ffmpeg and ffprobe in assets folder with similar CPU architecture. i don't have JNI folder, not any C++ native code in my project.

Now i am loading these so files using System.loadLibrary("") for all 7 .so files and it loads successfully.

Have moved ffmpeg binary from assets to data/data/ folder.
But when I run any command: it shows error:
CANNOT LINK EXECUTABLE "/data/user/0/<pkg_name>/files/ffmpeg": library "libavdevice.so" not found

What could be the reason? any idea what mistakes I am doing?

I went thru your part 2 of integration (https://github.com/Javernaut/WhatTheCodec), but that's using JNI and Cpp, which is out of scope for me as not aware about JNI and C coding and calling native methods from java code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.