From 5c6b98647b61e0d15af0457f3c542c9bd5944dc4 Mon Sep 17 00:00:00 2001 From: Sergio Costas Date: Tue, 1 May 2018 20:47:27 +0200 Subject: [PATCH] Added experimental support for 16:9 menues --- HISTORY.md | 1 + data/interface/wmenu.ui | 86 ++++++++++++++++++++++++++--- src/devedeng/avconv.py | 7 ++- src/devedeng/dvd_menu.py | 82 ++++++++++++--------------- src/devedeng/dvdauthor_converter.py | 73 ++++++++++++++++-------- src/devedeng/ffmpeg.py | 7 ++- src/devedeng/mux_dvd_menu.py | 3 +- src/devedeng/project.py | 9 +-- 8 files changed, 178 insertions(+), 90 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 540a2bb..9b12f8f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,7 @@ * version 4.11.0 (2018-05-01) * Added support for XFBurn + * Added experimental support for 16:9 menues * version 4.10.0 (2018-04-29) * Now, when using a custom audio in the menu, it will last the whole audio duration, not 30 seconds diff --git a/data/interface/wmenu.ui b/data/interface/wmenu.ui index 739d830..9bb8429 100644 --- a/data/interface/wmenu.ui +++ b/data/interface/wmenu.ui @@ -1,5 +1,5 @@ - + @@ -39,6 +39,9 @@ True center False + + + True @@ -257,7 +260,7 @@ False - True + False True 0 @@ -321,7 +324,7 @@ False - True + False True 0 @@ -424,6 +427,71 @@ 2 + + + True + False + 0 + none + + + True + False + 12 + + + True + False + + + 4:3 (classic) + True + True + False + True + True + + + False + True + 0 + + + + + 16:9 (widescreen) + True + True + False + True + True + menu_aspect_4_3 + + + False + True + 1 + + + + + + + + + True + False + <b>Menu aspect</b> + True + + + + + False + True + 3 + + True @@ -579,7 +647,7 @@ False True - 3 + 4 @@ -623,7 +691,7 @@ - True + False True 1 @@ -752,7 +820,7 @@ False True - 4 + 5 @@ -857,7 +925,7 @@ False True - 5 + 6 @@ -948,7 +1016,7 @@ False True - 6 + 7 @@ -990,7 +1058,7 @@ - False + True True 1 diff --git a/src/devedeng/avconv.py b/src/devedeng/avconv.py index dbde505..4b05bc7 100644 --- a/src/devedeng/avconv.py +++ b/src/devedeng/avconv.py @@ -494,7 +494,7 @@ class avconv(devedeng.avbase.avbase): self.command_var.append(output_file) - def create_menu_mpeg(self, n_page, background_music, sound_length, pal, video_rate, audio_rate, output_path, use_mp2): + 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) @@ -539,7 +539,10 @@ class avconv(devedeng.avbase.avbase): self.command_var.append("-b:a") self.command_var.append(str(audio_rate) + "k") self.command_var.append("-aspect") - self.command_var.append("4:3") + if widescreen: + self.command_var.append("16:9") + else: + self.command_var.append("4:3") self.command_var.append("-t") self.command_var.append(str(1 + sound_length)) diff --git a/src/devedeng/dvd_menu.py b/src/devedeng/dvd_menu.py index 46f64f6..320040f 100644 --- a/src/devedeng/dvd_menu.py +++ b/src/devedeng/dvd_menu.py @@ -34,8 +34,7 @@ class dvd_menu(devedeng.interface_manager.interface_manager): devedeng.interface_manager.interface_manager.__init__(self) self.config = devedeng.configuration_data.configuration.get_config() - self.default_background = os.path.join( - self.config.pic_path, "backgrounds", "default_bg.png") + self.default_background = os.path.join(self.config.pic_path, "backgrounds", "default_bg.png") self.default_sound = os.path.join(self.config.pic_path, "silence.ogg") self.add_colorbutton("title_color", (0, 0, 0, 1), self.update_preview) @@ -52,10 +51,9 @@ class dvd_menu(devedeng.interface_manager.interface_manager): self.add_text("playall_text", _("Play all"), self.update_preview) - self.add_group("position_horizontal", [ - "left", "center", "right"], "center", self.update_preview) - self.add_group("at_startup", [ - "menu_show_at_startup", "play_first_title_at_startup"], "menu_show_at_startup") + self.add_group("position_horizontal", ["left", "center", "right"], "center", self.update_preview) + self.add_group("at_startup", ["menu_show_at_startup", "play_first_title_at_startup"], "menu_show_at_startup") + self.add_group("menu_aspect_ratio", ["menu_aspect_4_3", "menu_aspect_16_9"], "menu_aspect_4_3", self.on_menu_aspect_changed) self.add_toggle("play_all_c", False, self.update_preview) self.add_integer_adjustment("sound_length", 30) @@ -72,10 +70,8 @@ class dvd_menu(devedeng.interface_manager.interface_manager): self.add_fontbutton("title_font", "Sans 28", self.update_preview) self.add_fontbutton("entry_font", "Sans 28", self.update_preview) - self.add_filebutton("background_picture", - self.default_background, self.update_preview) - self.add_filebutton("background_music", - self.default_sound, self.update_music) + self.add_filebutton("background_picture", self.default_background, self.update_preview) + self.add_filebutton("background_music", self.default_sound, self.update_music) self.cached_menu_font = None self.cached_menu_size = 0 @@ -346,13 +342,20 @@ class dvd_menu(devedeng.interface_manager.interface_manager): coordinates = [] if self.sf is None: - self.sf = cairo.ImageSurface(cairo.FORMAT_ARGB32, 720, int(self.y)) + if self.to_png: + self.sf = cairo.ImageSurface(cairo.FORMAT_ARGB32, 720, int(self.y)) + else: + self.sf = cairo.ImageSurface(cairo.FORMAT_ARGB32, 720, 540) self.cr = cairo.Context(self.sf) + if not self.to_png: + if self.menu_aspect_ratio == "menu_aspect_16_9": + self.cr.scale(1.0,405.0 / self.y) + else: + self.cr.scale(1.0,540.0 / self.y) if self.cached_menu_font != self.entry_font: # memorize the font sizes - (fontname, fontstyle, fontslant, - fontsize) = self.get_font_params(self.entry_font) + (fontname, fontstyle, fontslant, fontsize) = self.get_font_params(self.entry_font) self.cr.select_font_face(fontname, fontslant, fontstyle) self.cr.set_font_size(fontsize) extents = self.cr.font_extents() @@ -360,35 +363,27 @@ class dvd_menu(devedeng.interface_manager.interface_manager): self.cached_menu_font = self.entry_font if paint_background: - extra_pixbuf = GdkPixbuf.Pixbuf.new_from_file( - self.background_picture) + extra_pixbuf = GdkPixbuf.Pixbuf.new_from_file(self.background_picture) extra_x = float(extra_pixbuf.get_width()) extra_y = float(extra_pixbuf.get_height()) self.cr.save() self.cr.scale(720.0 / extra_x, self.y / extra_y) - surface = Gdk.cairo_surface_create_from_pixbuf( - extra_pixbuf, 1, None) + surface = Gdk.cairo_surface_create_from_pixbuf(extra_pixbuf, 1, None) self.cr.set_source_surface(surface, 0, 0) self.cr.paint() self.cr.restore() hmargin = self.title_horizontal * 720.0 / 100.0 - self.write_text(self.title_text, "title", 0 + hmargin, 720 + - hmargin, self.title_vertical * self.y / 100.0, "center") -# else: -# self.cr.set_source_rgb(1.0,1.0,1.0) -# self.cr.paint() + self.write_text(self.title_text, "title", 0 + hmargin, 720 + hmargin, self.title_vertical * self.y / 100.0, "center") top_margin_p = self.y * self.margin_top / 100.0 bottom_margin_p = self.y * self.margin_bottom / 100.0 left_margin_p = 720.0 * self.margin_left / 100.0 right_margin_p = 720.0 * self.margin_right / 100.0 - entry_height = self.cached_menu_size + \ - self.entry_vertical_margin * 2.0 + self.entry_separation - entries_per_page = int( - (self.y - top_margin_p - bottom_margin_p) / entry_height) + entry_height = self.cached_menu_size + self.entry_vertical_margin * 2.0 + self.entry_separation + entries_per_page = int((self.y - top_margin_p - bottom_margin_p) / entry_height) if (self.play_all_c): entries_per_page -= 1 n_entries = len(self.title_list) @@ -518,13 +513,16 @@ class dvd_menu(devedeng.interface_manager.interface_manager): self.current_shown_page = 0 self.update_preview() + def on_menu_aspect_changed(self, b=None): + self.update_preview() + def on_drawingarea_preview_draw(self, widget, cr): """ Callback to repaint the menu preview window when it sends the EXPOSE event """ if (self.sf is None): - self.paint_menu(True, self.wshow_as_selected.get_active( - ), False, self.current_shown_page) + self.to_png = False + self.paint_menu(True, self.wshow_as_selected.get_active(), False, self.current_shown_page) if (self.current_shown_page >= self.pages): self.current_shown_page = self.pages @@ -544,12 +542,9 @@ class dvd_menu(devedeng.interface_manager.interface_manager): # transparent="000000"') xml_file.write( '\n\t\n\t\t\n') n_elements = 0 has_next = False @@ -637,26 +632,21 @@ class dvd_menu(devedeng.interface_manager.interface_manager): menu_converter = cv.get_menu_converter() while n_page < self.pages: self.sf = None + self.to_png = True coordinates = self.paint_menu(True, False, False, n_page) - self.sf.write_to_png(os.path.join( - menu_folder, "menu_" + str(n_page) + "_bg.png")) + self.sf.write_to_png(os.path.join(menu_folder, "menu_" + str(n_page) + "_bg.png")) self.sf = None self.paint_menu(False, False, False, n_page) - self.sf.write_to_png(os.path.join( - menu_folder, "menu_" + str(n_page) + "_unselected_bg.png")) + self.sf.write_to_png(os.path.join(menu_folder, "menu_" + str(n_page) + "_unselected_bg.png")) self.sf = None self.paint_menu(False, True, False, n_page) - self.sf.write_to_png(os.path.join( - menu_folder, "menu_" + str(n_page) + "_selected_bg.png")) + self.sf.write_to_png(os.path.join(menu_folder, "menu_" + str(n_page) + "_selected_bg.png")) self.sf = None self.paint_menu(False, False, True, n_page) - self.sf.write_to_png(os.path.join( - menu_folder, "menu_" + str(n_page) + "_active_bg.png")) - entry_data = self.create_menu_stream( - menu_folder, n_page, coordinates) + self.sf.write_to_png(os.path.join(menu_folder, "menu_" + str(n_page) + "_active_bg.png")) + entry_data = self.create_menu_stream(menu_folder, n_page, coordinates) converter = menu_converter() - final_path = converter.create_menu_mpeg( - n_page, self.background_music, self.sound_length, self.config.PAL, self.video_rate, self.audio_rate, menu_folder, self.audio_mp2) + final_path = converter.create_menu_mpeg(n_page, self.background_music, self.sound_length, self.config.PAL, self.video_rate, self.audio_rate, menu_folder, self.audio_mp2, self.menu_aspect_ratio == "menu_aspect_16_9") entry_data["filename"] = final_path menu_entries.append(entry_data) # add this process without dependencies diff --git a/src/devedeng/dvdauthor_converter.py b/src/devedeng/dvdauthor_converter.py index bbc8026..a30bf7b 100644 --- a/src/devedeng/dvdauthor_converter.py +++ b/src/devedeng/dvdauthor_converter.py @@ -29,7 +29,7 @@ class dvdauthor_converter(devedeng.executor.executor): devedeng.executor.executor.__init__(self) self.config = devedeng.configuration_data.configuration.get_config() - def create_dvd_project(self, path, name, file_movies, menu_entries, start_with_menu, play_all_opt): + def create_dvd_project(self, path, name, file_movies, menu_entries, start_with_menu, play_all_opt, menuWide): movie_path = os.path.join(path, "dvd_tree") try: @@ -37,8 +37,7 @@ class dvdauthor_converter(devedeng.executor.executor): except: pass - xml_file = self.create_dvdauthor_xml( - path, file_movies, menu_entries, start_with_menu, play_all_opt) + xml_file = self.create_dvdauthor_xml(path, file_movies, menu_entries, start_with_menu, play_all_opt, menuWide) self.command_var = [] self.command_var.append("dvdauthor") @@ -57,7 +56,7 @@ class dvdauthor_converter(devedeng.executor.executor): self.progress_bar[1].set_text(data[0]) return - def create_dvdauthor_xml(self, movie_folder, file_movies, menu_entries, start_with_menu, play_all_opt): + def create_dvdauthor_xml(self, movie_folder, file_movies, menu_entries, start_with_menu, play_all_opt, menuWide): xmlpath = os.path.join(movie_folder, "xml_data") xml_file_path = os.path.join(xmlpath, "dvdauthor.xml") @@ -89,7 +88,11 @@ class dvdauthor_converter(devedeng.executor.executor): xml_file.write("pal") else: xml_file.write("ntsc") - xml_file.write('" aspect="4:3"> \n') + if menuWide: + xml_file.write('" aspect="16:9"> ') + else: + xml_file.write('" aspect="4:3"> ') + xml_file.write('\n') xml_file.write("\t\t\n") xml_file.write('\t\n') else: @@ -128,7 +131,11 @@ class dvdauthor_converter(devedeng.executor.executor): xml_file.write("pal") else: xml_file.write("ntsc") - xml_file.write('" aspect="4:3"> \n') + if menuWide: + xml_file.write('" aspect="16:9"> ') + else: + xml_file.write('" aspect="4:3"> ') + xml_file.write('\n') xml_file.write('\t\t\t\n') xml_file.write('\t\t\t\t
\n')
@@ -149,12 +156,16 @@ class dvdauthor_converter(devedeng.executor.executor):
             # 100% compatibility
             xml_file.write('\t\t\t\t\n')
             xml_file.write('\t\t\t\n')
