SubtitleEdit/subtitleedit · error · InvalidOperationException

MXF contained {subtitleTexts.Count} essence(s) but none matc

Error message

MXF contained {subtitleTexts.Count} essence(s) but none matched --track-number ({string.Join(",", options.TrackNumbers)}): {filePath}

What it means

Thrown when an MXF contains subtitle essences but none of them matched the track numbers requested via ConversionOptions.TrackNumbers. The filter 'options.TrackNumbers.Contains(trackNumber)' excluded every essence, leaving the tracks list empty. The message reports how many essences were present and which numbers were requested.

Source

Thrown at src/seconv/Core/ContainerSubtitleLoader.cs:226

            if (format == null || subtitle.Paragraphs.Count == 0)
            {
                AnsiConsole.MarkupLine(
                    $"[yellow]Warning: MXF essence #{trackNumber} doesn't parse as a known subtitle format; skipped.[/]");
                trackNumber++;
                continue;
            }
            subtitle.Renumber();
            // Use "mxf_track{n}" as the language-suffix slot so multi-track MXFs produce
            // stably-named outputs (mirrors the teletext_<page> / dvb_pid<n> conventions).
            tracks.Add(new LoadedTrack(subtitle, format, $"mxf_track{trackNumber}", trackNumber));
            trackNumber++;
        }

        if (tracks.Count == 0)
        {
            if (options.TrackNumbers.Count > 0)
            {
                throw new InvalidOperationException(
                    $"MXF contained {subtitleTexts.Count} essence(s) but none matched --track-number ({string.Join(",", options.TrackNumbers)}): {filePath}");
            }
            throw new InvalidOperationException(
                $"MXF contained {subtitleTexts.Count} candidate subtitle essence(s) but none parsed as a known format: {filePath}");
        }

        return tracks;
    }

    private static List<LoadedTrack> LoadMatroska(string filePath, ConversionOptions options)
    {
        var tracks = new List<LoadedTrack>();
        using var matroska = new MatroskaFile(filePath);
        if (!matroska.IsValid)
        {
            throw new InvalidOperationException($"Invalid Matroska file: {filePath}");
        }

View on GitHub (pinned to 17a9f07487)

Solutions

  1. List the MXF's subtitle essences (ffprobe / parser.GetSubtitles count) to find valid numbers.
  2. Use the correct 1-based essence index that matches the loader's numbering.
  3. Omit --track-number to convert all essences, then select the desired output.

Example fix

// before
seconv movie.mxf --track-number 3   # MXF only has 1-2 essences

// after
seconv movie.mxf --track-number 2   # valid 1-based essence number
Defensive patterns

Strategy: validation

Validate before calling

// Before requesting specific tracks, confirm they exist.
// (Track count is internal; omit --track-number to accept all, or list essences first.)
if (options.TrackNumbers.Count > 0) {
    // Ensure requested numbers are plausible; otherwise convert all.
}

Try / catch

try { tracks = ContainerSubtitleLoader.TryLoadTracks(mxfPath, options); }
catch (InvalidOperationException ex) when (ex.Message.Contains("--track-number"))
{ options.TrackNumbers.Clear(); tracks = ContainerSubtitleLoader.TryLoadTracks(mxfPath, options); }  // retry all

Prevention

When it happens

Trigger: Passing --track-number with values that do not correspond to any MXF essence number. The loop at ContainerSubtitleLoader.cs:213 increments trackNumber per essence; if none of those numbers intersect options.TrackNumbers, the post-loop guard at line 222 fires.

Common situations: User assumes 1-based or 0-based numbering that differs from the loader's internal count; an MXF with fewer essences than the requested number; a typo in the --track-number argument.

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/4441b290710b64f2. Report an issue: GitHub.