Skip to content

fix(host): 分条缩放的裁剪框越界导致软件编码每帧失败 - #144

Open
qwerty-a11y wants to merge 2 commits into
sqlpxc:mainfrom
qwerty-a11y:main
Open

qwerty-a11y wants to merge 2 commits into
sqlpxc:mainfrom
qwerty-a11y:main

Conversation

@qwerty-a11y

Copy link
Copy Markdown

该问题会导致在特定非标准分辨率下,被控端无法编码视频画面,出现黑屏

控制端连上后画面全黑、帧率一直是 0,被控端日志里反复出现:

    encoding failed, recreating the encoder: scaling failed:
    Source cropping option is invalid:
    Size of the crop box is out of the image boundaries

原因:分条缩放按 y0 * scale 算每条的裁剪框,最后一条的底部坐标在浮点下可能比源高度
大一点点(1080 * (1372/1080) = 1372.0000000000002)。fast_image_resize 对越界的裁剪框
直接报错,于是每一帧都编码失败、编码器被反复重建,一帧也发不出去。虚拟机里的
2037×1372 这种奇数尺寸最容易碰上;普通显示器 1920×1080 缩放到 1080 高度时恰好整除,
所以平时看不出来。

修法:把裁剪框底部钳制到源图高度以内。只在真的越界时收紧那一条的高度,其余各条不变,
分条与整幅缩放仍然逐像素相同(striped_resize_matches_whole 不变)。

加了 striped_resize_odd_source_stays_inside 覆盖奇数源尺寸 × 不整除的缩放比 × 不同分条数。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant