I saw many posts on internet about how to decrease FFmpeg/FFprobe
lib size in Android. Also I've investigated on this topic about a few months. So I decided to share my conclusions. I'm not talking about compile time settings and disable/enabling features. Of course you can do this to get better result but this post is not about that. It's about archiving FFmpeg/FFprobe compiled files which will reduce your library size by 85% .
Reducing app size by archiving ffmpeg/ffprobe library in Android
3.1k Views Asked by S.R At
2
Based on FFMpeg/FFprobe compiled for Android
1. Compress asset files
(ffmpeg && ffprobe)
to any archive format, and replace with current files.2. With some extra code, copy archive file in app directory with
asynctask
,3. Extract archive with this library (Also supports
rar
archive).Result: 79.8MB ==> 13.2MB
Extraction time: 1 Second (Honor 8 Lite API 25/26.).
Without Compression
With Compression
I'm using this settings for compression:
Windows 10 64bit,
7-Zip
Application,.7z
Archive format,Ultra
compression level,LZMA2
compression method.You can try other compression methods and archive formats to test different results.
Required codes to copy/extract archive to app directory:
Add this to anywhere you want to initialize copy process (I would prefer inside
onCreate
ofApplication
class).Above method will process this functions:
copy archive from asset to app directory.
check CPU arch model.
extract archive based on CPU model.
delete archive after extraction.
make file executable.
return true/false if device supports ffmpeg or not.
full code:
add to build.gradle :
FFmpegArchiveUtil.java