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.

79 lines
2.1 KiB

def filter_escape(s):
return (str(s)
.replace(':', '\\:')
.replace(',', '\\,')
.replace(';', '\\;')
class FFmpegFilter:
def __init__(self, name, *, ins=[], outs=[], **args): = name
self.args = args
self.ins = ins
self.outs = outs
def __repr__(self):
return '{}({}, {}, ins={!r}, outs={!r})'.format(
', '.join('{}={}'.format(k, v) for k, v in self.args.items()),
def __str__(self):
return '{}{}{}{}{}'.format(
''.join('[{}] '.format(i) for i in self.ins),
'=' if self.args else '',
':'.join('{}={}'.format(k, filter_escape(v)) for k, v in self.args.items()),
''.join(' [{}]'.format(o) for o in self.outs),
class FFmpegChain:
def __init__(self, *filters):
self.filters = list(filters)
def append(self, f):
def extend(self, l):
def __getitem__(self, i):
return self.filters[i]
def __add__(self, o):
if not isinstance(o, FFmpegChain):
raise TypeError('incompatible')
return FFmpegChain(*(self.filters + o.filters))
def __repr__(self):
return '{}({})'.format(self.__class__.__name__, ', '.join(repr(f) for f in self.filters))
def __str__(self):
return ', '.join(str(f) for f in self.filters)
class FFmpegGraph:
def __init__(self, *chains):
self.chains = list(chains)
def append(self, f):
def extend(self, l, link=False):
if self.chains and link:
l[0][0].ins = self.chains[-1][-1].outs
def fixup(self):
self.chains[-1][-1].outs = []
def __getitem__(self, i):
return self.chains[i]
def __repr__(self):
return '{}({})'.format(self.__class__.__name__, ', '.join(repr(c) for c in self.chains))
def __str__(self):
return '; '.join(str(c) for c in self.chains)