SubtitleEdit/subtitleedit · error · FormatException
Offset is empty.
Error message
Offset is empty.
What it means
Thrown by OffsetParser.Parse when the `--offset` value is null, empty, or whitespace. OffsetParser converts the legacy Subtitle Edit offset syntax (ms, ss:ms, mm:ss:ms, hh:mm:ss:ms) into a TimeSpan; an empty string has no parseable tokens, so it fails fast with FormatException.
Source
Thrown at src/seconv/Core/OffsetParser.cs:17
using System.Globalization;
namespace SeConv.Core;
/// <summary>
/// Parses offset strings in the legacy Subtitle Edit CLI format. Accepts
/// a plain integer (milliseconds) or colon/comma/period separated integer
/// tokens treated as (hh, mm, ss, ms) — 4 tokens = hh:mm:ss:ms,
/// 3 = mm:ss:ms, 2 = ss:ms, 1 = ms. Optional leading +/- repeated.
/// </summary>
internal static class OffsetParser
{
public static TimeSpan Parse(string input)
{
if (string.IsNullOrWhiteSpace(input))
{
throw new FormatException("Offset is empty.");
}
var s = input.Trim();
var negate = false;
while (s.Length > 0 && (s[0] == '-' || s[0] == '+'))
{
if (s[0] == '-')
{
negate = !negate;
}
s = s[1..];
}
if (s.Length == 0)
{
throw Bad(input);
}
View on GitHub (pinned to 17a9f07487)
Solutions
- Provide a concrete offset value, e.g. `--offset=1000` (1 second) or `--offset=00:00:01,500`.
- If no offset is wanted, omit the `--offset` flag entirely rather than passing an empty value.
- Guard wrapper scripts: only emit `--offset=` when the variable is non-empty.
Example fix
# before seconv in.srt out.srt --offset= # after seconv in.srt out.srt --offset=1000
Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(rawOffset))
throw new ArgumentException("--offset requires a value (ms or hh:mm:ss:ms)");
var ts = OffsetParser.Parse(rawOffset); Type guard
static bool IsOffsetParsable(string? s)
{
if (string.IsNullOrWhiteSpace(s)) return false;
try { OffsetParser.Parse(s); return true; } catch { return false; }
} Try / catch
try { var offset = OffsetParser.Parse(input); }
catch (FormatException ex) when (ex.Message == "Offset is empty.")
{
// treat as no offset, or report and abort
} Prevention
- Default --offset to null/absent rather than empty in wrapper scripts.
- Trim and length-check the value before calling Parse.
- Document the accepted token shapes in --help.
When it happens
Trigger: Calling `OffsetParser.Parse(input)` with an empty/whitespace string, typically because `--offset=` was passed with no value or the option was bound to an unset environment variable.
Common situations: Shell expansion that blanks the value (`--offset=$OFFSET` with OFFSET unset); a wrapper script passing an empty default; quoting mistake that strips the argument.
Related errors
- PAC code page is empty.
- Resolution is empty.
- {StaticName} returned an unexpected response: {responseStrin
- Translate engine '{options.TranslateEngine}' is not supporte
- Translate model '{name}' not found in {LlamaCppServerManager
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/5cde9f39668b7372.
Report an issue: GitHub.