Browse Source

simplify main function

master
Shiz 1 year ago
parent
commit
97938bd670
1 changed files with 12 additions and 19 deletions
  1. +12
    -19
      src/overlay/__main__.py

+ 12
- 19
src/overlay/__main__.py View File

@ -12,7 +12,8 @@ parser.add_argument('infile', type=argparse.FileType('r'), help='scene descripti
parser.add_argument('--nick-font', default='/Users/partynorge/down/Montserrat/Montserrat-Bold.ttf')
parser.add_argument('--chat-font', default='/Users/partynorge/down/Montserrat/Montserrat-Light.ttf')
parser.add_argument('-n', '--nickname', help='Twitch chat nickname', default='shizacular')
parser.add_argument('-t', '--token', help='Twitch OAuth token', required=True)
parser.add_argument('-t', '--token', help='Twitch OAuth token')
parser.add_argument('-p', '--preview', help='preview using mpv', default=False, action='store_true')
parser.add_argument('channel', help='Twitch channel')
args = parser.parse_args()
@ -23,22 +24,14 @@ scene = OBSScene()
scene.load(args.infile)
# Convert scene graph
runners, graph = scene.to_ffmpeg()
chat_runner, chat_chains = make_twitch_chat('test', args.nickname, args.token, args.channel,
nick_args={'fontfile': args.nick_font},
chat_args={'fontfile': args.chat_font}
)
runners.extend(chat_runner)
graph.extend(chat_chains, link=True)
graph = scene.to_ffmpeg()
graph.fixup()
# Launch background runners
threads = {}
for r in runners:
t = threading.Thread(target=r, daemon=True)
t.start()
threads[r] = t
# Launch main process
chain = str(graph)
subprocess.run('ffmpeg -re -f lavfi -i ' + shlex.quote(chain) + ' -f nut -c:v libx264 -preset veryfast pipe:1 | ffplay -', shell=True)
ffmpeg_args = graph.format()
if args.preview:
# Launch background runners
graph.run()
# Launch main process
subprocess.run('ffmpeg ' + ' '.join(shlex.quote(a) for a in ffmpeg_args) + ' -f nut -c:v libx264 -preset veryfast pipe:1 | mpv -', shell=True)
else:
raise ValueError('TODO')

Loading…
Cancel
Save