@@ -48,14 +48,36 @@ def export(task: ExportTask) -> bool:
4848
4949 logging .info ("导出命令: %s" , command )
5050
51- # 执行命令
51+ # 执行命令并捕获输出
5252 try :
53- subprocess .run (
54- command , shell = False , check = True , creationflags = subprocess .CREATE_NO_WINDOW
53+ result = subprocess .run (
54+ command ,
55+ shell = False ,
56+ check = True ,
57+ capture_output = True , # 捕获stdout和stderr
58+ text = True , # 以文本模式捕获输出
59+ encoding = "utf-8" , # 使用UTF-8编码
60+ errors = "replace" , # 替换无法解码的字符
61+ creationflags = subprocess .CREATE_NO_WINDOW ,
5562 )
63+
64+ # 将子进程输出写入日志
65+ if result .stdout :
66+ logging .info (f"FFmpeg stdout: { result .stdout } " )
67+ if result .stderr :
68+ logging .info (
69+ f"FFmpeg stderr: { result .stderr } "
70+ ) # 使用info级别记录,因为ffmpeg通常在stderr输出进度
71+
5672 logging .info ("export one success" )
5773 return True
5874 except subprocess .CalledProcessError as e :
75+ # 捕获错误输出
76+ if e .stdout :
77+ logging .error (f"FFmpeg stdout (error): { e .stdout } " )
78+
79+ logging .error (f"FFmpeg stderr (error): { e .stderr } " )
80+
5981 logging .error ("export one failed with error: {:?}" , e )
6082 return False
6183
@@ -69,7 +91,7 @@ def build_command_header(ffmpeg_path: str) -> str:
6991 Returns:
7092 str: 构建后的ffmpeg命令头字符串
7193 """
72- return ffmpeg_path + " -y"
94+ return ffmpeg_path + " -y -nostats "
7395
7496
7597def build_command_header_without_executeable () -> str :
@@ -78,7 +100,7 @@ def build_command_header_without_executeable() -> str:
78100 Returns:
79101 str: 构建后的不带执行文件路径的ffmpeg命令头字符串
80102 """
81- return " -y"
103+ return " -y -nostats "
82104
83105
84106def build_video_input (video_file : VideoFile ) -> str :
0 commit comments