我目前正在尝试在上传到在线云数据库之前降低视频和音频的质量。下面是我用来录制视频的代码。
recordVideoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
将 EXTRA_VIDEO_QUALITY 中的 0 更改为 1 将提高质量,反之亦然,但如果是 30 秒或更长时间的视频,文件仍然太大而无法下载。
private void RecordVideoMode() {
Intent recordVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
// Ensure that there's a camera activity to handle the intent
if (recordVideoIntent.resolveActivity(getPackageManager()) != null) {
videoFile = createVideoFile();
// Continue only if the File was successfully created
if (videoFile != null) {
videoURI = FileProvider.getUriForFile(this,
"com.example.android.fileprovider",
videoFile);
recordVideoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
recordVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, videoURI);
startActivityForResult(recordVideoIntent, REQUEST_VIDEO_CAPTURE);
}
}
}
很感谢任何形式的帮助!
一只甜甜圈
相关分类