gpt4 book ai didi

android - setOutputFormat 在无效状态下调用 : 4 (where and why)

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:14:44 28 4
gpt4 key购买 nike

我有以下代码:

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 ( between "C"& "D") 一定工作正常,但是 setProfile 本身必须再次调用 setOutputFormat 然后失败...这是怎么回事?

编辑: 无效状态 4 究竟意味着什么?是否有某个列表可以告诉您每个可能的无效状态编号 1、2、3、4 等的含义?

最佳答案

这里是setProfile方法的源代码:

public void setProfile(CamcorderProfile profile) {
setOutputFormat(profile.fileFormat);
setVideoFrameRate(profile.videoFrameRate);
setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
setVideoEncodingBitRate(profile.videoBitRate);
setVideoEncoder(profile.videoCodec);
if (profile.quality >= CamcorderProfile.QUALITY_TIME_LAPSE_LOW &&
profile.quality <= CamcorderProfile.QUALITY_TIME_LAPSE_QVGA) {
// Nothing needs to be done. Call to setCaptureRate() enables
// time lapse video recording.
} else {
setAudioEncodingBitRate(profile.audioBitRate);
setAudioChannels(profile.audioChannels);
setAudioSamplingRate(profile.audioSampleRate);
setAudioEncoder(profile.audioCodec);
}
}

例如它将 outputFormat、videoSize、encoder 和 frameRate 设置为配置文件中的值。所以你的代码:

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);

至少是无用的,也许在这些调用期间它会改变状态。不用它试试。

关于android - setOutputFormat 在无效状态下调用 : 4 (where and why),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21632769/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com