You've already forked FrameTour-RenderWorker
帧跳过、zoom
This commit is contained in:
@@ -246,12 +246,13 @@ class FfmpegTask(object):
|
||||
_mid_out_str = "[eff_m]"
|
||||
_end_out_str = "[eff_e]"
|
||||
filter_args.append(f"{video_output_str}split=3{_start_out_str}{_mid_out_str}{_end_out_str}")
|
||||
filter_args.append(f"{_start_out_str}select=lt(n\\,{int(start*self.frame_rate)}){_start_out_str}")
|
||||
filter_args.append(f"{_end_out_str}select=gt(n\\,{int(start*self.frame_rate)}){_end_out_str}")
|
||||
filter_args.append(f"{_mid_out_str}select=eq(n\\,{int(start*self.frame_rate)}){_mid_out_str}")
|
||||
filter_args.append(f"{_mid_out_str}tpad=start_mode=clone:start_duration={duration:.4f}{_mid_out_str}")
|
||||
filter_args.append(f"{_start_out_str}select=lt(n\\,{int(start * self.frame_rate)}){_start_out_str}")
|
||||
filter_args.append(f"{_end_out_str}select=gt(n\\,{int(start * self.frame_rate)}){_end_out_str}")
|
||||
filter_args.append(f"{_mid_out_str}select=eq(n\\,{int(start * self.frame_rate)}){_mid_out_str}")
|
||||
filter_args.append(
|
||||
f"{_mid_out_str}tpad=start_mode=clone:start_duration={duration:.4f}{_mid_out_str}")
|
||||
if rotate_deg != 0:
|
||||
filter_args.append(f"{_mid_out_str}rotate=PI*{rotate_deg}/360{_mid_out_str}")
|
||||
filter_args.append(f"{_mid_out_str}rotate=PI*{rotate_deg}/180{_mid_out_str}")
|
||||
# filter_args.append(f"{video_output_str}trim=start=0:end={start+duration},tpad=stop_mode=clone:stop_duration={duration},setpts=PTS-STARTPTS{_start_out_str}")
|
||||
# filter_args.append(f"tpad=start_mode=clone:start_duration={duration},setpts=PTS-STARTPTS{_start_out_str}")
|
||||
# filter_args.append(f"{_end_out_str}trim=start={start}{_end_out_str}")
|
||||
@@ -269,7 +270,44 @@ class FfmpegTask(object):
|
||||
filter_args.append(f"{video_output_str}setpts={param}*PTS[v_eff{effect_index}]")
|
||||
video_output_str = f"[v_eff{effect_index}]"
|
||||
elif effect.startswith("zoom:"):
|
||||
...
|
||||
param = effect.split(":", 2)[1]
|
||||
if param == '':
|
||||
continue
|
||||
_split = param.split(",")
|
||||
if len(_split) < 3:
|
||||
continue
|
||||
try:
|
||||
start_time = float(_split[0])
|
||||
zoom_factor = float(_split[1])
|
||||
duration = float(_split[2])
|
||||
if start_time < 0:
|
||||
start_time = 0
|
||||
if duration < 0:
|
||||
duration = 0
|
||||
if zoom_factor <= 0:
|
||||
zoom_factor = 1
|
||||
except (ValueError, IndexError):
|
||||
start_time = 0
|
||||
duration = 0
|
||||
zoom_factor = 1
|
||||
if zoom_factor == 1:
|
||||
continue
|
||||
effect_index += 1
|
||||
if duration == 0:
|
||||
filter_args.append(f"{video_output_str}trim=start={start_time},scale=iw*{zoom_factor}:ih*{zoom_factor},crop=iw/{zoom_factor}:ih/{zoom_factor}:(iw-iw/{zoom_factor})/2:(ih-ih/{zoom_factor})/2,setpts=PTS-STARTPTS[v_eff{effect_index}]")
|
||||
else:
|
||||
zoom_expr = f"if(between(t,{start_time},{start_time + duration}),{zoom_factor},1)"
|
||||
filter_args.append(f"{video_output_str}scale=iw*({zoom_expr}):ih*({zoom_expr}),crop=iw:ih:(iw-iw)/2:(ih-ih)/2[v_eff{effect_index}]")
|
||||
video_output_str = f"[v_eff{effect_index}]"
|
||||
elif effect.startswith("skip:"):
|
||||
param = effect.split(":", 2)[1]
|
||||
if param == '':
|
||||
param = "0"
|
||||
skip_seconds = float(param)
|
||||
if skip_seconds > 0:
|
||||
effect_index += 1
|
||||
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}]"
|
||||
...
|
||||
if self.resolution:
|
||||
filter_args.append(f"{video_output_str}scale={self.resolution.replace('x', ':')}[v]")
|
||||
|
Reference in New Issue
Block a user