gpt4 book ai didi

android - MediaRecorder 不再适用于新的 Google Glass 固件 (XE19.1) 媒体服务器死机错误 100

转载 作者:太空宇宙 更新时间:2023-11-03 13:22:48 31 4
gpt4 key购买 nike

我为谷歌眼镜制作了一个视频录制应用程序。在 Google 发布固件 XE19.1 之前,该应用程序运行良好。我有另一台固件为 XE18.11 的 Google Glass。该应用程序仍可在采用 XE18.11 的 Google Glass 上运行。

我收到以下错误:

07-30 15:39:32.273: V/MediaRecorder(17101): video.h264enc.profile is set to : 1
07-30 15:39:32.679: W/IMediaDeathNotifier(17101): media server died
07-30 15:39:32.679: W/CameraBase(17101): Camera service died!
07-30 15:39:32.679: W/CameraBase(17101): mediaserver's remote binder Camera object died
07-30 15:39:32.687: E/CameraManager(17101): Media Recorder error: what=100, extra=0
07-30 15:39:32.726: E/Camera(17101): Error 100

我试过但没用的:

  • 尝试过 MediaRecorder example from Google .仅适用于旧固件
  • 将 Google Glass 恢复出厂设置
  • 尝试在录制前开始预览和不开始预览。都适用于旧固件
  • 将 SurfaceView 更改为 TextureView。都适用于旧固件
  • 查看了 changelog GDK XE19.1
  • 谷歌搜索错误

这很奇怪,因为即使是 Google 示例也不起作用。这是将 SurfaceView 更改为 TextureView 后的代码:

public class CameraManager implements OnErrorListener
{
private final static String TAG = CameraManager.class.getName();
private final static int PREVIEW_SIZE_WIDTH = 640;
private final static int PREVIEW_SIZE_HEIGHT = 360;

private Activity mContext;
private Camera mCamera;
private TextureView mCameraPreview;
private CameraListener mCameraListener;
private MediaRecorder mMediaRecorder;
private File mOutputVideoFile;
private boolean mRecording;
private boolean mTakingPicture;

public CameraManager(Activity context, TextureView cameraPreview,
CameraListener cameraListener)
{
mRecording = false;
mTakingPicture = false;
mContext = context;

mCameraPreview = cameraPreview;
mCameraListener = cameraListener;
}

public void startRecording(File outputVideoFile)
{
Log.d(TAG, "startRecording");

mOutputVideoFile = outputVideoFile;
new MediaPrepareTask().execute(null, null, null);
}

public void stopRecording()
{
Log.d(TAG, "stopRecording");

mRecording = false;

// stop the recording
mMediaRecorder.stop();
// if we are using MediaRecorder, release it first
releaseMediaRecorder();
// take camera access back from MediaRecorder
mCamera.lock();
// release the camera immediately on pause event
releaseCamera();
}

public boolean isBusyRecording()
{
return mRecording;
}

public void takePicture(final TakePictureCallback pictureCallback)
{
if (isBusyRecording() && !mTakingPicture)
{
mTakingPicture = true;

mCamera.takePicture(null, null, new PictureCallback()
{
@Override
public void onPictureTaken(final byte[] pictureData, Camera camera)
{
pictureCallback.onPictureTaken(pictureData);
mTakingPicture = false;
}
});
}
}

@TargetApi(Build.VERSION_CODES.KITKAT)
private boolean prepareVideoRecorder()
{
Log.d(TAG, "prepareVideoRecorder");

// BEGIN_INCLUDE (configure_preview)
mCamera = CameraHelper.getDefaultCameraInstance();

// We need to make sure that our preview and recording video size are
// supported by the
// camera. Query camera to find all the sizes and choose the optimal
// size given the
// dimensions of our preview surface.
Camera.Parameters parameters = mCamera.getParameters();
List<Camera.Size> mSupportedPreviewSizes = parameters.getSupportedPreviewSizes();
Camera.Size optimalSize = CameraHelper.getOptimalPreviewSize(mSupportedPreviewSizes,
PREVIEW_SIZE_WIDTH, PREVIEW_SIZE_HEIGHT);

// Use the same size for recording profile.
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
profile.videoFrameWidth = optimalSize.width;
profile.videoFrameHeight = optimalSize.height;

// likewise for the camera object itself.
parameters.setPreviewSize(profile.videoFrameWidth, profile.videoFrameHeight);
mCamera.setParameters(parameters);
try
{
// Requires API level 11+, For backward compatibility use {@link
// setPreviewDisplay}
// with {@link SurfaceView}
mCamera.setPreviewTexture(mCameraPreview.getSurfaceTexture());
}
catch (IOException e)
{
Log.e(TAG, "Surface texture is unavailable or unsuitable" + e.getMessage());
return false;
}
// END_INCLUDE (configure_preview)

// BEGIN_INCLUDE (configure_media_recorder)
mMediaRecorder = new MediaRecorder();
mMediaRecorder.setOnErrorListener(this);

// Step 1: Unlock and set camera to MediaRecorder
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);

// Step 2: Set sources
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

// Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
mMediaRecorder.setProfile(profile);

// Step 4: Set output file
mMediaRecorder.setOutputFile(mOutputVideoFile.toString());
// END_INCLUDE (configure_media_recorder)

// Step 5: 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;
}

private void releaseMediaRecorder()
{
Log.d(TAG, "releaseMediaRecorder");

if (mMediaRecorder != null)
{
// clear recorder configuration
mMediaRecorder.reset();
// release the recorder object
mMediaRecorder.release();
mMediaRecorder = null;
// Lock camera for later use i.e taking it back from MediaRecorder.
// MediaRecorder doesn't need it anymore and we will release it if
// the activity pauses.
mCamera.lock();
}
}

private void releaseCamera()
{
Log.d(TAG, "releaseCamera");

if (mCamera != null)
{
// release the camera for other applications
mCamera.release();
mCamera = null;
}
}

/**
* Asynchronous task for preparing the {@link android.media.MediaRecorder}
* since it's a long blocking operation.
*/
class MediaPrepareTask extends AsyncTask<Void, Void, Boolean>
{
@Override
protected Boolean doInBackground(Void... voids)
{
Log.d(TAG, "MediaPrepareTask - doInBackground");

// initialize video camera
if (prepareVideoRecorder())
{
// Camera is available and unlocked, MediaRecorder is prepared,
// now you can start recording
mMediaRecorder.start();

mRecording = true;
}
else
{
// prepare didn't work, release the camera
releaseMediaRecorder();
return false;
}
return true;
}

@Override
protected void onPostExecute(Boolean result)
{
if (!result)
{
mContext.finish();
}

mCameraListener.onCameraRecording();
}
}

@Override
public void onError(MediaRecorder mr, int what, int extra)
{
Log.e(TAG, String.format("Media Recorder error: what=%d, extra=%d", what, extra));
}
}

谢谢

最佳答案

尝试设置参数。setRecordingHint(true);在开始录制过程之前在相机上。这为我解决了这个问题。参见 here一个完整的例子。

关于android - MediaRecorder 不再适用于新的 Google Glass 固件 (XE19.1) 媒体服务器死机错误 100,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25038828/

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