【发布时间】:2015-04-21 00:21:44
【问题描述】:
我想录制没有声音的原始 h.264 视频,并且可能需要硬件加速(稍后再进行流式传输)。所以我决定使用MediaRecorder(以及用于流式传输的套接字hack)。
我有以下代码:
final MediaRecorder recorder = new MediaRecorder();
final Camera camera = Camera.open();
camera.unlock();
recorder.setCamera(camera);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
final CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
recorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
recorder.setVideoFrameRate(profile.videoFrameRate);
recorder.setVideoEncodingBitRate(profile.videoBitRate);
recorder.prepare();
recorder.start();
然后砰!这在 logcat 中:
E/MediaRecorder﹕ start failed: -38
我开始用谷歌搜索,发现了很多问题和答案,但没有关于我的错误代码-38。
所以我尝试查看Android source code,发现它是native 方法,我不知道在哪里可以找到它。
所以我的大问题是:是否有一些错误代码列表,所以我可以找到错误-38 的含义?`
还知道我的目标是 API 10(Gingerbread)并使用最新的 SDK 21 进行构建。
【问题讨论】:
-
不幸的是,这并不意味着什么。几层之下的某个地方可能有一个有用的错误代码,但当它冒泡到应用程序时,它几乎总是-38。您可以通过查看 logcat 输出中的其他错误或警告来找到一些有用的信息。
标签: android android-mediarecorder