diff --git a/condenser.py b/condenser.py index 978cfdb..4213a09 100644 --- a/condenser.py +++ b/condenser.py @@ -302,15 +302,14 @@ def get_srt(subtitle_streams: List[dict], file_folder: str, filename: str, temp_ def convert_sub_if_needed(sub_path: str, temp_dir: str) -> str: - sub_root, sub_ext = op.splitext(sub_path) - if sub_ext.lower() != ".srt": - srt_path = op.join(temp_dir, "out.srt") - sub_convert_cmd = [ffmpeg_cmd, "-i", sub_path, srt_path] - result = sp.run(sub_convert_cmd, capture_output=True) - if result.returncode != 0: - raise SubtitleError("Could not open subtitle file " + sub_path + ": " + str(result.stderr)) - else: - srt_path = sub_path + srt_path = op.join(temp_dir, "out.srt") + + # Run ffmpeg even if the format doesn't change, as srt files may contain non-standard markup that should be stripped + sub_convert_cmd = [ffmpeg_cmd, "-i", sub_path, "-c:s", "text", srt_path] + result = sp.run(sub_convert_cmd, capture_output=True) + if result.returncode != 0: + raise SubtitleError("Could not open subtitle file " + sub_path + ": " + str(result.stderr)) + return srt_path