Completed the support for two-pass encoding

This commit is contained in:
Sergio Costas 2014-08-07 20:50:34 +02:00
parent ea028d50c3
commit 7646cdaf7e
5 changed files with 117 additions and 52 deletions

View file

@ -24,7 +24,7 @@ and can use only FFMpeg or AVConv for video conversion.
The current visible changes are quite small in number:
* Now allows to add several files at once
* Now make better use of multicore systems by parallelizing the conversion of several movie files
* Now makes better use of multicore systems by parallelizing the conversion of several movie files
* The menu edition is interactive
* Has a new "cut" resizing method, to allow to store as widescreen movies with black bars
* Allows to create Matroska files with H.264 video and MP3 audio
@ -37,15 +37,20 @@ The current visible changes are quite small in number:
Some of the future ideas to add to Devede NG are, without an specific order:
* allow to set properties for several files in one step
* add support for two-pass encoding
* add more backends
* add more output formats
* allow to replace the movie's audio track with one or several MP3 or OGG audio files
## History of versions ##
* version XXXXX
* Added two-pass conversion
* Now detects separately MKISOFS and GENISOIMAGE, allowing to have only one of them installed in the system
* Now checks that the number of files is smaller than the limit for DVD projects
* Now uses GLib for DBus instead of python-dbus
* Fixed the DESKTOP file to ensure that an icon is shown in the applications menu
* version 0.1 alpha 1 (2014-08-06)
* First public version
## CONTACTING THE AUTHOR ##

View file

@ -55,11 +55,6 @@
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<object class="GtkProgressBar" id="progress_total">
<property name="visible">True</property>
@ -67,8 +62,6 @@
<property name="show_text">True</property>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>

View file

