feat(ffmpeg): 使用 minterpolate 替代 fps 调整视频速度

- 将视频变速功能从直接调整帧率改为使用 minterpolate 滤镜- 通过设置 fps 和 mi_mode 参数实现平滑的视频慢放效果
- 解决了直接调整帧率可能导致的 PTS 冲突问题
This commit is contained in:
2025-09-12 16:50:53 +08:00
parent ce8854404b
commit cf43f6379e

View File

@@ -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]