From 2c630a3d235ba6ad1bf8318273e2d0d76beb5c14 Mon Sep 17 00:00:00 2001 From: Jitterbug <3130448+JuniorIsAJitterbug@users.noreply.github.com> Date: Wed, 25 Oct 2023 22:00:38 +0100 Subject: [PATCH] Add PAL-M handling --- tbc-video-export.py | 46 +++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/tbc-video-export.py b/tbc-video-export.py index 6d39ea4..21591e9 100644 --- a/tbc-video-export.py +++ b/tbc-video-export.py @@ -24,6 +24,7 @@ class VideoSystem(Enum): PAL = "pal" + PALM = "pal-m" NTSC = "ntsc" def __str__(self): @@ -99,11 +100,18 @@ def get_opts(self): if not self.program_opts.verbose: decoder_opts.append("-q") - if self.video_system is VideoSystem.PAL: - if self.program_opts.chroma_decoder is None: - # chroma decoder unset, use transform2d + if self.program_opts.chroma_decoder is None: + # set default chroma decoder if unset + if ( + self.video_system is VideoSystem.PAL + or self.video_system is VideoSystem.PALM + ): decoder_opts.append(["-f", ChromaDecoder.TRANSFORM2D.value]) + elif self.video_system is VideoSystem.NTSC: + decoder_opts.append(["-f", ChromaDecoder.NTSC2D.value]) + + if self.video_system is VideoSystem.PAL: # vbi is set, use preset line values if self.program_opts.vbi: decoder_opts.append(["--ffll", "2"]) @@ -116,13 +124,10 @@ def get_opts(self): decoder_opts.append(["--ffrl", "118"]) decoder_opts.append(["--lfrl", "548"]) - elif self.video_system is VideoSystem.NTSC: - if self.program_opts.chroma_decoder is None: - # chroma decoder unset, use ntsc2d - decoder_opts.append(["-f", ChromaDecoder.NTSC2D.value]) - - decoder_opts.append("--ntsc-phase-comp") - + elif ( + self.video_system is VideoSystem.NTSC + or self.video_system is VideoSystem.PALM + ): # vbi is set, use preset line values if self.program_opts.vbi: decoder_opts.append(["--ffll", "1"]) @@ -135,6 +140,9 @@ def get_opts(self): decoder_opts.append(["--ffrl", "118"]) decoder_opts.append(["--lfrl", "453"]) + if self.video_system is VideoSystem.NTSC: + decoder_opts.append("--ntsc-phase-comp") + if self.program_opts.chroma_decoder is not None: decoder_opts.append( self.convert_opt(self.program_opts, "chroma_decoder", "-f") @@ -311,7 +319,10 @@ def get_rate_opt(self): if self.video_system == VideoSystem.PAL: rate = 25 - elif self.video_system == VideoSystem.NTSC: + elif ( + self.video_system == VideoSystem.NTSC + or self.video_system == VideoSystem.PALM + ): rate = 29.97 if self.profile.get_video_doublerate(): @@ -339,7 +350,10 @@ def get_color_opts(self): """Returns FFmpeg opts for color settings.""" ffmpeg_opts = [] - if self.video_system == VideoSystem.PAL: + if ( + self.video_system == VideoSystem.PAL + or self.video_system == VideoSystem.PALM + ): ffmpeg_opts.append(["-colorspace", "bt470bg"]) ffmpeg_opts.append(["-color_primaries", "bt470bg"]) ffmpeg_opts.append(["-color_trc", "bt709"]) @@ -1283,11 +1297,15 @@ def get_video_system(self, tbc_json_data): # search for PAL* or NTSC* in videoParameters.system or the existence # if isSourcePal keys if ( - VideoSystem.PAL.value in tbc_json_data["videoParameters"]["system"].lower() + VideoSystem.PAL.value == tbc_json_data["videoParameters"]["system"].lower() or "isSourcePal" in tbc_json_data["videoParameters"] - or "isSourcePalM" in tbc_json_data["videoParameters"] ): return VideoSystem.PAL + elif ( + VideoSystem.PALM.value == tbc_json_data["videoParameters"]["system"].lower() + or "isSourcePalM" in tbc_json_data["videoParameters"] + ): + return VideoSystem.PALM elif ( VideoSystem.NTSC.value in tbc_json_data["videoParameters"]["system"].lower() ):