The main problem is this:

FFMPEG is a binary, and there are no nice, user-friendly libraries that mimick it's behaviour out there...

One attempt is this: https://github.com/RkShaRkz/android-ffmpeg (the avatar gives me away)

Another one is this: https://sourceforge.net/projects/ffmpeg4android/files/20121012/

Alot of "solutions" revolve around either 1) launching the FFMPEG binary (process) and piping commands to it. 2) calling into FFMPEG libraries

But noone has yet made a nice FFMPEG-alike SDK library which lets you use everything it offers programatically in Java nor Android.

This was too long for a comment so thats why i posted it as an answer, i hope this doesn't get downvoted to oblivion for not providing a concrete answer/solution to your question.

Answer from Shark on Stack Overflow
🌐
GitHub
github.com › tanersener › mobile-ffmpeg
GitHub - tanersener/mobile-ffmpeg: FFmpeg for Android, iOS and tvOS. Not maintained anymore. Superseded by FFmpegKit. · GitHub
January 6, 2025 - FFmpeg for Android, iOS and tvOS. Not maintained anymore as explained in What’s next for MobileFFmpeg?. Superseded by FFmpegKit. ... Use binaries available at Github/Maven Central/CocoaPods or build your own version with external libraries you need
Starred by 4.1K users
Forked by 893 users
Languages   C 61.3% | C++ 8.9% | HTML 6.7% | Shell 6.2% | Makefile 5.3% | Assembly 5.2%
🌐
Medium
medium.com › simform-engineering › multimedia-operations-for-android-using-ffmpeg-78f1fb480a83
Multimedia Operations for Android using FFmpeg | by Ashwin Vavaliya | Simform Engineering | Medium
March 22, 2021 - To integrate FFmpeg in your android application you can use pre-compiled libraries like FFmpeg, which provide multiple predefined multimedia operations(Queries) and which is easy to integrate by adding FFmpeg dependency in app module gradle ...
Top answer
1 of 4
37

The latest version of FFMPEG is 3.1.1, Just released before 12 days. So i think there is no readily available demo like this old one.

We need to build the FFMPEG library on our own. Some questions i found just pasting here that might help you. (Not tested)

How to Build FFmpeg for Android

  1. Compiling FFmpeg 2.3 with Android NDK r10
  2. How to compile ffmpeg-2.5.3 on windows with android-ndk-r10d
  3. How to compile ffmpeg-2.2.2 on windows with cygwin and android ndk r9c
  4. How to buid ffmpeg with android-ndk-r10d in windows

You need to compile it on your own the by downloading Android NDK & Latest Version of FFMPEG.

One tutorial is also there : How to Build FFmpeg for Android. This is quite old so you just need to change the versions mentioned here. For FFMPEG it will be 3.1.1 & NDK it will be r12b.


