RAZR当我录制视频

RAZR当我录制视频

本文介绍了摄像头问题,摩托​​罗拉DROID RAZR当我录制视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会试探我对各种手机应用程序。我的应用程序的主要功能是拍照,通过手机摄像头录制视频。我不是大部分的手机面临的一个问题,但我没有遇到这个问题上的。我的应用程序工作正常,当我拍照。但我面对我的时候录制视频的问题。当我录制一个视频,我得到了一个空白页面。没有preVIEW显示手机屏幕上。我不知道为什么它的发生,但对大多数的手机其工作的罚款。而拍照这款手机(该DROID RAZR)上工作的罚款。

I have tested my application on various mobile phones. My applications main functionality is taking pictures and recording video through the phones camera. I didn't face an issue on most of the mobile phones, but I did face this issue on Motorola DROID RAZR. My application works fine when i take a picture. But I'm facing an issue when I record a video. When I record a video, I get a blank screen. There is no preview showing on the mobile screen. I don't why its happening, but on most of the mobile phones its working fine. And taking picture working fine on this phone (the droid razr).

摩托罗拉Droid RAZR配置,

Motorola DROID RAZR configuration,

  1. 操作系统:Android的V2.3.5
  2. 相机:高清摄像头,800万像素
  3. 处理器:TI OMAP4430

下面是我的code,

Camera camera = Camera.open();
Parameters params = camera.getParameters();
camera.setDisplayOrientation(90);
camera.setParameters(params);
camera.setDisplayOrientation(90);

MediaRecorder recorder = new MediaRecorder();
recorder.setCamera(camera);
recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
recorder.setVideoSize(640, 480);
recorder.setMaxDuration(25000);
recorder.setOrientationHint(90);

更新:

我已经测试了摩托罗拉Droid RAZR模拟器这个应用程序。我得到了以下异常,

I have tested this application on Motorola Droid Razr emulator. I got the following exception,

MediaRecorder(430): prepare failed: -17
System.err(430): java.io.IOException: prepare failed.
System.err(430):    at android.media.MediaRecorder._prepare(Native Method)
System.err(430):    at android.media.MediaRecorder.prepare(MediaRecorder.java:590)

不过,我没有得到这个例外在我的其他模拟器。如何解决这个问题?

But I didn't get this exception on my other emulator. How to resolve this issue?

推荐答案

最后,我找到了解决办法。下面code行之有效的所有设备。 ;)

Finally I found the solution. Below code works well on all devices. ;)

        Holder holder = getHolder();
        holder.addCallback(this);
        holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        Camera camera = Camera.open();
        try {
            camera.setPreviewDisplay(holder);
            camera.startPreview();
        } catch (IOException e) {
            Log.e(TAG, e.getMessage());
            e.printStackTrace();
        }

        camera.unlock();
        MediaRecorder recorder = new MediaRecorder();
        recorder.setCamera(camera);
        recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        recorder.setVideoSize(640, 480);
        recorder.setVideoFrameRate(20);
        recorder.setVideoEncodingBitRate(3000000);
        recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
        recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);

        try {

            String videopath = File.createTempFile("video", ".mp4")
                    .getAbsolutePath();

            recorder.setOutputFile(videopath);

        } catch (IllegalStateException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        recorder.setPreviewDisplay(holder.getSurface());

这篇关于摄像头问题,摩托​​罗拉DROID RAZR当我录制视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 17:15