In this post, you will learn how to compress video in android studio. There are many ways to compress video in android. The logic used for compressing video is use low bit rate for video and convert video to lower resolution helps you to lower the file size of video but you have to also care about quality of video, that must be less effect during video compression. There is one way to compress video with no quality compromise and that is zipping the video, that reduce file size and increase speed of upload video but for larger size video it will be not effective, but for small size video it is very good choice. There are many libraries for video compressing without doing it zip that are
1. FFmpeg 4 android
3. Giraffe Compressor
Download Demo of this app from play store
My favorite library is FFmpeg because it is so accurate and it did not effect your video quality and also give you more control (programming related) but it is little tricky to implement. For this tutorial i will be using isoparser-1.0.6.jar and aspectjrt-1.7.3.jar, it will be simple for you, just copy videocompressor project and paste in your project and use three line of code to compress video, no coding stress for you.
First add these two permission in your manifest file
<uses-permission android:name=“android.permission.WRITE_EXTERNAL_STORAGE” />
<uses-permission android:name=“android.permission.READ_EXTERNAL_STORAGE” />
You need to download this project (link is below) and paste it in your project. See the picture to understand.