Skip to content

Commit

Permalink
audio-channel-bitrate option
Browse files Browse the repository at this point in the history
Option to adjust the bitrate of the audio channels. See readme for
details
  • Loading branch information
Michael Higgins committed Sep 29, 2014
1 parent 39eff1a commit f570023
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions autoProcess.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions mkvtomp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions readSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': '',
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit f570023

Please sign in to comment.