diff --git a/SUPer/__metadata__.py b/SUPer/__metadata__.py index 8b9861f..63a2559 100644 --- a/SUPer/__metadata__.py +++ b/SUPer/__metadata__.py @@ -20,7 +20,7 @@ __MAJOR = 0 __MINOR = 1 -__REVISION = 8 +__REVISION = 9 __name__ = "SUPer" __version__ = '.'.join(map(str, [__MAJOR, __MINOR, __REVISION])) diff --git a/SUPer/interface.py b/SUPer/interface.py index 5712544..76080a3 100644 --- a/SUPer/interface.py +++ b/SUPer/interface.py @@ -56,7 +56,7 @@ def optimise(self) -> None: if self.kwargs.get('adjust_dropframe', False): if isinstance(bdn.fps, float): bdn.fps = round(bdn.fps) - logger.info(f"NTSC timing flag: using {round(bdn.fps)} for timestamps rather than BDNXML {clip_framerate:.03f}.") + logger.info(f"NTSC timing flag: scaling all timestamps by 1.001.") else: self.kwargs['adjust_dropframe'] = False logger.warning("Ignored NDF flag with integer framerate.") @@ -118,7 +118,7 @@ def scale_pcsfps(self) -> bool: ds.pcs.fps = new_pcs_fps scaled_fps = True else: - logger.error(f"Expexcted 25 or 30 fps for 2x scaling. Got '{BDVideo.LUT_FPS_PCSFPS[pcs_fps]}'.") + logger.error(f"Expected 25 or 30 fps for 2x scaling. Got '{BDVideo.LUT_FPS_PCSFPS[pcs_fps]}'.") return scaled_fps def merge(self, input_sup) -> None: @@ -137,8 +137,24 @@ def merge(self, input_sup) -> None: def write_output(self, fp: str) -> None: if self._epochs: - if fp.lower().endswith('pes'): - writer = EsMuiStream.segment_writer(fp) + is_pes = fp.lower().endswith('pes') + is_sup = fp.lower().endswith('sup') + if not (is_pes or is_sup): + logger.warning("Unknown extension, assuming a .SUP file...") + is_sup = True + if self.kwargs.get('output_all_formats', False): + is_pes = is_sup = True + if len(filepath := fp.split('.')) > 1: + fp_pes = ''.join(filepath[:-1]) + '.pes' + fp_sup = ''.join(filepath[:-1]) + '.sup' + else: + fp_pes = filepath[0] + '.pes' + fp_sup = filepath[0] + '.sup' + + if is_pes: + logger.info(f"Writing output file {fp_pes}") + + writer = EsMuiStream.segment_writer(fp_pes) next(writer) #init writer for epoch in self._epochs: for ds in epoch: @@ -147,10 +163,10 @@ def write_output(self, fp: str) -> None: # Close ESMUI writer writer.send(None) writer.close() - else: - if not fp.lower().endswith('sup'): - logger.warning("Unknown extension, assuming a .SUP file...") - with open(fp, 'wb') as f: + if is_sup: + logger.info(f"Writing output file {fp_sup}") + + with open(fp_sup, 'wb') as f: for epoch in self._epochs: f.write(bytes(epoch)) else: diff --git a/supercli.py b/supercli.py index 3a0d835..946ff18 100644 --- a/supercli.py +++ b/supercli.py @@ -70,6 +70,8 @@ def check_ext(fp: Union[Path, str]) -> None: parser.add_argument('-a', '--aheadoftime', help="Allow ahead of time decoding.", action='store_true', default=False, required=False) parser.add_argument('-p', '--palette', help="Always write the full palette.", action='store_true', default=False, required=False) parser.add_argument('-y', '--yes', help="Overwrite output file", action='store_true', default=False, required=False) + parser.add_argument('-w', '--withsup', help="Write SUP aside of PES file", action='store_true', default=False, required=False) + parser.add_argument('-v', '--version', action='version', version=f"(c) {__author__}, v{LIB_VERSION}") parser.add_argument("output", type=str) @@ -92,6 +94,9 @@ def check_ext(fp: Union[Path, str]) -> None: if ext == 'pes' and not args.palette: logger.warning("PES output: generating with full palette flag.") args.palette = True + if ext != 'pes' and args.withsup: + args.withsup = False + logger.warning("Ignoring withsup flag, output is not PES.") print("\n @@@@@@@ &@@@ @@@@ @@@@@@@\n"\ "@@@B &@@@ @@@@ @@@@ @@@@ @@@\n"\ @@ -119,6 +124,7 @@ def check_ext(fp: Union[Path, str]) -> None: 'enforce_dts': not args.nodts, 'no_overlap': not args.aheadoftime, 'full_palette': args.palette, + 'output_all_formats': args.withsup, } bdnr = BDNRender(args.input, parameters) diff --git a/supergui.py b/supergui.py index 62d0d0f..bf1d079 100644 --- a/supergui.py +++ b/supergui.py @@ -49,6 +49,7 @@ def get_kwargs() -> dict[str, int]: 'enforce_dts': set_dts.value, 'no_overlap': scenarist_checks.value, 'full_palette': scenarist_fullpal.value, + 'output_all_formats': all_formats.value, } def wrapper_mp() -> None: @@ -107,6 +108,13 @@ def monitor_mp() -> None: do_super.enabled = True do_super.text = SUPER_STRING +def hide_chkbox() -> None: + if all_formats.value: + set_dts.value = scenarist_checks.value = scenarist_fullpal.value = True + set_dts.enabled = scenarist_checks.enabled = scenarist_fullpal.enabled = False + elif not supout.value.lower().endswith('pes'): + set_dts.enabled = scenarist_checks.enabled = scenarist_fullpal.enabled = True + def get_sup() -> None: pg_sup_types = ('*.sup', '*.SUP') supname.value = app.select_file(filetypes=[["SUP", pg_sup_types], ["All files", "*"]]) @@ -136,9 +144,10 @@ def set_outputsup() -> None: scenarist_fullpal.value = True scenarist_fullpal.enabled = False else: - set_dts.enabled = True - scenarist_checks.enabled = True - scenarist_fullpal.enabled = True + if not all_formats.value: + set_dts.enabled = True + scenarist_checks.enabled = True + scenarist_fullpal.enabled = True if bdnname.value != '': do_super.enabled = True @@ -179,7 +188,6 @@ def from_bdnxml(queue: ...) -> None: logger.info(f"Merging output with {supi}") sup_obj.merge(supi) - logger.info(f"Writing output file {supo}") sup_obj.write_output(supo) logger.info("Finished, exiting...") @@ -272,6 +280,7 @@ def from_bdnxml(queue: ...) -> None: Hovertip(scenarist_fullpal.tk, "Scenarist BD mendles with the imported files and may mess up the palette assignments.\n"\ "Writing the full palette everytime ensures palette data consistency throughout the stream.") + all_formats = CheckBox(app, text="Generate both SUP and PES+MUI files.", grid=[0,pos_v:=pos_v+1,2,1], align='left', command=hide_chkbox) bspace = Box(app, layout="grid", grid=[0,pos_v:=pos_v+1,2,1]) Text(bspace, "Color space: ", grid=[0,0], align='right')