【发布时间】:2014-02-07 16:21:00
【问题描述】:
我有以下代码:
Log.i("xx","A");
media_recorder = new MediaRecorder();
Log.i("xx","B");
media_recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
Log.i("xx","C");
media_recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
Log.i("xx","D");
media_recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
Log.i("xx","E");
media_recorder.setVideoSize(320, 240);
Log.i("xx","F");
media_recorder.setVideoFrameRate(15);
Log.i("xx","G");
CamcorderProfile profile = CamcorderProfile.get(CameraInfo.CAMERA_FACING_FRONT,CamcorderProfile.QUALITY_LOW);
Log.i("xx","H");
media_recorder.setProfile(profile);
Log.i("xx","I");
media_recorder.setOutputFile(fname);
执行代码时,我在日志中看到以下内容;
02-07 16:12:47.628: I/xx(15436): A
02-07 16:12:47.628: I/xx(15436): B
02-07 16:12:47.638: I/xx(15436): C
02-07 16:12:47.638: I/xx(15436): D
02-07 16:12:47.638: I/xx(15436): E
02-07 16:12:47.638: I/xx(15436): F
02-07 16:12:47.638: I/xx(15436): G
02-07 16:12:47.638: I/xx(15436): H
02-07 16:12:47.638: E/MediaRecorder(15436): setOutputFormat called in an invalid state: 4
这让我感到困惑,因为对 setOutputFormat 的调用是在“C”和“D”之间进行的,但错误报告似乎是在 H 之后立即报告的(从未到达“I”)。所以现在我不知道是什么导致了错误,而且我对错误发生在哪里感到困惑。
编辑:我刚刚在调试器中逐步完成了代码 - 果然在调用 setProfile(profile) 期间发生了错误......所以看起来对 setOutputFormat 的调用(在“C”和“D”之间)必须正常工作,但是 setProfile 必须自己再次调用 setOutputFormat ,然后失败......这是怎么回事?
编辑:无效状态 4 究竟是什么意思?是否有一些列表可以告诉您每个可能的无效状态编号 1、2、3、4...等的含义?
【问题讨论】:
标签: android video-capture