AbedElazizShe / LightCompressor

A powerful and easy-to-use video compression library for android uses MediaCodec API.
Apache License 2.0
533 stars 116 forks source link

Initial file gets cached and not deleted after compression #168

Open chaniotisalex opened 1 year ago

chaniotisalex commented 1 year ago

When the lib retrieves the file in order to compress it, it caches it inside /data/user/0/com.your.project.package/ . After compression is complete, the file doesn't get deleted, leaving a file which only has a name in form of currentTimeMillis and the size of the initial file.

AbedElazizShe commented 1 year ago

Thank you @chaniotisalex for pointing this out. I have fixed the issue.

SamAmco commented 1 year ago

I'm also having this issue. My app size is now 8GB on my device. The only way for me to reduce it is to "clear data" which would also delete all other data related to the app and essentially reduce it to a fresh install. I would suggest that you probably shouldn't store any files in this location at all. If you need to cache a temporary file you could use cacheDir and File.createTempFile: https://developer.android.com/training/data-storage/app-specific#internal-create-cache .. One thing to consider here is if the app process is killed in the middle of the compression job will the file still be deleted/deletable. If you use the cacheDir it will be. The system or the user can clear the cache for the app at any point without affecting the proper functioning of the app. If you put temporary files in the root data directory and the app is killed before it gets chance to delete that file, the opportunity is lost and it will be stuck there until the user clears all data for the app.

waterdrake commented 1 year ago

It would be great if we could just pass in a full path for the output file. The old version used to do that. By passing in a full path to a file, the developer could specify if they want to save it to the private caches folder, permanent storage, etc. Right now, everything goes into the files directory.

CristianMG commented 11 months ago

Open pull request https://github.com/AbedElazizShe/LightCompressor/pull/182 to fix this problem and make more flexible library @AbedElazizShe

karlovm commented 8 months ago

Same issue. Not fixed in 1.3.2

Andrey-Ageenko commented 2 months ago

The problem described by the author persists in version 1.3.3. If you shoot video with a phone camera, an intermediate file is created in the application folder, it has a name like currentTimeMillis and has no extension.

Additional information: I have an error on Android 12. When VideoCompressor.getMediaPath() throws an exception and returns file.absolutePath