diff --git a/app/services/material.py b/app/services/material.py index b3ce063..c048a92 100644 --- a/app/services/material.py +++ b/app/services/material.py @@ -446,7 +446,7 @@ def save_clip_video(timestamp: str, origin_video: str, save_dir: str = "") -> st ] # 执行FFmpeg命令 - logger.info(f"裁剪视频片段: {timestamp} -> {ffmpeg_start_time}到{ffmpeg_end_time}") + # logger.info(f"裁剪视频片段: {timestamp} -> {ffmpeg_start_time}到{ffmpeg_end_time}") # logger.debug(f"执行命令: {' '.join(ffmpeg_cmd)}") process = subprocess.run( @@ -478,7 +478,7 @@ def save_clip_video(timestamp: str, origin_video: str, save_dir: str = "") -> st if os.path.exists(video_path): os.remove(video_path) return '' - + except Exception as e: logger.error(f"视频剪辑过程中发生错误: \n{str(traceback.format_exc())}") if os.path.exists(video_path): @@ -505,7 +505,6 @@ def clip_videos(task_id: str, timestamp_terms: List[str], origin_video: str, pro try: saved_video_path = save_clip_video(timestamp=item, origin_video=origin_video, save_dir=material_directory) if saved_video_path: - logger.info(f"video saved: {saved_video_path}") video_paths.update({index+1:saved_video_path}) # 更新进度 @@ -516,6 +515,7 @@ def clip_videos(task_id: str, timestamp_terms: List[str], origin_video: str, pro return {} logger.success(f"裁剪 {len(video_paths)} videos") + # logger.debug(json.dumps(video_paths, indent=4, ensure_ascii=False)) return video_paths diff --git a/app/services/video_service.py b/app/services/video_service.py index 2a0a9a6..1b2ddf0 100644 --- a/app/services/video_service.py +++ b/app/services/video_service.py @@ -4,8 +4,6 @@ from loguru import logger from typing import Dict, List, Optional, Tuple from app.services import material -from app.models.schema import VideoClipParams -from app.utils import utils class VideoService: diff --git a/app/services/voice.py b/app/services/voice.py index 48197a8..31f6d66 100644 --- a/app/services/voice.py +++ b/app/services/voice.py @@ -1197,11 +1197,14 @@ def azure_tts_v2(text: str, voice_name: str, voice_file: str) -> Union[SubMaker, def _format_text(text: str) -> str: - # text = text.replace("\n", " ") + text = text.replace("\n", " ") + text = text.replace("\"", " ") text = text.replace("[", " ") text = text.replace("]", " ") text = text.replace("(", " ") text = text.replace(")", " ") + text = text.replace(")", " ") + text = text.replace("(", " ") text = text.replace("{", " ") text = text.replace("}", " ") text = text.strip() @@ -1394,8 +1397,10 @@ def create_subtitle(sub_maker: submaker.SubMaker, text: str, subtitle_file: str) logger.error(f"failed, error: {str(e)}") os.remove(subtitle_file) else: - logger.warning( + logger.error( f"字幕创建失败, 字幕长度: {len(sub_items)}, script_lines len: {len(script_lines)}" + f"\nsub_items:{json.dumps(sub_items, indent=4, ensure_ascii=False)}" + f"\nscript_lines:{json.dumps(script_lines, indent=4, ensure_ascii=False)}" ) except Exception as e: diff --git a/app/utils/utils.py b/app/utils/utils.py index 49d44be..e80cd87 100644 --- a/app/utils/utils.py +++ b/app/utils/utils.py @@ -506,7 +506,7 @@ def cut_video(params, progress_callback=None): st.session_state['subclip_videos'] = subclip_videos for i, video_script in enumerate(video_script_list): try: - video_script['path'] = subclip_videos[video_script['timestamp']] + video_script['path'] = subclip_videos[i+1] except KeyError as err: logger.error(f"裁剪视频失败: {err}") diff --git a/webui/components/review_settings.py b/webui/components/review_settings.py index 932ec9b..c4f3bce 100644 --- a/webui/components/review_settings.py +++ b/webui/components/review_settings.py @@ -33,7 +33,7 @@ def render_video_item(tr, video_list, subclip_videos, index): video_script = video_list[index] # 显示时间戳 - timestamp = video_script.get('timestamp', '') + timestamp = video_script.get('_id', '') st.text_area( tr("Timestamp"), value=timestamp,