Building FFMPEG with NDK r12b:

  1. Download Android NDK : The latest version of Android NDK can be downloaded at Android NDK website. At the time of writing this answer, the newest version is NDK r12. simply decompress the archive

  2. Download ffmpeg source code : FFMPEG source code can be downloaded from the ffmpeg website. The latest stable release is 3.1.1 (at the time of writing). Download the source code and decompress it to $NDK/sources folder.

  3. Update configure file : Open ffmpeg-3.1.1/configure file with a text editor, and locate the following lines.

    SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
    LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
    SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
    SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
    

    This cause ffmpeg shared libraries to be compiled to libavcodec.so. (e.g. libavcodec.so.55), which is not compatible with Android build system. Therefore we’ll need to replace the above lines with the following lines.

    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
    LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
    SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
    SLIB_INSTALL_LINKS='$(SLIBNAME)
    
  4. Build ffmpeg : Copy the following text to a text editor and save it as build_android.sh in ffmpeg_3.1.1 folder.

        #!/bin/bash
        NDK=$HOME/Desktop/adt/android-ndk-r9
        SYSROOT=$NDK/platforms/android-9/arch-arm/
        TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
        function build_one
        {
            ./configure
                --prefix=$PREFIX
                --enable-shared
                --disable-static
            --disable-doc
                    --disable-ffmpeg
                --disable-ffplay
                --disable-ffprobe
                --disable-ffserver
                --disable-avdevice
                --disable-doc
                --disable-symver
                --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi-
                --target-os=linux
                --arch=arm
                --enable-cross-compile
                --sysroot=$SYSROOT
                --extra-cflags="-Os -fpic $ADDI_CFLAGS"
                --extra-ldflags="$ADDI_LDFLAGS"
            $ADDITIONAL_CONFIGURE_FLAG
            make clean
            make
            make install
        }
        CPU=arm
        PREFIX=$(pwd)/android/$CPU
        ADDI_CFLAGS="-marm"
        build_one
    

    Once the file is saved, go to the directory where this file lies & execute the command below,

    sudo chmod +x build_android.sh
    

    Then execute the script by the command,

    ./build_android.sh
    
  5. Build Output : The build can take a while to finish depending on your computer speed. Once it’s done, you should be able to find a folder $NDK/sources/ffmpeg-3.1.1/android, which contains arm/lib and arm/include folders.

  6. Make ffmpeg Libraries available for Your Projects

Steps above are fully tested and i performed them on my machine and the build was successful. For writing this answer i have took the reference from this article How to Build ffmpeg with NDK r9 but as it was for older version i have made some corrections on my own.

Open for asking any doubts.

2 of 4
13

I suggest you these following URLs that was helpful for me :

http://androidwarzone.blogspot.in/2011/12/ffmpeg4android.html

http://writingminds.github.io/ffmpeg-android-java/

https://androiddeveloperhelp.wordpress.com/2015/12/19/video-editing-android-example/

For knowledge:

http://www.lai18.com/content/5175900.html

Android studio Source Code:

https://drive.google.com/file/d/0B9qAjo6wKhk9MEpNNjMxaG5oWXM/view?usp=sharing

It may be help you.

Top answer
1 of 10
111

Here are the steps I went through in getting ffmpeg to work on Android:

  1. Build static libraries of ffmpeg for Android. This was achieved by building olvaffe's ffmpeg android port (libffmpeg) using the Android Build System. Simply place the sources under /external and make away. You'll need to extract bionic(libc) and zlib(libz) from the Android build as well, as ffmpeg libraries depend on them.
  2. Create a dynamic library wrapping ffmpeg functionality using the Android NDK. There's a lot of documentation out there on how to work with the NDK. Basically you'll need to write some C/C++ code to export the functionality you need out of ffmpeg into a library java can interact with through JNI. The NDK allows you to easily link against the static libraries you've generated in step 1, just add a line similar to this to Android.mk: LOCAL_STATIC_LIBRARIES := libavcodec libavformat libavutil libc libz

  3. Use the ffmpeg-wrapping dynamic library from your java sources. There's enough documentation on JNI out there, you should be fine.

Regarding using ffmpeg for playback, there are many examples (the ffmpeg binary itself is a good example), here's a basic tutorial. The best documentation can be found in the headers.

Good luck :)

2 of 10
73

For various reasons, Multimedia was and is never easy in terms of achieving the task without compromising on efficiency. ffmpeg is an effort in improving it day by day. It supports different formats of codecs and containers.

Now to answer the question of how to use this library, i would say that it is not so simple to write it here. But i can guide you in following ways.

1) Inside the ffmpeg directory of source code, you have output_example.c or api_example.c. Here, you can see the code where encoding/decoding is done. You will get an idea as to which API's inside ffmpeg you should call. This would be your first step.

2) Dolphin player is a open source project for Android. Currently it is having bugs but developers are working continuously. In that project you have the whole setup ready which you can use to continue your investigation. Here is a link to the project from code.google.com or run the command "git clone https://code.google.com/p/dolphin-player/" in a terminal. You can see two projects named P and P86 . You can use either of them.