@ -105,10 +105,31 @@ class avconv_converter(devede.executor.executor):
devede.executor.executor.__init__(self)
self.config = devede.configuration_data.configuration.get_config()
def convert_file(self,file_project,output_file,video_length):
def convert_file(self,file_project,output_file,video_length,pass2 = False):
if file_project.two_pass_encoding:
if pass2:
self.text = _("Converting %(X)s (pass 2)") % {"X" : file_project.title_name}
else:
self.text = _("Converting %(X)s (pass 1)") % {"X" : file_project.title_name}
# Prepare the converting process for the second pass
tmp = devede.avconv_converter.avconv_converter()
tmp.convert_file(file_project, output_file, video_length, True)
# it deppends of this process
tmp.add_dependency(self)
# 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}
if (pass2 == False) and (file_project.two_pass_encoding == True):
# this is the first pass in a 2-pass codification
second_pass = False
else:
# second_pass is TRUE in the second pass of a 2-pass codification, and also when not doing 2-pass codification
# It is used to remove unnecessary steps during the first pass, but that are needed on the second pass, or when not using 2-pass codification
second_pass = True
if (video_length == 0):
self.final_length = file_project.original_length
else:
@ -118,11 +139,11 @@ class avconv_converter(devede.executor.executor):
self.command_var.append("-i")
self.command_var.append(file_project.file_name)
if (file_project.volume!=100):
if (file_project.volume!=100) and second_pass:
self.command_var.append("-vol")
self.command_var.append(str((256*file_project.volume)/100))
if (file_project.audio_delay != 0.0) and (file_project.copy_sound==False) and (file_project.no_reencode_audio_video==False):
if (file_project.audio_delay != 0.0) and (file_project.copy_sound==False) and (file_project.no_reencode_audio_video==False) and second_pass:
self.command_var.append("-itsoffset")
self.command_var.append(str(file_project.audio_delay))
@ -135,7 +156,7 @@ class avconv_converter(devede.executor.executor):
self.command_var.append("-map")
self.command_var.append("0"+":"+str(l+1))
if (file_project.no_reencode_audio_video==False):
if (file_project.no_reencode_audio_video==False) and second_pass:
cmd_line=""
if file_project.deinterlace=="deinterlace_yadif":
@ -218,6 +239,7 @@ class avconv_converter(devede.executor.executor):
else:
self.command_var.append("pal-dvd")
if (not file_project.copy_sound):
if file_project.sound5_1:
self.command_var.append("-acodec")
self.command_var.append("ac3")
elif (self.config.disc_type=="vcd"):
@ -243,14 +265,6 @@ class avconv_converter(devede.executor.executor):
if file_project.copy_sound or file_project.no_reencode_audio_video:
self.command_var.append("-acodec")
self.command_var.append("copy")
#else:
# if (self.config.disc_type=="divx"):
# self.command_var.append("-acodec")
# self.command_var.append("mp3")
#if (audiostream!=10000):
# self.command_var.append("-aid")
# self.command_var.append(str(audiostream))
if file_project.no_reencode_audio_video:
self.command_var.append("-vcodec")
@ -298,18 +312,23 @@ class avconv_converter(devede.executor.executor):
self.command_var.append("-vtag")
self.command_var.append("DX50")
if (file_project.deinterlace == "deinterlace_ffmpeg") and (file_project.no_reencode_audio_video==False):
if (file_project.deinterlace == "deinterlace_ffmpeg") and (file_project.no_reencode_audio_video==False) and second_pass:
self.command_var.append("-deinterlace")
if (file_project.no_reencode_audio_video==False) and (vcd==False):
if (file_project.no_reencode_audio_video==False) and (vcd==False) and second_pass:
self.command_var.append("-s")
self.command_var.append(str(file_project.width_final)+"x"+str(file_project.height_final))
if second_pass:
self.command_var.append("-trellis")
self.command_var.append("1")
self.command_var.append("-mbd")
self.command_var.append("2")
else:
self.command_var.append("-trellis")
self.command_var.append("0")
self.command_var.append("-mbd")
self.command_var.append("0")
if (vcd == False) and (file_project.no_reencode_audio_video == False):
self.command_var.append("-b:a")
@ -318,8 +337,16 @@ class avconv_converter(devede.executor.executor):
self.command_var.append("-b:v")
self.command_var.append(str(file_project.video_rate_final)+"k")
if file_project.two_pass_encoding == True:
self.command_var.append("-passlogfile")
self.command_var.append(output_file)
self.command_var.append("-pass")
if pass2:
self.command_var.append("2")
else:
self.command_var.append("1")
self.command_var.append(output_file)
def create_menu_mpeg(self,n_page,background_music,sound_length,pal,video_rate, audio_rate,output_path):
@ -388,6 +415,11 @@ class avconv_converter(devede.executor.executor):
pos+=5
pos2 = data[0].find(" ",pos)
if (pos2 != -1):
t = float(data[0][pos:pos2]) / self.final_length
parts = data[0][pos:pos2].split(":")
t = 0.0
for e in parts:
t *= 60.0
t += float(e)
t /= self.final_length
self.progress_bar[1].set_fraction(t)
self.progress_bar[1].set_text("%.1f%%" % (100.0 * t))

View file

