Fraps视频录制教程_图文_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
Fraps视频录制教程
上传于||暂无简介
阅读已结束,如果下载本文需要使用1下载券
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,查找使用更方便
还剩25页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢8025人阅读
Android(34)
我做毕业设计时候需要实现先拍摄后上传的功能,还要支持多分辨率,虽然MediaRecorder的教程很丰富,但是实现起来却一波三折,这里记录下来的代码也只是在我自己的2.3的Android上跑起来没有问题。在有些Moto的机子上会失败,具体原因还未分析出来。
直接上代码:根据MediaRecorder的状态
package net.john.
import java.io.F
import java.io.IOE
import java.util.ArrayL
import java.util.L
import android.app.A
import android.content.pm.ActivityI
import android.hardware.C
import android.hardware.Camera.S
import android.media.MediaR
import android.os.B
import android.os.E
import android.os.H
import android.util.L
import android.view.SurfaceH
import android.view.SurfaceV
import android.view.V
import android.view.W
import android.widget.AdapterV
import android.widget.ArrayA
import android.widget.B
import android.widget.S
import android.widget.TextV
import android.widget.T
import android.widget.AdapterView.OnItemSelectedL
public class MediaRecorderDemoActivity extends Activity implements SurfaceHolder.Callback {
private Button button_
private Button button_
private Button button_
private SurfaceView surfaceV
private SurfaceHolder surfaceH
private File storageD
private File tempF
private MediaRecorder mediaR
private TextView textView_
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // no title
//screen orientation landscape
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setContentView(R.layout.main);
button_start = (Button)this.findViewById(R.id.button_start);
button_stop = (Button)this.findViewById(R.id.button_stop);
button_back = (Button)this.findViewById(R.id.button_back);
surfaceView = (SurfaceView)this.findViewById(R.id.surfaceView);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(MediaRecorderDemoActivity.this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
spinner = (Spinner)this.findViewById(R.id.spinner_size);
width = 480;
height = 320;
handler = new Handler();
textView_time = (TextView)this.findViewById(R.id.textView_time);
button_start.setOnClickListener(btnStartListener);
button_stop.setOnClickListener(btnStopListener);
button_back.setOnClickListener(btnBackListener);
spinner.setOnItemSelectedListener(spinnerListener);
boolean sdCardExist = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
if (sdCardExist) {
storageDir = new File(Environment.getExternalStorageDirectory().toString() + File.separator + &Demo& + File.separator);
if (!storageDir.exists()) {
storageDir.mkdir();
button_stop.setVisibility(View.GONE);
button_start.setVisibility(View.GONE);
Toast.makeText(MediaRecorderDemoActivity.this, &SDcard is not exist&, Toast.LENGTH_LONG).show();
private View.OnClickListener btnStartListener = new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
button_start.setVisibility(View.GONE);
button_stop.setVisibility(View.VISIBLE);
spinner.setVisibility(View.GONE);
handler.postDelayed(refreshTime, 1000);
tempFile = File.createTempFile(&Demo&, &.3gp&, storageDir);
mediaRecorder = new MediaRecorder();
mediaRecorder.setCamera(camera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mediaRecorder.setVideoSize(width, height);
mediaRecorder.setVideoFrameRate(16);
mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
mediaRecorder.setOutputFile(tempFile.getAbsolutePath());
mediaRecorder.prepare();
mediaRecorder.start();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
private View.OnClickListener btnStopListener = new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
button_start.setVisibility(View.VISIBLE);
button_stop.setVisibility(View.GONE);
spinner.setVisibility(View.VISIBLE);
handler.removeCallbacks(refreshTime);
if (mediaRecorder != null) {
mediaRecorder.stop();
mediaRecorder.release();
Log.e(&Demo&, tempFile.getAbsolutePath());
} catch(RuntimeException e) {
Log.e(&Demo&, e.getMessage());
private View.OnClickListener btnBackListener = new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
private OnItemSelectedListener spinnerListener = new Spinner.OnItemSelectedListener() {
public void onItemSelected(AdapterView&?& arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Spinner spinner = (Spinner)arg0;
String wh[] = spinner.getSelectedItem().toString().split(&\\*&);
width = Integer.parseInt(wh[0]);
height = Integer.parseInt(wh[1]);
camera.lock();
camera.stopPreview();
Camera.Parameters para = camera.getParameters();
para.setPreviewSize(width, height);
camera.setParameters(para);
camera.setPreviewDisplay(surfaceHolder);
camera.startPreview();
Log.d(&Demo&, camera.getParameters().getPreviewSize().width + &*&
+ camera.getParameters().getPreviewSize().height);
camera.unlock();
} catch (IOException e) {
// TODO Auto-generated catch block
Log.e(&Demo&, e.getMessage());
public void onNothingSelected(AdapterView&?& arg0) {
// TODO Auto-generated method stub
private Runnable refreshTime = new Runnable() {
public void run() {
// TODO Auto-generated method stub
handler.postDelayed(refreshTime, 1000);
if (sec &= 60) {
sec = sec % 60;
if (min &= 60) {
min = min % 60;
textView_time.setText(timeFormat(hou) + &:& + timeFormat(min) + &:& + timeFormat(sec));
private String timeFormat(int t) {
if (t / 10 == 0) {
return &0& +
return t + &&;
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// TODO Auto-generated method stub
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
camera = Camera.open();
List&Size& supportedSize = camera.getParameters().getSupportedPreviewSizes();
if (supportedSize != null) {
List&String& list = new ArrayList&String&();
for (Size s: supportedSize) {
list.add(s.width + &*& + s.height);
list.remove(0); // 在使用G7的摄像头支持的最大分辨率进行拍摄的时候会出现stop failed错误,无法关闭MediaRecorder,原因不明!
ArrayAdapter&String& adapter = new ArrayAdapter&String&(MediaRecorderDemoActivity.this,
android.R.layout.simple_spinner_dropdown_item, list);
spinner.setAdapter(adapter);
public void surfaceDestroyed(SurfaceHolder holder) {
// TODO Auto-generated method stub
camera.release();
三个权限:
&uses-permission android:name=&android.permission.RECORD_AUDIO&/&
&uses-permission android:name=&android.permission.CAMERA&/&
&uses-permission android:name=&android.permission.WRITE_EXTERNAL_STORAGE&/&
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:533452次
积分:4551
积分:4551
排名:第4688名
原创:53篇
转载:11篇
评论:194条
(1)(1)(1)(9)(3)(7)(3)(1)(1)(9)(4)(6)(2)(1)(4)(1)(2)(9)如何用Fraps录像工具录制出高清的视频_百度知道游戏视频制作的问题,懂的人进~本人视频录制软件:fraps编辑: - 爱问知识人
(window.slotbydup=window.slotbydup || []).push({
id: '2491531',
container: s,
size: '150,90',
display: 'inlay-fix'
游戏视频制作的问题,懂的人进~
编辑:adobe 1.5
游戏分辨率800*600
窗口并最大化 ,电脑分辨率
录制出来的素材为什么是的~而且编辑好之后画面还不是很清楚?
是和你使用窗口模式有关,全屏就能解决问题。
视频的清晰程度取决于你的原始视频的清晰和你处理后的压缩比例高低。视频不能压缩的太很否则会很不清楚.要是用REAL格式压缩,一般都要把象素调低,看的过程中最好别全屏,否则还是不清楚。MPEG、***I、DVD的很清晰但占空间较大
时的分辨率仍然是和你桌面分辨率一样,解决这个问题很简单,全屏模式运行就可以了。
您的举报已经提交成功,我们将尽快处理,谢谢!
***,功能齐全,操作简单方便。
大家还关注用fraps录制游戏视频,怎样让录制出来的分辨率高点呢?我看有人说是按游戏的分辨率的_百度知道