Skip to content

Commit

Permalink
video-bitrate update
Browse files Browse the repository at this point in the history
Allows you to set a maximum video bitrate
  • Loading branch information
Michael Higgins committed Jan 22, 2015
1 parent ebbca75 commit 2565aea
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions autoProcess.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ delete_original=True
relocate_moov=True
audio-codec=ac3
video-codec=h264,x264
video-bitrate=
ios-audio=True
max-audio-channels=
audio-language=
Expand Down
14 changes: 11 additions & 3 deletions mkvtomp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def __init__( self, settings=None,
output_dir=None,
relocate_moov=True,
output_format = 'mp4',
video_codec=['h264', 'x264'],
video_codec=['h264', 'x264'],
video_bitrate=None,
audio_codec=['ac3'],
audio_bitrate=256,
iOS=False,
Expand Down Expand Up @@ -48,6 +49,7 @@ def __init__( self, settings=None,
self.relocate_moov=relocate_moov
# Video settings
self.video_codec=video_codec
self.video_bitrate=video_bitrate
# Audio settings
self.audio_codec=audio_codec
self.audio_bitrate=audio_bitrate
Expand Down Expand Up @@ -81,6 +83,7 @@ def importSettings(self, settings):
self.relocate_moov = settings.relocate_moov
#Video settings
self.video_codec=settings.vcodec
self.video_bitrate=settings.vbitrate
#Audio settings
self.audio_codec=settings.acodec
self.audio_bitrate=settings.abitrate
Expand Down Expand Up @@ -185,7 +188,12 @@ def generateOptions(self, inputfile, original=None):

#Video stream
print "Video codec detected: " + info.video.codec
vcodec = 'copy' if info.video.codec in self.video_codec else self.video_codec[0]
if self.video_bitrate is not None and info.format.bitrate > self.video_bitrate:
vcodec = self.video_codec
vbitrate = self.video_bitrate
else:
vcodec = 'copy' if info.video.codec in self.video_codec else self.video_codec[0]
vbitrate = info.format.bitrate

#Audio streams
audio_settings = {}
Expand Down Expand Up @@ -362,7 +370,7 @@ def generateOptions(self, inputfile, original=None):
'video': {
'codec': vcodec,
'map': info.video.index,
'bitrate': info.format.bitrate
'bitrate': vbitrate
},
'audio': audio_settings,
'subtitle': subtitle_settings,
Expand Down
11 changes: 11 additions & 0 deletions readSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, directory, filename):
'audio-codec': 'ac3',
'audio-channel-bitrate': '256',
'video-codec': 'h264, x264',
'video-bitrate': '',
'subtitle-language': '',
'audio-default-language': '',
'subtitle-default-language': '',
Expand Down Expand Up @@ -201,6 +202,16 @@ def __init__(self, directory, filename):
else:
self.vcodec = self.vcodec.lower().replace(' ', '').split(',')

self.vbitrate = config.get(section, "video-bitrate")
if self.vbitrate == '':
self.vbitrate = None
else:
try:
self.vbitrate = int(self.vbitrate)
except:
print "Invalid video bitrate, defaulting to no video bitrate cap"
self.vbitrate = None

self.awl = config.get(section, 'audio-language').strip().lower() # List of acceptable languages for audio streams to be carried over from the original file, separated by a comma. Blank for all
if self.awl == '':
self.awl = None
Expand Down

0 comments on commit 2565aea

Please sign in to comment.