[Q]Sample Camera App with poor fps

Search This thread

chuaniyang

Member
Aug 20, 2010
38
9
Taipei
plus.google.com
Hey, guys

I just write a sample application for video recording.

All function works. but the record video file only 15 fps.

on the same environment, stock camera app can recording at 29 fps.

Am I missing something ?

Main code about recording is here :
Code:
    private void startRecord(){
        try{
            mRecorder=new MediaRecorder();
            mCamera.unlock();
            mRecorder.setCamera(mCamera);
            mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
            mRecorder.setOrientationHint(getRotation());
            mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
            mRecorder.setVideoSize(1920, 1080);
            mRecorder.setVideoEncodingBitRate(20000000);
            mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
            mRecorder.setVideoFrameRate(30);
            mRecorder.setPreviewDisplay(mHolder.getSurface());
            mCurrentVideoPath=getOutputMediaFile(MEDIA_TYPE_VIDEO).toString();
            mRecorder.setOutputFile(mCurrentVideoPath);
            mRecorder.prepare();
            mRecorder.start();
            recording=true;
            Toast.makeText(getBaseContext(), "Start Recording.", Toast.LENGTH_SHORT).show();
        }catch(Exception e){
            e.printStackTrace();
            mRecorder.release();
            mRecorder=null;
            mCamera.lock();
            recording=false;
            Toast.makeText(getBaseContext(), "Recording Fail.", Toast.LENGTH_SHORT).show();
        }
    }

Whole Project can be find at this link below :
https://github.com/alex-yang/MyCamera

thanks for helping.
 
Last edited:
  • Like
Reactions: LibertyMarine

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    Hey, guys

    I just write a sample application for video recording.

    All function works. but the record video file only 15 fps.

    on the same environment, stock camera app can recording at 29 fps.

    Am I missing something ?

    Main code about recording is here :
    Code:
        private void startRecord(){
            try{
                mRecorder=new MediaRecorder();
                mCamera.unlock();
                mRecorder.setCamera(mCamera);
                mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
                mRecorder.setOrientationHint(getRotation());
                mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
                mRecorder.setVideoSize(1920, 1080);
                mRecorder.setVideoEncodingBitRate(20000000);
                mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
                mRecorder.setVideoFrameRate(30);
                mRecorder.setPreviewDisplay(mHolder.getSurface());
                mCurrentVideoPath=getOutputMediaFile(MEDIA_TYPE_VIDEO).toString();
                mRecorder.setOutputFile(mCurrentVideoPath);
                mRecorder.prepare();
                mRecorder.start();
                recording=true;
                Toast.makeText(getBaseContext(), "Start Recording.", Toast.LENGTH_SHORT).show();
            }catch(Exception e){
                e.printStackTrace();
                mRecorder.release();
                mRecorder=null;
                mCamera.lock();
                recording=false;
                Toast.makeText(getBaseContext(), "Recording Fail.", Toast.LENGTH_SHORT).show();
            }
        }

    Whole Project can be find at this link below :
    https://github.com/alex-yang/MyCamera

    thanks for helping.