SubtitleEdit/subtitleedit · error · FormatException
Resolution '{input}' is invalid. Expected WIDTHxHEIGHT, e.g.
Error message
Resolution '{input}' is invalid. Expected WIDTHxHEIGHT, e.g. 1920x1080. What it means
Thrown by ResolutionParser.Parse when the trimmed input has no 'x'/'X' separator in a valid position (index <= 0 means no leading width, index == last means no trailing height). FormatException because the structural shape is wrong even before integer parsing.
Source
Thrown at src/seconv/Core/ResolutionParser.cs:22
/// <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.");
}
return (w, h);
}
}
View on GitHub (pinned to 17a9f07487)
Solutions
- Use the literal ASCII 'x' or 'X' between width and height: `1920x1080`.
- Remove any suffix like 'p' or 'i' — pass only numbers.
- If copying from documentation, retype the separator to avoid Unicode lookalikes.
- Provide both dimensions; do not omit either side.
Example fix
# before seconv in.sup out.bdnxml --resolution=1920×1080 # unicode multiply # after seconv in.sup out.bdnxml --resolution=1920x1080
Defensive patterns
Strategy: validation
Validate before calling
var sepIdx = input.IndexOfAny(new[] { 'x', 'X' });
if (sepIdx <= 0 || sepIdx == input.Length - 1)
throw new ArgumentException("--resolution must be WIDTHxHEIGHT, e.g. 1920x1080"); Type guard
static bool HasValidResolutionShape(string? s)
{
if (string.IsNullOrWhiteSpace(s)) return false;
var i = s.IndexOfAny(new[] { 'x', 'X' });
return i > 0 && i < s.Length - 1;
} Try / catch
try { var res = ResolutionParser.Parse(input); }
catch (FormatException ex) when (ex.Message.Contains("Expected WIDTHxHEIGHT"))
{
// reject and show example
} Prevention
- Normalize Unicode lookalikes (×, multiply sign) to ASCII 'x' before parsing.
- Reject hyphen/dash separators at arg-parse time.
- Strip trailing 'p'/'i' before validation if your CLI accepts them.
When it happens
Trigger: Calling `ResolutionParser.Parse(input)` with values like '1920', 'x1080', '1920x' (missing one side), '1920X1080' works (X is allowed), but '1920-1080' or '1920×1080' (Unicode multiply) fails.
Common situations: Using a hyphen or en-dash instead of 'x'; using the Unicode multiplication sign × (copy-paste from a formatted doc); passing only one dimension; trailing units like '1920x1080p'.
Related errors
- Resolution is empty.
- Resolution '{input}' is invalid. Width and height must be po
- Offset is empty.
- PAC code page is empty.
- PAC code page '{input}' is invalid. Expected a name (Latin,
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/d74f92eb22c72bf5.
Report an issue: GitHub.