bravobit / FFmpeg-Android

FFMpeg/FFprobe compiled for Android
https://bravobit.nl/
MIT License
734 stars 172 forks source link

isSupported increasing app data #114

Closed HBiSoft closed 4 years ago

HBiSoft commented 5 years ago

I've noticed that my app data increases by 19MB whenever I open my media player activity, after a lot of debugging I came to the conclusion that the cause of the data increase is when calling:

if (FFmpeg.getInstance(getApplication()).isSupported()) {
    Toast.makeText(Tester.this, "FFMPEG is supported", Toast.LENGTH_SHORT).show();
} else {
    Toast.makeText(Tester.this, "FFMPEG not supported", Toast.LENGTH_SHORT).show();
}

I'm not sure what FFmpeg stores in data when calling the above, but thats fine. I'm looking for a way to clear this data when backing out of the activity.

You can imagine why I would want to do this - for the user my application "looks" 19MB bigger then what it really is.

Any suggestions?


EDIT

After reading #99 I realised that isSupported actually loads/installs the binary (if FFmpeg is supported), so the increase of the app data makes sense. But, I'm still looking for a way to clear it once I'm done using FFmpeg.

liamcottle commented 5 years ago

Calling FFmpeg.getInstance(getApplication()).isSupported() actually installs/copies the ffmpeg binary into the app data if it is supported.

There is an open issue about this: https://github.com/bravobit/FFmpeg-Android/issues/99

If you take a look at the isSupported method, you'll be able to see that it copies the ffmpeg binary to app data: https://github.com/bravobit/FFmpeg-Android/blob/master/android-ffmpeg/src/main/java/nl/bravobit/ffmpeg/FFmpeg.java#L42

It could be helpful in some cases if FileUtils.getFFmpeg and FileUtils.getFFprobe were public methods. I have had to delete the installed binaries in certain situtations, but had to manually write the file names.

liamcottle commented 5 years ago

^ heh, saw your edit come through just as I was about to click Comment...

If the two methods mentioned above were made public, you could delete the files without having to rely on duplicating the binary locations elsewhere when wanting to delete the files.

For now, you can just use:

File folder = context.getFilesDir();
File ffmpeg = new File(folder, "ffmpeg");
ffmpeg.delete();
HBiSoft commented 5 years ago

@liamcottle Awesome, I will give it a try. I think that @Brianvdb could even add a method that clears the data without the developer having to do so "manually".

Anyway, thank you for your quick response.