@@ -173,7 +184,11 @@ class dvdauthor_converter(devedeng.executor.executor):
                 xml_file.write("pal")
             else:
                 xml_file.write("ntsc")
-            xml_file.write('" aspect="4:3"> \n')
+            if menuWide:
+                xml_file.write('" aspect="16:9"> ')
+            else:
+                xml_file.write('" aspect="4:3"> ')
+            xml_file.write('\n')
 
             first_entry = True
             menu_number = 0
@@ -275,12 +290,16 @@ class dvdauthor_converter(devedeng.executor.executor):
 
                 xml_file.write('\t\t\t\t
\n') xml_file.write('\t\t\t\t\n') xml_file.write('\t\t\t\t\n') @@ -298,15 +317,23 @@ class dvdauthor_converter(devedeng.executor.executor): xml_file.write("pal") else: xml_file.write("ntsc") - xml_file.write('" aspect="4:3"> \n') + if menuWide: + xml_file.write('" aspect="16:9"> ') + else: + xml_file.write('" aspect="4:3"> ') + xml_file.write('\n') xml_file.write('\t\t\t\n') xml_file.write('\t\t\t\t\n') xml_file.write('\t\t\t\t\n') xml_file.write('\t\t\t\t\tg0=1;\n') diff --git a/src/devedeng/ffmpeg.py b/src/devedeng/ffmpeg.py index b89b11a..e70d61b 100644 --- a/src/devedeng/ffmpeg.py +++ b/src/devedeng/ffmpeg.py @@ -489,7 +489,7 @@ class ffmpeg(devedeng.executor.executor): self.command_var.append(output_file) - def create_menu_mpeg(self, n_page, background_music, sound_length, pal, video_rate, audio_rate, output_path, use_mp2): + 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) @@ -534,7 +534,10 @@ class ffmpeg(devedeng.executor.executor): self.command_var.append("-b:a") self.command_var.append(str(audio_rate) + "k") self.command_var.append("-aspect") - self.command_var.append("4:3") + if widescreen: + self.command_var.append("16:9") + else: + self.command_var.append("4:3") self.command_var.append("-t") self.command_var.append(str(1 + sound_length)) diff --git a/src/devedeng/mux_dvd_menu.py b/src/devedeng/mux_dvd_menu.py index e8e62e1..5146f0d 100644 --- a/src/devedeng/mux_dvd_menu.py +++ b/src/devedeng/mux_dvd_menu.py @@ -38,8 +38,7 @@ class mux_dvd_menu(devedeng.executor.executor): self.command_var = [] self.command_var.append("spumux") - self.command_var.append(os.path.join( - output_path, "menu_" + str(n_page) + ".xml")) + self.command_var.append(os.path.join(output_path, "menu_" + str(n_page) + ".xml")) self.stdin_file = movie_path self.stdout_file = final_path diff --git a/src/devedeng/project.py b/src/devedeng/project.py index 78816ba..8eb1d64 100644 --- a/src/devedeng/project.py +++ b/src/devedeng/project.py @@ -491,8 +491,7 @@ class devede_project: file_movies = self.get_all_files() t = len(file_movies) if (max_files != -1) and (t > max_files): - devedeng.message.message_window(_("The limit for this format is %(l)d files, but your project has %(h)d.") % { - "l": max_files, "h": t}, _("Too many files in the project")) + devedeng.message.message_window(_("The limit for this format is %(l)d files, but your project has %(h)d.") % {"l": max_files, "h": t}, _("Too many files in the project")) return data = devedeng.create_disk_window.create_disk_window() @@ -532,8 +531,7 @@ class devede_project: final_dependencies = [] if (self.disc_type == "dvd") and (self.wcreate_menu.get_active()): - processes, menu_entries = self.menu.create_dvd_menus( - file_movies, data.path) + processes, menu_entries = self.menu.create_dvd_menus(file_movies, data.path) for p in processes: run_window.add_process(p) final_dependencies.append(p) @@ -565,8 +563,7 @@ class devede_project: else: start_with_menu = False dvdauthor = devedeng.dvdauthor_converter.dvdauthor_converter() - dvdauthor.create_dvd_project( - data.path, data.name, file_movies, menu_entries, start_with_menu, self.menu.play_all_c) + dvdauthor.create_dvd_project(data.path, data.name, file_movies, menu_entries, start_with_menu, self.menu.play_all_c, self.menu.menu_aspect_ratio == "menu_aspect_16_9") # dvdauthor must wait until all the files have been converted for element in final_dependencies: dvdauthor.add_dependency(element)