app/src/main/java/cn/lytcom/camera2kit/Camera2Fragment.java
/**
     * We choose a largest video size with mAspectRatio. Also, we don't use sizes
     * larger than 1080p, since MediaRecorder cannot handle such a high-resolution video.
     *
     * @param choices The list of available sizes
     * @return The video size
     */
We choose a largest video size with mAspectRatio. Also, we don't use sizes
larger than 1080p, since MediaRecorder cannot handle such a high-resolution video.

@param choices The list of available sizes
@return The video size
We choose a largest video size with mAspectRatio . Also we don ' t use sizes larger than 1080p since MediaRecorder cannot handle such a high - resolution video . @param choices The list of available sizes @return The video size
Size chooseVideoSize(Size[] choices) {
        List<Size> videoSizes = Arrays.asList(choices);
        List<Size> supportedVideoSizes = new ArrayList<>();
        Collections.sort(videoSizes, new CompareSizesByArea());
        for (int i = videoSizes.size() - 1; i >= 0; i--) {
            if (videoSizes.get(i).getWidth() <= MAX_PREVIEW_WIDTH &&
                videoSizes.get(i).getHeight() <= MAX_PREVIEW_HEIGHT) {
                supportedVideoSizes.add(videoSizes.get(i));
                if (videoSizes.get(i).getWidth() == videoSizes.get(i).getHeight() *
                    mAspectRatio.getX() / mAspectRatio.getY()) {
                    return videoSizes.get(i);
                }
            }
        }
        return supportedVideoSizes.size() > 0 ? supportedVideoSizes.get(0) : choices[choices.length - 1];
    }
Size chooseVideoSize ( Size [ ] choices ) { List < Size > videoSizes = Arrays . asList ( choices ) ; List < Size > supportedVideoSizes = new ArrayList < > ( ) ; Collections . sort ( videoSizes , new CompareSizesByArea ( ) ) ; for ( int i = videoSizes . size ( ) - 1 ; i >= 0 ; i -- ) { if ( videoSizes . get ( i ) . getWidth ( ) <= MAX_PREVIEW_WIDTH && videoSizes . get ( i ) . getHeight ( ) <= MAX_PREVIEW_HEIGHT ) { supportedVideoSizes . add ( videoSizes . get ( i ) ) ; if ( videoSizes . get ( i ) . getWidth ( ) == videoSizes . get ( i ) . getHeight ( ) * mAspectRatio . getX ( ) / mAspectRatio . getY ( ) ) { return videoSizes . get ( i ) ; } } } return supportedVideoSizes . size ( ) > 0 ? supportedVideoSizes . get ( 0 ) : choices [ choices . length - 1 ] ; }
We choose a largest video size with mAspectRatio.
We choose a largest video size with mAspectRatio .