From 519e70cad09a2563c8861e8ed9a85b42393f4f37 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 2 Sep 2021 20:48:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=8F=82=E6=95=B0=E4=B8=AD?= =?UTF-8?q?=E6=9C=89=E7=A9=BA=E6=A0=BC=E5=AF=BC=E8=87=B4=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto_convert_flv_to_mp4.py | 4 ++-- auto_merge_video.py | 16 ++++++++-------- auto_split_video.py | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/auto_convert_flv_to_mp4.py b/auto_convert_flv_to_mp4.py index fff77b9..a00ed39 100644 --- a/auto_convert_flv_to_mp4.py +++ b/auto_convert_flv_to_mp4.py @@ -7,7 +7,7 @@ for file in glob("*.flv"): if os.path.exists(new_file): continue os.system(" ".join([ - "ffmpeg", "-y", "-i", file, + "ffmpeg", "-y", "-i", f"\"{file}\"", "-c copy", "-f mp4", - new_file, + f"\"{new_file}\"", ])) diff --git a/auto_merge_video.py b/auto_merge_video.py index edec02e..aab98e8 100644 --- a/auto_merge_video.py +++ b/auto_merge_video.py @@ -38,30 +38,30 @@ def merge_video_parts_and_split(video): prev_part["duration"] = str(duration) new_filename = str(time.time()) os.system(" ".join([ - "ffmpeg", "-y", "-i", "{filename}.{file_ext}".format_map(prev_part), + "ffmpeg", "-y", "-i", "\"{filename}.{file_ext}\"".format_map(prev_part), "-c copy", "-f mpegts", "-t {duration}".format_map(prev_part), - "{}.ts".format(new_filename) + "\"{}.ts\"".format(new_filename) ])) os.system(" ".join([ - "ffmpeg", "-y", "-i", "{}.ts".format(new_filename), + "ffmpeg", "-y", "-i", "\"{}.ts\"".format(new_filename), "-c copy", "-f mpegts", "-ss {start}".format_map(prev_part) if prev_part["start"] != "" else "", "-to {end}".format_map(prev_part) if prev_part["end"] != "" else "", - "{filename}.ts".format_map(prev_part) + "\"{filename}.ts\"".format_map(prev_part) ])) os.remove("{}.ts".format(new_filename)) ts_part.append("{filename}.ts".format_map(prev_part)) prev_part = part os.system(" ".join([ - "ffmpeg", "-y", "-i", "{filename}.{file_ext}".format_map(prev_part), + "ffmpeg", "-y", "-i", "\"{filename}.{file_ext}\"".format_map(prev_part), "-c copy", "-f mpegts", "-ss {start}".format_map(prev_part) if prev_part["start"] != "" else "", "-to {end}".format_map(prev_part) if prev_part["end"] != "" else "", - "{filename}.ts".format_map(prev_part) + "\"{filename}.ts\"".format_map(prev_part) ])) ts_part.append("{filename}.ts".format_map(prev_part)) os.system(" ".join([ "ffmpeg", "-y", "-i", "\"concat:{}\"".format("|".join(ts_part)), "-c copy", "-f {pack_ext}".format_map(video), - "{target_name}{suffix}.{out_ext}".format_map(video), + "\"{target_name}{suffix}.{out_ext}\"".format_map(video), ])) for _delete in ts_part: os.remove(_delete) @@ -81,7 +81,7 @@ def get_video_part_start(file): return match.group(1) -with open("../a.txt", "r", encoding="gbk") as f: +with open("a.txt", "r", encoding="gbk") as f: skip_current = False current_video = copy.deepcopy(template_current_video) for current_line in f.readlines(): diff --git a/auto_split_video.py b/auto_split_video.py index 4dd6339..bc2990b 100644 --- a/auto_split_video.py +++ b/auto_split_video.py @@ -13,7 +13,7 @@ template_current_video = { } current_line = "" -with open("../a.txt", "r", encoding="GB2312") as f: +with open("a.txt", "r", encoding="GB2312") as f: skip_current = False current_video_params = copy.deepcopy(template_current_video) for current_line in f.readlines(): @@ -23,11 +23,11 @@ with open("../a.txt", "r", encoding="GB2312") as f: skip_current = False else: os.system(" ".join([ - "ffmpeg", "-y", "-i", "{filename}.{file_ext}".format_map(current_video_params), + "ffmpeg", "-y", "-i", "\"{filename}.{file_ext}\"".format_map(current_video_params), "-c copy", "-f {pack_ext}".format_map(current_video_params), "-ss","{start}".format_map(current_video_params), "-to","{end}".format_map(current_video_params), - "{target_name}{suffix}.{out_ext}".format_map(current_video_params), + "\"{target_name}{suffix}.{out_ext}\"".format_map(current_video_params), ])) current_video_params = copy.deepcopy(template_current_video) continue