拍摄时视频正在拉伸

时间:2016-08-22 07:06:43

标签: android camera

这是拍摄视频前的正常图像      [1]:http://i.stack.imgur.com/prm5D.png

这是拉伸图像,当我点击录制视频按钮图像时,这样伸展。       [2]:http://i.stack.imgur.com/9Yx34.png

private boolean startRecording() {
            if(camera!=null)
            {
                camera.stopPreview();
                try {
                    camera.unlock();
                    prMediaRecorder = new MediaRecorder();
                    prMediaRecorder.setCamera(camera);
                    if(id==0)
                    {
                        prMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
                        prMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
                        prMediaRecorder.setOrientationHint(rotated_angle);
                        prMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));//code setting camera quality
                    }
                    if(id==1)//this is id of camera,i.e front or back
                    {
                        prMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
                        prMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
                        prMediaRecorder.setOrientationHint(rotated_angle);
                        prMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));
                    }

                    /*prMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
                    prMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
                    prMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);*/
                    prMediaRecorder.setMaxDuration(cMaxRecordDurationInMs);
                    prMediaRecorder.setMaxFileSize(cMaxFileSizeInBytes);
                    prRecordedFile = new File(cVideoFilePath + String.valueOf(System.currentTimeMillis()) + ".mp4");
                    prMediaRecorder.setOutputFile(prRecordedFile.getPath());
                    prMediaRecorder.setPreviewDisplay(prSurfaceHolder.getSurface());
                    prMediaRecorder.prepare();
                    prMediaRecorder.start();
                    prRecordInProcess = true;
                    return true;
                } catch (IllegalStateException e) {
                    Log.e("error", "f");
                    Log.e("error", e.getMessage());
                   // e.printStackTrace();
                    camera.lock();
                    return false;
                } catch (IOException e) {
                    Log.i("error", "g");
                    Log.e("error", e.getMessage());
                    camera.lock();
                    return false;
                } catch (RuntimeException e) {
                    Log.i("error", "h");
                    Log.e("error", e.getMessage());
                    camera.lock();
                    return false;
                }
            }
            else
            {

            }
            return false;
        }

0 个答案:

没有答案