ffmpeg-android-java icon indicating copy to clipboard operation
ffmpeg-android-java copied to clipboard

Reduce APK Size / Split project into three different libraries for x86, armv7 and armv7-neon

Open neurospeech opened this issue 9 years ago • 23 comments

This project leads to apk of size > 40mb, this is huge waste of space and download time as most of the time, device has only one cpu architecture. Most android phones are armv7, so no need to ship x86 libraries along with the app. And as very few phones support armv7-neon, so no need to ship armv7-neon as well, you can always create three different apps for three different platforms.

Manually, I was able to delete x86 and armv7-neon, and brought down size of app to 10mb. So if there are three different libraries,

ffmpeg-android-java-x86 ffmpeg-android-java-armv7 ffmpeg-android-java-armv7-neon

It will be of great help to developers.

UPDATE

It turns out that you can use cdn.jsdelivr to directly download ffmpeg binaries when user tries to use ffmpeg first time. There is no need to package this inside apk. See https://github.com/neurospeech/xamarin-android-ffmpeg

neurospeech avatar Feb 11 '16 03:02 neurospeech

Release Apk with different cpu architecture and delete the rest of libraries (as neurospeech mentioned) try reading this, http://developer.android.com/google/play/publishing/multiple-apks.html

JayParikh20 avatar Mar 18 '16 10:03 JayParikh20

Hi guys. Sorry about the noob question, but is there a way for this lib to work as Facebook's Fresco lib? A simple split on gradle (as http://frescolib.org/docs/multiple-apks.html) would not ship the ffmpeg executables from another architectures.

ivanviragine avatar Jun 21 '16 13:06 ivanviragine

Is there any tutorial how to remove libraries for ffmpeg? I'm not familiar with NDK

sashatinkoff avatar Sep 17 '16 19:09 sashatinkoff

Yes, if anyone could share some document for doing this, then that would be great as I am using FFmpegAndroid but not very familiar with NDK.

NilaySheth avatar Nov 15 '16 06:11 NilaySheth

I agree with the above statements. A lot of us here probably aren't familiar with the NDK. A simple document detailing how to split the binaries would be very helpful.

I personally find it frustrating having spent weeks optimizing all assets in my APK only for it to become 5x larger after including this library...

Pkmmte avatar Dec 02 '16 00:12 Pkmmte

same problem here. i removed those files from x86 and armv7 and output is in forcestoping app. can any one help us and above mate?

jaydeepbhanderi007 avatar Dec 27 '16 07:12 jaydeepbhanderi007

I was able to remove unused architecture. If somebody is wonder, I can share it with you.

sashatinkoff avatar Dec 27 '16 07:12 sashatinkoff

please share it with me.

jaydeepbhanderi007 avatar Dec 27 '16 08:12 jaydeepbhanderi007

https://cloud.mail.ru/public/H1uB/k2nKhj4ru

sashatinkoff avatar Dec 27 '16 08:12 sashatinkoff

thanks for sharing the lib. all are working. i replaced your file with my larger file. but apk size is still >35 mb. apk size not reducing. i also tried clean and rebuild project after replacing your lib.

jaydeepbhanderi007 avatar Dec 27 '16 09:12 jaydeepbhanderi007

You shouldn't use both aar files, only one. As for me, I use gradle to make flavor for different architectures, one for x86 and another one for arm. AFAIK, x86 is not popular architecture so I decided to not publish build for it.

sashatinkoff avatar Dec 27 '16 09:12 sashatinkoff

ok thanks a lot for helping. thanks again.

jaydeepbhanderi007 avatar Dec 27 '16 09:12 jaydeepbhanderi007

i am using nexus device for testing. and still confused about app size.

On 27-Dec-2016, at 3:03 PM, sashatinkoff [email protected] wrote:

You shouldn't use both aar files, only one. As for me, I use gradle to make flavor for different architectures, one for x86 and another one for arm. AFAIK, x86 is not popular architecture so I decided to not publish build for it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/WritingMinds/ffmpeg-android-java/issues/66#issuecomment-269300884, or mute the thread https://github.com/notifications/unsubscribe-auth/AXo7cD6Bvqzs6oATVutw47gXd3DvJFmEks5rMNtQgaJpZM4HX4as.

jaydeepbhanderi007 avatar Dec 28 '16 05:12 jaydeepbhanderi007

@sashatinkoff do you mind if you upload the file again? thank you

jossydeleon avatar Feb 03 '17 04:02 jossydeleon

@zoedevelopers i've just created a repo on github https://github.com/sashatinkoff/ffmpeg-for-Android-compiled

sashatinkoff avatar Feb 03 '17 05:02 sashatinkoff

@sashatinkoff pretty soon, Thank you so much!!!

jossydeleon avatar Feb 03 '17 05:02 jossydeleon

@zoedevelopers I've just updated a readme file. Using this short guide you can assemble a project for certain architecture

sashatinkoff avatar Feb 09 '17 17:02 sashatinkoff

@sashatinkoff do you know how to speed up the conversion using this lib? I just want to convert m4a and mp4 to mp3 but it is taking too long. Thanks. This library does not have enough support from theirs developers

jossydeleon avatar Mar 01 '17 15:03 jossydeleon

@zoedevelopers I guess ffmpeg has couple of flags that can affect on speed conversion. Unfortunately I faced that native ffmpeg library seems a little outdated and doesn't support them (such as -preset ultrafast). If you'll find any way to do it please share your solution here =)

As for me, conversion seems too slow. To make it a little faster I reduce a size of input video / images. In fact, you'll get a video with low quality but it's a best way that I found how to handle it. Honestly speaking, I didn't spend a much time to find a solution that really works.

sashatinkoff avatar Mar 01 '17 20:03 sashatinkoff

This is kind of a hack but the initial apk size can drastically be reduced by downloading the .so files after installation.

gulzar1996 avatar Aug 25 '17 20:08 gulzar1996

@gulzar1996 So you mean no need to create different apks for different archs? And if it so, can you please tell where one can find those ".so" files and how any resource which can show how to implement ffmpeg using ".so" files? Help Appreciated :) Thank You.

sanketthecoder avatar Sep 04 '17 19:09 sanketthecoder

@gulzar1996 how to do it ?

JasonOldWoo avatar Mar 13 '18 02:03 JasonOldWoo

@sashatinkoff I saw ur aar file in github. If I want to make app for video to audio conversation bso which aar file is best for it from those three aar file and how it can be implement in my project?

AbhishekDevani avatar Apr 21 '19 07:04 AbhishekDevani