I use CameraView from CameraX library, for recording video. But I can't find any settings of video recording process. Earlier I use old library version 1.0.0-alpha08 and default resolution(1920 х 1080) suited me, but that version had some issues. For now I'm using 1.0.0-beta02, I get very strange resolution (1600 x 1200 - Pixel 3a 1400x1200 - Huawei p20 lite).
Android CameraX CameraView how to set video resolution?
3k Views Asked by DemCh At
        	3
        	
        There are 3 best solutions below
0
                 On
                        
                            
                        
                        
                            On
                            
                                                    
                    
                You can configure recorder's quality using QualitySelector
val preferredQuality = Quality.HD
val recorder = Recorder.Builder()
    .setQualitySelector(
        QualitySelector.from(
            preferredQuality,
            FallbackStrategy.higherQualityOrLowerThan(preferredQuality)
        )
    )
    .build()
val videoCapture = VideoCapture.withOutput(recorder)
2
                 On
                        
                            
                        
                        
                            On
                            
                                                    
                    
                In version 1.0.0-beta06 you can use setTargetResolution(resolution: Size) or setMaxResolution(resolution: Size) in VideoCaptureConfig.Builder() used for video UseCase.
videoCapture = VideoCaptureConfig.Builder()
    .setTargetResolution(VIDEO_SIZE)
    .setMaxResolution(VIDEO_SIZE)
    .build()
replace width and height with your dimens. 3,4 in 'Rational(3,4)' with your ratio (you can also remove it)