Skip to content

Commit

Permalink
added max-audio-channel option
Browse files Browse the repository at this point in the history
A much requested feature to limit the number of audio channels for all
audio streams. Can be use in lieu of the iso-audio option to cap
channels without the creation of additional audio streams.
  • Loading branch information
michael committed Aug 20, 2014
1 parent 933faaa commit f094fbc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ General Installation Instructions
- `delete_original` = True/False
- `relocate_moov` = True/False - relocates the MOOV atom to the beginning of the file for better streaming
- `ios-audio` = creates a 2nd copy of an audio stream that will be iOS compatible (AAC Stereo) if the normal output will not be. If a stereo source stream is detected with this option enabled, an AAC stereo stream will be the only one produced (essentially overriding the codec option) to avoid multiple stereo audio stream copies in different codecs.
- `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-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)
Expand Down
1 change: 1 addition & 0 deletions autoProcess.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ relocate_moov=True
audio-codec=ac3
video-codec=h264,x264
ios-audio=True
max-audio-channels=
audio-language=
audio-default-language=
subtitle-language=
Expand Down
13 changes: 12 additions & 1 deletion mkvtomp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__( self, settings=None,
audio_codec=['ac3'],
audio_bitrate=None,
iOS=False,
maxchannels=None,
awl=None,
swl=None,
adl=None,
Expand Down Expand Up @@ -51,6 +52,7 @@ def __init__( self, settings=None,
self.audio_codec=audio_codec
self.audio_bitrate=audio_bitrate
self.iOS=iOS
self.maxchannels=maxchannels
self.awl=awl
self.adl=adl
# Subtitle settings
Expand Down Expand Up @@ -83,6 +85,7 @@ def importSettings(self, settings):
self.audio_codec=settings.acodec
#self.audio_bitrate=settings.abitrate
self.iOS=settings.iOS
self.maxchannels=settings.maxchannels
self.awl=settings.awl
self.adl=settings.adl
#Subtitle settings
Expand Down Expand Up @@ -214,10 +217,18 @@ def generateOptions(self, inputfile, original=None):
else:
abitrate = self.audio_bitrate

# Audio channel adjustments
if self.maxchannels and a.audio_channels > self.maxchannels:
audio_channels = self.maxchannels
if acodec == 'copy':
acodec = self.audio_codec[0]
else:
audio_channels = a.audio_channels

audio_settings.update({l: {
'map': a.index,
'codec': acodec,
'channels': a.audio_channels,
'channels': audio_channels,
'bitrate': abitrate,
'language': a.language,
}})
Expand Down
15 changes: 15 additions & 0 deletions readSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, directory, filename):
'delete_original': 'True',
'relocate_moov': 'True',
'ios-audio': 'True',
'max-audio-channels': '',
'audio-language': '',
'audio-codec': 'ac3',
'video-codec': 'h264, x264',
Expand Down Expand Up @@ -161,6 +162,20 @@ def __init__(self, directory, filename):

self.embedsubs = config.getboolean(section, 'embed-subs')

#Setup variable for maximum audio channels
self.maxchannels = config.get(section, 'max-audio-channels')
if self.maxchannels == ""
self.maxchannels = None
else:
try:
self.maxchannels = int(self.maxchannels)
except:
print "Invalid number of audio channels specified"
self.maxchannels = None
if self.maxchannels is not None and self.maxchannels < 1:
print "Must have at least 1 audio channel"
self.maxchannels = None

self.vcodec = config.get(section, "video-codec")
if self.vcodec == '':
self.vcodec == ['h264', 'x264']
Expand Down

0 comments on commit f094fbc

Please sign in to comment.