Android: How to Solve Video Compression

Android: How to Solve Video Compression

Android Video Compression
< 1 Minute Read

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.

[code language=”html”]
mediaRecorder.setVideoSize(640, 480);


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.


Jayadev Das

Do what you do best in – that’s what I’ve always believed in and that’s what I preach. Over the past 25+ years (yup that’s my expertise ‘n’ experience in the Information Technology domain), I’ve been consulting to small, medium and large companies ‘bout Web Technologies, Mobile Future as well as on the good-and-bad of tech. Blogger, International Business Advisor, Web Technology Expert, Sales Guru, Startup Mentor, Insurance Sales Portal Expert & a Tennis Player. And top of all – a complete family man!

1 Comment
  • Avatar
    Vinit Kumar
    Posted at 14:10h, 17 June Reply

    Hello Jayadev ! How about an already recorded video ? Something like Instagram. If i have to share a video from my gallery and it is pretty big in size then in that case how do i compress it ? I did see FFMPEG for video compression but it is increasing the android application size by close to 20Mb. Is there any other solution that FFMPEG to compress video before uploading it to the server ?

Post A Comment

Exit pop up

Sad to see you leaving early...

From "Aha" to "Oh shit" we are sharing everything on our journey.
Enter your email address to stay up to date with the latest news.
Holler Box