You've already forked FrameTour-RenderWorker
支持zoom_cut
This commit is contained in:
@@ -50,6 +50,7 @@ def parse_ffmpeg_task(task_info, template_info):
|
||||
sub_ffmpeg_task.ext_data = ext_data or {}
|
||||
sub_ffmpeg_task.frame_rate = template_info.get("frame_rate", 25)
|
||||
sub_ffmpeg_task.center_cut = part.get("crop_mode", None)
|
||||
sub_ffmpeg_task.zoom_cut = part.get("zoom_cut", None)
|
||||
for effect in part.get('effects', []):
|
||||
sub_ffmpeg_task.add_effect(effect)
|
||||
for lut in part.get('filters', []):
|
||||
@@ -64,6 +65,7 @@ def parse_ffmpeg_task(task_info, template_info):
|
||||
task.resolution = template_info.get("video_size", "")
|
||||
overall = template_info.get("overall_template")
|
||||
task.center_cut = template_info.get("crop_mode", None)
|
||||
task.zoom_cut = template_info.get("zoom_cut", None)
|
||||
task.frame_rate = template_info.get("frame_rate", 25)
|
||||
# if overall.get('source', ''):
|
||||
# source, ext_data = parse_video(overall.get('source'), task_params, template_info)
|
||||
|
@@ -187,6 +187,32 @@ class FfmpegTask(object):
|
||||
filter_args.append(f"{video_output_str}crop=x={_x}:y=0:w=ih*ih/iw:h=ih[v_cut{effect_index}]")
|
||||
video_output_str = f"[v_cut{effect_index}]"
|
||||
effect_index += 1
|
||||
if self.zoom_cut == 1 and self.resolution:
|
||||
_input = None
|
||||
for input_file in self.input_file:
|
||||
if type(input_file) is str:
|
||||
_input = input_file
|
||||
break
|
||||
elif isinstance(input_file, FfmpegTask):
|
||||
_input = input_file.get_output_file()
|
||||
break
|
||||
if _input:
|
||||
from util.ffmpeg import probe_video_info
|
||||
_iw, _ih, _ = probe_video_info(_input)
|
||||
_w, _h = self.resolution.split('x', 1)
|
||||
pos_json_str = self.ext_data.get('posJson', '{}')
|
||||
pos_json = json.loads(pos_json_str)
|
||||
_v_w = pos_json.get('imgWidth', 1)
|
||||
_v_h = pos_json.get('imgHeight', 1)
|
||||
_f_x = pos_json.get('ltX', 0)
|
||||
_f_x2 = pos_json.get('rbX', 0)
|
||||
_f_y = pos_json.get('ltY', 0)
|
||||
_f_y2 = pos_json.get('rbY', 0)
|
||||
_x = min(max(0, (_f_x + _f_x2) / 2 - int(_w) / 2), _iw - int(_w))
|
||||
_y = min(max(0, (_f_y + _f_y2) / 2 - int(_h) / 2), _ih - int(_h))
|
||||
filter_args.append(f"{video_output_str}crop=x={_x}:y={_y}:w={_w}:h={_h}[vz_cut{effect_index}]")
|
||||
video_output_str = f"[vz_cut{effect_index}]"
|
||||
effect_index += 1
|
||||
for effect in self.effects:
|
||||
if effect.startswith("cameraShot:"):
|
||||
param = effect.split(":", 2)[1]
|
||||
|
Reference in New Issue
Block a user