Gangnaminmo Ako
Gangnaminmo Ako

Reputation: 577

setting Video Resolution using Intent

I'm trying to record a video in my app. What I'm trying to do is to set the video resolution to lowest resolution of the device.

I'm using this code to record a video:

Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

fileUri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO);

// set video quality
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 1099648L);
intent.putExtra(MediaStore.EXTRA_FINISH_ON_COMPLETION, true);

intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file
                                                        // name
// start the video capture Intent
startActivityForResult(intent, CAMERA_CAPTURE_VIDEO_REQUEST_CODE);

is it possible? or do I need to use MediaRecorder to customize the video settings. any thoughts will be highly appreciated.

Upvotes: 1

Views: 5704

Answers (2)

Valter Negreiros
Valter Negreiros

Reputation: 21

Use this

Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        takeVideoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 3); // Duration in Seconds
        takeVideoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); // Quality Low
        takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 5491520L); // 5MB
        takeVideoIntent.putExtra(MediaStore.Video.Thumbnails.HEIGHT, 320);
        takeVideoIntent.putExtra(MediaStore.Video.Thumbnails.WIDTH, 240);

        if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(takeVideoIntent, CAMERA_RQ);
        }

Upvotes: 1

Salmaan
Salmaan

Reputation: 3624

Setting the lowest resolution might not be good approach but thats the only thing you can do, i was trying to set kinda medium resolution but failed.

intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); //sets lowest resolution
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); //sets highest resolution

But the problem is samsung camera app ignore the intent extras in this case. this behaviour is same across all samsung devices. but this works fine on Google Nexus devices.
I tried on motoroa and it works fine.

For some people, as mentioned here, EXTRA_VIDEO_QUALITY is working just opposite as it was expected to work. If we pass 1 the video quality would be worse and for 0 will be the best. Sadly this didnt worked for me :(

Upvotes: 1

Related Questions