From ce8854404b2d98efae698d0db721f95ab6befa69 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Fri, 12 Sep 2025 14:54:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(entity):=20=E4=BF=AE=E5=A4=8D=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=85=A2=E6=94=BE=E6=97=B6=20PTS=20=E5=86=B2=E7=AA=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改视频变速功能,通过改变帧率实现慢放效果 -避免使用 setpts滤镜导致的 PTS 冲突 - 优化代码结构,提高可读性和可维护性 --- entity/ffmpeg.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/entity/ffmpeg.py b/entity/ffmpeg.py index 3e864a0..7471be4 100644 --- a/entity/ffmpeg.py +++ b/entity/ffmpeg.py @@ -271,9 +271,10 @@ class FfmpegTask(object): if param == '': param = "1" if param != "1": - # 视频变速 + # 视频变速:通过改变帧率实现,避免PTS冲突 effect_index += 1 - filter_args.append(f"{video_output_str}setpts={param}*PTS[v_eff{effect_index}]") + new_fps = self.frame_rate / float(param) + filter_args.append(f"{video_output_str}fps={new_fps}[v_eff{effect_index}]") video_output_str = f"[v_eff{effect_index}]" elif effect.startswith("zoom:"): param = effect.split(":", 2)[1]