You've already forked my-video-workflow
删除无用内容
This commit is contained in:
33
workflow/worker.py
Normal file
33
workflow/worker.py
Normal file
@ -0,0 +1,33 @@
|
||||
import os.path
|
||||
from datetime import datetime
|
||||
|
||||
from exception.danmaku import DanmakuException
|
||||
from workflow.danmaku import get_file_start, diff_danmaku_files, danmaku_to_subtitle
|
||||
from workflow.video import encode_video_with_subtitles, quick_split_video
|
||||
|
||||
|
||||
def do_workflow(video_file, danmaku_base_file, *danmaku_files):
|
||||
if not os.path.exists(danmaku_base_file):
|
||||
...
|
||||
result = []
|
||||
start_ts = get_file_start(danmaku_base_file)
|
||||
base_start = datetime.fromtimestamp(start_ts)
|
||||
new_file_name = base_start.strftime("%Y%m%d_%H%M.flv")
|
||||
result.append(danmaku_to_subtitle(danmaku_base_file, 0))
|
||||
for danmaku_file in danmaku_files:
|
||||
try:
|
||||
bias = diff_danmaku_files(danmaku_base_file, danmaku_file)
|
||||
if bias < -600:
|
||||
print("弹幕文件", danmaku_file, "反向偏移超过10分钟")
|
||||
result.append(danmaku_to_subtitle(danmaku_file, bias))
|
||||
except DanmakuException:
|
||||
print("弹幕文件", danmaku_file, "异常")
|
||||
continue
|
||||
print(result)
|
||||
encode_video_with_subtitles(video_file, result, new_file_name)
|
||||
quick_split_video(new_file_name)
|
||||
# clean files
|
||||
for file in result:
|
||||
os.remove(file)
|
||||
os.remove(new_file_name)
|
||||
|
Reference in New Issue
Block a user