Android Compress Video before uploading to server

How to compress a video file in Android before uploading to a remote server? I am not going to write the file because I do not think this will help. I want to compress a video and transcode it with a lower data rate or resolution. The idea is to get a standard 360x480, 30 FPS video file from each device. In this way, I can avoid the fact that users with better cameras will be forced to upload huge video files.

I know that iOS makes formatting video files easier. 10 second video recorded on iPhone 4:

  • high (1280x720) = ~ 14 MB = ~ 11 Mbps
  • 640 (640x480) = ~ 4 MB = ~ 3.2 Mbps
  • medium (360x480) = ~ 1MB = ~ 820 Kbps
  • low (144x192) = ~ 208 KB = ~ 170 Kbps

Is there an easy way to do this in Android? Do I need to find an external library that will allow me to transcode the video file and then save it to the SD card (or overwrite the old video file) and then upload this file? Mostly looking for a general direction here, not code for copy and paste, although something is useful.

+4
source share
3 answers

I had a similar problem. Where I had to upload video on a server with a size of 5.4mb.bt due to different camera resolutions on different phones, a problem arose. These are the solutions that I have chosen

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

hope this helps you

+7
source

We decided to keep this functionality for another iteration of the project. We decided to warn users about the heavy data load (especially if they are not connected to Wi-Fi). I am sure it can be done, and the link provided by tabbykitten is the best SO related publication I have found on this topic at this date.

0
source

Starting with Android 18, you have a direct Android API for encoding video, but if you focus on an API level of less than 18, then it is not direct

the link below encodes https://github.com/google/grafika/blob/master/src/com/android/grafika/VideoEncoderCore.java

0
source

All Articles