add (& fix) audio rendering

This commit is contained in:
kleines Filmröllchen 2025-04-16 00:08:52 +02:00
parent be59f3ad69
commit 9712c37e9c
Signed by: filmroellchen
SSH key fingerprint: SHA256:NarU6J/XgCfEae4rbei0YIdN2pYaYDccarK6R53dnc8
3 changed files with 7 additions and 10 deletions

View file

@ -146,7 +146,7 @@ def outroFrames(args):
def debug():
render(
"intro.svg",
["intro.svg", "intro.flac"],
"../intro.ts",
introFrames,
{
@ -181,7 +181,7 @@ def tasks(queue, args, idlist, skiplist):
# generate a task description and put it into the queue
queue.put(
Rendertask(
infile="intro.svg",
infile=["intro.svg", "intro.flac"],
outfile=str(event["id"]) + ".ts",
sequence=introFrames,
parameters={

BIN
fsck2025/artwork/intro.flac Normal file

Binary file not shown.

View file

@ -41,7 +41,8 @@ class Rendertask:
def __init__(self, infile, parameters={}, outfile=None, workdir='.', sequence=None):
if isinstance(infile, list):
self.infile = infile[0]
# self.audiofile = infile[1]
self.audiofile = infile[1]
print(f"using audio file {self.audiofile}")
else:
self.infile = infile
self.audiofile = None
@ -200,16 +201,12 @@ def rendertask_video(task):
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 '
cmd += '-ar 48000 -ac 1 -f s16le -i /dev/zero '
else:
cmd += '-i {0} -i {0} '.format(task.audiofile)
cmd += '-i {0} '.format(task.audiofile)
cmd += '-map 0:0 -c:v mpeg2video -q:v 2 -aspect 16:9 '
cmd += '-map 0:0 -c:v mpeg2video -q:v 2 -aspect 16:9 -map 1:a '
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)
elif task.outfile.endswith('.mov'):
cmd = 'cd {0} && '.format(task.workdir)