FFmpeg
Android FFmpeg Library — Video/Audio Converter, Cutter, Merger, Mixer, AI Sound
Install / Use
/learn @media6666/FFmpegREADME
FFmpeg Android Library
Android FFmpeg Library — Video/Audio Converter, Cutter, Merger, Mixer
FFmpeg is an open-source Android library that allows you to run FFmpeg commands directly inside your Android application.
Features
- Video to MP3
- Audio Cutter
- Audio Merger
- Audio Mixer
- Change speed / volume
- Video Cutter / Compressor
- Supports all FFmpeg custom commands
- AI Sound / AI Voice Changer
Installation
Step 1 — Add JitPack
dependencyResolutionManagement {
repositories {
maven { url "https://jitpack.io" }
}
}
Step 2 — Add Dependency
// Version 1.12: Media only (audio/video features)
implementation("com.github.media6666:FFmpeg:1.16")
// Version 1.14: Media + AI Sound features
implementation("com.github.media6666:FFmpeg:1.14")
Step 3 — Init FFmpeg
FFmpegMedia.getInstance().initLib { loaded ->
Log.e("LIB loaded", "$loaded")
}
Usage
1. FFmpegMedia.getInstance().setCancelFlag(0) // ← Reset once before running FFmpeg
2. FFmpegMedia.getInstance().run(
command = commandArray,
durationTotal = 10000L,
progressCallBack = progressCallBack
)
3. FFmpegMedia.getInstance().setCancelFlag() // when destroy Activity or Done task
Video → MP3
val cmd = "-i ${videoPath} -vn -ar 44100 -ac 2 -b:a 192k ${outputPath}"
val commandArray = cmd.split(" ").toTypedArray()
FFmpegMedia.getInstance().run(
command = commandArray,
durationTotal = 10,
progressCallBack = progressCallBack
)
Audio Cutter
val cmd = "-i $input -ss 00:00:05 -to 00:00:12 -c copy $output"
val commandArray = cmd.split(" ").toTypedArray()
FFmpegMedia.getInstance().run(
command = commandArray,
durationTotal = 10,
progressCallBack = progressCallBack
)
Merge 2 Audio Files
val cmd = "-i $input1 -i $input2 -filter_complex amix=inputs=2:duration=longest $output"
val commandArray = cmd.split(" ").toTypedArray()
FFmpegMedia.getInstance().run(
command = commandArray,
durationTotal = 10,
progressCallBack = progressCallBack
)
Change Speed / Volume
val cmd = "-i $input -filter:a "atempo=1.25,volume=1.5" $output"
val commandArray = cmd.split(" ").toTypedArray()
FFmpegMedia.getInstance().run(
command = commandArray,
durationTotal = 10,
progressCallBack = progressCallBack
)
AI Sound / AI Voice Changer
🚨 NOTE
The AI Sound feature has been removed from this project.
AI Sound will be developed and maintained in a separate standalone project.
This change does not affect other existing features in this repository.
Notes
- FFmpeg binaries included — no extra setup required.
- AI Sound works offline.
- Supports Android 7.0+
- Handle storage permissions for Android < 10 if needed.
Reference Libraries
- https://github.com/bilibili/ijkplayer
- https://github.com/bilibili/FFmpeg
License
MIT License
