You've already forked FrameTour-RenderWorker
修改
This commit is contained in:
@ -33,6 +33,9 @@ def parse_ffmpeg_task(task_info, template_info):
|
|||||||
task = FfmpegTask(tasks, output_file=output_file)
|
task = FfmpegTask(tasks, output_file=output_file)
|
||||||
overall = template_info.get("overall_template")
|
overall = template_info.get("overall_template")
|
||||||
task.frame_rate = template_info.get("frame_rate", 25)
|
task.frame_rate = template_info.get("frame_rate", 25)
|
||||||
|
if overall.get('source', ''):
|
||||||
|
source = parse_video(overall.get('source'), task_params, template_info)
|
||||||
|
task.add_inputs(source)
|
||||||
for lut in overall.get('filters', []):
|
for lut in overall.get('filters', []):
|
||||||
task.add_lut(os.path.join(template_info.get("local_path"), lut))
|
task.add_lut(os.path.join(template_info.get("local_path"), lut))
|
||||||
for audio in overall.get('audios', []):
|
for audio in overall.get('audios', []):
|
||||||
@ -56,7 +59,7 @@ def parse_video(source, task_params, template_info):
|
|||||||
new_sources = new_sources[0].get("url")
|
new_sources = new_sources[0].get("url")
|
||||||
if new_sources.startswith("http"):
|
if new_sources.startswith("http"):
|
||||||
_, source_name = os.path.split(new_sources)
|
_, source_name = os.path.split(new_sources)
|
||||||
oss.download_from_oss(new_sources, source)
|
oss.download_from_oss(new_sources, source_name)
|
||||||
return source_name
|
return source_name
|
||||||
return new_sources
|
return new_sources
|
||||||
return os.path.join(template_info.get("local_path"), source)
|
return os.path.join(template_info.get("local_path"), source)
|
||||||
|
@ -2,16 +2,11 @@ from template import get_template_def
|
|||||||
from util import api
|
from util import api
|
||||||
|
|
||||||
|
|
||||||
def normalize_task(task_info):
|
|
||||||
...
|
|
||||||
return task_info
|
|
||||||
|
|
||||||
|
|
||||||
def start_task(task_info):
|
def start_task(task_info):
|
||||||
from biz.ffmpeg import parse_ffmpeg_task, start_ffmpeg_task, clear_task_tmp_file
|
from biz.ffmpeg import parse_ffmpeg_task, start_ffmpeg_task, clear_task_tmp_file
|
||||||
task_info = normalize_task(task_info)
|
task_info = api.normalize_task(task_info)
|
||||||
api.report_task_start(task_info)
|
|
||||||
template_info = get_template_def(task_info.get("templateId"))
|
template_info = get_template_def(task_info.get("templateId"))
|
||||||
|
api.report_task_start(task_info)
|
||||||
ffmpeg_task = parse_ffmpeg_task(task_info, template_info)
|
ffmpeg_task = parse_ffmpeg_task(task_info, template_info)
|
||||||
result = start_ffmpeg_task(ffmpeg_task)
|
result = start_ffmpeg_task(ffmpeg_task)
|
||||||
if not result:
|
if not result:
|
||||||
|
@ -4,7 +4,7 @@ from logging.handlers import TimedRotatingFileHandler
|
|||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.INFO)
|
||||||
root_logger = logging.getLogger()
|
root_logger = logging.getLogger()
|
||||||
rf_handler = TimedRotatingFileHandler('all_log.log', when='midnight')
|
rf_handler = TimedRotatingFileHandler('all_log.log', when='midnight')
|
||||||
rf_handler.setFormatter(logging.Formatter("[%(asctime)s][%(name)s]%(levelname)s - %(message)s"))
|
rf_handler.setFormatter(logging.Formatter("[%(asctime)s][%(name)s]%(levelname)s - %(message)s"))
|
||||||
|
@ -213,6 +213,12 @@ class FfmpegTask(object):
|
|||||||
output_args.append(f"-map")
|
output_args.append(f"-map")
|
||||||
output_args.append(audio_output_str)
|
output_args.append(audio_output_str)
|
||||||
return args + input_args + ["-filter_complex", ";".join(filter_args)] + output_args + [self.get_output_file()]
|
return args + input_args + ["-filter_complex", ";".join(filter_args)] + output_args + [self.get_output_file()]
|
||||||
|
elif self.task_type == 'copy':
|
||||||
|
if len(self.input_file) == 1:
|
||||||
|
if type(self.input_file[0]) is str:
|
||||||
|
if self.input_file[0] == self.get_output_file():
|
||||||
|
return None
|
||||||
|
return args + ["-i", self.input_file[0]] + ["-c", "copy", self.get_output_file()]
|
||||||
|
|
||||||
def set_output_file(self, file=None):
|
def set_output_file(self, file=None):
|
||||||
if file is None:
|
if file is None:
|
||||||
|
3
index.py
3
index.py
@ -12,7 +12,8 @@ while True:
|
|||||||
# print(get_sys_info())
|
# print(get_sys_info())
|
||||||
print("waiting for task...")
|
print("waiting for task...")
|
||||||
task_list = api.sync_center()
|
task_list = api.sync_center()
|
||||||
|
if len(task_list) == 0:
|
||||||
|
sleep(5)
|
||||||
for task in task_list:
|
for task in task_list:
|
||||||
print("start task:", task)
|
print("start task:", task)
|
||||||
biz.task.start_task(task)
|
biz.task.start_task(task)
|
||||||
sleep(10000)
|
|
@ -76,6 +76,8 @@ def get_template_def(template_id):
|
|||||||
|
|
||||||
def download_template(template_id):
|
def download_template(template_id):
|
||||||
template_info = api.get_template_info(template_id)
|
template_info = api.get_template_info(template_id)
|
||||||
|
if not os.path.isdir(template_info['local_path']):
|
||||||
|
os.makedirs(template_info['local_path'])
|
||||||
# download template assets
|
# download template assets
|
||||||
overall_template = template_info['overall_template']
|
overall_template = template_info['overall_template']
|
||||||
video_parts = template_info['video_parts']
|
video_parts = template_info['video_parts']
|
||||||
|
@ -9,6 +9,11 @@ session = requests.Session()
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def normalize_task(task_info):
|
||||||
|
...
|
||||||
|
return task_info
|
||||||
|
|
||||||
|
|
||||||
def sync_center():
|
def sync_center():
|
||||||
"""
|
"""
|
||||||
通过接口获取任务
|
通过接口获取任务
|
||||||
|
@ -8,6 +8,9 @@ from entity.ffmpeg import FfmpegTask
|
|||||||
def start_render(ffmpeg_task: FfmpegTask):
|
def start_render(ffmpeg_task: FfmpegTask):
|
||||||
print(ffmpeg_task)
|
print(ffmpeg_task)
|
||||||
print(ffmpeg_task.get_ffmpeg_args())
|
print(ffmpeg_task.get_ffmpeg_args())
|
||||||
|
if not ffmpeg_task.need_run():
|
||||||
|
ffmpeg_task.set_output_file(ffmpeg_task.input_file[0])
|
||||||
|
return True
|
||||||
code = os.system("ffmpeg.exe "+" ".join(ffmpeg_task.get_ffmpeg_args()))
|
code = os.system("ffmpeg.exe "+" ".join(ffmpeg_task.get_ffmpeg_args()))
|
||||||
return code == 0
|
return code == 0
|
||||||
|
|
||||||
|
@ -26,8 +26,9 @@ def download_from_oss(url, file_path):
|
|||||||
:return bool: 是否成功
|
:return bool: 是否成功
|
||||||
"""
|
"""
|
||||||
file_dir, file_name = os.path.split(file_path)
|
file_dir, file_name = os.path.split(file_path)
|
||||||
if not os.path.exists(file_dir):
|
if file_dir:
|
||||||
os.makedirs(file_dir)
|
if not os.path.exists(file_dir):
|
||||||
|
os.makedirs(file_dir)
|
||||||
try:
|
try:
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
with open(file_path, 'wb') as f:
|
with open(file_path, 'wb') as f:
|
||||||
|
Reference in New Issue
Block a user