Skip to content

Commit 52eac62

Browse files
author
Daniel Nylander
committed
v0.11.2: Detect and reject bitmap subtitles (PGS/VobSub)
Bitmap subtitle formats (hdmv_pgs_subtitle, dvd_subtitle, dvb_subtitle, xsub) contain images, not text, and cannot be translated. Previously these were extracted as binary data and sent to DeepL, producing garbled output. - find_source_subtitle(): filter out bitmap codecs, prefer text tracks - translate_subtitle(): check codec before extraction, raise clear error - Log warning when only bitmap subtitles available Fixes: Grand Designs UK S27E06 producing 86% corrupted output
1 parent 8356088 commit 52eac62

3 files changed

Lines changed: 48 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## v0.11.2 — Bitmap subtitle detection
2+
3+
**Bug fix: Reject bitmap subtitles (PGS/VobSub/DVB)**
4+
5+
- Detect bitmap subtitle codecs (`hdmv_pgs_subtitle`, `dvd_subtitle`, `dvb_subtitle`, `xsub`) before extraction
6+
- Skip bitmap tracks in `find_source_subtitle()` — prefer text-based tracks (SRT/ASS/SSA/VTT)
7+
- Show clear error message when only bitmap subtitles are available
8+
- Prevents sending binary PGS data to DeepL (which produced garbled output)
9+
10+
Reported by Daniel via Grand Designs UK S27E06 subtitle with PGS tracks.
11+
112
## v0.11.0 (2026-03-22)
213

314
### New: Context-Aware Translation

addon.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<addon id="service.subtitletranslator"
33
name="Subtitle Translator"
4-
version="0.11.1"
4+
version="0.11.2"
55
provider-name="yeager">
66
<requires>
77
<import addon="xbmc.python" version="3.0.0"/>

service.py

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -553,20 +553,36 @@ def find_source_subtitle(self, subtitles):
553553
"""Find the best source subtitle for translation."""
554554
source_lang = self.source_language.lower()
555555

556+
# Filter out bitmap subtitle formats (PGS, VobSub, DVB) — can't translate those
557+
BITMAP_CODECS = {'hdmv_pgs_subtitle', 'dvd_subtitle', 'dvb_subtitle', 'xsub'}
558+
text_subs = [s for s in subtitles if s.get('codec', '').lower() not in BITMAP_CODECS]
559+
bitmap_subs = [s for s in subtitles if s.get('codec', '').lower() in BITMAP_CODECS]
560+
561+
if not text_subs and bitmap_subs:
562+
log(f"Only bitmap subtitles found ({len(bitmap_subs)} tracks, codecs: "
563+
f"{', '.join(s.get('codec','?') for s in bitmap_subs)}). "
564+
f"Bitmap subtitles cannot be translated — they contain images, not text.",
565+
xbmc.LOGWARNING)
566+
return None
567+
568+
if bitmap_subs:
569+
log(f"Skipping {len(bitmap_subs)} bitmap subtitle track(s), "
570+
f"using {len(text_subs)} text-based track(s)")
571+
556572
# First, try to find the specified source language
557573
if source_lang != 'auto':
558-
for sub in subtitles:
574+
for sub in text_subs:
559575
if self._lang_match(sub.get('language', ''), source_lang):
560576
return sub
561577

562578
# Fallback: look for English
563-
for sub in subtitles:
579+
for sub in text_subs:
564580
if self._lang_match(sub.get('language', ''), 'en'):
565581
return sub
566582

567-
# Last resort: take the first subtitle
568-
if subtitles:
569-
return subtitles[0]
583+
# Last resort: take the first text subtitle
584+
if text_subs:
585+
return text_subs[0]
570586

571587
return None
572588

@@ -620,6 +636,21 @@ def translate_subtitle(self, source_sub):
620636
progress.set_stage('extract', get_string(30707)) # "Extracting subtitles..."
621637
get_debug_logger().debug(f"Extracting subtitle index {source_sub.get('index', 0)}", 'ffmpeg')
622638

639+
# Check if subtitle is a bitmap format (PGS/VobSub) — can't translate those
640+
BITMAP_CODECS = {'hdmv_pgs_subtitle', 'dvd_subtitle', 'dvb_subtitle', 'xsub'}
641+
sub_codec = source_sub.get('codec', 'unknown').lower()
642+
if sub_codec in BITMAP_CODECS:
643+
error_msg = (
644+
f"Cannot translate bitmap subtitles (codec: {sub_codec}). "
645+
f"This subtitle track contains images, not text. "
646+
f"Only text-based subtitles (SRT, ASS, SSA, VTT) can be translated."
647+
)
648+
log(error_msg, xbmc.LOGWARNING)
649+
if self.show_notification:
650+
notify(get_string(30720) if get_string(30720) != '' else
651+
"Bitmap subtitles cannot be translated")
652+
raise Exception(error_msg)
653+
623654
extractor = SubtitleExtractor(ffmpeg_path)
624655
subtitle_content = extractor.extract(
625656
self.current_file,

0 commit comments

Comments
 (0)