fix(entity): 修复视频慢放时 PTS 冲突问题

- 修改视频变速功能,通过改变帧率实现慢放效果
-避免使用 setpts滤镜导致的 PTS 冲突
- 优化代码结构,提高可读性和可维护性
This commit is contained in:
2025-09-12 14:54:01 +08:00
parent c36e838d4f
commit ce8854404b

View File

@@ -271,9 +271,10 @@ class FfmpegTask(object):
if param == '': if param == '':
param = "1" param = "1"
if param != "1": if param != "1":
# 视频变速 # 视频变速:通过改变帧率实现,避免PTS冲突
effect_index += 1 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}]" video_output_str = f"[v_eff{effect_index}]"
elif effect.startswith("zoom:"): elif effect.startswith("zoom:"):
param = effect.split(":", 2)[1] param = effect.split(":", 2)[1]