避免参数中有空格导致异常
This commit is contained in:
parent
0787d24014
commit
519e70cad0
@ -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}\"",
|
||||
]))
|
||||
|
@ -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():
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user