我目前正在尝试在上载到在线云数据库之前降低视频和音频的质量。以下是我一直用来录制视频的代码。
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);
}
}
}
非常感谢您的帮助!
答案 0 :(得分:0)
您可以使用以下两种方法:
将其编码为较低的比特率和/或较低的分辨率。在这里看看:
Is it possible to compress video on Android?
尝试压缩/压缩它。在这里看看:
http://www.jondev.net/articles/Zipping_Files_with_Android_%28Programmatically%29