Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recording time not working properly #4

Closed
jeremyjamez opened this issue Jun 1, 2018 · 6 comments
Closed

Recording time not working properly #4

jeremyjamez opened this issue Jun 1, 2018 · 6 comments

Comments

@jeremyjamez
Copy link

jeremyjamez commented Jun 1, 2018

Thank you for this awesome library!

I'm having an issue where I'm trying to record a 15 second video however, it seems as if the recording time of the button and cameraview are not in sync.

If I set the button duration to 15000, it only records 4 seconds of video but if I set it to 38000, it records 15 seconds. There is an issue with that also, if I set the duration to 38000, and let go of the button the onCancel method should be called and stop the video at whatever interval it was at (for arguments sake lets say 5 seconds), but this is not the case, it instead stops at less than a second.

On the other hand, if I set the cameraview record duration to 15000, the same thing happens, it records 4 seconds of video and if I let go of the button early it only records less than a second.

cameraButton.setVideoDuration(38000);

        cameraButton.setOnVideoEventListener(new CameraButton.OnVideoEventListener() {
            @Override
            public void onStart() {
                cameraView.setSessionType(SessionType.VIDEO);

                if (mCapturingPicture || mCapturingVideo)
                    mCapturingVideo = true;
                flashSwitchView.setVisibility(View.GONE);
                gallery.setVisibility(View.GONE);

                File path = new File(Environment.getExternalStorageDirectory() + "/Pictematic/Media/Pictematic Video");

                File file = new File(path, "VID-" + System.currentTimeMillis() + ".mp4");
                cameraView.startCapturingVideo(file);
            }

            @Override
            public void onFinish() {
                flashSwitchView.setVisibility(View.VISIBLE);
                gallery.setVisibility(View.VISIBLE);
                cameraView.stopCapturingVideo(); //works fine and saves the entire 15 seconds video if I let the button progress complete
            }

            @Override
            public void onCancel() {
                flashSwitchView.setVisibility(View.VISIBLE);
                gallery.setVisibility(View.VISIBLE);
                cameraView.stopCapturingVideo(); //Should save the video at whatever interval the button was released
            }
        });

XML snippet

<com.otaliastudios.cameraview.CameraView
        android:id="@+id/cameraView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:cameraGrid="off"
        app:cameraCropOutput="false"
        app:cameraFacing="back"
        app:cameraFlash="off"
        app:cameraGestureTap="focusWithMarker"
        app:cameraGestureLongTap="none"
        app:cameraGesturePinch="zoom"
        app:cameraGestureScrollHorizontal="exposureCorrection"
        app:cameraGestureScrollVertical="none"
        app:cameraJpegQuality="100"
        app:cameraVideoQuality="highest"/>
<com.hluhovskyi.camerabutton.CameraButton
            android:id="@+id/camera_button"
            android:layout_centerInParent="true"
            android:layout_alignParentBottom="true"
            android:layout_width="@dimen/cb_layout_width_default"
            android:layout_height="@dimen/cb_layout_height_default" />
@hluhovskyi
Copy link
Owner

Hey, thanks for opening the issue!
Can you also attach a xml snippet to make a full picture?

@jeremyjamez
Copy link
Author

@hluhovskyi I've updated the question with the xml snippet

@hluhovskyi
Copy link
Owner

And one more question. Is problem about length of captured video or about animation duration of button? I mean, if you set duration 38000 is it animating all 38 secs or only 15 ones?

@jeremyjamez
Copy link
Author

The length of the captured video is the issue. When I set duration 38000 it animates the 38 secs but the captured video is 15 secs, which is what I want. However the issue with setting it to 38000 is that if I assume the video is at least 3 secs in, when I release the button the captured video is actually less than a second

@jeremyjamez
Copy link
Author

jeremyjamez commented Jun 3, 2018

@hluhovskyi When I say it animates the 38 secs, I mean the time it takes to finish animating is 38 secs, therefore it progresses more slowly than 15 secs. But still ends up capturing 15 secs of video

@hluhovskyi
Copy link
Owner

I've double checked listener events and I can say that problem is definitely inside the library which you are using for recording video. Here is my logs when I set video duration to 10 seconds:

06-04 11:25:32.884 32758-32758/com.hluhovskyi.camerabutton V/MainActivity: startRecordVideo = 11:25:32
06-04 11:25:42.914 32758-32758/com.hluhovskyi.camerabutton V/CameraButton: progressAnimator, onAnimationEnd
collapsingAnimator, onAnimationStart
dispatchStateChange EXPANDED -> START_COLLAPSING
06-04 11:25:42.916 32758-32758/com.hluhovskyi.camerabutton V/MainActivity: finishRecordVideo = 11:25:42
06-04 11:25:43.138 32758-32758/com.hluhovskyi.camerabutton V/CameraButton: collapsingAnimator, onAnimationEnd
dispatchStateChange START_COLLAPSING -> DEFAULT

As you can see difference in seconds is exactly 10 seconds. I bet, that some method like cameraView.setSessionType(SessionType.VIDEO); or cameraView.startCapturingVideo(file); requires some asynchronous preparation which takes a lot of time.

Please, reach out developers of video recording library or check out docs, cause problem isn't on side of CameraButton.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants