diff --git a/python_core/ai_video/api_client.py b/python_core/ai_video/api_client.py index d733348..e4dc43a 100644 --- a/python_core/ai_video/api_client.py +++ b/python_core/ai_video/api_client.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# -*- coding: utf-8 -*- """ API Client Module API 客户端模块 @@ -236,30 +237,30 @@ class APIClient: result['data'] = status_result['data'] result['msg'] = 'succeeded' if progress_callback: - progress_callback("✓ 视频生成完成!") + progress_callback("[完成] 视频生成完成!") break elif status_result['msg'] == 'running': wait_count += 1 elapsed = wait_count * interval remaining = max(0, timeout - elapsed) - progress_msg = f"⏳ 任务运行中,已等待{elapsed}秒,预计剩余{remaining}秒..." + progress_msg = f"[运行中] 任务运行中,已等待{elapsed}秒,预计剩余{remaining}秒..." logger.info(progress_msg) if progress_callback: progress_callback(progress_msg) time.sleep(interval) - + elif status_result['msg'] == 'failed': result['msg'] = '任务执行失败' if progress_callback: - progress_callback("✗ 任务执行失败") + progress_callback("[失败] 任务执行失败") break elif status_result['msg'] in ['pending', 'queued']: wait_count += 1 elapsed = wait_count * interval remaining = max(0, timeout - elapsed) - progress_msg = f"⏳ 任务排队中,已等待{elapsed}秒,预计剩余{remaining}秒..." + progress_msg = f"[排队中] 任务排队中,已等待{elapsed}秒,预计剩余{remaining}秒..." logger.info(progress_msg) if progress_callback: progress_callback(progress_msg) @@ -270,12 +271,12 @@ class APIClient: wait_count += 1 logger.info(f"未知状态: {status_result['msg']},继续等待...") if progress_callback: - progress_callback(f"❔ 状态: {status_result['msg']},继续等待...") + progress_callback(f"[未知] 状态: {status_result['msg']},继续等待...") time.sleep(interval) if not result['status'] and result['msg'] == '': result['msg'] = '任务超时' if progress_callback: - progress_callback(f"⏰ 任务查询超时({timeout}秒)") + progress_callback(f"[超时] 任务查询超时({timeout}秒)") return result diff --git a/python_core/ai_video/video_generator.py b/python_core/ai_video/video_generator.py index a814fcb..65dce00 100644 --- a/python_core/ai_video/video_generator.py +++ b/python_core/ai_video/video_generator.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# -*- coding: utf-8 -*- """ Video Generator Module 视频生成器模块 @@ -108,7 +109,7 @@ class VideoGenerator: # Step 1: Upload image to cloud storage if progress_callback: - progress_callback("📤 正在上传图片到云存储...") + progress_callback("[1/4] 正在上传图片到云存储...") logger.info(f"Uploading image to cloud storage: {image_path}") upload_result = self.cloud_storage.upload_file(image_path) @@ -119,12 +120,12 @@ class VideoGenerator: img_url = upload_result['data'] if progress_callback: - progress_callback("✓ 图片上传成功") + progress_callback("[1/4] 图片上传成功") logger.info(f"Image uploaded successfully: {img_url}") # Step 2: Submit video generation task if progress_callback: - progress_callback("🚀 正在提交视频生成任务...") + progress_callback("[2/4] 正在提交视频生成任务...") logger.info("Submitting video generation task...") task_result = self.api_client.submit_task(prompt, img_url, duration, model_type) @@ -135,12 +136,12 @@ class VideoGenerator: task_id = task_result['data'] if progress_callback: - progress_callback(f"✓ 任务提交成功,任务ID: {task_id}") + progress_callback(f"[2/4] 任务提交成功,任务ID: {task_id}") logger.info(f"Task submitted successfully, task ID: {task_id}") # Step 3: Wait for task completion if progress_callback: - progress_callback("⏳ 正在等待视频生成完成...") + progress_callback("[3/4] 正在等待视频生成完成...") logger.info("Waiting for video generation to complete...") completion_result = self.api_client.wait_for_completion( @@ -162,7 +163,7 @@ class VideoGenerator: # Step 4: Download video if save_path is provided if save_path: if progress_callback: - progress_callback("📥 正在下载视频到本地...") + progress_callback("[4/4] 正在下载视频到本地...") logger.info("Downloading video to local storage...") video_path = self.cloud_storage.download_file(video_url, save_path) @@ -171,12 +172,12 @@ class VideoGenerator: result['video_path'] = video_path result['msg'] = '视频生成并下载成功' if progress_callback: - progress_callback(f"✓ 视频下载成功: {os.path.basename(video_path)}") + progress_callback(f"[4/4] 视频下载成功: {os.path.basename(video_path)}") logger.info(f"Video downloaded successfully: {video_path}") else: result['msg'] = '视频下载失败' if progress_callback: - progress_callback("✗ 视频下载失败") + progress_callback("[4/4] 视频下载失败") logger.error(result['msg']) else: result['status'] = True @@ -288,12 +289,12 @@ class VideoGenerator: success_count += 1 video_path = video_result.get('video_path', '') if progress_callback: - progress_callback(f" ✓ 视频生成成功: {os.path.basename(video_path)}") + progress_callback(f" [成功] 视频生成成功: {os.path.basename(video_path)}") else: failed_count += 1 error_msg = video_result.get('msg', '未知错误') if video_result else '处理失败' if progress_callback: - progress_callback(f" ✗ 视频生成失败: {error_msg}") + progress_callback(f" [失败] 视频生成失败: {error_msg}") result['results'].append({ 'image_path': image_path, @@ -305,7 +306,7 @@ class VideoGenerator: failed_count += 1 error_msg = str(e) if progress_callback: - progress_callback(f" ✗ 处理图片时出错: {error_msg}") + progress_callback(f" [错误] 处理图片时出错: {error_msg}") result['results'].append({ 'image_path': image_path, @@ -356,7 +357,11 @@ def main(): generator = VideoGenerator() def progress_callback(message): - print(message) + try: + print(message) + except UnicodeEncodeError: + # Fallback for Windows GBK encoding issues + print(message.encode('utf-8', errors='ignore').decode('utf-8', errors='ignore')) if args.action == "single": if not args.image or not args.prompt or not args.output: diff --git a/src/components/AIVideoGenerator.tsx b/src/components/AIVideoGenerator.tsx index fc2ae66..9a95524 100644 --- a/src/components/AIVideoGenerator.tsx +++ b/src/components/AIVideoGenerator.tsx @@ -157,9 +157,6 @@ const AIVideoGenerator: React.FC = ({ className = '' }) =
{/* Header */}
-

AI 视频生成

- - {/* Mode Selection */}