SubtitleEdit/subtitleedit · error · FormatException
Resolution is empty.
Error message
Resolution is empty.
What it means
Thrown by ResolutionParser.Parse when the `--resolution` value is null/empty/whitespace. The parser splits a WIDTHxHEIGHT string (e.g. 1920x1080) into a tuple for bitmap rendering at the correct dimensions; an empty string has no separator or tokens.
Source
Thrown at src/seconv/Core/ResolutionParser.cs:15
using System.Globalization;
namespace SeConv.Core;
/// <summary>
/// Parses <c>WIDTHxHEIGHT</c> strings (e.g. <c>1920x1080</c>) used by <c>--resolution</c>.
/// Both lowercase <c>x</c> and uppercase <c>X</c> are accepted.
/// </summary>
internal static class ResolutionParser
{
public static (int Width, int Height) Parse(string input)
{
if (string.IsNullOrWhiteSpace(input))
{
throw new FormatException("Resolution is empty.");
}
var s = input.Trim();
var idx = s.IndexOfAny(['x', 'X']);
if (idx <= 0 || idx == s.Length - 1)
{
throw new FormatException($"Resolution '{input}' is invalid. Expected WIDTHxHEIGHT, e.g. 1920x1080.");
}
var wPart = s[..idx];
var hPart = s[(idx + 1)..];
if (!int.TryParse(wPart, NumberStyles.None, CultureInfo.InvariantCulture, out var w) ||
!int.TryParse(hPart, NumberStyles.None, CultureInfo.InvariantCulture, out var h) ||
w <= 0 || h <= 0)
{
throw new FormatException($"Resolution '{input}' is invalid. Width and height must be positive integers.");
}View on GitHub (pinned to 17a9f07487)
Solutions
- Pass a WIDTHxHEIGHT value, e.g. `--resolution=1920x1080`.
- Omit `--resolution` entirely if your conversion does not need bitmap dimensions.
- Guard scripts: only emit the flag when the variable is non-empty.
Example fix
# before seconv in.sup out.bdnxml --resolution= # after seconv in.sup out.bdnxml --resolution=1920x1080
Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(rawRes))
throw new ArgumentException("--resolution requires WIDTHxHEIGHT");
var (w,h) = ResolutionParser.Parse(rawRes); Type guard
static bool IsResolutionParsable(string? s)
{
if (string.IsNullOrWhiteSpace(s)) return false;
try { ResolutionParser.Parse(s); return true; } catch { return false; }
} Try / catch
try { var res = ResolutionParser.Parse(input); }
catch (FormatException ex) when (ex.Message == "Resolution is empty.")
{
// require resolution for bitmap targets, else skip
} Prevention
- Make --resolution mandatory only for bitmap outputs (.sup, .bdnxml, ...).
- Trim and length-check the value before parsing.
- Document a default (e.g. 1920x1080) in --help.
When it happens
Trigger: Calling `ResolutionParser.Parse(input)` with an empty/whitespace string, typically `--resolution=` with no value.
Common situations: Shell expansion blanking the variable; wrapper script defaulting to empty; user assumes a default resolution exists but bitmap export requires an explicit one.
Related errors
- Offset is empty.
- PAC code page is empty.
- Resolution '{input}' is invalid. Expected WIDTHxHEIGHT, e.g.
- Resolution '{input}' is invalid. Width and height must be po
- {StaticName} returned an unexpected response: {responseStrin
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/5983d2a78d09e1a8.
Report an issue: GitHub.