Android IMediaDeathNotifier:媒体服务器已死亡

Android IMediaDeathNotifier:媒体服务器已死亡,android,android-camera,audio-recording,Android,Android Camera,Audio Recording,最近我遇到了这个问题,但没有任何线索。我想使用“mediarecorder”录制720P视频流,并将其实时发送到服务器。这是我的密码: try{ soc = new Socket(InetAddress.getByName(hostname), port); } catch (UnknownHostException e){ e.printStackTrace(); } catch (IOException e){ e.printStackTrace(); } Camco

最近我遇到了这个问题,但没有任何线索。我想使用“mediarecorder”录制720P视频流,并将其实时发送到服务器。这是我的密码:

try{
    soc = new Socket(InetAddress.getByName(hostname), port);
} catch (UnknownHostException e){
    e.printStackTrace();
} catch (IOException e){
    e.printStackTrace();
}
CamcorderProfile pProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_720P);
//pProfile.videoFrameWidth = 1280;
//pProfile.videoFrameWidth = 720;
recorder.setProfile(pProfile);

//recorder.setOutputFile(myRecAudioFile.getAbsolutePath());//保存路径

pfd = ParcelFileDescriptor.fromSocket(soc);
recorder.setOutputFile(pfd.getFileDescriptor());
recorder.prepare();
recorder.start();
android API级别为17,当我启动媒体录制器时,程序将在一两秒钟内关闭。错误日志如下所示:

IMediaDeathNotifier- media server died
Camera  -  Camera server died

遇到类似问题的任何人都能给我一些建议吗?

我认为您需要为您的
MediaRecorder设置预览显示:

SurfaceView mySurfaceView = (SurfaceView) findViewById(R.id.my_surface_view);
Surface mySurface = camera.getHolder().getSurface();
recorder.setPreviewDisplay(mySurface);
显然,android不允许你播放视频,除非你设置了预览显示界面