开发者

Android setVideoEncodingBitRate() is not defined in package MediaRecorder

I am trying to the change the encoding bit rate of the video recording on Android using MediaRecorder.setVideoEncodingBitRate(int).

I looked in the android documentation and it states this method to set/change the bit rate but when I try to us开发者_如何学Pythone this method I am getting setVideoEncodingBitrRate(int) is not defined in package MediaRecorder.

Why it is so?


I suggest you should check that which API version you are using

setVideoEncodingBitRate() just come on API v8 or Android 2.1

If you use version less than that it would not be available :D


Also you could use it like this

webCamRecorder = new MediaRecorder();
if (target_holder == null)
    return;
webCamRecorder.setPreviewDisplay(target_holder.getSurface());
webCamRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
webCamRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
webCamRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
webCamRecorder.setAudioEncodingBitRate(196608);
webCamRecorder.setVideoSize(640, 480);
webCamRecorder.setVideoFrameRate(30);
webCamRecorder.setVideoEncodingBitRate(15000000);
webCamRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
webCamRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
webCamRecorder.setOutputFile("your location to save");


setVideoEncodingBitRate is an instance method, seems that you are trying to call it as a static method (MediaRecorder.setVideoEncodingBitRate(int)), instead, call it from the MediaRecorder object.

MediaRecorder mr = new MediaRecorder();
mr.setVideoEncodingBitRate(someint);

Also, did you import android.media.MediaRecorder ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