fix(video): 修复硬件加速滤镜中的颜色空间转换问题

- 将硬件下载后的格式从 nv12 改为 yuv420p
- 确保与 RGBA/YUVA 格式的 overlay 混合时颜色空间转换正确
- 解决复杂滤镜(如 lut3d, overlay, crop 等)在硬件表面的颜色显示问题
This commit is contained in:
2026-01-21 16:12:53 +08:00
parent 0a7a0dac89
commit ed8dca543e

View File

@@ -114,6 +114,8 @@ def get_hwaccel_filter_prefix(hw_accel: str = HW_ACCEL_NONE) -> str:
注意:由于大多数复杂滤镜(如 lut3d, overlay, crop 等)不支持硬件表面,
我们需要在滤镜链开始时将硬件表面下载到系统内存。
使用 yuv420p 而非 nv12 格式,以确保颜色空间转换正确(特别是与 RGBA/YUVA 格式的 overlay 混合时)。
Args:
hw_accel: 硬件加速类型
@@ -121,9 +123,9 @@ def get_hwaccel_filter_prefix(hw_accel: str = HW_ACCEL_NONE) -> str:
需要添加到滤镜链开头的 hwdownload 滤镜字符串
"""
if hw_accel == HW_ACCEL_CUDA:
return 'hwdownload,format=nv12,'
return 'hwdownload,format=yuv420p,'
elif hw_accel == HW_ACCEL_QSV:
return 'hwdownload,format=nv12,'
return 'hwdownload,format=yuv420p,'
else:
return ''