-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use jniLibs to work with targetSdkVersion=29 #130
base: master
Are you sure you want to change the base?
Conversation
Just curious why this hasn't been merged in. Seems straightforward and needed. |
@darrinps there are some good reasons why this was not merged. One, as you noticed, is that this still lacks 64 bit, which makes this solution unsatisfactory for majority of the people who need to target Android Q. Second, people may consider renaming the executable to lib…so to be a dirty trick. Third, this removes a lot of code people had wrote, debugged, and invested into. Not a very nice feeling for a maintainer. |
I'm strongly looking forward speedy marge and release, and next one as completely fix. |
I would like to target Q as well but cannot until ffmpeg is working with it. Is this code in a fork with a release that can be included? |
@pcm2a what is your incentive to target Q? Remember, you can use Q APIs in a project that targets earlier SDK. At any rate, if you don't set min supported SDK to Q, you have to check the availability of these APIs before using them. |
@alexcohn just planning ahead. When R is released in 2020 all apps will be forced to target Q I plan on being ready in advance vs rushing to the finish line. |
@pcm2a if you think this PR is important, feel free to vote for it. |
Waiting for this merge |
Besides this fix, for this library to work when targeting Q, we need an option to pass a For example, instead of: String[] command = {"-i", mStringFilePath, "-crf", "18", "-c:v", "libx264", "-c:a", "copy", pathToAppDirectory};
FFmpeg.getInstance(this).execute(command, new ExecuteBinaryResponseHandler()... We could be given an option to pass a FileDescriptor fd = getContentResolver().openFileDescriptor(Uri, "r").getFileDescriptor();
//Note that there is no input path provided below
String[] command = {"-crf", "18", "-c:v", "libx264", "-c:a", "copy", pathToAppDirectory};
FFmpeg.getInstance(this).execute(command, fd, new ExecuteBinaryResponseHandler()...
//and when the developer doesn't want to use the FileDescriptor
FFmpeg.getInstance(this).execute(command, null, new ExecuteBinaryResponseHandler() |
@HBiSoft Passing FileDescriptor still won't let you work around the scoped storage. You need significant changes on the ffmpeg binary as well, to handle this: pass these file descriptors via Unix sockets. If you switch to an ffmpeg in-process library solution, e.g. https://github.com/tanersener/mobile-ffmpeg, you can transparently pass your FileDescriptor with the /proc/self/fd/%d trick or |
@alexcohn The owner of FFmpegMediaMetadataRetriever did something similar, have a look here: You can also have a look at my post on the mobile-ffmpeg library which is related to this - tanersener/mobile-ffmpeg#334 (comment) I believe the owner of this library can easily implement this as well. |
@HBiSoft they have their struct State that can handle such URI, that's not how FFmpeg-Android is built. |
@alexcohn What suggestions do you have if we want to achieve the same using this library? |
@HBiSoft on the one hand, ffmpeg supports the pipe protocol out-of-the-box, and I believe that the Android port did not damage this functionality. On the other hand, the pipe protocol is not seekable, which may be a significant limitation for some ffmpeg file formats and some applications. I won't propose it as a panacea. |
@alexcohn |
I am confused. Did you test pipes or the |
@alexcohn I tested with pipe -> String safUriToFFmpegPath(final Uri uri) {
try {
ParcelFileDescriptor parcelFileDescriptor = getContentResolver().openFileDescriptor(uri, "r");
return String.format(Locale.getDefault(), "pipe:%d", parcelFileDescriptor.getFd());
} catch (FileNotFoundException e) {
return "";
}
} |
The |
@HBiSoft please see alexcohn@686c4b5 – for me it resolves the problem with Android Q. I only care about input, but I have no doubt you can follow the same approach to use an output directory out of the app sandbox. |
@alexcohn I have tested the above and I get I see you mentioned this:
|
Yes, it seems to only work for Downloads. |
Thanks to @Le-Dinh-Nam #126 comment, I could clean up a bit more. It seems that later platform versions extract all files from lib folder, not filtering by the lib….so pattern, as earlier. UPDATE no, it does not, see Google Issue. I was forced to revert this change. |
Looks good! @Brianvdb Please merge this. |
Any update about this? |
waiting for this to be merged.. |
This reverts commit e50d1c4 See https://issuetracker.google.com/issues/152645643 for discussion: this is not supposed to work, wrap.sh is a special well-known name. Also, older devices (e.g. API 24) don't install files from libs directory if they don't match the expected "lib.*\.so" pattern.
Any update about this? |
Any update about this? When can I expect a new version? |
Any update about this? |
any update ?? |
Hi @alexcohn Any update...? Then please help me.. |
@GauravCreed help you what? |
Hi @alexcohn getting ffmpeg error code 13 in android 10 permission denied in android 10 device. |
Looks like this isn't going to be merged, is it safe to use the fork directly? @alexcohn Any gotchas? Does this fully work with Android Q/R in the way we expect bravobit/FFmpeg-Android to work? |
@AdityaAnand1 I would recommend using (https://github.com/tanersener/mobile-ffmpeg). You get more control over what arch you want to build and you can pass it a |
Hi, @alexcohn I am using this library, https://github.com/tanersener/mobile-ffmpeg this is working on android 10 too , Could you please help me with this? |
@pratik-tech4 you definitely don't need the 'full' flavor of mobile-ffmpeg: it includes extra libraries that are not part of bravobit. You can make the right choice, or even build a bespoke mixture yourself, only including the external libs that you really need (and maybe revisit your commands to avoid non-necessary external libs, too). Also, if you don't use AAB and don't use split APK, the APK now includes all ABIs. For production, you only care about arm64 and armv7-a as separate binaries. |
HI @alexcohn How about when I am using both audio and video both, i want to add text and image both in video, implementation 'com.arthenica:mobile-ffmpeg-audio:4.4' it will gives some error like duplicate classes. |
Hi @alexcohn as @GauravCreed said same way i tried but same error. If i add audio and video version both it gives me same error as @GauravCreed faced. Thats why i am using full version. I am using it to cut audio then merge it and adding audio to video. So if possible which version i should use to work these functionality. |
@GauravCreed, @pratik-tech4: no, you cannot and should not add two ffmpeg-mobile packages. I would suggest to start with min, and find out what is missing for you. Only if you find that you desperately need more, consider another package. Note that the audio package does contain basic video capabilities, while the video package still provides the essential audio functions. |
@GauravCreed, @pratik-tech4
Use the By doing this, you have full control over which libs you want based on what you need. |
Thank you for your response, for now i used so, I added ndk filters like below ndk { abiFilters "armeabi-v7a","arm64-v8a" } by this two filters apk size is around 48MB. So now i have one doubt is that if i make sign apk with these two filters "armeabi-v7a","arm64-v8a", is it approve in play store? as in play store apk must have 64-bit support. So by these two filter it will approve or no? And it will run in older devices? like which are 32 bit. Thanks in advance! |
@pratik-tech4 I would rather suggest using splits (as shown below) instead of using abiFilter. By splitting the apk`s you will only install the necessary apk. Using abiFilter, you will include all the archs, which increases your apk size unnecessarily. android.splits {
abi {
enable true
reset()
include 'armeabi-v7a', 'arm64-v8a'
universalApk false
}
} |
@HBiSoft by doing this changes both apk is build separately app_armeabi-v7a.apk, app_arm64-v8a.apk. So which one need to upload in play store? |
When will you release new version of library with this merge? Please release this as soon as possible. I am waiting for this.. |
@alexcohn Hey thanks for this PR and it works fine when building and using debug apk, but as soon as I use a release apk after signing, it doesn't save ffmpeg & ffprobe in /data/app/xxxx/libs folder. I have tried various methods like enabling/disabling android:extractNativeLibs="true" in App manifest but no luck However migrating libs to jniLibs folder as lib..ffmpeg.so worked , no idea why.... |
@Shabinder that's true. Android system APK installer extracts only libraries that follow the strict When I published this PR, I was not aware of this weird behavior. |
Yeah the most weird about it is that there is no flag to keep such resources when building release apk. |
At any rate, I strongly recommend you to switch from a poorly supported executable-based solution to a library-based one, e.g. https://github.com/tanersener/ffmpeg-kit. |
I did went to initially configure ffmpeg-kit, but I needed very much control over ffmpeg-build configuration and wanted to keep the lib size to as low as possible, hence I decided to build my own ffmpeg libs and include them in-app, Adding FFmpeg-kit as a submodule was not a solution while configuring it custom as It was giving some error that said that produced aar wont be included in parent app(I don't remember the proper wording but there was a limitation) and I didn't wanted to go to the route of maintaining my fork and using mavenCentral as the source |
You cannot rely on Android Studio to build and copy the ffmpeg aar into your apk. You can include any custom build steps in your build.gradle, though. Or simply copy the aar into your project, the way you handle the executables. But even if you work with executables, it's worth the hassle to split APKs or build a Bundle. |
Fixing #126