summaryrefslogtreecommitdiff
path: root/src/flufigut.py
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2018-01-25 23:51:44 +0100
committerChristian Pointner <equinox@spreadspace.org>2018-01-25 23:51:44 +0100
commit67b3888899bbdd7bd80536fa8fb33fd2eac34b38 (patch)
tree1c6245cc2195dd7f65ccb972d41079855e55382a /src/flufigut.py
parentgenerating inputs works now (diff)
generate resampler and resizer
Diffstat (limited to 'src/flufigut.py')
-rwxr-xr-xsrc/flufigut.py69
1 files changed, 68 insertions, 1 deletions
diff --git a/src/flufigut.py b/src/flufigut.py
index 03dd084..bc389f1 100755
--- a/src/flufigut.py
+++ b/src/flufigut.py
@@ -70,7 +70,7 @@ class Description:
self.globals = config['globals']
self.inputs = config['inputs']
- self.muxs = config['muxes']
+ self.muxes = config['muxes']
self.streams = config['streams']
if 'records' in config:
self.records = config['records']
@@ -89,6 +89,8 @@ class Planet:
self._workers = {}
self._components = {}
+ #
+ # inputs
def __set_input_properties(self, name, props, globals):
for prop in props.keys():
if prop == 'resolution':
@@ -123,8 +125,73 @@ class Planet:
elif master_cnt > 1:
raise exception("You have configured multiple master clock devices!")
+ #
+ # muxes
+ def __generate_audio_resampler(self, mux, format, inputs, globals):
+ source = mux['audio'].split(':')[0]
+ input_samplerate = inputs[source]['properties']['samplerate']
+ if 'samplerate' in globals['formats'][format]:
+ samplerate = globals['formats'][format]['samplerate']
+ if samplerate != input_samplerate:
+ comp_name = 'resample-%s' % (source)
+ if comp_name not in self._components:
+ self._components[comp_name] = -1
+ else:
+ self._components[comp_name] = 1
+ feeder = 'input-%s' % (mux['audio'])
+ self.flow['inputs']['resample-%s-%s' % (source, samplerate)] = {
+ 'type': 'audio-resample',
+ 'desc': "resample audio from %s to %s Hz" % (source, samplerate),
+ 'worker': comp_name,
+ 'feeder': feeder,
+ 'properties': {
+ 'samplerate': samplerate,
+ },
+ }
+
+ def __generate_video_resizer(self, mux, format, inputs, globals):
+ source = mux['video'].split(':')[0]
+ input_resolution = inputs[source]['properties']['resolution']
+ for profile in mux['formats'][format]:
+ if 'video' in globals['profiles'][profile]:
+ if input_resolution == "":
+ raise exception("format definition needs video but no video input given")
+ resolution = globals['profiles'][profile]['video']
+ if input_resolution != resolution:
+ if globals['resolutions'][resolution]['rate'] != globals['resolutions'][input_resolution]['rate']:
+ raise exception("ERROR: video rate conversion is not yet supported!!!")
+ comp_name = 'resize-%s' % (source)
+ if comp_name not in self._components:
+ self._components[comp_name] = -1
+ else:
+ self._components[comp_name] = 1
+ feeder = 'input-%s' % (mux['video'])
+ self.flow['inputs']['resize-%s-%s' % (source, resolution)] = {
+ 'type': 'video-resize',
+ 'desc': "resize video from %s to %sx%s" % (source, globals['resolutions'][resolution]['width'], globals['resolutions'][resolution]['height']),
+ 'worker': comp_name,
+ 'feeder': feeder,
+ 'properties': {
+ 'width': globals['resolutions'][resolution]['width'],
+ 'height': globals['resolutions'][resolution]['height'],
+ },
+ }
+
+ def _generate_muxes(self, muxes, inputs, globals):
+ for _, mux in muxes.items():
+ for format in mux['formats'].keys():
+ if 'audio' in mux:
+ self.__generate_audio_resampler(mux, format, inputs, globals)
+ if 'video' in mux:
+ self.__generate_video_resizer(mux, format, inputs, globals)
+
+ # TODO: add encoder and muxer
+
+ #
+ # all
def generate(self, desc):
self._generate_inputs(desc.inputs, desc.globals)
+ self._generate_muxes(desc.muxes, desc.inputs, desc.globals)
# Main ########################################################