diff --git a/converter/__init__.py b/converter/__init__.py index 739f8a19..a564d1b3 100644 --- a/converter/__init__.py +++ b/converter/__init__.py @@ -72,66 +72,72 @@ def parse_options(self, opt, twopass=None): if 'audio' not in opt and 'video' not in opt and 'subtitle' not in opt: raise ConverterError('Neither audio nor video nor subtitle streams requested') - if 'audio' in opt: - y = opt['audio'] - - # Creates the new nested dictionary to preserve backwards compatability - try: - first = y.values()[0] - if not isinstance(first, dict) and first is not None: - y = {0: y} - except IndexError: - pass - - for n in y: - x = y[n] - - if not isinstance(x, dict) or 'codec' not in x: - raise ConverterError('Invalid audio codec specification') - - if 'path' in x and 'source' not in x: - raise ConverterError('Cannot specify audio path without FFMPEG source number') - - if 'source' in x and 'path' not in x: - raise ConverterError('Cannot specify alternate input source without a path') - - c = x['codec'] - if c not in self.audio_codecs: - raise ConverterError('Requested unknown audio codec ' + str(c)) - - audio_options.extend(self.audio_codecs[c]().parse_options(x, n)) - if audio_options is None: - raise ConverterError('Unknown audio codec error') - - if 'subtitle' in opt: - y = opt['subtitle'] - - # Creates the new nested dictionary to preserve backwards compatability - try: - first = y.values()[0] - if not isinstance(first, dict) and first is not None: - y = {0: y} - except IndexError: - pass - - for n in y: - x = y[n] - if not isinstance(x, dict) or 'codec' not in x: - raise ConverterError('Invalid subtitle codec specification') - - if 'path' in x and 'source' not in x: - raise ConverterError('Cannot specify subtitle path without FFMPEG source number') - - if 'source' in x and 'path' not in x: - raise ConverterError('Cannot specify alternate input source without a path') - - c = x['codec'] - if c not in self.subtitle_codecs: - raise ConverterError('Requested unknown subtitle codec ' + str(c)) - - subtitle_options.extend(self.subtitle_codecs[c]().parse_options(x, n)) - if subtitle_options is None: - raise ConverterError('Unknown subtitle codec error') + if 'audio' not in opt: + opt['audio'] = {'codec': None} + + if 'subtitle' not in opt: + opt['subtitle'] = {'codec': None} + + # Audio + y = opt['audio'] + + # Creates the new nested dictionary to preserve backwards compatability + try: + first = list(y.values())[0] + if not isinstance(first, dict): + y = {0: y} + except IndexError: + pass + + for n in y: + x = y[n] + + if not isinstance(x, dict) or 'codec' not in x: + raise ConverterError('Invalid audio codec specification') + + if 'path' in x and 'source' not in x: + raise ConverterError('Cannot specify audio path without FFMPEG source number') + + if 'source' in x and 'path' not in x: + raise ConverterError('Cannot specify alternate input source without a path') + + c = x['codec'] + if c not in self.audio_codecs: + raise ConverterError('Requested unknown audio codec ' + str(c)) + + audio_options.extend(self.audio_codecs[c]().parse_options(x, n)) + if audio_options is None: + raise ConverterError('Unknown audio codec error') + + # Subtitle + y = opt['subtitle'] + + # Creates the new nested dictionary to preserve backwards compatability + try: + first = list(y.values())[0] + if not isinstance(first, dict): + y = {0: y} + except IndexError: + pass + + for n in y: + x = y[n] + if not isinstance(x, dict) or 'codec' not in x: + raise ConverterError('Invalid subtitle codec specification') + + if 'path' in x and 'source' not in x: + raise ConverterError('Cannot specify subtitle path without FFMPEG source number') + + if 'source' in x and 'path' not in x: + raise ConverterError('Cannot specify alternate input source without a path') + + c = x['codec'] + if c not in self.subtitle_codecs: + raise ConverterError('Requested unknown subtitle codec ' + str(c)) + + subtitle_options.extend(self.subtitle_codecs[c]().parse_options(x, n)) + if subtitle_options is None: + raise ConverterError('Unknown subtitle codec error') if 'video' in opt: x = opt['video'] diff --git a/converter/avcodecs.py b/converter/avcodecs.py index b837d9b2..376a6608 100644 --- a/converter/avcodecs.py +++ b/converter/avcodecs.py @@ -105,7 +105,7 @@ def parse_options(self, opt, stream=0): if 'bitrate' in safe: optlist.extend(['-b:a:' + stream, str(safe['bitrate']) + 'k']) if 'samplerate' in safe: - optlist.extend(['-r:a:' + stream, str(safe['samplerate'])]) + optlist.extend(['-ar:a:' + stream, str(safe['samplerate'])]) if 'language' in safe: lang = str(safe['language']) else: