You've already forked FrameTour-RenderWorker
Compare commits
2 Commits
8f0250df43
...
master
Author | SHA1 | Date | |
---|---|---|---|
bd0c44b17f | |||
432472fd19 |
@@ -27,10 +27,6 @@ def parse_ffmpeg_task(task_info, template_info):
|
|||||||
|
|
||||||
# 统计only_if占位符的使用次数
|
# 统计only_if占位符的使用次数
|
||||||
only_if_usage_count = {}
|
only_if_usage_count = {}
|
||||||
for part in template_info.get("video_parts", []):
|
|
||||||
only_if = part.get('only_if', '')
|
|
||||||
if only_if:
|
|
||||||
only_if_usage_count[only_if] = only_if_usage_count.get(only_if, 0) + 1
|
|
||||||
with tracer.start_as_current_span("parse_ffmpeg_task.download_all") as sub_span:
|
with tracer.start_as_current_span("parse_ffmpeg_task.download_all") as sub_span:
|
||||||
with ThreadPoolExecutor(max_workers=8) as executor:
|
with ThreadPoolExecutor(max_workers=8) as executor:
|
||||||
param_list: list[dict]
|
param_list: list[dict]
|
||||||
@@ -48,7 +44,8 @@ def parse_ffmpeg_task(task_info, template_info):
|
|||||||
continue
|
continue
|
||||||
only_if = part.get('only_if', '')
|
only_if = part.get('only_if', '')
|
||||||
if only_if:
|
if only_if:
|
||||||
required_count = only_if_usage_count.get(only_if, 1)
|
only_if_usage_count[only_if] = only_if_usage_count.get(only_if, 0) + 1
|
||||||
|
required_count = only_if_usage_count.get(only_if)
|
||||||
if not check_placeholder_exist_with_count(only_if, task_params_orig, required_count):
|
if not check_placeholder_exist_with_count(only_if, task_params_orig, required_count):
|
||||||
logger.info("because only_if exist, placeholder: %s insufficient (need %d), skip part: %s", only_if, required_count, part)
|
logger.info("because only_if exist, placeholder: %s insufficient (need %d), skip part: %s", only_if, required_count, part)
|
||||||
continue
|
continue
|
||||||
|
@@ -308,6 +308,19 @@ class FfmpegTask(object):
|
|||||||
effect_index += 1
|
effect_index += 1
|
||||||
filter_args.append(f"{video_output_str}trim=start={skip_seconds},setpts=PTS-STARTPTS[v_eff{effect_index}]")
|
filter_args.append(f"{video_output_str}trim=start={skip_seconds},setpts=PTS-STARTPTS[v_eff{effect_index}]")
|
||||||
video_output_str = f"[v_eff{effect_index}]"
|
video_output_str = f"[v_eff{effect_index}]"
|
||||||
|
elif effect.startswith("tail:"):
|
||||||
|
param = effect.split(":", 2)[1]
|
||||||
|
if param == '':
|
||||||
|
param = "0"
|
||||||
|
tail_seconds = float(param)
|
||||||
|
if tail_seconds > 0:
|
||||||
|
effect_index += 1
|
||||||
|
# 首先获取视频总时长,然后计算开始时间
|
||||||
|
# 使用reverse+trim+reverse的方法来精确获取最后N秒
|
||||||
|
filter_args.append(f"{video_output_str}reverse[v_rev{effect_index}]")
|
||||||
|
filter_args.append(f"[v_rev{effect_index}]trim=duration={tail_seconds},setpts=PTS-STARTPTS[v_trim{effect_index}]")
|
||||||
|
filter_args.append(f"[v_trim{effect_index}]reverse[v_eff{effect_index}]")
|
||||||
|
video_output_str = f"[v_eff{effect_index}]"
|
||||||
...
|
...
|
||||||
if self.resolution:
|
if self.resolution:
|
||||||
filter_args.append(f"{video_output_str}scale={self.resolution.replace('x', ':')}[v]")
|
filter_args.append(f"{video_output_str}scale={self.resolution.replace('x', ':')}[v]")
|
||||||
|
Reference in New Issue
Block a user