@ -105,10 +105,31 @@ class ffmpeg_converter(devede.executor.executor):
devede.executor.executor.__init__(self)
self.config = devede.configuration_data.configuration.get_config()
def convert_file(self,file_project,output_file,video_length):
def convert_file(self,file_project,output_file,video_length,pass2 = False):
if file_project.two_pass_encoding:
if pass2:
self.text = _("Converting %(X)s (pass 2)") % {"X" : file_project.title_name}
else:
self.text = _("Converting %(X)s (pass 1)") % {"X" : file_project.title_name}
# Prepare the converting process for the second pass
tmp = devede.avconv_converter.avconv_converter()
tmp.convert_file(file_project, output_file, video_length, True)
# it deppends of this process
tmp.add_dependency(self)
# 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}
if (pass2 == False) and (file_project.two_pass_encoding == True):
# this is the first pass in a 2-pass codification
second_pass = False
else:
# second_pass is TRUE in the second pass of a 2-pass codification, and also when not doing 2-pass codification
# It is used to remove unnecessary steps during the first pass, but that are needed on the second pass, or when not using 2-pass codification
second_pass = True
if (video_length == 0):
self.final_length = file_project.original_length
else:
@ -118,11 +139,11 @@ class ffmpeg_converter(devede.executor.executor):
self.command_var.append("-i")
self.command_var.append(file_project.file_name)
if (file_project.volume!=100):
if (file_project.volume!=100) and second_pass:
self.command_var.append("-vol")
self.command_var.append(str((256*file_project.volume)/100))
if (file_project.audio_delay != 0.0) and (file_project.copy_sound==False) and (file_project.no_reencode_audio_video==False):
if (file_project.audio_delay != 0.0) and (file_project.copy_sound==False) and (file_project.no_reencode_audio_video==False) and second_pass:
self.command_var.append("-itsoffset")
self.command_var.append(str(file_project.audio_delay))
@ -135,7 +156,7 @@ class ffmpeg_converter(devede.executor.executor):
self.command_var.append("-map")
self.command_var.append("0"+":"+str(l+1))
if (file_project.no_reencode_audio_video==False):
if (file_project.no_reencode_audio_video==False) and second_pass:
cmd_line=""
if file_project.deinterlace=="deinterlace_yadif":
@ -218,6 +239,7 @@ class ffmpeg_converter(devede.executor.executor):
else:
self.command_var.append("pal-dvd")
if (not file_project.copy_sound):
if file_project.sound5_1:
self.command_var.append("-acodec")
self.command_var.append("ac3")
elif (self.config.disc_type=="vcd"):
@ -290,18 +312,23 @@ class ffmpeg_converter(devede.executor.executor):
self.command_var.append("-vtag")
self.command_var.append("DX50")
if (file_project.deinterlace == "deinterlace_ffmpeg") and (file_project.no_reencode_audio_video==False):
if (file_project.deinterlace == "deinterlace_ffmpeg") and (file_project.no_reencode_audio_video==False) and second_pass:
self.command_var.append("-deinterlace")
if (file_project.no_reencode_audio_video==False) and (vcd==False):
if (file_project.no_reencode_audio_video==False) and (vcd==False) and second_pass:
self.command_var.append("-s")
self.command_var.append(str(file_project.width_final)+"x"+str(file_project.height_final))
if second_pass:
self.command_var.append("-trellis")
self.command_var.append("1")
self.command_var.append("-mbd")
self.command_var.append("2")
else:
self.command_var.append("-trellis")
self.command_var.append("0")
self.command_var.append("-mbd")
self.command_var.append("0")
if (vcd == False) and (file_project.no_reencode_audio_video == False):
self.command_var.append("-b:a")
@ -310,8 +337,16 @@ class ffmpeg_converter(devede.executor.executor):
self.command_var.append("-b:v")
self.command_var.append(str(file_project.video_rate_final)+"k")
if file_project.two_pass_encoding == True:
self.command_var.append("-passlogfile")
self.command_var.append(output_file)
self.command_var.append("-pass")
if pass2:
self.command_var.append("2")
else:
self.command_var.append("1")
self.command_var.append(output_file)
def create_menu_mpeg(self,n_page,background_music,sound_length,pal,video_rate, audio_rate,output_path):

View file

@ -58,7 +58,7 @@ class file_movie(devede.interface_manager.interface_manager):
self.add_toggle("force_subtitles", False)
self.add_toggle("mirror_horizontal", False)
self.add_toggle("mirror_vertical", False)
self.add_toggle("two_pass_encoding", True)
self.add_toggle("two_pass_encoding", False)
self.add_toggle("sound5_1", False)
self.add_toggle("copy_sound", False)
self.add_toggle("is_mpeg_ps", False)