Android Java Compress Video size before upload

313 views Asked by At

I am developing an app which has similar features to instagram for learning purposes. I want to upload a video from gallery to my cloud. In iOS, Swift already offers an in-built function which fixes the quality to my needs (.low, .medium, .high). Is there any way to achieve a similar behavior in android?

I have tried multiple things like Silicompressor and lightCompressor but they did not work.

The workflow is:

-> select video from storage
-> resize video size in background without saving it as a new one in the storage
-> uploading the selected and compressed video

Any help is highly appreciated

1

There are 1 answers

0
vkrott On

In android there's no built-in method for that. You can create your own transcoder using MedixMuxer, MediaCodec or FFMPEG or you can add existing libraries like: https://github.com/natario1/Transcoder, https://github.com/ypresto/android-transcoder, https://github.com/linkedin/LiTr

Also resizing video without saving it as a new one is not a good idea. I mean a user probably wouldn't like that his video is changed. You can save it to cache folder in android - Context.getCacheDir()