Home > Mobile >  Android6.0 video camera2 MediaRecorder. Getsurface failure
Android6.0 video camera2 MediaRecorder. Getsurface failure

Time:09-23

Android version: 6.0, the realization of functions: video code is as follows:
MMediaRecorder=new MediaRecorder ();
MMediaRecorder. SetVideoSource (MediaRecorder. VideoSource. SURFACE);
MMediaRecorder. SetOutputFormat (MediaRecorder. OutputFormat. THREE_GPP);
MMediaRecorder. SetOutputFile ("/sdcard/surface. 3 gp ");
MMediaRecorder. SetVideoFrameRate (30);
MMediaRecorder. SetVideoSize (352, 288);
MMediaRecorder. SetVideoEncoder (MediaRecorder. VideoEncoder. H264);
Try {
MMediaRecorder. Prepare ();
} the catch (IOException e)
{

}
Surface recorderSurface=mMediaRecorder. GetSurface ();
Perform at the end of the line of errors: E/MediaRecorder: SurfaceMediaSource could not be initialized.
Java. Lang. An IllegalStateException: failed to get surface

CodePudding user response:

Can you tell me the solution?

CodePudding user response:

MMediaRecorde. SetPreviewDisplay (mSurfaceHolder. GetSurface)

CodePudding user response:

With the problem, solves the pray tell ah

CodePudding user response:

This problem solved?

CodePudding user response:

Could you tell me how to solve your problem?

CodePudding user response:

This should be a permissions problem, dynamic application {Manifest. Permission. The CAMERA, the Manifest. Permission. WRITE_EXTERNAL_STORAGE, Manifest. Permission. READ_EXTERNAL_STORAGE, Manifest. Permission. RECORD_AUDIO} these, plus in Manifes & lt; USES - feature android: name="android. Hardware. Camera"/& gt;
CodePudding user response:

MMediaRecorder. SetVideoSize (352, 288); Set the width of high not appropriate, set the size of the several kinds of commonly used mobile phone try, such as the 1920 x1080
  • Related