This question is targeted to high-speed video sessions, and not normal video sessions.
Currently in Android Camera2 API, to resolve the optimal preview size I use a target video output size as reference, and compute from it the best preview size by using the list of size choices returned by:
// SurfaceTexture.class to get the preview sizes supported by the surface
StreamConfigurationMap.getOutputSizes(SurfaceTexture.class);
The video output size is selected from the list returned by: StreamConfigurationMap.getHighSpeedVideoSizes();
The preview size computation is done by selecting the size from the SurfaceTexture.class list, with the same aspect ratio as the video output size, and within the 1920x0180 size constrain, which is the max preview size to be guaranteed by the camera2 API.
Said all that, when using createHighSpeedRequestList, this method will fail if it finds that any of the surfaces passed to the session doesn't have a size from the supported high-speed sizes, and this applies also to the preview surface. See the source in: android.hardware.camera2.utils.SurfaceUtils.checkConstrainedHighSpeedSurfaces
The question is, what is the optimal way to get a valid preview size for high-speed video sessions? I can’t rely in the list of choices returned by SurfaceTexture.class since these are unrelated to a high-speed session.
My best guess is that I should iterate through all of them and just find one that is within the list of high-speed sizes returned by StreamConfigurationMap.getHighSpeedVideoSizes, but I want to know if there is a more solid reliable way, or a good example which I could look at.
ifwhen the high speed video at 4K will be introduced. First of all, the limitation that the preview surface for high speed capture *must be same size* as the recorder surface, this limitation is artificial and can be lifted for all or for custom platform. Second, the same device could provide a 4K screen, or more. Finally, they may say that capture at 120 FPS is not 'high speed' anymore, and will follow the rules for regular recording. – Alex Cohn Apr 22 '19 at 13:56