简体   繁体   English

在没有音频的情况下在android中录制视频

[英]Record video in android without audio

I'm working on a project and I'm curious to know if its possible to configure the MediaRecorder in Android to record just the video and exclude audio, ie 我正在研究一个项目,很想知道是否有可能在Android中配置MediaRecorder以仅记录视频并排除音频,即

mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

changed to something along the lines of 变成了类似的东西

mRecorder = new MediaRecorder();
mRecorder.setAudioSource(null);
mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

When I try to do the above, I get different exceptions when I either try to initialize the MediaRecorder or when I try to start the recording. 当我尝试执行上述操作时,尝试初始化MediaRecorder或尝试开始录制时会遇到不同的异常。

According to the documentation , it would seem that I can do this. 根据文档 ,看来我可以做到这一点。

If this method is not called, the output file will not contain an audio track. 如果未调用此方法,则输出文件将不包含音轨。

The issue I was having was a result of using a CamcorderProfile . 我遇到的问题是使用CamcorderProfile导致的。 Once that was removed, I no longer had issues building the project. 删除之后,我再也不会在构建项目时遇到问题。 As CodeX mentioned, there is no need to have an audio source. 如CodeX所述,不需要音频源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM