SubtitleEdit/subtitleedit · error · InvalidOperationException

No paragraphs to render.

Error message

No paragraphs to render.

What it means

Thrown by ImageOutputWriter.Write when the subtitle being exported to an image-based format (BDN-XML, Blu-ray sup, DOST, WebVTT thumbnail, etc.) has zero paragraphs (cues). Image rendering iterates over Paragraphs to generate bitmaps — an empty subtitle produces no images and no index, so the writer refuses rather than emit a hollow export.

Source

Thrown at src/seconv/Core/ImageOutputWriter.cs:56

                => new ExportHandlerDCinemaSmpte2014Png(),
            var x when x.Equals("Images with time codes in file name", StringComparison.OrdinalIgnoreCase) || x.Equals("ImagesWithTimeCodes", StringComparison.OrdinalIgnoreCase)
                => new ExportHandlerImagesWithTimeCode(),
            // WebVTT thumbnail bundle: a directory of numbered PNG sprites plus an
            // index.vtt that references each by start/end time. The handler treats
            // the output path as a folder (creates it, writes PNGs + index.vtt
            // inside), so e.g. `seconv movie.srt webvttthumbnail` produces
            // `movie.vtt/0001.png`, `0002.png`, ..., `index.vtt`.
            var x when x.Equals("WebVTT Thumbnail", StringComparison.OrdinalIgnoreCase) || x.Equals("WebVttThumbnail", StringComparison.OrdinalIgnoreCase)
                => new ExportHandlerWebVttThumbnail(),
            _ => null,
        };
    }

    public static void Write(Subtitle subtitle, string filePath, IExportHandler handler, ConversionOptions options)
    {
        if (subtitle.Paragraphs.Count == 0)
        {
            throw new InvalidOperationException("No paragraphs to render.");
        }

        var (screenWidth, screenHeight) = options.Resolution ?? (1920, 1080);

        // "{\pos(x,y)}" is in the script's own resolution, the export canvas may be another one.
        var (scriptWidth, scriptHeight) = ExportTextTags.GetScriptResolution(subtitle.Header);

        // Pre-render header with the first paragraph as a representative
        var firstParam = BuildParameter(subtitle.Paragraphs[0], 0, screenWidth, screenHeight, options);
        firstParam.Bitmap = ImageRenderer.GenerateBitmap(firstParam);
        handler.WriteHeader(filePath, firstParam);
        firstParam.Bitmap?.Dispose();

        for (var i = 0; i < subtitle.Paragraphs.Count; i++)
        {
            var p = subtitle.Paragraphs[i];
            var ip = BuildParameter(p, i, screenWidth, screenHeight, options);
            ip.Bitmap = ImageRenderer.GenerateBitmap(ip);

View on GitHub (pinned to 17a9f07487)

Solutions

  1. Check subtitle.Paragraphs.Count > 0 before invoking the image export path, and report a meaningful message to the end user.
  2. Inspect the source file — if it should have cues, the load or an upstream filter is silently dropping them; enable warnings and verify paragraph count right after LoadSubtitleWithFormat returns.
  3. If the empty subtitle is expected (e.g. a template), skip the image export entirely rather than calling Write.

Example fix

// before
ImageOutputWriter.Write(subtitle, outPath, handler, options);

// after
if (subtitle.Paragraphs.Count == 0)
    return; // or report "no subtitles to render"
ImageOutputWriter.Write(subtitle, outPath, handler, options);
Defensive patterns

Strategy: validation

Validate before calling

if (subtitle == null || subtitle.Paragraphs.Count == 0)
{
    Console.Error.WriteLine("No subtitle paragraphs to render to image format.");
    return;
}

Type guard

static bool HasRenderableParagraphs(Subtitle subtitle) => subtitle != null && subtitle.Paragraphs.Count > 0;

Try / catch

try { ImageOutputWriter.Write(subtitle, outPath, handler, options); }
catch (InvalidOperationException ex) when (ex.Message.Contains("No paragraphs to render"))
{ /* report empty-input error to user */ }

Prevention

When it happens

Trigger: Calling ImageOutputWriter.Write(subtitle, filePath, handler, options) where subtitle.Paragraphs.Count == 0. This happens when the loaded source subtitle is empty, when all paragraphs were filtered out upstream (e.g. by a timing or style filter), or when a malformed source produced no decodable cues despite loading without error.

Common situations: Converting a nearly-empty or whitespace-only SRT/ASS to an image format; a source file whose paragraphs were all removed by a sync/split/cleanup pass before the image export step; piping a subtitle through an intermediate filter that stripped every cue.

Related errors


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