You've already forked lubo_toolkit
初始化项目
This commit is contained in:
55
auto_split_video.py
Normal file
55
auto_split_video.py
Normal file
@ -0,0 +1,55 @@
|
||||
import os
|
||||
import copy
|
||||
|
||||
template_current_video = {
|
||||
"filename": "",
|
||||
"file_ext": "mp4",
|
||||
"pack_ext": "mp4",
|
||||
"out_ext": "mp4",
|
||||
"start": "",
|
||||
"end": "",
|
||||
"suffix": "",
|
||||
"target_name": "",
|
||||
}
|
||||
|
||||
current_line = ""
|
||||
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():
|
||||
current_line = current_line.strip()
|
||||
if current_line == "":
|
||||
if skip_current:
|
||||
skip_current = False
|
||||
else:
|
||||
os.system(" ".join([
|
||||
"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),
|
||||
]))
|
||||
current_video_params = copy.deepcopy(template_current_video)
|
||||
continue
|
||||
if current_line.startswith("=" * 5):
|
||||
break
|
||||
if "~" in current_line:
|
||||
skip_current = True
|
||||
continue
|
||||
if "+" in current_line and "-" in current_line:
|
||||
filename, time_series = current_line.split("+", 1)
|
||||
if "." in filename:
|
||||
filename, file_ext = filename.split(".", 1)
|
||||
current_video_params['file_ext'] = file_ext
|
||||
current_video_params['filename'] = filename
|
||||
suffix, _ = filename.split("_")
|
||||
current_video_params['suffix'] = "_"+suffix[4:]
|
||||
start, end = time_series.split("-", 1)
|
||||
current_video_params['start'] = start
|
||||
current_video_params['end'] = end
|
||||
else:
|
||||
if current_video_params['filename'] == "":
|
||||
skip_current = True
|
||||
continue
|
||||
current_video_params['target_name'] = current_line
|
||||
continue
|
Reference in New Issue
Block a user