From c40992d473550037814d71bd7c05e5305ce641e5 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 27 Jan 2018 01:38:39 +0100 Subject: cleanup --- src/flufigut.py | 99 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 41 deletions(-) diff --git a/src/flufigut.py b/src/flufigut.py index bc389f1..d7b4836 100755 --- a/src/flufigut.py +++ b/src/flufigut.py @@ -130,56 +130,73 @@ class Planet: 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, - }, - } + if 'samplerate' not in globals['formats'][format]: + return + + samplerate = globals['formats'][format]['samplerate'] + if samplerate == input_samplerate: + return + + 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'], - }, - } + if 'video' not in globals['profiles'][profile]: + continue + + if input_resolution == "": + raise exception("format definition needs video but no video input given") + resolution = globals['profiles'][profile]['video'] + + if input_resolution == resolution: + continue + + 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): + self.flow['encoders_audio'] = {} + self.flow['encoders_video'] = {} + self.flow['muxers'] = {} + for _, mux in muxes.items(): for format in mux['formats'].keys(): + audio_encoder = 'none' + video_encoder = 'none' if 'audio' in mux: self.__generate_audio_resampler(mux, format, inputs, globals) if 'video' in mux: -- cgit v1.2.3