From cf43f6379ee01d86df135d486607e4cd2cb11c49 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Fri, 12 Sep 2025 16:50:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(ffmpeg):=20=E4=BD=BF=E7=94=A8=20minterpola?= =?UTF-8?q?te=20=E6=9B=BF=E4=BB=A3=20fps=20=E8=B0=83=E6=95=B4=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将视频变速功能从直接调整帧率改为使用 minterpolate 滤镜- 通过设置 fps 和 mi_mode 参数实现平滑的视频慢放效果 - 解决了直接调整帧率可能导致的 PTS 冲突问题 --- entity/ffmpeg.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/entity/ffmpeg.py b/entity/ffmpeg.py index 7471be4..796d20c 100644 --- a/entity/ffmpeg.py +++ b/entity/ffmpeg.py @@ -271,10 +271,10 @@ class FfmpegTask(object): if param == '': param = "1" if param != "1": - # 视频变速:通过改变帧率实现,避免PTS冲突 + # 视频变速:使用minterpolate实现,避免PTS冲突 effect_index += 1 - new_fps = self.frame_rate / float(param) - filter_args.append(f"{video_output_str}fps={new_fps}[v_eff{effect_index}]") + speed_factor = 1.0 / float(param) # 慢放倍数转换为速度因子 + filter_args.append(f"{video_output_str}minterpolate=fps=25*{speed_factor}:mi_mode=mci[v_eff{effect_index}]") video_output_str = f"[v_eff{effect_index}]" elif effect.startswith("zoom:"): param = effect.split(":", 2)[1]