{"record":{"id":"f46076014b359259","repo":"SubtitleEdit/subtitleedit","slug":"no-pgs-subtitles-in-mkv-track-track-tracknumber","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/BitmapSubtitleLoader.cs","lineNumber":67,"sourceCode":"        var log = new StringBuilder();\n        var pcsList = BluRaySupParser.ParseBluRaySup(filePath, log);\n        if (pcsList.Count == 0)\n        {\n            throw new InvalidOperationException($\"No Blu-Ray sup subtitles found in: {filePath}\");\n        }\n        return PcsListToItems(pcsList);\n    }\n\n    /// <summary>\n    /// MKV PGS track (S_HDMV/PGS) → bitmap events. PGS-in-MKV is the same PCS payload\n    /// as a .sup file, just wrapped in Matroska block timing.\n    /// </summary>\n    public static IReadOnlyList<BitmapSubtitleItem> LoadMatroskaPgs(MatroskaFile matroska, MatroskaTrackInfo track)\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        return PcsListToItems(pcsList);\n    }\n\n    /// <summary>\n    /// VobSub <c>.sub</c> (+ optional <c>.idx</c>) → bitmap events. Uses\n    /// <see cref=\"VobSubParser.OpenSubIdx\"/>, which uses the .idx for timing + palette when\n    /// present and otherwise parses the .sub's MPEG-PS stream directly (stream PTS timing +\n    /// a default palette). The frame size comes from the .idx's <c>size:</c> line when it has\n    /// one — VobSub is not always DVD-sized (Subtitle Edit's own export writes whatever the\n    /// source was, e.g. <c>size: 1920x1080</c>) and squeezing a 1920x1080 stream into a DVD\n    /// frame moves every subpicture. Without that line, fall back to the DVD standards\n    /// (720x576 PAL, 720x480 NTSC) rather than <c>--resolution</c> / 1920x1080.\n    /// </summary>\n    public static IReadOnlyList<BitmapSubtitleItem> LoadVobSub(string subPath, string idxPath, bool isPal)\n    {\n        var parser = new VobSubParser(isPal);\n        // OpenSubIdx falls back to parsing the .sub stream directly when the .idx is missing,","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/seconv/Core/BitmapSubtitleLoader.cs#L49-L85","documentation":"InvalidOperationException from LoadMatroskaPgs: parsing the selected MKV track as PGS yielded zero PCS entries. The track was identified as S_HDMV/PGS but its blocks did not decode into any presentation composition segments.","triggerScenarios":"Passing the wrong track.TrackNumber to LoadMatroskaPgs — e.g. an audio track, a VobSub track, or an empty PGS track — so ParseBluRaySupFromMatroska returns an empty list.","commonSituations":"Caller enumerated MKV tracks but indexed by position rather than by codec ID; the chosen track is actually S_VOBSUB; PGS track is present but has no events.","solutions":["Enumerate tracks and select one whose CodecID/TrackCodec is S_HDMV/PGS before calling LoadMatroskaPgs.","Inspect tracks with mkvinfo or ffprobe to confirm which track number holds the PGS stream.","If the track is actually VobSub, call LoadMatroskaVobSub instead."],"exampleFix":"// before\nif (pcsList.Count == 0)\n    throw new InvalidOperationException($\"No PGS subtitles in MKV track #{track.TrackNumber}.\");\n\n// after\nif (pcsList.Count == 0)\n    throw new InvalidOperationException($\"No PGS subtitles in MKV track #{track.TrackNumber} (codec: {track.CodecID}). Pick an S_HDMV/PGS track.\");","handlingStrategy":"validation","validationCode":"if (!string.Equals(track.CodecID, \"S_HDMV/PGS\", StringComparison.OrdinalIgnoreCase))\n    throw new InvalidOperationException($\"Track #{track.TrackNumber} is {track.CodecID}, not PGS. Pick an S_HDMV/PGS track.\");","typeGuard":"static bool IsPgsTrack(MatroskaTrackInfo t) => string.Equals(t.CodecID, \"S_HDMV/PGS\", StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"null","preventionTips":["Enumerate MKV tracks and select by CodecID, not by position.","Use mkvinfo/ffprobe to confirm the PGS track number before invoking."],"tags":["subtitles","mkv","pgs","track-selection","validation"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}