add support for background audio during intro
This commit is contained in:
parent
7b19aa5b20
commit
c593a0dd07
3 changed files with 22 additions and 5 deletions
20
renderlib.py
20
renderlib.py
|
@ -37,7 +37,12 @@ def easeDelay(easer, delay, t, b, c, d, *args):
|
||||||
|
|
||||||
class Rendertask:
|
class Rendertask:
|
||||||
def __init__(self, infile, sequence, parameters={}, outfile=None, workdir='.'):
|
def __init__(self, infile, sequence, parameters={}, outfile=None, workdir='.'):
|
||||||
self.infile = infile
|
if isinstance(infile, list):
|
||||||
|
self.infile = infile[0]
|
||||||
|
self.audiofile = infile[1]
|
||||||
|
else:
|
||||||
|
self.infile = infile
|
||||||
|
self.audiofile = None
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
self.parameters = parameters
|
self.parameters = parameters
|
||||||
self.outfile = outfile
|
self.outfile = outfile
|
||||||
|
@ -153,7 +158,18 @@ def rendertask(task):
|
||||||
# invoke avconv aka ffmpeg and renerate a lossles-dv from the frames
|
# invoke avconv aka ffmpeg and renerate a lossles-dv from the frames
|
||||||
# if we're not in debug-mode, suppress all output
|
# if we're not in debug-mode, suppress all output
|
||||||
if task.outfile.endswith('.ts'):
|
if task.outfile.endswith('.ts'):
|
||||||
cmd = 'cd {0} && ffmpeg -f image2 -i .frames/%04d.png -ar 48000 -ac 1 -f s16le -i /dev/zero -ar 48000 -ac 1 -f s16le -i /dev/zero -map 0:0 -c:v mpeg2video -q:v 0 -aspect 16:9 -map 1:0 -map 2:0 -shortest -f mpegts "{1}"'.format(task.workdir, task.outfile)
|
cmd = 'cd {0} && '.format(task.workdir)
|
||||||
|
cmd += 'ffmpeg -f image2 -i .frames/%04d.png '
|
||||||
|
if task.audiofile is None:
|
||||||
|
cmd += '-ar 48000 -ac 1 -f s16le -i /dev/zero -ar 48000 -ac 1 -f s16le -i /dev/zero '
|
||||||
|
else:
|
||||||
|
cmd += '-i {0} -i {0} '.format(task.audiofile)
|
||||||
|
cmd += '-map 0:0 -c:v mpeg2video -q:v 0 -aspect 16:9'
|
||||||
|
if task.audiofile is None:
|
||||||
|
cmd += '-map 1:0 -map 2:0 '
|
||||||
|
else:
|
||||||
|
cmd += '-map 1:0 -c:a copy -map 2:0 -c:a copy '
|
||||||
|
cmd += '-shortest -f mpegts "{0}"'.format(task.outfile)
|
||||||
else:
|
else:
|
||||||
cmd = 'cd {0} && ffmpeg -ar 48000 -ac 2 -f s16le -i /dev/zero -f image2 -i .frames/%04d.png -target pal-dv -aspect 16:9 -shortest "{1}"'.format(task.workdir, task.outfile)
|
cmd = 'cd {0} && ffmpeg -ar 48000 -ac 2 -f s16le -i /dev/zero -f image2 -i .frames/%04d.png -target pal-dv -aspect 16:9 -shortest "{1}"'.format(task.workdir, task.outfile)
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ def pauseFrames(p):
|
||||||
|
|
||||||
def debug():
|
def debug():
|
||||||
render(
|
render(
|
||||||
'intro.svg',
|
['intro.svg', 'intro_audio.ts'],
|
||||||
'../intro.ts',
|
'../intro.ts',
|
||||||
introFrames,
|
introFrames,
|
||||||
{
|
{
|
||||||
|
@ -127,8 +127,8 @@ def tasks(queue, args):
|
||||||
|
|
||||||
# generate a task description and put them into the queue
|
# generate a task description and put them into the queue
|
||||||
queue.put(Rendertask(
|
queue.put(Rendertask(
|
||||||
infile = 'intro.svg',
|
infile = ['intro.svg', 'intro_audio.ts'],
|
||||||
outfile = str(event['id'])+".ts",
|
outfile = str(event['id']) + ".ts",
|
||||||
sequence = introFrames,
|
sequence = introFrames,
|
||||||
parameters = {
|
parameters = {
|
||||||
'$id': event['id'],
|
'$id': event['id'],
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
ffmpeg -i session_opener-25fps.mp4 given-frames/frame%04d.png
|
ffmpeg -i session_opener-25fps.mp4 given-frames/frame%04d.png
|
||||||
|
ffmpeg -i session_opener-25fps.mp4 -map 0:a -ar 48000 -ac 1 -f s16le -shortest -f mpegts intro_audio.ts
|
||||||
|
|
Loading…
Add table
Reference in a new issue