Commit 64e29a3d authored by Andreas Valder's avatar Andreas Valder

even faster thumbnails

parent 44ec93b9
......@@ -43,6 +43,7 @@ def ping_website_for_host():
if not api.worker_ping():
print("Error sending host ping")
@sched_func(5)
def get_job():
if psutil.cpu_percent(interval=3) > 85:
return
......@@ -51,6 +52,7 @@ def get_job():
return
print("id: %i, data: %s, all: %s"%(j['id'],j['data'],j))
subprocess.Popen(['./worker.py', str(j['id']), str(j['type']), str(j['priority']) , str(j['data']) ] )
print("forked")
while True:
get_job()
time.sleep(10)
......@@ -26,7 +26,7 @@ if (jobtype == 'thumbnail'):
api.job_ping(id=id)
duration = float(subprocess.run(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", inputfile], stdout=subprocess.PIPE).stdout)
api.job_ping(id=id)
if subprocess.run(["ffmpeg", "-loglevel", "error", "-ss", str(duration*0.4), "-i", inputfile, "-vf", "scale=640:360", "-frames:v", "1", outputfile]).returncode == 0:
if subprocess.run(["ffmpeg", "-loglevel", "error", "-y", "-ss", str(duration*0.4), "-i", inputfile, "-vf", "scale=640:-1", "-frames:v", "1", outputfile]).returncode == 0:
api.job_ping(id=id,state='finished')
else:
api.job_ping(id=id,state='failed')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment