fix: 硬切场景改用concat filter替代xfade,提升多素材场景性能与稳定性
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 1m19s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1516h27m30s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1516h27m32s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1516h27m32s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1516h27m30s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 1516h27m34s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 1516h27m34s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 1516h27m34s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 1516h27m34s
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1516h59m11s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 1516h59m15s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 1516h59m15s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 1m19s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1516h27m30s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1516h27m32s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1516h27m32s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1516h27m30s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 1516h27m34s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 1516h27m34s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 1516h27m34s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 1516h27m34s
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1516h59m11s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 1516h59m15s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 1516h59m15s
- 全硬切(no transition)场景下使用concat filter,性能远优于xfade - 有转场效果时继续走xfade路径,保持兼容 - 修复硬切默认走xfade(fade fallback)的设计问题 - 新增单元测试覆盖concat和xfade两种路径 - 87个unified_render测试全绿,全套2147测试零回归
This commit is contained in:
@@ -1363,23 +1363,39 @@ class UnifiedRenderService:
|
||||
# 单 clip 层,直接使用预处理标签
|
||||
layer_output_labels[layer.role] = layer_labels[0]
|
||||
else:
|
||||
# 多 clip 层,用 TransitionEngine 构建转场链
|
||||
out_label = f"{layer.role}_merged"
|
||||
# 计算该层使用的转场时长(取首个非零值,否则用默认)
|
||||
layer_dur = 0.0
|
||||
for d in layer_transition_durations:
|
||||
if d > 0:
|
||||
layer_dur = d
|
||||
break
|
||||
xfade_filter, _ = self._transition_engine.build_xfade_chain(
|
||||
clip_durations=layer_durations,
|
||||
clip_video_labels=layer_labels,
|
||||
transitions=layer_transitions,
|
||||
transition_duration=layer_dur if layer_dur > 0 else None,
|
||||
output_label=out_label,
|
||||
# 判断是否全部为硬切:是则用 concat filter,否则用 xfade 转场链
|
||||
all_cut = all(
|
||||
t is None or t == "" or str(t).lower() == "cut"
|
||||
for t in layer_transitions[1:] # 第一个 clip 的转场忽略
|
||||
)
|
||||
if xfade_filter:
|
||||
filter_parts.append(xfade_filter)
|
||||
if all_cut:
|
||||
# 全硬切:用 concat filter,性能远优于 xfade
|
||||
concat_inputs = "".join(f"[{label}]" for label in layer_labels)
|
||||
filter_parts.append(
|
||||
f"{concat_inputs}concat=n={len(layer_labels)}:v=1:a=0[{out_label}]"
|
||||
)
|
||||
logger.info(
|
||||
"[unified-render] layer=%s clips=%d using concat (all hard-cut)",
|
||||
layer.role,
|
||||
len(layer_labels),
|
||||
)
|
||||
else:
|
||||
# 有转场效果:用 TransitionEngine 构建 xfade 链
|
||||
layer_dur = 0.0
|
||||
for d in layer_transition_durations:
|
||||
if d > 0:
|
||||
layer_dur = d
|
||||
break
|
||||
xfade_filter, _ = self._transition_engine.build_xfade_chain(
|
||||
clip_durations=layer_durations,
|
||||
clip_video_labels=layer_labels,
|
||||
transitions=layer_transitions,
|
||||
transition_duration=layer_dur if layer_dur > 0 else None,
|
||||
output_label=out_label,
|
||||
)
|
||||
if xfade_filter:
|
||||
filter_parts.append(xfade_filter)
|
||||
layer_output_labels[layer.role] = out_label
|
||||
|
||||
# Step 3: 合成各层
|
||||
|
||||
Reference in New Issue
Block a user