feat(video): 添加原始变速效果支持

- 在常量定义中新增 ospeed 效果类型用于兼容旧模板
- 在任务域中实现 get_ospeed_params 方法解析变速参数
- 修改视频渲染处理器合并 speed 与 ospeed 效果计算
- 更新时长计算逻辑以正确处理 ospeed 变速影响
- 新增 ospeed 参数验证和边界值处理机制
- 添加完整的 ospeed 效果单元测试覆盖各种场景
This commit is contained in:
2026-02-10 12:20:20 +08:00
parent 3cb2f8d02a
commit 952b8f5c01
4 changed files with 184 additions and 20 deletions

View File

@@ -46,6 +46,7 @@ EFFECT_TYPES = {
'cameraShot', # 相机定格效果
'zoom', # 缩放效果(预留)
'blur', # 模糊效果(预留)
'ospeed', # 原始变速效果(兼容旧模板)
}
@@ -189,6 +190,20 @@ class Effect:
return (start_sec, scale_factor, duration_sec)
def get_ospeed_params(self) -> float:
"""获取 ospeed 效果参数,返回 PTS 乘数(>0),无效时返回 1.0"""
if self.effect_type != 'ospeed':
return 1.0
if not self.params:
return 1.0
try:
factor = float(self.params.strip())
except ValueError:
return 1.0
if not isfinite(factor) or factor <= 0:
return 1.0
return factor
@dataclass
class RenderSpec: