尝试设置时xamarin错误SetVideoFrameRate

问题描述:

我正在使用xamarin。我使用MediaRecorder,我只是想设置的帧速率,但是当我把它recorder.SetVideoFrameRate(30);我得到尝试设置时xamarin错误SetVideoFrameRate

Java.Lang.IllegalStateException的错误:

我不知道,如果它装置不能处理它还是有一定的方式让它工作。我只是使用简单的MediaRecorder。

MediaRecorder recorder; 

video.StopPlayback(); 

recorder = new MediaRecorder(); 
//-- 
recorder.SetVideoFrameRate(30); 
// recorder.SetCaptureRate(150); 
recorder.SetVideoSource(VideoSource.Camera); 
recorder.SetAudioSource(AudioSource.Mic); 
recorder.SetOutputFormat(OutputFormat.Default); 
recorder.SetVideoEncoder(VideoEncoder.Default); 
recorder.SetAudioEncoder(AudioEncoder.Default); 
recorder.SetOutputFile(path); 
recorder.SetPreviewDisplay(video.Holder.Surface); 
recorder.Prepare(); 
recorder.Start(); 

SetOutputFormat之前,您不能调用SetVideoFramerate。在SetOutputFormat下移动该方法调用,它将起作用。

recorder = new MediaRecorder(); 
recorder.SetVideoSource(VideoSource.Camera); 
recorder.SetAudioSource(AudioSource.Mic); 
recorder.SetOutputFormat(OutputFormat.Default); 
recorder.SetVideoFrameRate(30); // Move it here 

Android实际上有一个很棒的文档,告诉你每种方法可以抛出什么异常。这是从MediaRecorder's page报价:

抛出()setOutputFormat()之前

IllegalStateException异常,如果它被称为准备后,或。注意:在某些具有自动帧速率的设备上,这会设置最大帧速率,而不是固定帧速率。实际帧速率将根据照明条件而变化。

+0

感谢你的帮助:) – oisin1min

+0

你会知道的任何事情有关设置相机的曝光或镜头 – oisin1min

+0

的焦距@ oisin1min [Camera.Parameters](https://developer.android.com/ reference/android/hardware/Camera.Parameters.html)是你正在寻找的东西,但现在已经被弃用了。文档提到你现在应该使用[android.hardware.camera2 API](https://developer.android.com/reference/android/hardware/camera2/package-summary.html),但我没有任何经验它。 – hankide