From 583f23623ff4e23e523827d0ede896fc1bcecd81 Mon Sep 17 00:00:00 2001 From: Sergio Costas Date: Mon, 28 Jul 2014 23:17:13 +0200 Subject: [PATCH] Now takes into account the desired aspect ratio Now changes the pictures for black bars and scale --- data/interface/wfile_properties.ui | 1 + src/devede/avconv_converter.py | 18 ++++++++++++---- src/devede/file_movie.py | 33 ++++++++++++++++++++++-------- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/data/interface/wfile_properties.ui b/data/interface/wfile_properties.ui index f14746c..c27242a 100644 --- a/data/interface/wfile_properties.ui +++ b/data/interface/wfile_properties.ui @@ -2244,6 +2244,7 @@ True True True + False diff --git a/src/devede/avconv_converter.py b/src/devede/avconv_converter.py index 55cb1f6..50e751b 100644 --- a/src/devede/avconv_converter.py +++ b/src/devede/avconv_converter.py @@ -114,10 +114,17 @@ class avconv_converter(devede.executor.executor): cmd_line+=",fifo," cmd_line+="hflip" -# if addbars and ((resx_inter!=resx_original) or (resy_inter!=resy_original)) and (default_res==False): -# if (cmd_line!=""): -# cmd_line+=",fifo," -# cmd_line+="scale="+str(resx_inter)+":"+str(resy_inter)+",fifo,pad="+str(resx_final)+":"+str(resy_final)+":"+str(addx)+":"+str(addy)+":0x000000" + if (file_project.width_midle != file_project.original_width) or (file_project.height_midle != file_project.original_height): + if (cmd_line!=""): + cmd_line+=",fifo," + x = (file_project.width_midle - file_project.original_width) /2 + y = (file_project.height_midle - file_project.original_height) /2 + cmd_line+="pad="+str(file_project.width_midle)+":"+str(file_project.height_midle)+":"+str(x)+":"+str(y)+":0x000000" + + if (file_project.width_final != file_project.width_midle) or (file_project.height_final != file_project.height_midle): + if (cmd_line!=""): + cmd_line+=",fifo," + cmd_line+="scale="+str(file_project.width_final)+":"+str(file_project.height_final) if cmd_line!="": self.command_var.append("-vf") @@ -236,6 +243,9 @@ class avconv_converter(devede.executor.executor): # self.command_var.append("-ofps") # self.command_var.append(str_final_framerate) + self.command_var.append("-aspect") + self.command_var.append(str(file_project.aspect_ratio_final)) + if self.config.disc_type=="divx": self.command_var.append("-vtag") self.command_var.append("DX50") diff --git a/src/devede/file_movie.py b/src/devede/file_movie.py index 0334e06..9a5c0a1 100644 --- a/src/devede/file_movie.py +++ b/src/devede/file_movie.py @@ -92,6 +92,9 @@ class file_movie(devede.interface_manager.interface_manager): self.add_enable_disable("audio_rate_automatic", [], ["audio_spinbutton"]) self.add_enable_disable("sound5_1", ["copy_sound"], []) + if (self.disc_type == "dvd"): + self.add_enable_disable("aspect_wide", [], ["size_704x576", "size_480x576","size_352x576", "size_352x288","size_704x480_ntsc", "size_480x480_ntsc","size_352x480_ntsc", "size_352x240_ntsc"]) + 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", @@ -167,8 +170,8 @@ class file_movie(devede.interface_manager.interface_manager): # The steps are: # - Decide the final aspect ratio - # - Calculate the midle size: the original video will be scaled to this size - # - Calculate the final size: the midle video will be cut to this size, or black bars will be added + # - Calculate the midle size: the original video will be cut to this size, or black bars will be added + # - Calculate the final size: the midle video will be scaled to this size aspect_wide = False # first, decide the final aspect ratio @@ -253,14 +256,14 @@ class file_movie(devede.interface_manager.interface_manager): midle_aspect_ratio = self.original_aspect_ratio if self.scaling == "scale_picture": - self.width_midle = self.width_final - self.height_midle = self.height_final + self.width_midle = self.original_width + self.height_midle = self.original_height elif self.scaling == "add_black_bars": if midle_aspect_ratio > self.aspect_ratio_final: # add horizontal black bars, at top and bottom - self.width_midle = self.width_final - self.height_midle = self.height_final * self.aspect_ratio_final / midle_aspect_ratio + self.width_midle = self.original_width + self.height_midle = self.original_height * midle_aspect_ratio / self.aspect_ratio_final else: # add vertical black bars, at left and right - self.width_midle = self.height_final * midle_aspect_ratio + self.width_midle = self.original_width * self.aspect_ratio_final / midle_aspect_ratio self.height_midle = self.original_height else: # cut picture #if midle_aspect_ratio > self.aspect_ratio_final: # add horizontal black bars, at top and bottom @@ -314,6 +317,7 @@ class file_movie(devede.interface_manager.interface_manager): self.wframe_final_size = self.builder.get_object("frame_final_size") self.wframe_aspect_ratio = self.builder.get_object("frame_aspect_ratio") self.waspect_classic = self.builder.get_object("aspect_classic") + self.waspect_wide = self.builder.get_object("aspect_wide") self.wadd_black_bars_pic = self.builder.get_object("add_black_bars_pic") self.wscale_picture_pic = self.builder.get_object("scale_picture_pic") self.wcut_picture_pic = self.builder.get_object("cut_picture_pic") @@ -379,8 +383,19 @@ class file_movie(devede.interface_manager.interface_manager): def on_aspect_classic_toggled(self,b): - status = self.waspect_classic.get_active() - if (status): + + status1 = self.waspect_classic.get_active() + status2 = self.waspect_wide.get_active() + if (status1): + final_aspect = 4.0/3.0 + elif (status2): + final_aspect = 16.0/9.0 + else: + if self.original_aspect_ratio >= 1.7: + final_aspect = 16.0/9.0 + else: + final_aspect = 4.0/3.0 + if (final_aspect < self.original_aspect_ratio): self.wadd_black_bars_pic.set_from_file(os.path.join(self.config.pic_path,"to_classic_blackbars.png")) self.wcut_picture_pic.set_from_file(os.path.join(self.config.pic_path,"to_classic_cut.png")) self.wscale_picture_pic.set_from_file(os.path.join(self.config.pic_path,"to_classic_scale.png"))