You've already forked FrameTour-RenderWorker
Compare commits
2 Commits
92160b05ea
...
windows
Author | SHA1 | Date | |
---|---|---|---|
4c05846986 | |||
8e558396c5 |
16
util/api.py
16
util/api.py
@ -20,9 +20,12 @@ def sync_center():
|
||||
:return: 任务列表
|
||||
"""
|
||||
try:
|
||||
from template import TEMPLATES, download_template
|
||||
|
||||
response = session.post(os.getenv('API_ENDPOINT') + "/sync", json={
|
||||
'accessKey': os.getenv('ACCESS_KEY'),
|
||||
'clientStatus': util.system.get_sys_info()
|
||||
'clientStatus': util.system.get_sys_info(),
|
||||
'templateList': [{'id': t.get('id', ''), 'updateTime': t.get('updateTime', '')} for t in TEMPLATES.values()]
|
||||
}, timeout=10)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as e:
|
||||
@ -31,10 +34,17 @@ def sync_center():
|
||||
data = response.json()
|
||||
logger.debug("获取任务结果:【%s】", data)
|
||||
if data.get('code', 0) == 200:
|
||||
templates = data.get('data', {}).get('templates', [])
|
||||
tasks = data.get('data', {}).get('tasks', [])
|
||||
else:
|
||||
tasks = []
|
||||
templates = []
|
||||
logger.warning("获取任务失败")
|
||||
for template in templates:
|
||||
template_id = template.get('id', '')
|
||||
if template_id:
|
||||
logger.info("更新模板:【%s】", template_id)
|
||||
download_template(template_id)
|
||||
return tasks
|
||||
|
||||
|
||||
@ -59,6 +69,7 @@ def get_template_info(template_id):
|
||||
logger.debug("获取模板信息结果:【%s】", remote_template_info)
|
||||
template = {
|
||||
'id': template_id,
|
||||
'updateTime': remote_template_info.get('updateTime', template_id),
|
||||
'scenic_name': remote_template_info.get('scenicName', '景区'),
|
||||
'name': remote_template_info.get('name', '模版'),
|
||||
'video_size': '1920x1080',
|
||||
@ -127,10 +138,11 @@ def report_task_start(task_info):
|
||||
return None
|
||||
|
||||
|
||||
def report_task_failed(task_info):
|
||||
def report_task_failed(task_info, reason=''):
|
||||
try:
|
||||
response = session.post('{0}/{1}/fail'.format(os.getenv('API_ENDPOINT'), task_info.get("id")), json={
|
||||
'accessKey': os.getenv('ACCESS_KEY'),
|
||||
'reason': reason
|
||||
}, timeout=10)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as e:
|
||||
|
@ -12,7 +12,7 @@ def to_annexb(file):
|
||||
if not os.path.exists(file):
|
||||
return file
|
||||
logger.info("ToAnnexb: %s", file)
|
||||
ffmpeg_process = subprocess.run(["ffmpeg.exe", "-y", "-hide_banner", "-i", file, "-c", "copy", "-bsf:v", "h264_mp4toannexb",
|
||||
ffmpeg_process = subprocess.run(["ffmpeg", "-y", "-hide_banner", "-i", file, "-c", "copy", "-bsf:v", "h264_mp4toannexb",
|
||||
"-f", "mpegts", file+".ts"])
|
||||
logger.info("ToAnnexb: %s, returned: %s", file, ffmpeg_process.returncode)
|
||||
if ffmpeg_process.returncode == 0:
|
||||
@ -31,7 +31,7 @@ def start_render(ffmpeg_task: FfmpegTask):
|
||||
if len(ffmpeg_args) == 0:
|
||||
ffmpeg_task.set_output_file(ffmpeg_task.input_file[0])
|
||||
return True
|
||||
ffmpeg_process = subprocess.run(["ffmpeg.exe", "-progress", "-", "-loglevel", "error", *ffmpeg_args], **subprocess_args(True))
|
||||
ffmpeg_process = subprocess.run(["ffmpeg", "-progress", "-", "-loglevel", "error", *ffmpeg_args], **subprocess_args(True))
|
||||
logger.info("FINISH TASK, OUTPUT IS %s", handle_ffmpeg_output(ffmpeg_process.stdout))
|
||||
code = ffmpeg_process.returncode
|
||||
return code == 0
|
||||
|
Reference in New Issue
Block a user