安卓:有谁知道如何捕捉视频? [英] Android: Does anyone know how to capture video?

查看:154
本文介绍了安卓:有谁知道如何捕捉视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个视频录像机和到目前为止还没有想出如何才能顺利通过MediaRecorder。prepare()方法来设置参数。

I would like to create a video recorder and so far haven't figured out how to set parameters in order to successfully go through MediaRecorder.prepare() method.

执行以下步骤:

public void start() throws IOException{
	String state = android.os.Environment.getExternalStorageState();
	if(!state.equals(Environment.MEDIA_MOUNTED))
	{
		throw new IOException("SD card is not mounted. It is " + state + ".");
	}
	File directory = new File(path).getParentFile();
	if(!directory.exists() && !directory.mkdirs())
	{
		throw new IOException("Path to file could not be created.");
	}

	recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
	recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
	recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
	recorder.setVideoFrameRate(15);
	recorder.setVideoSize(176, 144);
	recorder.setOutputFile(path);
	recorder.prepare();
	recorder.start();
	this.state = VideoRecorderState.STATE_RECORDING;
}

它抛出线异常录音机。prepare()。

有谁知道如何为了能够捕捉到的视频?设置参数

Does anyone know how to set parameters in order to be able to capture video?

谢谢!

推荐答案

下面是一个片段,它的工作原理:

Here is a snippet that works:

m_recorder = new MediaRecorder();
m_recorder.setPreviewDisplay(m_BeMeSurface);
m_recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
m_recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
m_recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
m_recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
m_recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
m_recorder.setMaxDuration((int) MAX_TIME); 
m_recorder.setOnInfoListener(m_BeMeSelf);
m_recorder.setVideoSize(320, 240); 
m_recorder.setVideoFrameRate(15); 
m_recorder.setOutputFile(m_path);

m_recorder.prepare();
m_recorder.start();

最重要的是表面。你不用它,所以没有它失败。

THE most important thing is the surface. You don't have it, so without it it fails.

问候

BeMeCollective

BeMeCollective

这篇关于安卓:有谁知道如何捕捉视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