Multi-DJ livestream toolkit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.4 KiB

2 years ago
  1. import argparse
  2. import subprocess
  3. import shlex
  4. import threading
  5. from .obs import OBSScene
  6. from .twitch_chat import make_twitch_chat
  7. parser = argparse.ArgumentParser()
  8. parser.add_argument('infile', type=argparse.FileType('r'), help='scene description file')
  9. parser.add_argument('--nick-font', default='/Users/partynorge/down/Montserrat/Montserrat-Bold.ttf')
  10. parser.add_argument('--chat-font', default='/Users/partynorge/down/Montserrat/Montserrat-Light.ttf')
  11. parser.add_argument('-n', '--nickname', help='Twitch chat nickname', default='shizacular')
  12. parser.add_argument('-t', '--token', help='Twitch OAuth token', required=True)
  13. parser.add_argument('channel', help='Twitch channel')
  14. args = parser.parse_args()
  15. # Load scene
  16. scene = OBSScene()
  17. scene.load(args.infile)
  18. # Convert scene graph
  19. runners, graph = scene.to_ffmpeg()
  20. chat_runner, chat_chains = make_twitch_chat('test', args.nickname, args.token, args.channel,
  21. nick_args={'fontfile': args.nick_font},
  22. chat_args={'fontfile': args.chat_font}
  23. )
  24. runners.extend(chat_runner)
  25. graph.extend(chat_chains, link=True)
  26. graph.fixup()
  27. # Launch background runners
  28. threads = {}
  29. for r in runners:
  30. t = threading.Thread(target=r, daemon=True)
  31. t.start()
  32. threads[r] = t
  33. # Launch main process
  34. chain = str(graph)
  35. subprocess.run('ffmpeg -re -f lavfi -i ' + shlex.quote(chain) + ' -f nut -c:v libx264 -preset veryfast pipe:1 | ffplay -', shell=True)