Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Compress Video before Upload to Server

How can I compress a video file in Android before uploading to a remote server? I'm not looking to zip up the file, because I don't think that will help much. I want to compress the video and re-encode it with a lower bit-rate or resolution. The idea is to get a standard 360х480, 30 FPS video file from every device. This way I can avoid users with better cameras being forced to upload huge video files.

I know iOS makes it fairly simple to force video file resolutions. 10 second video recorded on iPhone 4:

  • high (1280х720) = ~14MB = ~11Mbit/s
  • 640 (640х480) = ~4MB = ~3.2Mbit/s
  • medium (360х480) = ~1MB = ~820Kbit/s
  • low (144х192) = ~208KB = ~170Kbit/s

Is there any easy way to do this in Android? Do I need to find some external library that will let me re-encode the video file, then save it to the SD card (or overwrite the old video file), then upload that file? Mainly looking for general direction here and not code to copy and paste, although anything is helpful.

like image 525
Kyle Clegg Avatar asked Jul 03 '12 15:07

Kyle Clegg


People also ask

Can you compress video without losing quality in Android?

HEVC stands for 'High Efficiency Video Coding' most commonly known as H. 265. This is a compressed file format that reduces the file size by a good margin without sacrificing on quality and resolution of the video. Almost all premium Android smartphones offer this video encoding option under the camera settings.

Can you compress a video file on Android?

Luckily, you can easily compress these videos on your Android phone using a video compressor app.

Should I compress my videos before uploading to YouTube?

According to Google, “If your video is larger than 128GB, try compressing your video in a video editor before uploading it to YouTube. This will reduce your video file size while still keeping the video quality high. One common way to compress a video for YouTube is to encode it using the H. 264 codec.”


1 Answers

I got a similar problem. Where I had to upload video in server having size within 5.4mb. But due to different camera resolutions of different phones, there was a problem. These are the solutions which I have opted

mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
mediaRecorder.setVideoEncodingBitRate(690000 );

Hope these will help you

like image 137
user1859771 Avatar answered Oct 19 '22 03:10

user1859771