Now stores and recovers all the file properties

More changes in the interface to allow a better workflow

Started support for Matroska and H.264
This commit is contained in:
Sergio Costas 2014-07-17 00:21:36 +02:00
parent 4e6a269475
commit d59fc7c0e7
15 changed files with 1495 additions and 418 deletions

View file

@ -17,72 +17,149 @@
from gi.repository import Gtk,GObject
import os
import devede.configuration_data
import devede.interface_manager
import devede.converter
class file_movie(GObject.GObject):
class file_movie(devede.interface_manager.interface_manager):
counter2 = 0
__gsignals__ = {'title_changed': (GObject.SIGNAL_RUN_FIRST, None,(str,))}
def __init__(self,file_name):
GObject.GObject.__init__(self)
self.config = devede.configuration_data.configuration.get_config()
self.file_name = file_name
self.title_name = os.path.splitext(os.path.basename(file_name))[0]
self.wfile_properties = None
self.model = None
self.treeiter = None
self.builder = None
self.video_rate = 0
self.audio_rate = 0
self.final_size = None
self.aspect_ratio = None
devede.interface_manager.interface_manager.__init__(self)
def set_type(self,disc_type = None):
self.wfile_properties = None
self.builder = None
self.config = devede.configuration_data.configuration.get_config()
self.set_type(None, self.config.disc_type)
self.config.connect('disc_type',self.set_type)
self.add_text("file_name", file_name)
self.add_text("title_name", os.path.splitext(os.path.basename(file_name))[0])
self.add_label("original_size",None)
self.add_label("original_length",None)
self.add_label("original_videorate",None)
self.add_label("original_audiorate",None)
self.add_label("original_aspect_ratio",None)
self.add_label("original_fps",None)
self.add_toggle("show_in_menu", True)
self.add_toggle("format_pal",self.config.PAL)
self.add_toggle("video_rate_automatic", True)
self.add_toggle("audio_rate_automatic", True)
self.add_toggle("divide_in_chapters", True)
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("sound5_1", False)
self.add_toggle("copy_sound", False)
self.add_toggle("is_mpeg_ps", False)
self.add_toggle("no_reencode_audio_video", False)
if (self.disc_type == "divx") or (self.disc_type == "mkv"):
self.add_toggle("gop12", False)
else:
self.add_toggle("gop12", True)
self.add_group("final_size_pal", ["size_auto", "size_1920x1080", "size_1280x720", "size_720x576", "size_704x576", "size_480x576","size_352x576", "size_352x288"], "size_auto")
self.add_group("final_size_ntsc", ["size_auto_ntsc", "size_1920x1080_ntsc", "size_1280x720_ntsc", "size_720x480", "size_704x480", "size_480x480","size_352x480", "size_352x240"], "size_auto_ntsc")
self.add_group("aspect_ratio", ["aspect_auto", "aspect_classic", "aspect_wide"], "aspect_auto")
self.add_group("scaling", ["add_black_bars", "scale_picture" ,"cut_picture"], "add_black_bars")
self.add_group("rotation",["rotation_0","rotation_90","rotation_180","rotation_270"], "rotation_0")
self.add_group("deinterlace", ["deinterlace_none", "deinterlace_ffmpeg", "deinterlace_yadif"], "deinterlace_none")
self.add_group("actions", ["action_stop","action_play_first","action__play_previous","action_play_again","action_play_next","action_play_last"], "action_stop")
self.add_integer_adjustment("volume", 100)
if (self.disc_type == "dvd"):
self.add_integer_adjustment("video_rate", 5000)
elif (self.disc_type == "vcd"):
self.add_integer_adjustment("video_rate", 1152)
else:
self.add_integer_adjustment("video_rate", 2000)
self.add_integer_adjustment("audio_rate", 224)
self.add_integer_adjustment("subt_font_size", 28)
self.add_float_adjustment("audio_delay", 0.0)
self.add_show_hide("format_pal", ["size_pal"], ["size_ntsc"])
self.add_enable_disable("divide_in_chapters", ["chapter_size_spinbutton"], [])
self.add_enable_disable("video_rate_automatic", [], ["video_spinbutton"])
self.add_enable_disable("audio_rate_automatic", [], ["audio_spinbutton"])
self.add_enable_disable("sound5_1", ["copy_sound"], [])
self.add_enable_disable("copy_sound", [], ["audio_delay_spinbutton","audio_rate_automatic","audio_spinbutton","spinbutton_volume","scale_volume","reset_volume"])
common_elements = ["gop12","video_rate_automatic","video_spinbutton","audio_rate_automatic","audio_spinbutton","format_pal","format_ntsc","spinbutton_volume","scale_volume","reset_volume",
"size_auto", "size_1920x1080", "size_1280x720", "size_720x576", "size_704x576", "size_480x576","size_352x576", "size_352x288",
"size_auto_ntsc", "size_1920x1080_ntsc", "size_1280x720_ntsc", "size_720x480", "size_704x480", "size_480x480","size_352x480", "size_352x240",
"aspect_auto","aspect_classic","aspect_wide","mirror_horizontal","mirror_vertical","add_black_bars","scale_picture","cut_picture",
"rotation_0","rotation_90","rotation_180","rotation_270","two_pass_encoding","deinterlace_none","deinterlace_ffmpeg","deinterlace_yadif",
"audio_delay_spinbutton","sound5_1","copy_sound"]
is_mpeg_ps_list = common_elements[:]
is_mpeg_ps_list.append("no_reencode_audio_video")
is_mpeg_ps_list.append("font_size_spinbutton")
is_mpeg_ps_list.append("force_subtitles")
is_mpeg_ps_list.append("button_add_subtitles")
is_mpeg_ps_list.append("button_del_subtitles")
no_reencode_audio_video_list = common_elements[:]
no_reencode_audio_video_list.append("is_mpeg_ps")
self.add_enable_disable("is_mpeg_ps", [], is_mpeg_ps_list)
self.add_enable_disable("no_reencode_audio_video", [], no_reencode_audio_video_list)
#self.add_enable_disable("", [], [])
#cv = devede.converter.converter()
#cv.get_film_data(self)
def set_type(self,obj = None,disc_type = None):
if (disc_type != None):
self.disc_type = disc_type
if (disc_type == "dvd"):
self.video_rate = 5000
self.audio_rate = 224
self.final_size = "size_auto"
self.aspect_ratio = "aspect_auto"
elif (disc_type == "vcd"):
self.video_rate = 1152
self.audio_rate = 224
self.final_size = "size_352x288"
self.aspect_ratio = "aspect_classic"
elif (disc_type == "svcd"):
self.video_rate = 2000
self.audio_rate = 224
self.final_size = "size_480x576"
self.aspect_ratio = "aspect_classic"
elif (disc_type == "cvd"):
self.video_rate = 2000
self.audio_rate = 224
self.final_size = "size_352x576"
self.aspect_ratio = "aspect_classic"
elif (disc_type == "divx"):
self.video_rate = 5000
self.audio_rate = 224
self.final_size = "size_auto"
self.aspect_ratio = "aspect_auto"
if (disc_type == "vcd"):
self.final_size_auto_width = 352
self.final_size_auto_height_pal = 288
self.final_size_auto_height_ntsc = 240
self.video_rate_auto_value = 1152
self.audio_rate_auto_value = 224
elif (disc_type == "svcd"):
self.final_size_auto_width = 480
self.final_size_auto_height_pal = 576
self.final_size_auto_height_ntsc = 480
self.video_rate_auto_value = -1
self.audio_rate_auto_value = -1
elif (disc_type == "cvd"):
self.final_size_auto_width = 352
self.final_size_auto_height_pal = 576
self.final_size_auto_height_ntsc = 480
self.video_rate_auto_value = -1
self.audio_rate_auto_value = -1
else: # dvd, divx and mkv
self.final_size_auto_width = -1
self.final_size_auto_height_pal = -1
self.final_size_auto_height_ntsc = -1
self.video_rate_auto_value = -1
self.audio_rate_auto_value = -1
def delete_file(self):
print("Deleted file "+self.file_name)
def properties(self,model,treeiter):
def properties(self):
if (self.wfile_properties != None):
self.wfile_properties.present()
return
self.model = model
self.treeiter = treeiter
self.builder = Gtk.Builder()
self.builder.set_translation_domain(self.config.gettext_domain)
@ -90,25 +167,89 @@ class file_movie(GObject.GObject):
self.builder.connect_signals(self)
self.wfile_properties = self.builder.get_object("file_properties")
self.wfile_properties.show_all()
self.wfile = self.builder.get_object("label_filename")
self.wtitle = self.builder.get_object("entry_title")
self.wfile.set_text(self.file_name)
self.wtitle.set_text(self.title_name)
self.wshow_in_menu = self.builder.get_object("show_in_menu")
self.wnotebook = self.builder.get_object("notebook")
# elements in page GENERAL
self.wframe_video_rate = self.builder.get_object("frame_video_rate")
self.wframe_audio_rate = self.builder.get_object("frame_audio_rate")
self.wframe_division_chapters = self.builder.get_object("frame_division_chapters")
# elements in page VIDEO OPTIONS
self.wsize_1920x1080 = self.builder.get_object("size_1920x1080")
self.wsize_1280x720 = self.builder.get_object("size_1280x720")
self.wsize_1920x1080_ntsc = self.builder.get_object("size_1920x1080_ntsc")
self.wsize_1280x720_ntsc = self.builder.get_object("size_1280x720_ntsc")
self.wframe_final_size = self.builder.get_object("frame_final_size")
self.wframe_aspect_ratio = self.builder.get_object("frame_aspect_ratio")
# elements in page AUDIO
self.wsound5_1 = self.builder.get_object("sound5_1")
self.wcopy_sound = self.builder.get_object("copy_sound")
# Adjust the interface UI to the kind of disc
if (self.disc_type == 'dvd'):
self.wsize_1920x1080.hide()
self.wsize_1280x720.hide()
self.wsize_1920x1080_ntsc.hide()
self.wsize_1280x720_ntsc.hide()
elif (self.disc_type == 'vcd'):
self.wshow_in_menu.hide()
self.wframe_video_rate.hide()
self.wframe_audio_rate.hide()
self.wframe_division_chapters.hide()
self.wframe_final_size.hide()
self.wframe_aspect_ratio.hide()
self.wsound5_1.hide()
self.wcopy_sound.hide()
self.wnotebook.remove_page(5)
elif (self.disc_type == 'svcd'):
self.wsize_1920x1080.hide()
self.wsize_1280x720.hide()
self.wsize_1920x1080_ntsc.hide()
self.wsize_1280x720_ntsc.hide()
self.wshow_in_menu.hide()
self.wframe_division_chapters.hide()
self.wframe_aspect_ratio.hide()
self.wsound5_1.hide()
self.wcopy_sound.hide()
self.wnotebook.remove_page(5)
elif (self.disc_type == 'cvd'):
self.wsize_1920x1080.hide()
self.wsize_1280x720.hide()
self.wsize_1920x1080_ntsc.hide()
self.wsize_1280x720_ntsc.hide()
self.wshow_in_menu.hide()
self.wframe_division_chapters.hide()
self.wframe_aspect_ratio.hide()
self.wsound5_1.hide()
self.wcopy_sound.hide()
self.wnotebook.remove_page(5)
elif (self.disc_type == 'divx'):
self.wshow_in_menu.hide()
self.wframe_division_chapters.hide()
self.wsound5_1.hide()
self.wcopy_sound.hide()
self.wnotebook.remove_page(5)
self.wnotebook.remove_page(1)
elif (self.disc_type == 'mkv'):
self.wshow_in_menu.hide()
self.wframe_division_chapters.hide()
self.wnotebook.remove_page(5)
self.update_ui(self.builder)
def on_button_accept_clicked(self,b):
self.title_name = self.wtitle.get_text()
self.model.set_value(self.treeiter,1,self.title_name)
self.store_ui(self.builder)
self.emit('title_changed',self.title_name)
self.on_button_cancel_clicked(None)
def on_button_cancel_clicked(self,b):
self.wfile_properties.destroy()
self.wfile_properties = None
self.builder = None
self.model = None
self.treeiter = None