Android: How to Solve Video Compression
May 17, 2016
A high quality recording by an Android phone for 30 seconds is around 40 to 45 MB in size; storage space is not a concern now-a-days! However, it is a concern for anyone while sharing the video through an app or mail. For example, sharing it in WhatsApp is a problem, as the app does not support videos more than 16 MB in size. This article will help you in Video Compression so that you can share it easily!
What is Video Compression?
Video compression uses modern coding techniques to reduce redundancy in video data. Most video compression algorithms and codecs combine spatial image compression and temporal motion compensation. Most video codecs also use audio compression techniques in parallel to compress the separate, but combined data streams as one package.
To implement the video compression in Android we need a video to be recorded with the surfaceView and a Media recorder. Therefore, before starting a video recording we need to set the required parameters to the Media recorder like the Video Frame Rate, Video Size, Video Encoder, and Video Encoding Bitrate.
Compressing a video of 20MB can reduce to 2 to 4 MB, helping users to a much faster sharing/uploading.
Here’s the code snippet for compressing a video file in the Android app.
Compressed video files will take less time to Upload, Sync, Share while saving storage space. However, compressing a video file may reduce the video quality depending upon the settings that have been applied.