mabeijianxi / small-video-record

利用FFmpeg视频录制微信小视频与其压缩处理
Apache License 2.0
3.46k stars 729 forks source link

Video2 崩溃 #347

Closed luyun181 closed 6 years ago

luyun181 commented 6 years ago

java.lang.NullPointerException: Attempt to invoke virtual method 'int com.mabeijianxi.smallvideorecord2.model.MediaObject.getDuration()' on a null object reference at com.mabeijianxi.smallvideorecord2.MediaRecorderActivity$1.onTouch(MediaRecorderActivity.java:282) at android.view.View.dispatchTouchEvent(View.java:10035) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2634) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2264) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2634) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2264) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2634) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2264) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2634) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2264) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2634) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2264) at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:417) at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1808) at android.app.Activity.dispatchTouchEvent(Activity.java:3198) at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:379) at android.view.View.dispatchPointerEvent(View.java:10261) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4500) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4365) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3905) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3958) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3924) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4051) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3932) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4108) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3905) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3958) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3924) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3932) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3905) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6309) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6283) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6244) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6415) at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:187) at android.os.MessageQueue.nativePollOnce(Native Method) at android.os.MessageQueue.next(MessageQueue.java:323) at android.os.Looper.loop(Looper.java:142) at android.app.ActivityThread.main(ActivityThread.java:6396) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)

private void getRecoder(){ MediaRecorderConfig config = new MediaRecorderConfig.Buidler()

            .fullScreen(false)
            .smallVideoWidth(720)
            .smallVideoHeight(960)
            .recordTimeMax(60000)
            .recordTimeMin(1500)
            .maxFrameRate(20)
            .videoBitrate(600000)
            .captureThumbnailsTime(1)
            .build();
    MediaRecorderActivity.goSmallVideoRecorder(this, MainActivity.class.getName(), config);
}

录制界面能打开,一点录制就崩溃 这样写有什么问题吗?所有权限都申请了。还是崩溃 但是我发现一个规律,如果崩溃,就去app的权限页随便更改一项权限。就不崩溃了。

luyun181 commented 6 years ago

miui 调用相机bug,应该怎么在onSaveInstanceState中保存MediaRecorder对象?

luyun181 commented 6 years ago

Manifest.permission.WRITE_EXTERNAL_STORAGE 权限写错。