gpt4 book ai didi

android - 视频录制功能在眼镜上崩溃,但在手机上不会

转载 作者:行者123 更新时间:2023-11-30 02:45:10 26 4
gpt4 key购买 nike

知道发生了什么事吗?错误消息不断提示:MediaRecorder start failed: -19 and android.media.MediaRecorder.start(Native Method)

我是 Android 编程世界的新手,我很困惑。为什么它会在眼镜上崩溃并在手机上完美运行。我目前正在为 Vuzix 智能眼镜开发一个简单的视频录制应用。

这是我目前所拥有的:

     @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

recording = false;

mediaRecorder = new MediaRecorder();
initMediaRecorder();

setContentView(R.layout.video_main);

SurfaceView myVideoView = (SurfaceView)findViewById(R.id.videoview);
surfaceHolder = myVideoView.getHolder();
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

myButton = (Button)findViewById(R.id.mybutton);
myButton.setOnClickListener(myButtonOnClickListener);
}

private Button.OnClickListener myButtonOnClickListener
= new Button.OnClickListener(){

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(recording)
{
mediaRecorder.stop();
mediaRecorder.release();
finish();
}
else
{
mediaRecorder.start();
recording = true;
myButton.setText("STOP");
}
}};

@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub

}
@Override
public void surfaceCreated(SurfaceHolder arg0) {
// TODO Auto-generated method stub
prepareMediaRecorder();
}
@Override
public void surfaceDestroyed(SurfaceHolder arg0) {
// TODO Auto-generated method stub

}

private void initMediaRecorder(){

mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
CamcorderProfile camcorderProfile_HQ = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
mediaRecorder.setProfile(camcorderProfile_HQ);
mediaRecorder.setOutputFile("/sdcard/myvideo.mp4");
//mediaRecorder.setMaxDuration(60000); // Set max duration 60 sec.
//mediaRecorder.setMaxFileSize(5000000); // Set max file size 5M
}

private void prepareMediaRecorder(){

mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());

try
{
mediaRecorder.prepare();
}
catch (IllegalStateException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}

最佳答案

这里是 Vuzix 的高级支持专家 Todd Ferguson。我们的一位客户告诉我这个帖子,我想我会在这里发布我给他的答案,以帮助您。

如果您对此有任何疑问,请通过 todd_ferguson@vuzix.com 联系我。

Hmm. Apparently that method of using a TextureView doesn’t seem to work for us. I had to change it back to a SurfaceView to get it working. I also had to set the video framerate to 24 and increase the resolution since the function getOptimalPreviewSize() was being based on the size of the preview surface and returned a weird resolution.
I’ll add the TextureView weirdness to the bug list as that should be working in our API version. The framerate issue is a camera driver problem and a known bug. Thank you for bringing this to our attention. We’ll address these issues in an upcoming build.

问候,

托德·R·弗 Gson

关于android - 视频录制功能在眼镜上崩溃,但在手机上不会,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25176746/

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