Skip to content

Commit

Permalink
Add --audio-streams flag to configure number of audio streams for .ts…
Browse files Browse the repository at this point in the history
… 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).
  • Loading branch information
mstock committed Aug 27, 2022
1 parent edf8624 commit af310d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
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()
Expand Down
10 changes: 6 additions & 4 deletions renderlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit af310d7

Please sign in to comment.