Add --audio-streams flag to configure number of audio streams for .ts output

Since videos with translations appear to require at least as many audio
streams in the intro/outro as there are audio streams in the main video,
this allows to create intro/outro files for videos with more than one
translation (so far, the code already created 2 streams).
This commit is contained in:
Manfred Stock 2021-07-22 22:42:02 +02:00
parent edf8624da4
commit af310d7e3e
2 changed files with 10 additions and 4 deletions

View file

@ -56,6 +56,10 @@ parser.add_argument('--resvg', action="store_true", default=False, help='''
Render frames using resvg instead of Inkscape.
Usage: ./make.py yourproject/ --resvg
''')
parser.add_argument('--audio-streams', action="store", default=2, type=int, help='''
Number of audio streams to generate.
Usage: ./make.py yourproject/ --audio-streams 4
''')
if len(sys.argv) < 2:
parser.print_help()

View file

@ -176,16 +176,18 @@ 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 '
audio_input = '-ar 48000 -ac 1 -f s16le -i /dev/zero '
else:
cmd += '-i {0} -i {0} '.format(task.audiofile)
audio_input = '-i {0} '.format(task.audiofile)
cmd += audio_input * args.audio_streams
cmd += '-map 0:0 -c:v mpeg2video -q:v 2 -aspect 16:9 '
if task.audiofile is None:
cmd += '-map 1:0 -map 2:0 '
audio_map = '-map {0}:0 '
else:
cmd += '-map 1:0 -c:a copy -map 2:0 -c:a copy '
audio_map = '-map {0}:0 -c:a copy '
cmd += ''.join(audio_map.format(index + 1) for index in range(args.audio_streams))
cmd += '-shortest -f mpegts "{0}"'.format(task.outfile)
elif task.outfile.endswith('.mov'):
cmd = 'cd {0} && '.format(task.workdir)