Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture Low resolution video in android via intent camera

How can i record low resolution videos in andorid to upload to server why because recorded videos in android is havin 3 MB in size even of 3 sec video.i have searched all way please help me out

like image 348
kondal Avatar asked Mar 19 '23 12:03

kondal


2 Answers

If you're using the MediaStore.ACTION_VIDEO_CAPTURE intent, you can adjust the quality by setting the MediaStore.EXTRA_VIDEO_QUALITY extra to 0 for a lower quality video, if you're accessing the camera API directly, then you'd have to adjust the camera profile via MediaRecorder.setProfile(). Here's an example from the Android developer site .

like image 124
zharguy Avatar answered Apr 09 '23 18:04

zharguy


As per the MediaStore docs, ACTION_VIDEO_CAPTURE is Standard Intent action that can be sent to have the camera application capture a video and return it.

The caller may pass in an extra EXTRA_VIDEO_QUALITY to control the video quality.

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

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 the video in low quality compare to the normal intent. But still in some of the cases like recording more time will also may cause the video size increase.

So you can also look for EXTRA_SIZE_LIMIT and EXTRA_DURATION_LIMIT to set the Specify the maximum allowed size and Specify the maximum allowed recording duration in seconds.

In other hand,If these things not worked or suitable you can record the video normally and compress the video while uploading into the server. It will reduce the size of the video.

Look this sample for video compression.

like image 23
King of Masses Avatar answered Apr 09 '23 18:04

King of Masses