0

how to record rightly 720p video in android? And how to set correctly the frame rate of video for it.

mParameters = mCameraDevice.getParameters();
        mParameters.setPreviewSize(1280,
                720);
mParameters.setPreviewFrameRate(30);

    mMediaRecorder = new MediaRecorder();

        // Unlock the camera object before passing it to media recorder.
        mCameraDevice.unlock();
        mMediaRecorder.setCamera(mCameraDevice);
        mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        //mMediaRecorder.setProfile(mProfile);
        mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);




        mMediaRecorder.setMaxDuration(mMaxVideoDurationInMs);


        // Set output file.
        if (mStorageStatus != STORAGE_STATUS_OK) {
            mMediaRecorder.setOutputFile("/dev/null");
        } else {
            // Try Uri in the intent first. If it doesn't exist, use our own
            // instead.
            createVideoPath();
            mMediaRecorder.setOutputFile(mVideoFilename);

        }
        mMediaRecorder.setVideoSize(1280, 720);
        mMediaRecorder.setVideoFrameRate(30);

        mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());

I test this code in HTC HD device. It can record successfully. But when play the recorded video, the screen is just green with sound. Who can give some explain the relation between video size and video frame rate and the difference of all kinds of video(audio) source and encoder.

Judy
  • 1,806
  • 5
  • 27
  • 48

2 Answers2

0

You can record at 720p with a properly specced camera, but most devices will not be able to display 720p video without scaling it down to standard def. the 720 in 720p refers to its pixel measure of the smaller axis (height) and in general most devices' screen resolutions are NOT 1280x720px. Feel free to post code about how you decode and playback the video.

Eric
  • 1,913
  • 4
  • 23
  • 33
  • There is the playback code: `mVideoView = (VideoView) findViewById(R.id.surface_view); mVideoView.setOnErrorListener(this); mVideoView.setOnCompletionListener(this); mVideoView.setOnPreparedListener(this); mVideoView.requestFocus();` And I find my recorded video can be played by the "com.htc.album" application but can't be player by the "com.coolirs.media" application. – Judy Jun 29 '11 at 05:41
  • It changed a bit since then. Most devices handle 720p and 1080p, and some even handle 4K. I let 8K and up for a comment from the future – Louis CAD Oct 15 '17 at 15:32
0

For decoding you can use the ffmpeg. More information can found here:

When you use ffmpeg, you can use the CamcorderProfile for the record.

Community
  • 1
  • 1
CSchulz
  • 10,102
  • 9
  • 54
  • 107