Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative ways to set durationLimit or sizeLimit while video recording?

The thing what I wanted to implement that users can record video only for 30 seconds or by a specific size.

I tried to use those below (both seperately or together)

public static final java.lang.String EXTRA_SIZE_LIMIT = "android.intent.extra.sizeLimit";
public static final java.lang.String EXTRA_DURATION_LIMIT = "android.intent.extra.durationLimit";

Results

  1. EXTRA_SIZE_LIMIT did not work on Samsung Phones. On HTC it worked very inaccurately. You must set EXTRA_VIDEO_QUALITY as 0 which means low quality (it's sh*t as hell) and if you set it to "1" it wont work.

  2. EXTRA_DURATION_LIMIT did not work on HTC Phones. Except HTC it worked without any problem all brands which I tried.

So I wonder if there are another ways to set limit for duration or size while video recording on Android?

like image 687
Mustafa Güven Avatar asked Jan 24 '13 12:01

Mustafa Güven


2 Answers

No, not when using ACTION_VIDEO_CAPTURE. Using the MediaRecorder directly will probably cause similar problems.

The alternative is to inform the user of the limitations and reject recorded videos that go beyond the limitations you've set up.

like image 181
Adam Nybäck Avatar answered Oct 19 '22 20:10

Adam Nybäck


Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); //Low Quality
    intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT,2097152L);  //2MB
    intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT,30); //30Seconds
    startActivityForResult(intent, CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);

You can use this way to set video size or duration passing in intent with keys "EXTRA_SIZE_LIMIT" and "EXTRA_DURATION_LIMIT".

This works fine.

like image 2
Priyanka Thakkar Avatar answered Oct 19 '22 22:10

Priyanka Thakkar