Code Monkey home page Code Monkey logo

Comments (6)

robertlevonyan avatar robertlevonyan commented on May 17, 2024

You can use whatever aspect ratio you want with your camera configuration

val aspectRatio = aspectRatio(metrics.widthPixels, metrics.heightPixels)

this is how it is implemented for now, you can change it to smth like this

val aspectRatio = aspectRatio(1920, 908)

I believe this should work

from camerax-demo.

mikhail-kiselev-dev avatar mikhail-kiselev-dev commented on May 17, 2024

As aspectRatio() returns only 16/9 and 4/3 - preview still stretching and video res still 1920x1080 (note that I want to place my preview on whole screen).
P.S: when I run android/camera-samples Camera2Video project (with list of resolutions on cameras) - I didn't found 1920x908. It is possible that my device just cutting video on hardware level or something?

from camerax-demo.

robertlevonyan avatar robertlevonyan commented on May 17, 2024

I think it depends on lib version you are using. In the version used in sample you can set ratio as I wrote in previous comment.

from camerax-demo.

mikhail-kiselev-dev avatar mikhail-kiselev-dev commented on May 17, 2024

If we talk about VideoFragment, aspectRatio() fun is:

private fun aspectRatio(width: Int, height: Int): Int {
        val previewRatio = max(width, height).toDouble() / min(width, height)
        if (abs(previewRatio - RATIO_4_3_VALUE) <= abs(previewRatio - RATIO_16_9_VALUE)) {
            return AspectRatio.RATIO_4_3
        }
        return AspectRatio.RATIO_16_9
    }

So it returns only 16_9 and 4_3. Both ratios impossible to fit in 19:9 without stretching or cutting.
Or I don't understand something?(
Also I tried .setTargetResolution() istead of .setTargetAspectRatio() - same result.

from camerax-demo.

robertlevonyan avatar robertlevonyan commented on May 17, 2024

No you are correct. This are the ratios supported by CameraX. You can try to set resolution, but I think it will not change the ratio.

from camerax-demo.

robertlevonyan avatar robertlevonyan commented on May 17, 2024

I'm closing the issue since the issue you mentioned is in fact an API restriction by CameraX

from camerax-demo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.