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

video recording support in logging #225

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

dhruv2295
Copy link
Contributor

No description provided.

@thias15
Copy link
Collaborator

thias15 commented Sep 20, 2021

Please fix the style.

@thias15 thias15 linked an issue Sep 20, 2021 that may be closed by this pull request
Copy link
Collaborator

@thias15 thias15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works. But on recording start there is shortly a black screen. Do you know why? Can this be fixed?

@hardikgarg02
Copy link
Contributor

hardikgarg02 commented Dec 28, 2023

Hi! I've fixed the issue related to the front-facing camera not opening in the fragment, which was causing video capturing to fail. Additionally, after shifting to a different fragment, the camera displays a blank screen.

Navigate to the CameraFragment.java file and replace the bindCameraUseCases function with the following code:

     protected void bindCameraUseCases() {
        converter = new YuvToRgbConverter(requireContext());
        bitmapBuffer = null;
        preview = new Preview.Builder().setTargetAspectRatio(AspectRatio.RATIO_16_9).build();
        final boolean rotated = ImageUtils.getScreenOrientation(requireActivity()) % 180 == 90;
        final PreviewView.ScaleType scaleType =
                rotated ? PreviewView.ScaleType.FIT_CENTER : PreviewView.ScaleType.FIT_START;
        previewView.setScaleType(scaleType);
        preview.setSurfaceProvider(previewView.getSurfaceProvider());
        CameraSelector cameraSelector =
                new CameraSelector.Builder().requireLensFacing(lensFacing).build();
        ImageAnalysis imageAnalysis;
        if (analyserResolution == null)
            imageAnalysis =
                    new ImageAnalysis.Builder().setTargetAspectRatio(AspectRatio.RATIO_16_9).build();
        else
            imageAnalysis = new ImageAnalysis.Builder().setTargetResolution(analyserResolution).build();

        imageAnalysis.setAnalyzer(
                cameraExecutor,
                image -> {
                    if (bitmapBuffer == null)
                        bitmapBuffer =
                                Bitmap.createBitmap(image.getWidth(), image.getHeight(), Bitmap.Config.ARGB_8888);

                    rotationDegrees = image.getImageInfo().getRotationDegrees();
                    converter.yuvToRgb(image.getImage(), bitmapBuffer);
                    image.close();

                    processFrame(bitmapBuffer, image);
                });
        try {
            if (cameraProvider != null) {
                cameraProvider.unbindAll();
                cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageAnalysis);
            }
        } catch (Exception e) {
            Timber.e("Use case binding failed: %s", e.toString());
        }
        try {
            if (cameraProvider != null) {
                cameraProvider.unbindAll();
                cameraProvider.bindToLifecycle(this, cameraSelector, preview, videoCapture);
            }
        } catch (Exception e) {
            Timber.e("VideoCapture binding failed: %s", e.toString());
        }
    }

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

Successfully merging this pull request may close these issues.

Logger Fragment - Video
3 participants