Capturing low-resolution video in android via intent camera

How can I record low resolution video in andorid to upload to server because recorded videos in android are 3MB in size, even 3 seconds of video. And searched everything please help me


source to share

2 answers

If you are using the intent MediaStore.ACTION_VIDEO_CAPTURE you can adjust the quality by setting MediaStore.EXTRA_VIDEO_QUALITY to an additional 0 for lower quality videos, if you are accessing the camera API directly then you have to adjust the camera profile with MediaRecorder.setProfile()

. Here's an example from the Android developer site .



According to the MediaStore docs, ACTION_VIDEO_CAPTURE

this is a standard Intent that can be sent to have the camera app capture the video and return it.

The caller can send an additional one EXTRA_VIDEO_QUALITY

to control the video quality.

The name of the add-on used to control the quality of the recorded video. This is an integer property. Currently, a value of 0 means a low quality level, suitable for MMS messages, and a value of 1 means a high quality. Other quality levels may be added in the future.

So, you can use it like below,

Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(android.provider.MediaStore.EXTRA_VIDEO_QUALITY, 0);
startActivityForResult(intent, REQUEST_VIDEO_CAPTURED);


This will record video in low quality compared to normal intent. But still, in some cases, such as recording a longer time, it can also lead to an increase in the video size.

So, you can also find EXTRA_SIZE_LIMIT and EXTRA_DURATION_LIMIT to set the maximum allowed size and specify the maximum allowed recording duration in seconds.

Otherwise, if these things don't work or fit, you can record video normally and compress video when uploading to server. This will reduce the video size.

Check out the video compression sample .



All Articles