You've already forked FrameTour-RenderWorker
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
from typing import List
|
|
from .base import EffectProcessor
|
|
|
|
class SkipEffect(EffectProcessor):
|
|
"""跳过开头效果处理器"""
|
|
|
|
def validate_params(self) -> bool:
|
|
"""验证参数:跳过的秒数"""
|
|
if not self.params:
|
|
return True # 默认不跳过
|
|
|
|
try:
|
|
skip_seconds = float(self.params)
|
|
return skip_seconds >= 0
|
|
except ValueError:
|
|
return False
|
|
|
|
def generate_filter_args(self, video_input: str, effect_index: int) -> tuple[List[str], str]:
|
|
"""生成跳过开头效果的滤镜参数"""
|
|
if not self.validate_params():
|
|
return [], video_input
|
|
|
|
if not self.params:
|
|
return [], video_input
|
|
|
|
skip_seconds = float(self.params)
|
|
if skip_seconds <= 0:
|
|
return [], video_input
|
|
|
|
output_stream = f"[v_eff{effect_index}]"
|
|
|
|
# 使用trim滤镜跳过开头
|
|
filter_args = [f"{video_input}trim=start={skip_seconds}{output_stream}"]
|
|
|
|
return filter_args, output_stream
|
|
|
|
def get_effect_name(self) -> str:
|
|
return "skip" |