Extra tip i would like to offer is that when you are building the ffmpeg code, inside build.sh you need to enable the muxers/demuxers/encoders/decoders of the formats you want to use. Else the corresponding code will not be included in the libraries. It took a lot of time for me to realize this. So thought of sharing it with you.

Few Basics : When we say a video file, ex : avi, it is combination of both audio and video

Video file = Video + Audio


Video = Codec + Muxer + Demuxer

codec = encoder + Decoder

=> Video = encoder + decoder + Muxer + Demuxer(Mpeg4 + Mpeg4 + avi +avi - Example for avi container)


Audio = Codec + Muxer + Demuxer

codec = encoder + Decoder

=> Audio = encoder + decoder + Muxer + Demuxer(mp2 + mp2 + avi + avi - Example for avi container)


Codec(name is deriverd from a combination of en*co*der/*dec*oder) is just a part of format which defines the algorithms used to encode/decode a frame. AVI is not a codec, it is a container which uses Video codec of Mpeg4 and Audio codec of mp2.

Muxer/demuxer is used to combine/separate the frames from a file used while encoding/decoding.

So if you want to use avi format, you need to enable Video components + Audio components.

Ex, for avi, you need to enable the following. mpeg4 Encoder, mpeg4 decoder, mp2 encoder, mp2 decoder, avi muxer, avi demuxer.

phewwwwwww...

Programmatically build.sh should contain the following code:

--enable-muxer=avi --enable-demuxer=avi (Generic for both audio/video. generally Specific to a container)
--enable-encoder=mpeg4 --enable-decoder=mpeg4(For video support)
--enable-encoder=mp2 --enable-decoder=mp2 (For Audio support)

Hope i idid not confuse you more after all this...

Thanks, Any assistance needed, please let me know.

🌐
GitHub
github.com › arthenica › ffmpeg-kit
GitHub - arthenica/ffmpeg-kit: FFmpeg Kit for applications. Supports Android, Flutter, iOS, Linux, macOS, React Native and tvOS. Supersedes MobileFFmpeg, flutter_ffmpeg and react-native-ffmpeg. · GitHub
FFmpegKit is a collection of tools to use FFmpeg1 in Android, iOS, Linux, macOS, tvOS, Flutter and React Native applications. It includes scripts to build FFmpeg native libraries, a wrapper library to run FFmpeg/FFprobe commands in applications ...
Starred by 5.8K users
Forked by 2.5K users
Languages   C 54.3% | Shell 15.8% | Java 9.3% | Objective-C 7.4% | C++ 4.9% | Makefile 3.4%
🌐
GeeksforGeeks
geeksforgeeks.org › android › how-to-use-ffmpeg-in-android-with-example
How to Use FFmpeg in Android with Example? - GeeksforGeeks
July 23, 2025 - In the below example I will be using tanersener/mobile-ffmpeg, as it has support for Android 10 scoped storage, and also it is the best library available on the internet for FFmpeg mobile. A sample GIF is given below to get an idea about what we are going to do in this article. Note that we are going to implement this project using the Java language. To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.
Find elsewhere
🌐
Medium
medium.com › @eeddeellee › how-to-use-ffmpeg-in-android-37b1d732c31b
How to Use FFmpeg in Android. FFmpeg is an open-source project full… | by eeddeellee | Medium
April 20, 2022 - Taner Sener has created a great ffmpeg-kit library that wraps the core ffmpeg code in various wrappers for use in iOS, Android, Flutter, etc.
🌐
GitHub
github.com › madhavanmalolan › ffmpegandroidlibrary
GitHub - madhavanmalolan/ffmpegandroidlibrary: One line integration for FFMPEG Library in Android
The library is available on jcenter() App level build.gradle · compile 'com.madhavanmalolan.android:ffmpegandroidlibrary:0.0.4' Use the Controller singleton class's run method to execute your commands. run takes as argument an array of Strings which are the arguments you would send to the ffmpeg command on cli.
Starred by 89 users
Forked by 15 users
Languages   C 84.5% | Assembly 5.4% | Objective-C 4.7% | Makefile 4.5% | C++ 0.7% | Shell 0.1% | C 84.5% | Assembly 5.4% | Objective-C 4.7% | Makefile 4.5% | C++ 0.7% | Shell 0.1%
🌐
Blogger
ffmpeg-android.blogspot.com
Integrate FFMPEG library in Android
Create a file build_ffmpeg_android.sh under the $NDK/sources/ ffmpeg-2.2.3 folder and paste below code: ... After saving this file, it will disabled static library and enabled shared library (.so files).
🌐
Medium
medium.com › madhavanmalolan › ffmpeg-for-android-b307f2613c82
FFmpeg for Android. Full ffmpeg commandline functionality… | by Madhavan Malolan | madhavanmalolan | Medium
March 23, 2018 - After you have saved the contents of build_ffmpeg.sh run the script. ... On successful completion you should see the android/ directory in the /path/to/ffmpeg directory.
🌐
Medium
proandroiddev.com › a-story-about-ffmpeg-in-android-part-ii-integration-55fb217251f0
A Story about FFmpeg on Android. Part II: Integration. | by Oleksandr Berezhnyi | ProAndroidDev
January 3, 2020 - Define a shared library for our JNI layer and specify all *.cpp files for it (also with add_library()); Link the JNI layer library against FFmpeg’s shared libraries, Android logging library and Bitmap processing library with target_link_libraries().
🌐
GitHub
github.com › bravobit › FFmpeg-Android
GitHub - bravobit/FFmpeg-Android: FFMpeg/FFprobe compiled for Android · GitHub
FFMpeg/FFprobe compiled for Android. Contribute to bravobit/FFmpeg-Android development by creating an account on GitHub.
Starred by 762 users
Forked by 182 users
Languages   Java
🌐
Medium
medium.com › @213maheta › ffmpeg-create-aar-file-add-it-into-android-project-7e069b0fe23f
Building FFmpeg (Minimal) with 16KB Page Size Support in Android | by 213 developer | Medium
3 weeks ago - Open Android Studio → Settings → Android SDK → SDK Tools ... export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk export ANDROID_HOME=$ANDROID_SDK_ROOT export ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/25.1.8937393 export ANDROID_NDK=$ANDROID_NDK_ROOT
🌐
GitHub
github.com › appunite › AndroidFFmpeg
GitHub - appunite/AndroidFFmpeg: [DEPRECATED] FFmpeg build for android random architectures with example jni
This project aims to create working library providing playing video files in android via ffmpeg libraries. With some effort and NDK knowledge you can use this ffmpeg libraries build to convert video files.
Starred by 1.1K users
Forked by 467 users
Languages   C 64.7% | Java 24.5% | Shell 5.5% | Makefile 3.2% | C++ 2.1% | C 64.7% | Java 24.5% | Shell 5.5% | Makefile 3.2% | C++ 2.1%
🌐
Oodlestechnologies
oodlestechnologies.com › blogs › ffmpeg-for-android
FFMPEG for android
February 14, 2020 - 1) To integrate ffmpeg in your android appliation you can use precompiled libraries like ffmpeg-android (credit - Writing-Minds) , which is easy to integrate by adding FFmpeg dependency in app module gradle file and sync project.:-
🌐
Appscms
appscms.com › library › ffmpeg-android-library
Android ffmpeg libraries for use in your project
See collection of all Android ffmpeg libraries, filter by license, modified date, languages, and select best for your usecase.
Rating: 1 ​ - ​ 2 votes
🌐
Medium
medium.com › @ilja.kosynkin › building-ffmpeg-for-android-607222677a9e
Building FFmpeg for Android. Originally was posted at my blog here… | by Ilia Kosynkin | Medium
September 9, 2018 - If everything was configured properly — you should get your library and copied FFmpeg libraries in libs folder. After you got everything prepared you must load libraries in memory of your application. First of all, make sure that libraries located in right folder in the project. It have to be in /src/main/jniLibs//. If you will not put it there — Android system will not be able to locate libraries.