try {
descriptors = ParcelFileDescriptor.createPipe();
} catch (IOException e) {
e.printStackTrace();
}
parcelRead = new ParcelFileDescriptor(descriptors[0]);
parcelWrite = new ParcelFileDescriptor(descriptors[1]);
inputStream = new ParcelFileDescriptor.AutoCloseInputStream(parcelRead);
媒体记录器 = 新媒体记录器();
// Step 1: Unlock and set camera to MediaRecorder
mCamera.unlock();
mediaRecorder.setCamera(mCamera);
// Step 2: Set sources
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
// Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_720P));
// The bandwidth actually consumed is often above what was requested
// Step 4: Set output file
mediaRecorder.setOutputFile(parcelWrite.getFileDescriptor());
// Step 5: Set the preview output
mediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());
mediaRecorder.prepare();
mediaRecorder.start();
E/MediaRecorder: start failed: -2147483648 0xb400007c921b82c0
W/System.err:java.lang.RuntimeException:启动失败。W/System.err:在 com.googleDev21ex.videorecorder.VideoRecordActivity2$2$1$1.run(VideoRecordActivity2.java:150) 的 android.media.MediaRecorder.start(Native Method) 在 android.os.Handler.handleCallback(Handler.java :938) 在 android.os.Handler.dispatchMessage(Handler.java:99) 在 android.os.Looper.loop(Looper.java:239) 在 android.app.ActivityThread.main(ActivityThread.java:8212) 在 java .lang.reflect.Method.invoke(Native Method) 在 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:626)