RecordingProxy::releaseRecordingFrame 在 Android 手机上录制时每 25 毫秒在日志中重复一次
Posted
技术标签:
【中文标题】RecordingProxy::releaseRecordingFrame 在 Android 手机上录制时每 25 毫秒在日志中重复一次【英文标题】:RecordingProxy::releaseRecordingFrame repeating in log every 25ms while recording on Android phone 【发布时间】:2014-06-14 02:52:05 【问题描述】:当我在自制应用程序中录制视频时,我会每隔 25 毫秒左右重复这两行(然后它会立即填充一个日志文件):
04-28 09:33:07.705: V/Camera(3161): RecordingProxy::releaseRecordingFrame
04-28 09:33:07.705: V/Camera(3161): releaseRecordingFrame
我不认为这是正常的,因为我也经常遇到臭名昭著的“媒体服务器死机”错误或电影崩溃。这是在 4.0.4 Samsung Discover 设备上。我在我的 LG Optimus One 设备上看不到这些日志行。
您会在代码here 中找到这些日志行,每次“// 时间戳帧准备就绪时来自相机服务的回调”。正常吗?我读到在日志中投入太多最终会减慢/出错的应用程序。更多代码如下。谢谢!
这里是登录视频开始:
04-28 09:33:05.635: V/Camera-JNI(3161): unlock
04-28 09:33:05.635: V/Camera-JNI(3161): get_native_camera: context=0x1287378, camera=0x1473a88
04-28 09:33:05.635: V/Camera-JNI(3161): get_native_camera: context=0x1287378, camera=0x1473a88
04-28 09:33:05.635: V/Camera(3161): getProxy
04-28 09:33:05.645: V/MediaProfilesJNI(3161): native_get_camcorder_profile: 0 1
04-28 09:33:05.665: D/ASC(3161): mounted
04-28 09:33:05.685: V/VoirCam(3161): ts 1398691985695
04-28 09:33:05.925: V/Camera(3161): RecordingProxy::startRecording
04-28 09:33:05.925: V/Camera(3161): reconnect
04-28 09:33:05.925: V/Camera(3161): startRecording
04-28 09:33:06.305: V/Camera(3161): RecordingProxy::releaseRecordingFrame
04-28 09:33:06.305: V/Camera(3161): releaseRecordingFrame
04-28 09:33:06.325: V/Camera(3161): RecordingProxy::releaseRecordingFrame
04-28 09:33:06.325: V/Camera(3161): releaseRecordingFrame
04-28 09:33:06.325: V/Camera(3161): RecordingProxy::releaseRecordingFrame
04-28 09:33:06.325: V/Camera(3161): releaseRecordingFrame
04-28 09:33:06.345: V/Camera(3161): RecordingProxy::releaseRecordingFrame
04-28 09:33:06.345: V/Camera(3161): releaseRecordingFrame
04-28 09:33:06.375: V/Camera(3161): RecordingProxy::releaseRecordingFrame
04-28 09:33:06.375: V/Camera(3161): releaseRecordingFrame
然后停下来:
04-28 09:29:38.555: V/Camera(3161): RecordingProxy::releaseRecordingFrame
04-28 09:29:38.555: V/Camera(3161): releaseRecordingFrame
04-28 09:29:38.695: V/Camera(3161): RecordingProxy::releaseRecordingFrame
04-28 09:29:38.695: V/Camera(3161): releaseRecordingFrame
04-28 09:29:38.705: V/Camera(3161): RecordingProxy::stopRecording
04-28 09:29:38.705: V/Camera(3161): stopRecording
04-28 09:29:39.065: V/Camera-JNI(3161): lock
04-28 09:29:39.065: V/Camera-JNI(3161): get_native_camera: context=0x1287378, camera=0x1473a88
04-28 09:29:39.065: V/Camera-JNI(3161): lock
04-28 09:29:39.065: V/Camera-JNI(3161): get_native_camera: context=0x1287378, camera=0x1473a88
录音开始如下:
if (prepareVideoRecorder())
mMediaRecorder.start();
我的prepareVideoRecorder函数是:
私有布尔prepareVideoRecorder()
mMediaRecorder = new MediaRecorder();
// Step 1: Unlock and set camera to MediaRecorder
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
// Step 2: Set sources
mMediaRecorder.setAudiosource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
CamcorderProfile camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
camcorderProfile.videoCodec = MediaRecorder.VideoEncoder.H264;
camcorderProfile.audioCodec = MediaRecorder.AudioEncoder.AAC;
camcorderProfile.fileFormat = MediaRecorder.OutputFormat.MPEG_4;
// Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
mMediaRecorder.setProfile(camcorderProfile);
// Step 4: Set output file
mMediaRecorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());
mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());
// Step 6: Prepare configured MediaRecorder
try
mMediaRecorder.prepare();
catch (IllegalStateException e)
Log.d(TAG, "IllegalStateException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
catch (IOException e)
Log.d(TAG, "IOException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
return true;
【问题讨论】:
【参考方案1】:预计不会出现该消息,但可能不是出于您期望的原因。
在 android 源代码中,默认编译出详细级别的日志记录 (ALOGV)。要启用它,您在包含 Log.h
标头之前将符号 LOG_NDEBUG
定义为零。查看 androidcodesearch.com 链接中出现的源文件,您可以在第 18 行看到这个#define -- 已注释掉。如果您正在调试 Camera 实现,您首先要取消注释该行。
看来,构建您正在使用的系统的人(三星?)为此文件启用了详细日志记录并将其保留,因此仅在调试期间可见的消息始终处于打开状态。
我以前没有看过这段代码,但我猜这个函数通常每帧运行一次。所以你看到的可能是“正常的”。
【讨论】:
天啊...所以三星的某个人在发布期间正在睡觉?!?不知道强制不登录的方法,是吗? 没有。您可以过滤掉消息,这样您就不会看到它们流过,但它们仍会填充环形缓冲区。您最好的选择是将 logcat 输出发送到文件,例如ANDROID_LOG_TAGS=Camera:d adb logcat -v threadtime > log.txt
将忽略所有带有相机标签的详细级别消息。将其发送到文件应有助于避免在设备上缓冲区填满时丢失内容。 DDMS 具有类似的过滤能力。以上是关于RecordingProxy::releaseRecordingFrame 在 Android 手机上录制时每 25 毫秒在日志中重复一次的主要内容,如果未能解决你的问题,请参考以下文章