diff --git a/nodes/compute_video_point.py b/nodes/compute_video_point.py index 8351448..147f135 100644 --- a/nodes/compute_video_point.py +++ b/nodes/compute_video_point.py @@ -2,6 +2,8 @@ import re from datetime import datetime from math import ceil +import loguru + def validate_time_format(time_str): pattern = r'^([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|\d{1,2}).(\d{3})$' @@ -21,6 +23,7 @@ class VideoStartPointDurationCompute: "required": { "start_time": ("STRING", {"forceInput": True}), "audio": ("AUDIO", {"forceInput": True}), + "end_padding": ("FLOAT", {"forceInput": True, "default": 0.4}), "fps": ("INT", {"default": 25, "step": 1}), }, } @@ -32,7 +35,7 @@ class VideoStartPointDurationCompute: CATEGORY = "不忘科技-自定义节点🚩" - def compute(self, start_time, audio, fps): + def compute(self, start_time, audio, fps, end_padding): if not validate_time_format(start_time): raise ValueError("start_time或者end_time时间格式不对(start_time or end_time is not in time format)") @@ -40,7 +43,9 @@ class VideoStartPointDurationCompute: start_dt = datetime.strptime(start_time, time_format) start_sec = (start_dt - datetime(1900, 1, 1)).total_seconds() start_point = start_sec * fps - print("audio duration %.3f s"%get_duration_wave(audio)) - duration = get_duration_wave(audio) * fps - return (start_point, duration,) + duration = get_duration_wave(audio) + loguru.logger.info("audio duration %.3f s" % duration) + duration = duration + end_padding + loguru.logger.info("audio duration with padding %.3f s" % get_duration_wave(audio)) + return (start_point, duration*fps,)