添加util.flask;video_clip编辑逻辑

This commit is contained in:
2022-04-19 09:42:39 +08:00
parent 3f5df9df29
commit df20bab1ac
5 changed files with 105 additions and 18 deletions

@ -52,6 +52,12 @@ def handle_ffmpeg_output(stderr: IO[bytes]) -> None:
print("Speed", speed.strip())
def duration_str_to_float(duration_str) -> float:
_duration = datetime.strptime(duration_str, "%H:%M:%S.%f") - datetime(1900, 1, 1)
return _duration.total_seconds()
def quick_split_video(file):
if not os.path.isfile(file):
raise FileNotFoundError(file)
@ -59,8 +65,7 @@ def quick_split_video(file):
_create_dt = os.path.splitext(file_name)[0]
create_dt = datetime.strptime(_create_dt, "%Y%m%d_%H%M")
_duration_str = get_video_real_duration(file)
_duration = datetime.strptime(_duration_str, "%H:%M:%S.%f") - datetime(1900, 1, 1)
duration = _duration.total_seconds()
duration = duration_str_to_float(_duration_str)
current_sec = 0
while current_sec < duration:
current_dt = (create_dt + timedelta(seconds=current_sec)).strftime("%Y%m%d_%H%M_")