From 11a15b9b78dea2905bb94fb7abc702c242670851 Mon Sep 17 00:00:00 2001 From: linyq Date: Thu, 8 May 2025 00:42:06 +0800 Subject: [PATCH] =?UTF-8?q?refactor(app):=20=E4=BC=98=E5=8C=96=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E8=B7=AF=E5=BE=84=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新视频路径获取方式,支持Windows和Unix/Mac系统的路径格式 - 增加对路径中单引号的处理,确保路径正确性 - 简化代码逻辑,提高可读性 --- app/services/merger_video.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/services/merger_video.py b/app/services/merger_video.py index 7f8e590..66b58de 100644 --- a/app/services/merger_video.py +++ b/app/services/merger_video.py @@ -131,8 +131,18 @@ def create_ffmpeg_concat_file(video_paths: List[str], concat_file_path: str) -> """ with open(concat_file_path, 'w', encoding='utf-8') as f: for video_path in video_paths: - # 使用绝对路径并转义特殊字符 - abs_path = os.path.abspath(video_path).replace('\\', '\\\\').replace(':', '\\:') + # 获取绝对路径 + abs_path = os.path.abspath(video_path) + # 在Windows上将反斜杠替换为正斜杠 + if os.name == 'nt': # Windows系统 + abs_path = abs_path.replace('\\', '/') + else: # Unix/Mac系统 + # 转义特殊字符 + abs_path = abs_path.replace('\\', '\\\\').replace(':', '\\:') + + # 处理路径中的单引号 (如果有) + abs_path = abs_path.replace("'", "\\'") + f.write(f"file '{abs_path}'\n") return concat_file_path