{"record":{"id":"646a20ea2f117375","repo":"SubtitleEdit/subtitleedit","slug":"no-pgs-subtitles-in-mkv-track-track-tracknumber-646a20","errorCode":null,"errorMessage":"No PGS subtitles in MKV track #{track.TrackNumber}.","messagePattern":"No PGS subtitles in MKV track #(.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/seconv/Core/ImageOcrLoader.cs","lineNumber":54,"sourceCode":"            return PcsListToSubtitle(pcsList, null);\n        }\n\n        using var ocr = OcrEngineFactory.Create(options);\n        var isolationNote = options.PgsIsolateColors ? string.Empty : \" (colour isolation off)\";\n        AnsiConsole.MarkupLine($\"[dim]Running {ocr.Name} OCR on {pcsList.Count} Blu-Ray sup image(s){isolationNote}...[/]\");\n        return PcsListToSubtitle(pcsList, ocr, options.PgsIsolateColors);\n    }\n\n    /// <summary>\n    /// MKV PGS track (S_HDMV/PGS) → text via the configured OCR engine, or time codes only\n    /// when <see cref=\"ConversionOptions.TimeCodesOnly\"/> is set.\n    /// </summary>\n    public static Subtitle LoadMatroskaPgs(MatroskaFile matroska, MatroskaTrackInfo track, ConversionOptions options)\n    {\n        var pcsList = BluRaySupParser.ParseBluRaySupFromMatroska(track, matroska);\n        if (pcsList.Count == 0)\n        {\n            throw new InvalidOperationException($\"No PGS subtitles in MKV track #{track.TrackNumber}.\");\n        }\n\n        if (options.TimeCodesOnly)\n        {\n            AnsiConsole.MarkupLine($\"[dim]Extracting time codes from {pcsList.Count} MKV PGS image(s) (track #{track.TrackNumber}, no OCR)...[/]\");\n            return PcsListToSubtitle(pcsList, null);\n        }\n\n        using var ocr = OcrEngineFactory.Create(options);\n        var isolationNote = options.PgsIsolateColors ? string.Empty : \" (colour isolation off)\";\n        AnsiConsole.MarkupLine($\"[dim]Running {ocr.Name} OCR on {pcsList.Count} MKV PGS image(s) (track #{track.TrackNumber}){isolationNote}...[/]\");\n        return PcsListToSubtitle(pcsList, ocr, options.PgsIsolateColors);\n    }\n\n    /// <summary>\n    /// Transport stream DVB-sub → text via the configured OCR engine, or time codes only\n    /// when <see cref=\"ConversionOptions.TimeCodesOnly\"/> is set. Returns one Subtitle per\n    /// packet ID that has subtitles. Teletext PIDs are not handled here (they're already","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/seconv/Core/ImageOcrLoader.cs#L36-L72","documentation":"Thrown by ImageOcrLoader.LoadMatroskaPgs when BluRaySupParser.ParseBluRaySupFromMatroska(track, matroska) returns an empty PCS list for the given MKV PGS track (codec S_HDMV/PGS). The track was selected as a PGS subtitle track but its embedded PGS data decoded to zero presentation composition segments, so there is nothing to OCR.","triggerScenarios":"Calling LoadMatroskaPgs(matroska, track, options) on an MKV PGS track whose payload contains no usable PCS entries (ImageOcrLoader.cs:55). Occurs with a corrupt/truncated PGS track or a track flagged S_HDMV/PGS that is actually empty.","commonSituations":"A PGS track truncated during muxing; an MKV whose PGS packets were corrupted by a faulty remux; a placeholder PGS track; a track whose PGS data is compressed/encoded in a way the parser rejects.","solutions":["Extract the PGS track to a standalone .sup (mkvextract / ffmpeg) and validate it with BDSup2Sub.","Re-mux the MKV from the original Blu-ray source including the intact PGS track.","If the track is empty/corrupt, select a different PGS track or re-extract subtitles from the source."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Extract the PGS track to .sup first and validate, then OCR the standalone file.\n// (No public pre-check for embedded PGS; rely on the loader guard.)","typeGuard":null,"tryCatchPattern":"try { sub = ImageOcrLoader.LoadMatroskaPgs(matroska, track, options); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"No PGS subtitles in MKV track\"))\n{ AnsiConsole.MarkupLine($\"[yellow]Skipping PGS track #{track.TrackNumber}: {ex.Message.EscapeMarkup()}[/]\"); continue; }","preventionTips":["Extract the PGS track with mkvextract/ffmpeg and validate it with BDSup2Sub before OCR.","Re-mux MKVs from the original source to preserve intact PGS payloads.","Catch the InvalidOperationException per-track so other MKV tracks still convert."],"tags":["matroska","mkv","pgs","subtitle","ocr","no-content"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}