Alternative ways to set durationLimit or sizeLimit while video recording?
Asked Answered
P

4

10

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?

Phenetidine answered 24/1, 2013 at 12:55 Comment(2)
duration not working for me in samsung note as wellFaxan
Look at my answer for similar questionCalkins
P
2
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.

Parthenopaeus answered 16/2, 2018 at 13:36 Comment(2)
Please add some explenation to your answer. Only showing code can be confusing.Superorder
Nice one beautiful !! :)Pixie
A
1

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.

Apteryx answered 10/4, 2013 at 14:4 Comment(0)
C
0

This is my configuration

intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);//0 for low, 1 higth
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT,20); //20seq
intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT,size*1048576L);//X mb *1024*1024 
startActivityForResult(intent, VIDEO_CAMERA_SELECT);

Works fine on LG phones, neverless Samsung devices ignore the quality parameter

Caoutchouc answered 24/4, 2015 at 11:6 Comment(0)
C
-1

You can set maximum duration and maximum file size

 recorder.setMaxDuration(80000); // 80 seconds
 recorder.setMaxFileSize(5000000); 
Counterpressure answered 24/1, 2013 at 18:57 Comment(2)
Where is recorder? I just send extra, didn't implement any class.Pell
"recorder" isn't available if you're just throwing intents to the OS to handle recording for you. It seems there's very little control when you do this, unfortunately; the restrictions you want should work but don't, at least not uniformly across devices.Piny

© 2022 - 2024 — McMap. All rights reserved.