Android Camera2 API Cropping Video

守給你的承諾、 提交于 2019-11-30 23:14:54

Assuming zoom_level=1, and SCALER_AVAILABLE_MAX_DIGITAL_ZOOM is 4, then you end up with

minW = m.width/40
minH = m.height/40
difW = m.width*39/40
difH = m.height*39/40
cropW = m.width*39/40/100 * 1
cropH = m.height*39/40/100 * 1
(floor cropW/cropH down to nearest multiple of 4)

if m.width = 3000, m.width=2000, then cropW = 28, cropH = 16.

so mZoom for recording is

Rect(28, 16, 2972, 2972).

Which isn't centered, and many devices only support center-zoom. But it is a square region at least.

The real issue is that you can't change the aspect ratio of an output by cropping - the aspect ratio is fixed by the resolution of the output Surface when you create a capture session. See these diagrams for how the cropping works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!