From 7c6e4a97b2411fef6a5f480009ec5a378abaa327 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Fri, 28 Mar 2025 17:26:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=87=E6=AE=B5=E6=9C=89=E9=9F=B3=E9=A2=91?= =?UTF-8?q?=E4=B8=8D=E5=8F=AF=E4=BB=A5copy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entity/ffmpeg.py | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/entity/ffmpeg.py b/entity/ffmpeg.py index 678573b..d765b70 100644 --- a/entity/ffmpeg.py +++ b/entity/ffmpeg.py @@ -141,7 +141,7 @@ class FfmpegTask(object): return False if self.speed != 1: return False - if len(self.audios) > 1: + if len(self.audios) >= 1: return False if len(self.input_file) > 1: return False @@ -277,16 +277,26 @@ class FfmpegTask(object): audio_output_str = "" audio_track_index = 0 # output_args - _tmp_file = "tmp_concat_"+str(time.time())+".txt" - with open(_tmp_file, "w", encoding="utf-8") as f: - for input_file in self.input_file: - if type(input_file) is str: - f.write("file '"+input_file+"'\n") - elif isinstance(input_file, FfmpegTask): - f.write("file '" + input_file.get_output_file() + "'\n") - input_args += ["-f", "concat", "-safe", "0", "-i", _tmp_file] - from util.ffmpeg import probe_video_audio - self.mute = not probe_video_audio(_tmp_file, "concat") + if len(self.input_file) == 1: + _file = self.input_file[0] + from util.ffmpeg import probe_video_audio + if type(_file) is str: + input_args += ["-i", _file] + self.mute = not probe_video_audio(_file) + elif isinstance(_file, FfmpegTask): + input_args += ["-i", _file.get_output_file()] + self.mute = not probe_video_audio(_file.get_output_file()) + else: + _tmp_file = "tmp_concat_" + str(time.time()) + ".txt" + from util.ffmpeg import probe_video_audio + with open(_tmp_file, "w", encoding="utf-8") as f: + for input_file in self.input_file: + if type(input_file) is str: + f.write("file '" + input_file + "'\n") + elif isinstance(input_file, FfmpegTask): + f.write("file '" + input_file.get_output_file() + "'\n") + input_args += ["-f", "concat", "-safe", "0", "-i", _tmp_file] + self.mute = not probe_video_audio(_tmp_file, "concat") output_args.append("-map") output_args.append("0:v") output_args.append("-c:v")