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 :)

Answer from yonilevy 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 - Supports bzip2, iconv, libuuid, zlib system libraries and AudioToolbox, VideoToolbox system frameworks ... Prebuilt binaries are available at Github, Maven Central and CocoaPods. There are eight different mobile-ffmpeg packages.
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%
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.

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 :)

Answer from yonilevy on Stack Overflow
🌐
FFmpeg
ffmpeg.org
FFmpeg
After the work spearheaded by Rostislav Pehlivanov and Claudio Freire, the now-stable FFmpeg native AAC encoder is ready to compete with much more mature encoders. The Fraunhofer FDK AAC Codec Library for Android was added in 2012 as the fourth supported external AAC encoder, and the one with ...
🌐
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%
🌐
GitHub
github.com › mzgs › FFmpegX-Android
GitHub - mzgs/FFmpegX-Android: Native FFmpeg library for Android that solves Android 10+ W^X restrictions. Features hardware-accelerated codecs via MediaCodec, full GPL build with 300+ filters, and Android 15+ 16KB page alignment support
This library provides a complete FFmpeg 6.0 implementation with extensive codec support, hardware acceleration, and a simple Kotlin API. ✅ Android 10+ Support - Works on Android 10, 11, 12, 13, 14, 15+ using JNI wrapper approach ✅ No External ...
Starred by 16 users
Forked by 5 users
Languages   Kotlin 40.5% | C 37.8% | Shell 12.0% | C++ 8.8% | CMake 0.9% | Kotlin 40.5% | C 37.8% | Shell 12.0% | C++ 8.8% | CMake 0.9%
🌐
GitHub
github.com › madhavanmalolan › ffmpegandroidlibrary
GitHub - madhavanmalolan/ffmpegandroidlibrary: One line integration for FFMPEG Library in Android
One line integration for FFMPEG Library in Android - madhavanmalolan/ffmpegandroidlibrary
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%
🌐
GitHub
github.com › cmeng-git › ffmpeg-android
GitHub - cmeng-git/ffmpeg-android: ffmpeg for android · GitHub
FFmpeg for Android with libvpx, x264 and lame options.
Starred by 67 users
Forked by 24 users
Languages   Shell
Find elsewhere
🌐
GitHub
github.com › bravobit › FFmpeg-Android
GitHub - bravobit/FFmpeg-Android: FFMpeg/FFprobe compiled for Android · GitHub
Uses the latest FFmpeg release n4.0-39-gda39990 · Uses native CPU capabilities on ARM architectures · FFprobe is bundled in this library too · Enabled network capabilities · Multithreading · Include the dependency · dependencies { implementation 'nl.bravobit:android-ffmpeg:1.1.7' } To check whether FFmpeg is available on your device you can use the following method.
Starred by 762 users
Forked by 182 users
Languages   Java
🌐
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.
🌐
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 ...
🌐
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 - This is why we have to specify all FFmpeg’s shared libraries using sourceSets block. The ndk.abiFilters restricts ABIs to build for the JNI layer. This is needed because MIPS processors are not supported by Android NDK anymore and ffmpeg-android-maker doesn’t produce binaries for them.
🌐
GeeksforGeeks
geeksforgeeks.org › android › how-to-use-ffmpeg-in-android-with-example
How to Use FFmpeg in Android with Example? - GeeksforGeeks
July 23, 2025 - So, as a beginner, you can use some above-mentioned libraries and if you face some issue you can raise that issue on their respective GitHub repository. 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.
🌐
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%
🌐
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.
🌐
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).
🌐
Gitbooks
yesimroy.gitbooks.io › android-note › content › compile_ffmpeg_for_android.html
Compile ffmpeg for Android | Android Note - Roy (@yesimroy)
This tutorial is for generating android jni needed ffmpeg shared libraries for platform (armeabi, armeabi-v7a, arm64-v8a, x86, x86_64, mips).
🌐
GitHub
github.com › topics › ffmpeg-android
ffmpeg-android · GitHub Topics · GitHub
android kotlin player ffmpeg video-player kotlin-android exoplayer ffmpeg-android kotlin-coroutines jni-android room-database jetpack-compose media3 ... Android java library for FFmpeg binary compiled using https://github.com/writingminds/ffmpeg-android
🌐
GitHub
github.com › Javernaut › ffmpeg-android-maker
GitHub - Javernaut/ffmpeg-android-maker: Contains a script that assembles FFmpeg library for Android · GitHub
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 ...
Starred by 791 users
Forked by 220 users
Languages   Shell 91.2% | Dockerfile 4.8% | CMake 4.0%