Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a352d1e2 authored by James Dong's avatar James Dong Committed by Android (Google) Code Review
Browse files

Merge "Allow to record time lapse videos without using setProfile()"

parents 0b2cfd8c a4d205d0
Loading
Loading
Loading
Loading
+11 −3
Original line number Original line Diff line number Diff line
@@ -303,6 +303,8 @@ public class MediaRecorder
    /**
    /**
     * Uses the settings from a CamcorderProfile object for recording. This method should
     * Uses the settings from a CamcorderProfile object for recording. This method should
     * be called after the video AND audio sources are set, and before setOutputFile().
     * be called after the video AND audio sources are set, and before setOutputFile().
     * If a time lapse CamcorderProfile is used, audio related source or recording
     * parameters are ignored.
     *
     *
     * @param profile the CamcorderProfile to use
     * @param profile the CamcorderProfile to use
     * @see android.media.CamcorderProfile
     * @see android.media.CamcorderProfile
@@ -315,8 +317,8 @@ public class MediaRecorder
        setVideoEncoder(profile.videoCodec);
        setVideoEncoder(profile.videoCodec);
        if (profile.quality >= CamcorderProfile.QUALITY_TIME_LAPSE_LOW &&
        if (profile.quality >= CamcorderProfile.QUALITY_TIME_LAPSE_LOW &&
             profile.quality <= CamcorderProfile.QUALITY_TIME_LAPSE_QVGA) {
             profile.quality <= CamcorderProfile.QUALITY_TIME_LAPSE_QVGA) {
            // Enable time lapse. Also don't set audio for time lapse.
            // Nothing needs to be done. Call to setCaptureRate() enables
            setParameter(String.format("time-lapse-enable=1"));
            // time lapse video recording.
        } else {
        } else {
            setAudioEncodingBitRate(profile.audioBitRate);
            setAudioEncodingBitRate(profile.audioBitRate);
            setAudioChannels(profile.audioChannels);
            setAudioChannels(profile.audioChannels);
@@ -327,7 +329,10 @@ public class MediaRecorder


    /**
    /**
     * Set video frame capture rate. This can be used to set a different video frame capture
     * Set video frame capture rate. This can be used to set a different video frame capture
     * rate than the recorded video's playback rate. Currently this works only for time lapse mode.
     * rate than the recorded video's playback rate. This method also sets the recording mode
     * to time lapse. In time lapse video recording, only video is recorded. Audio related
     * parameters are ignored when a time lapse recording session starts, if an application
     * sets them.
     *
     *
     * @param fps Rate at which frames should be captured in frames per second.
     * @param fps Rate at which frames should be captured in frames per second.
     * The fps can go as low as desired. However the fastest fps will be limited by the hardware.
     * The fps can go as low as desired. However the fastest fps will be limited by the hardware.
@@ -339,6 +344,9 @@ public class MediaRecorder
     * possible.
     * possible.
     */
     */
    public void setCaptureRate(double fps) {
    public void setCaptureRate(double fps) {
        // Make sure that time lapse is enabled when this method is called.
        setParameter(String.format("time-lapse-enable=1"));

        double timeBetweenFrameCapture = 1 / fps;
        double timeBetweenFrameCapture = 1 / fps;
        int timeBetweenFrameCaptureMs = (int) (1000 * timeBetweenFrameCapture);
        int timeBetweenFrameCaptureMs = (int) (1000 * timeBetweenFrameCapture);
        setParameter(String.format("time-between-time-lapse-frame-capture=%d",
        setParameter(String.format("time-between-time-lapse-frame-capture=%d",
+6 −0
Original line number Original line Diff line number Diff line
@@ -1291,6 +1291,12 @@ status_t StagefrightRecorder::setupCameraSource(
    videoSize.width = mVideoWidth;
    videoSize.width = mVideoWidth;
    videoSize.height = mVideoHeight;
    videoSize.height = mVideoHeight;
    if (mCaptureTimeLapse) {
    if (mCaptureTimeLapse) {
        if (mTimeBetweenTimeLapseFrameCaptureUs < 0) {
            ALOGE("Invalid mTimeBetweenTimeLapseFrameCaptureUs value: %lld",
                mTimeBetweenTimeLapseFrameCaptureUs);
            return BAD_VALUE;
        }

        mCameraSourceTimeLapse = CameraSourceTimeLapse::CreateFromCamera(
        mCameraSourceTimeLapse = CameraSourceTimeLapse::CreateFromCamera(
                mCamera, mCameraProxy, mCameraId,
                mCamera, mCameraProxy, mCameraId,
                videoSize, mFrameRate, mPreviewSurface,
                videoSize, mFrameRate, mPreviewSurface,