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