使用MediaRecorder录制时,水平“条”而不是视频

主题A:水平酒吧

视频上的水平酒吧

这是一个奇怪的。 视频记录和声音很好,但那些酒吧代表我的手。 这就好像我正在寻找一个带肋的pyrex碗:

主题B:

带肋Pyrex碗

我正在使用前置摄像头(API 16)在Samsung Galaxy Note 10.1上测试此功能。 一些说明:

  • 当我使用背面照相机录制时,它录制得很好。
  • 当我在标准相机应用程序中使用前置摄像头进行录制时,它可以正常工作。
  • 当我在三星Galaxy S4(API 21)上运行相同的代码时,后置和前置摄像头都可以正常工作。
  • 我使用CamcorderProfile来选择适当的MediaRecorder设置。 这是我的代码:

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private boolean prepareVideoRecorder() {
        // Get screen width and height for supported video sizes
        Display display = getWindowManager().getDefaultDisplay();
        int width, height;
    
        if (Build.VERSION.SDK_INT < 13) {
            width = display.getWidth();
            height = display.getHeight();
        } else {
            Point size = new Point();
            display.getSize(size);
            width = size.x;
            height = size.y;
        }
    
        // Check and set the highest quality available recording profile of the camera.
        int frontCamera = Camera.CameraInfo.CAMERA_FACING_FRONT;
        CamcorderProfile profile = null;
    
        if (CamcorderProfile.hasProfile(frontCamera, CamcorderProfile.QUALITY_1080P))
            profile = CamcorderProfile.get(frontCamera, CamcorderProfile.QUALITY_1080P);
        else if (CamcorderProfile.hasProfile(frontCamera, CamcorderProfile.QUALITY_720P))
            profile = CamcorderProfile.get(frontCamera, CamcorderProfile.QUALITY_720P);
        else if (CamcorderProfile.hasProfile(frontCamera, CamcorderProfile.QUALITY_480P))
            profile = CamcorderProfile.get(frontCamera, CamcorderProfile.QUALITY_480P);
        else if (CamcorderProfile.hasProfile(frontCamera, CamcorderProfile.QUALITY_HIGH))
            profile = CamcorderProfile.get(frontCamera, CamcorderProfile.QUALITY_HIGH);
    
        mCamera = CameraHelper.getDefaultFrontFacingCameraInstance();
    
        // Need to make sure that our recording video size is supported by the camera.
        // Query camera to find all sizes and choose the optimal size given the dimensions of screen.
        Camera.Parameters parameters = mCamera.getParameters();
        List<Camera.Size> mSupportedVideoSizes = parameters.getSupportedVideoSizes();
        Camera.Size optimalSize = CameraHelper.getOptimalRecordingSize(mSupportedVideoSizes,
                width, height);
    
        // link camera to preview surface
        try {
            mCamera.setPreviewDisplay(mPreview.getHolder());
        } catch (IOException e) {
            Log.e(TAG, "Surface text is unavailable or unsuitable for preview" + e.getMessage());
            return false;
        }
    
        // Unlock the camera to allow the Media Recorder to own it
        mCamera.unlock();
    
        // Create and assign the Camera to the Media Recorder
        mMediaRecorder = new MediaRecorder();
        mMediaRecorder.setCamera(mCamera);
    
        // Set Sources
        mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
        mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
    
        if (profile != null) {
            profile.videoFrameWidth = optimalSize.width;
            profile.videoFrameHeight = optimalSize.height;
            mMediaRecorder.setProfile(profile);
        }
    
        // Specify the output file
        mMediaRecorder.setOutputFile(CameraHelper.getOutputMediaFile(
                CameraHelper.MEDIA_TYPE_VIDEO).toString());
    
        // Prepare configured MediaRecorder
        try {
            mMediaRecorder.prepare();
        } catch (IllegalStateException e) {
            Log.d(TAG, "IllegalStateException preparing MediaRecorder: " + e.getMessage());
            releaseMediaRecorder();
            return false;
        } catch (IOException e) {
            Log.d(TAG, "IOException preparing MediaRecorder: " + e.getMessage());
            releaseMediaRecorder();
            return false;
        }
        return true;
    }
    

    我尝试绕过CamcorderProfile并尝试使用每个MediaRecorder.VideoEncoder编码器。 文件格式是.mp4,我不相信这是问题,因为设备上的标准Camera应用程序输出.mp4。 有任何想法吗?

    链接地址: http://www.djcxy.com/p/31131.html

    上一篇: Horizontal "bars" instead of video when recording with MediaRecorder

    下一篇: Front facing Camera Recorded video not proper