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.
 

60 lines
1.4 KiB

import json
from ..filters import FFmpegGraph
class OBSSource:
TYPES = {}
def __init__(self, name='Untitled'):
self.name = name
def load(self, data):
raise NotImplementedError
def to_ffmpeg(self, scene):
raise NotImplementedError
@classmethod
def register(cls, type, c):
cls.TYPES[type] = c
@classmethod
def type(cls, type):
def inner(c):
cls.register(type, c)
return c
return inner
@classmethod
def find_and_load(cls, data):
name = data['name']
type = data['id']
if type not in cls.TYPES:
raise NotImplementedType('unknown type: {}'.format(type))
s = cls.TYPES[type](name)
s.load(data)
return s
class OBSScene:
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.sources = {}
self.current_scene = None
self.dimensions = (1280, 720)
def load(self, infile):
data = json.load(infile)
self.current_scene = data['current_scene']
for src in data['sources']:
self.sources[src['name']] = OBSSource.find_and_load(src)
def to_ffmpeg(self, scene=None):
scene = scene or self.current_scene
runners, chains = self.sources[scene].to_ffmpeg(self)
r = FFmpegGraph()
r.extend(chains)
return runners, r