From 568cb616dfcbb40e328e4b196487ecbe0fb2dd4c Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Mon, 5 Feb 2024 12:10:33 +0000 Subject: [PATCH] Use /ConvertColorsToDialog when converting subs to SRT format This is because SubtitleEdit keeps color-related information when converting to SRT from WebVTT, TTML, and such formats. Why? Not 100% sure. Maybe some players support colors, but generally if you are using SubRip, it's because you either only want basic text subs, or your player doesn't support these "fancy" ooh-la-la colors. This is a better solution to just stripped out the information. As the option name suggests, it isn't just removing the color information but rather using it to detect different speakers, then appropriately "dialogify" the captions when needed. I.e., start each speaker's sentence with `- `, and separate them with a new line. The dash-style dialog formatting is quite vital to know if a caption is all spoken by one speaker versus multiple. Not particularly necessary for non-SDH captioning, but would be wanted for SDH subtitles. --- devine/core/tracks/subtitle.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/devine/core/tracks/subtitle.py b/devine/core/tracks/subtitle.py index a4c28f8..0c98f5f 100644 --- a/devine/core/tracks/subtitle.py +++ b/devine/core/tracks/subtitle.py @@ -181,14 +181,16 @@ class Subtitle(Track): Subtitle.Codec.SubStationAlphav4: "AdvancedSubStationAlpha", Subtitle.Codec.TimedTextMarkupLang: "TimedText1.0" }.get(codec, codec.name) + sub_edit_args = [ + sub_edit_executable, + "/Convert", self.path, sub_edit_format, + f"/outputfilename:{output_path.name}", + "/encoding:utf8" + ] + if codec == Subtitle.Codec.SubRip: + sub_edit_args.append("/ConvertColorsToDialog") subprocess.run( - [ - sub_edit_executable, - "/Convert", self.path, sub_edit_format, - f"/outputfilename:{output_path.name}", - f"/outputfolder:{output_path.parent}", - "/encoding:utf8" - ], + sub_edit_args, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL