Git Product home page Git Product logo

Comments (2)

mohanrajsambath avatar mohanrajsambath commented on August 17, 2024

I've also faced this issue, I resolved this by maximum resolution of media recorder is 1080x720p, please maintain this ratio for recording, here is the method I customized for my requirement, hope it will help you.

/To maintain the aspect ratio 16:9 for record video/
/*
* In this sample, we choose a video size with 3x4 aspect ratio. Also, we don't use sizes
* larger than 1080p, since MediaRecorder cannot handle such a high-resolution video.
*
*
* In this method used for recording video in Landsacpe(WxH)=1080x720,Portrait(WxH)=720x1080.
*
* @param choices The list of available sizes
* @return The video size
*/

private  Size chooseVideoSize(Size[] choices) {
        for (Size size : choices) {
            int orientation = getActivityContext.getResources().getConfiguration().orientation;
            if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                //if((size.getWidth()/16) == (size.getHeight()/9) && size.getWidth() <=720) {
                if((size.getWidth()/16) == (size.getHeight()/9) && size.getWidth() <=3840 ) {
                    Log.e(TAG1, "chooseVideoSize:"+size);
                    return size;
                }
            } else {
                if((size.getWidth()/16) == (size.getHeight()/9) && (size.getWidth() <=3840) ) {
                    //if((size.getWidth()/16) == (size.getHeight()/9) && size.getWidth() <=4480 ) {
                    Log.e(TAG1, "chooseVideoSize:"+size);
                    return size;
                }else if((size.getHeight()/18) == (size.getWidth()/9) && ((size.getWidth() <=3840)||(size.getHeight()<=2160))) {
                    //if((size.getWidth()/16) == (size.getHeight()/9) && size.getWidth() <=4480 ) {
                    Log.e(TAG1, "chooseVideoSize:"+size);
                    return size;
                }else if((size.getWidth()/19) == (size.getHeight()/9) && ((size.getWidth() <=3840)||(size.getHeight()<=2160))) {
                    Log.e(TAG1, "chooseOptimalSize:"+size+"-19:9");
                    return size;
                }else if((size.getWidth()/19.5) == (size.getHeight()/9) && ((size.getWidth() <=3840)||(size.getHeight()<=2160))) {
                    Log.e(TAG1, "chooseOptimalSize:"+size+"-19.5:9");
                    return size;
                }
            }
        }
       // Log.e(TAG1, "chooseVideoSize:Couldn't find any suitable video size");
        return choices[choices.length - 1];
    }

from android-camera2video.

codingjeremy avatar codingjeremy commented on August 17, 2024

This sample has been migrated to a new location (check README for more information).

As recommended by GitHub, we are closing all issues and pull requests now that this older repo will be archived.

If you still see this issue in the updated repo, please reopen the issue/PR there. Thank you!

from android-camera2video.

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.