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

import argparse
import subprocess
import shlex
import threading
from .obs import OBSScene
from .twitch_chat import make_twitch_chat
parser = argparse.ArgumentParser()
parser.add_argument('infile', type=argparse.FileType('r'), help='scene description file')
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('channel', help='Twitch channel')
args = parser.parse_args()
# Load scene
scene = OBSScene()
# Convert scene graph
runners, graph = scene.to_ffmpeg()
chat_runner, chat_chains = make_twitch_chat('test', args.nickname, args.token,,
nick_args={'fontfile': args.nick_font},
chat_args={'fontfile': args.chat_font}
graph.extend(chat_chains, link=True)
# Launch background runners
threads = {}
for r in runners:
t = threading.Thread(target=r, daemon=True)
threads[r] = t
# Launch main process
chain = str(graph)'ffmpeg -re -f lavfi -i ' + shlex.quote(chain) + ' -f nut -c:v libx264 -preset veryfast pipe:1 | ffplay -', shell=True)