Actually run ffmpeg

This commit is contained in:
boyska 2013-12-03 02:24:08 +01:00
parent 11bdd11749
commit 6c7b6d6239
2 changed files with 23 additions and 3 deletions

View file

@ -1,4 +1,5 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from subprocess import Popen
def get_timefile_exact(time): def get_timefile_exact(time):
@ -74,4 +75,16 @@ def mp3_join(named_intervals, target):
if endskip is not None: if endskip is not None:
cmdline += ['-to', str(len(files)*3600 - endskip)] cmdline += ['-to', str(len(files)*3600 - endskip)]
cmdline += [target] cmdline += [target]
cmdline += ['-loglevel', 'warning']
return cmdline return cmdline
def create_mp3(start, end, outfile, options={}, **kwargs):
p = Popen(mp3_join([(get_timefile(begin), start_cut, end_cut)
for begin, start_cut, end_cut
in get_files_and_intervals(start, end)],
outfile))
p.wait()
if p.returncode != 0:
raise OSError("return code was %d" % p.returncode)
return True

View file

@ -5,7 +5,8 @@ from functools import partial
from bottle import Bottle, request, static_file, redirect, abort from bottle import Bottle, request, static_file, redirect, abort
from techrec import Rec, RecDB from techrec import Rec, RecDB
from processqueue import get_process_queue, simulate_long_job from processqueue import get_process_queue
from forge import create_mp3
from config_manager import get_config from config_manager import get_config
@ -98,7 +99,11 @@ class RecServer:
req['filename'] = 'ror-%s-%s' % (req['recid'], newrec['name']) req['filename'] = 'ror-%s-%s' % (req['recid'], newrec['name'])
# TODO: real ffmpeg job! # TODO: real ffmpeg job!
job_id = get_process_queue().submit(simulate_long_job, **req) job_id = get_process_queue().submit(
create_mp3,
start=datetime.fromtimestamp(newrec['starttime']),
end=datetime.fromtimestamp(newrec['endtime']),
outfile=req['filename'])
print "SUBMITTED: %d" % job_id print "SUBMITTED: %d" % job_id
return self.rec_msg("Aggiornamento completato!", job_id=job_id, return self.rec_msg("Aggiornamento completato!", job_id=job_id,
result='/output/' + req['filename']) result='/output/' + req['filename'])
@ -121,7 +126,9 @@ class RecServer:
res = job.get() res = job.get()
return res return res
except Exception as exc: except Exception as exc:
return ret('FAILED') r = ret('FAILED')
r['exception'] = str(exc)
return r
return ret('WIP') return ret('WIP')
def running_jobs(self): def running_jobs(self):