From 7a4748102f23341ebfc2537b74c6fa61101f4ff9 Mon Sep 17 00:00:00 2001 From: "kyj@bowong.ai" Date: Wed, 26 Mar 2025 16:25:33 +0800 Subject: [PATCH] =?UTF-8?q?FIX=20=E4=BF=AE=E5=A4=8D=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodes/compute_video_point.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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,)