Now adjusts the audio bitrate to ensure that it is legal for MP2

This commit is contained in:
Sergio Costas 2018-06-28 01:00:40 +02:00
parent 6c1a186bb0
commit f0893b3ff7
5 changed files with 31 additions and 9 deletions

View file

@ -478,7 +478,7 @@ class avconv(devedeng.avbase.avbase):
if (vcd == False) and (file_project.no_reencode_audio_video == False):
self.command_var.append("-b:a")
self.command_var.append(str(file_project.audio_rate_final*1000))
self.command_var.append(str(self._adjust_audio_bitrate(file_project.audio_rate_final)*1000))
self.command_var.append("-b:v")
self.command_var.append(str(file_project.video_rate_final*1000))
@ -494,6 +494,13 @@ class avconv(devedeng.avbase.avbase):
self.command_var.append(output_file)
def _adjust_audio_bitrate(self, bitrate):
br = [32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384]
for a in br:
if a >= bitrate:
return a
return 384
def create_menu_mpeg(self, n_page, background_music, sound_length, pal, video_rate, audio_rate, output_path, use_mp2, widescreen):
self.n_page = n_page
@ -537,7 +544,7 @@ class avconv(devedeng.avbase.avbase):
self.command_var.append("-b:v")
self.command_var.append(str(video_rate) + "k")
self.command_var.append("-b:a")
self.command_var.append(str(audio_rate) + "k")
self.command_var.append(str(self._adjust_audio_bitrate(audio_rate)) + "k")
self.command_var.append("-aspect")
if widescreen:
self.command_var.append("16:9")

View file

@ -125,7 +125,7 @@ class ffmpeg(devedeng.executor.executor):
# add it as a child process of this one
self.add_child_process(tmp)
else:
self.text = _("Converting %(X)s") % {"X": file_project.title_name}
self.text = ("Converting %(X)s") % {"X": file_project.title_name}
if (pass2 == False) and (file_project.two_pass_encoding == True):
# this is the first pass in a 2-pass codification
@ -473,7 +473,7 @@ class ffmpeg(devedeng.executor.executor):
if (vcd == False) and (file_project.no_reencode_audio_video == False):
self.command_var.append("-b:a")
self.command_var.append(str(file_project.audio_rate_final*1000))
self.command_var.append(str(self._adjust_audio_bitrate(file_project.audio_rate_final)*1000))
self.command_var.append("-b:v")
self.command_var.append(str(file_project.video_rate_final*1000))
@ -489,11 +489,20 @@ class ffmpeg(devedeng.executor.executor):
self.command_var.append(output_file)
def _adjust_audio_bitrate(self, bitrate):
br = [32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384]
for a in br:
if a >= bitrate:
print(a)
return a
print("384b")
return 384
def create_menu_mpeg(self, n_page, background_music, sound_length, pal, video_rate, audio_rate, output_path, use_mp2, widescreen):
self.n_page = n_page
self.final_length = float(sound_length)
self.text = _("Creating menu %(X)d") % {"X": self.n_page}
self.text = ("Creating menu %(X)d") % {"X": self.n_page}
self.command_var = []
self.command_var.append("ffmpeg")
@ -532,7 +541,7 @@ class ffmpeg(devedeng.executor.executor):
self.command_var.append("-b:v")
self.command_var.append(str(video_rate) + "k")
self.command_var.append("-b:a")
self.command_var.append(str(audio_rate) + "k")
self.command_var.append(str(self._adjust_audio_bitrate(audio_rate)) + "k")
self.command_var.append("-aspect")
if widescreen:
self.command_var.append("16:9")