cropsly / ffmpeg-android-java

Android java library for FFmpeg binary compiled using https://github.com/writingminds/ffmpeg-android
http://writingminds.github.io/ffmpeg-android-java
GNU General Public License v3.0
3.33k stars 829 forks source link

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

Open neurospeech opened 8 years ago

neurospeech commented 8 years ago

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

JayParikh20 commented 8 years ago

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

ivanviragine commented 8 years ago

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.

sashatinkoff commented 8 years ago

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

NilaySheth commented 8 years ago

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.

Pkmmte commented 8 years ago

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...

jaydeepbhanderi007 commented 7 years ago

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?

sashatinkoff commented 7 years ago

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

jaydeepbhanderi007 commented 7 years ago

please share it with me.

sashatinkoff commented 7 years ago

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

jaydeepbhanderi007 commented 7 years ago

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.

sashatinkoff commented 7 years ago

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.

jaydeepbhanderi007 commented 7 years ago

ok thanks a lot for helping. thanks again.

jaydeepbhanderi007 commented 7 years ago

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

On 27-Dec-2016, at 3:03 PM, sashatinkoff notifications@github.com 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.

jossydeleon commented 7 years ago

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

sashatinkoff commented 7 years ago

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

jossydeleon commented 7 years ago

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

sashatinkoff commented 7 years ago

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

jossydeleon commented 7 years ago

@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

sashatinkoff commented 7 years ago

@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.

gulzar1996 commented 7 years ago

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

sanketthecoder commented 7 years ago

@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.

JasonOldWoo commented 6 years ago

@gulzar1996 how to do it ?

AbhishekDevani commented 5 years ago

@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?