9

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?

4

4 回答 4

1

不,不是在使用ACTION_VIDEO_CAPTURE. 直接使用MediaRecorder可能会导致类似的问题。

另一种方法是通知用户限制并拒绝超出您设置的限制的录制视频。

于 2013-04-10T14:04:11.210 回答
1
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);

您可以使用这种方式通过键“EXTRA_SIZE_LIMIT”和“EXTRA_DURATION_LIMIT”来设置视频大小或持续时间。

这工作正常。

于 2018-02-16T13:36:57.137 回答
0

这是我的配置

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);

在 LG 手机上运行良好,但三星设备始终忽略质量参数

于 2015-04-24T11:06:24.497 回答
-1

您可以设置最长持续时间和最大文件大小

 recorder.setMaxDuration(80000); // 80 seconds
 recorder.setMaxFileSize(5000000); 
于 2013-01-24T18:57:44.873 回答