MediaRecorder: prepare failed: -2147483648

这个问题在google手机上没有任何问题,在我使用了小米之后出现的问题,先看报错信息:

Caused by: java.io.IOException: prepare failed.
        at android.media.MediaRecorder._prepare(Native Method)
        at android.media.MediaRecorder.prepare(MediaRecorder.java:1079)
        at com.kiwisec.flirapp.video.SurfaceRecorder.start(SurfaceRecorder.kt:92)
        at com.kiwisec.flirapp.activities.MainActivity.checkPxPermission$lambda$13(MainActivity.kt:373)
        at com.kiwisec.flirapp.activities.MainActivity.$r8$lambda$tDIroOtqhx1B4En7t_dYqDPRyGI(Unknown Source:0)
        at com.kiwisec.flirapp.activities.MainActivity$$ExternalSyntheticLambda15.onResult(Unknown Source:2)
        at com.permissionx.guolindev.request.BaseTask.finish(BaseTask.kt:117)
        at com.permissionx.guolindev.request.RequestBodySensorsBackgroundPermission.request(RequestBodySensorsBackgroundPermission.kt:67)
        at com.permissionx.guolindev.request.BaseTask.finish(BaseTask.kt:54)
        at com.permissionx.guolindev.request.RequestNotificationPermission.request(RequestNotificationPermission.kt:47)
        at com.permissionx.guolindev.request.BaseTask.finish(BaseTask.kt:54)
        at com.permissionx.guolindev.request.RequestInstallPackagesPermission.request(RequestInstallPackagesPermission.kt:54)
        at com.permissionx.guolindev.request.BaseTask.finish(BaseTask.kt:54)
        at com.permissionx.guolindev.request.RequestManageExternalStoragePermission.request(RequestManageExternalStoragePermission.kt:54)
        at com.permissionx.guolindev.request.BaseTask.finish(BaseTask.kt:54)
        at com.permissionx.guolindev.request.RequestWriteSettingsPermission.request(RequestWriteSettingsPermission.kt:61)
        at com.permissionx.guolindev.request.BaseTask.finish(BaseTask.kt:54)
        at com.permissionx.guolindev.request.RequestSystemAlertWindowPermission.request(RequestSystemAlertWindowPermission.kt:61)
        at com.permissionx.guolindev.request.BaseTask.finish(BaseTask.kt:54)
        at com.permissionx.guolindev.request.RequestBackgroundLocationPermission.request(RequestBackgroundLocationPermission.kt:64)
        at com.permissionx.guolindev.request.BaseTask.finish(BaseTask.kt:54)
        at com.permissionx.guolindev.request.RequestNormalPermissions.request(RequestNormalPermissions.kt:39)
        at com.permissionx.guolindev.request.RequestChain.runTask$permissionx_release(RequestChain.kt:51)
        at com.permissionx.guolindev.request.PermissionBuilder.startRequest(PermissionBuilder.kt:572)
        at com.permissionx.guolindev.request.PermissionBuilder.request(PermissionBuilder.kt:288)
        at com.kiwisec.flirapp.activities.MainActivity.checkPxPermission(MainActivity.kt:329)
        at com.kiwisec.flirapp.activities.MainActivity.initListener$lambda$8(MainActivity.kt:281)
        at com.kiwisec.flirapp.activities.MainActivity.$r8$lambda$1icCSC27MqRv5PNn13c1RunKiIw(Unknown Source:0)
        at com.kiwisec.flirapp.activities.MainActivity$$ExternalSyntheticLambda4.onClick(Unknown Source:2)
        at android.view.View.performClick(View.java:7185)
        at android.view.View.performClickInternal(View.java:7162)
        at android.view.View.access$3500(View.java:819)
        at android.view.View$PerformClick.run(View.java:27678)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:224)

说的是mediarecorder准备就是失败,在网上收集了很多问题也试了不行绝望啊,很多东西都说的和模糊还好在网上找到了问题,说的是设置MediaRecorder.setVideoSize方法宽高时,因为宽高设置的是动态获取的,可能获取的高度是奇数,那么就是报这个错误,把奇数改成偶数就成功了。

Camera2录制视频报错“E/MediaRecorder: prepare failed: -2147483648”_雪下的回忆的博客-CSDN博客_prepare failed: -2147483648

MediaRecorder准备失败,使用setVideoSize 1080p(MediaRecorder prepare fails with setVideoSize 1080p)_电脑培训

MediaRecorder录制屏幕时在部分机型上报错prepare failed:-22

总有你需要的解决的问题

你可能感兴趣的:(录屏,android,java,开发语言)