切割模式
This commit is contained in:
parent
2ea248c02e
commit
67696739f9
@ -38,6 +38,7 @@ def parse_ffmpeg_task(task_info, template_info):
|
|||||||
output_file = "out_" + str(time.time()) + ".mp4"
|
output_file = "out_" + str(time.time()) + ".mp4"
|
||||||
task = FfmpegTask(tasks, output_file=output_file)
|
task = FfmpegTask(tasks, output_file=output_file)
|
||||||
overall = template_info.get("overall_template")
|
overall = template_info.get("overall_template")
|
||||||
|
task.center_cut = template_info.get("crop_mode", None)
|
||||||
task.frame_rate = template_info.get("frame_rate", 25)
|
task.frame_rate = template_info.get("frame_rate", 25)
|
||||||
if overall.get('source', ''):
|
if overall.get('source', ''):
|
||||||
source = parse_video(overall.get('source'), task_params, template_info)
|
source = parse_video(overall.get('source'), task_params, template_info)
|
||||||
|
@ -14,6 +14,9 @@ class FfmpegTask(object):
|
|||||||
self.input_file = input_file
|
self.input_file = input_file
|
||||||
else:
|
else:
|
||||||
self.input_file = []
|
self.input_file = []
|
||||||
|
self.zoom_cut = None
|
||||||
|
self.center_cut = None
|
||||||
|
self.ext_data = {}
|
||||||
self.task_type = task_type
|
self.task_type = task_type
|
||||||
self.output_file = output_file
|
self.output_file = output_file
|
||||||
self.mute = True
|
self.mute = True
|
||||||
@ -101,6 +104,10 @@ class FfmpegTask(object):
|
|||||||
return False
|
return False
|
||||||
if self.speed != 1:
|
if self.speed != 1:
|
||||||
return False
|
return False
|
||||||
|
if self.zoom_cut is not None:
|
||||||
|
return False
|
||||||
|
if self.center_cut is not None:
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check_can_copy(self):
|
def check_can_copy(self):
|
||||||
@ -116,6 +123,10 @@ class FfmpegTask(object):
|
|||||||
return False
|
return False
|
||||||
if len(self.input_file) > 1:
|
if len(self.input_file) > 1:
|
||||||
return False
|
return False
|
||||||
|
if self.zoom_cut is not None:
|
||||||
|
return False
|
||||||
|
if self.center_cut is not None:
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check_audio_track(self):
|
def check_audio_track(self):
|
||||||
@ -134,7 +145,6 @@ class FfmpegTask(object):
|
|||||||
output_args.append("h264_mp4toannexb")
|
output_args.append("h264_mp4toannexb")
|
||||||
video_output_str = "[0:v]"
|
video_output_str = "[0:v]"
|
||||||
audio_output_str = "[0:v]"
|
audio_output_str = "[0:v]"
|
||||||
video_input_count = 0
|
|
||||||
audio_input_count = 0
|
audio_input_count = 0
|
||||||
for input_file in self.input_file:
|
for input_file in self.input_file:
|
||||||
input_args.append("-i")
|
input_args.append("-i")
|
||||||
@ -142,8 +152,14 @@ class FfmpegTask(object):
|
|||||||
input_args.append(input_file)
|
input_args.append(input_file)
|
||||||
elif isinstance(input_file, FfmpegTask):
|
elif isinstance(input_file, FfmpegTask):
|
||||||
input_args.append(input_file.get_output_file())
|
input_args.append(input_file.get_output_file())
|
||||||
|
if self.center_cut == 1:
|
||||||
|
pos_json = self.ext_data.get('posJson', {})
|
||||||
|
_v_w = pos_json.get('imgWidth', 1)
|
||||||
|
_f_x = pos_json.get('ltX', 0)
|
||||||
|
_x = f'{float(_f_x/_v_w) :.5f}*iw'
|
||||||
|
filter_args.append(f"[{video_output_str}]crop=x={_x}:y=0:w=ih*ih/iw:h=ih[{video_output_str}]")
|
||||||
for lut in self.luts:
|
for lut in self.luts:
|
||||||
filter_args.append("[0:v]lut3d=file=" + lut + "[0:v]")
|
filter_args.append(f"[{video_output_str}]lut3d=file={lut}[{video_output_str}]")
|
||||||
for overlay in self.overlays:
|
for overlay in self.overlays:
|
||||||
input_index = input_args.count("-i")
|
input_index = input_args.count("-i")
|
||||||
input_args.append("-i")
|
input_args.append("-i")
|
||||||
|
@ -90,6 +90,7 @@ def get_template_info(template_id):
|
|||||||
# 占位符
|
# 占位符
|
||||||
_template['source'] = "PLACEHOLDER_" + template_info.get('sourceUrl', '')
|
_template['source'] = "PLACEHOLDER_" + template_info.get('sourceUrl', '')
|
||||||
_template['mute'] = template_info.get('mute', True)
|
_template['mute'] = template_info.get('mute', True)
|
||||||
|
_template['crop_mode'] = template_info.get('cropEnable', None)
|
||||||
else:
|
else:
|
||||||
_template['source'] = None
|
_template['source'] = None
|
||||||
_overlays = template_info.get('overlays', '')
|
_overlays = template_info.get('overlays', '')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user