diff --git a/README.md b/README.md index 27cfc8e1..a8c71694 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ General Installation Instructions - `max-audio-channels` = Sets a maximum number of audio channels. This may provide an alternative to the iOS audio option, where instead users can simply select the desired output codec and the max number of audio channels without the creation of an additional audio track. - `video-codec` = set your desired video codecs. May specificy multiple comma separated values (ex: h264, x264). The first value specified will be the default conversion choice when an undesired codec is encountered; any codecs specified here will be remuxed/copied rather than converted. - `audio-codec` = set your desired audio codecs. May specificy multiple comma separated values (ex: ac3, aac). The first value specified will be the default conversion choice when an undesired codec is encountered; any codecs specified here will be remuxed/copied rather than converted. + - `audio-channel-bitrate` = set the bitrate for each audio channel. Default is 256. Setting this value to 0 will attempt to mirror the bitrate of the audio source, but this can be unreliable as bitrates vary between different codecs. - `audio-language` = 3 letter language code for audio streams you wish to copy. Leave blank to copy all. Separate multiple audio streams with commas (ex: eng,spa) - `audio-default-language` = If an audio stream with an unidentified/untagged language is detected, you can default that language tag to whatever this value is (ex: eng). This is useful for many single-audio releases which don't bother to tag the audio stream as anything - `subtitle-language` = same as audio-language but for subtitles diff --git a/autoProcess.ini.sample b/autoProcess.ini.sample index 62e4c2ec..3e775fb0 100644 --- a/autoProcess.ini.sample +++ b/autoProcess.ini.sample @@ -30,6 +30,7 @@ ios-audio=True max-audio-channels= audio-language= audio-default-language= +audio-channel-bitrate= subtitle-language= subtitle-default-language= fullpathguess=True diff --git a/mkvtomp4.py b/mkvtomp4.py index 660fd87c..abc49bf3 100644 --- a/mkvtomp4.py +++ b/mkvtomp4.py @@ -21,7 +21,7 @@ def __init__( self, settings=None, output_format = 'mp4', video_codec=['h264', 'x264'], audio_codec=['ac3'], - audio_bitrate=None, + audio_bitrate=256, iOS=False, maxchannels=None, awl=None, @@ -83,7 +83,7 @@ def importSettings(self, settings): self.video_codec=settings.vcodec #Audio settings self.audio_codec=settings.acodec - #self.audio_bitrate=settings.abitrate + self.audio_bitrate=settings.abitrate self.iOS=settings.iOS self.maxchannels=settings.maxchannels self.awl=settings.awl @@ -226,10 +226,10 @@ def generateOptions(self, inputfile, original=None): audio_channels = a.audio_channels # Bitrate calculations/overrides - if self.audio_bitrate is None or self.audio_bitrate > (a.audio_channels * 256): - abitrate = 256 * audio_channels + if self.audio_bitrate is 0: + abitrate = a.bitrate else: - abitrate = self.audio_bitrate + abitrate = a.audio_channels * self.audio_bitrate audio_settings.update({l: { 'map': a.index, diff --git a/readSettings.py b/readSettings.py index 11975458..7d071ca8 100644 --- a/readSettings.py +++ b/readSettings.py @@ -35,6 +35,7 @@ def __init__(self, directory, filename): 'max-audio-channels': '', 'audio-language': '', 'audio-codec': 'ac3', + 'audio-channel-bitrate': '256', 'video-codec': 'h264, x264', 'subtitle-language': '', 'audio-default-language': '', @@ -133,6 +134,15 @@ def __init__(self, directory, filename): else: self.acodec = self.acodec.lower().replace(' ', '').split(',') + self.abitrate = config.get(section, "audio-channel-bitrate") + try: + self.abitrate = int(self.audio_bitrate) + except: + self.abitrate = 256 + print "Audio bitrate was invalid, defaulting to 256 per channel" + if self.abitrate > 256: + print "Warning - audio bitrates >256 may create errors with common codecs" + # !!! Leaving this disabled for now, users will be responsible for knowing whicn codecs do and don't work with mp4 files !!! #if self.acodec not in valid_audio_codecs: # self.acodec = 'aac'