SubtitleEdit/subtitleedit · error · InvalidOperationException
OCR engine '{options.OcrEngine}' is not supported. Use one o
Error message
OCR engine '{options.OcrEngine}' is not supported. Use one of: tesseract, nocr, binaryocr, ollama, llamacpp, paddle. What it means
Thrown by OcrEngineFactory.Create when the requested engine name (after trim + lowercase) matches none of the supported arms in its switch. The factory is the single dispatch point for the `--ocr-engine` CLI option; an unknown name is a user/CLI typo, not a recoverable runtime condition.
Source
Thrown at src/seconv/Core/OcrEngineFactory.cs:21
/// <summary>
/// Creates an <see cref="IOcrEngine"/> from CLI options. Throws with a clear message when
/// the requested engine is unsupported or its prerequisites (binary on PATH, database file)
/// aren't satisfied.
/// </summary>
internal static class OcrEngineFactory
{
public static IOcrEngine Create(ConversionOptions options)
{
var engine = (options.OcrEngine ?? "tesseract").Trim().ToLowerInvariant();
return engine switch
{
"tesseract" or "" => TesseractOcrEngine.Create(options.OcrLanguage),
"nocr" => new NOcrOcrEngine(ResolveOcrDbPath(options, "nocr", ".nocr")),
"binaryocr" or "binary" => new BinaryOcrOcrEngine(ResolveOcrDbPath(options, "binaryocr", ".db")),
"ollama" => new OllamaOcrEngine(options.OllamaUrl, options.OllamaModel, options.OcrLanguage),
"llamacpp" or "llama.cpp" or "llama" => LlamaCppOcrEngine.Create(options),
"paddle" or "paddleocr" => PaddleOcrEngine.Create(options.OcrLanguage),
_ => throw new InvalidOperationException(
$"OCR engine '{options.OcrEngine}' is not supported. Use one of: tesseract, nocr, binaryocr, ollama, llamacpp, paddle.")
};
}
private static string ResolveOcrDbPath(ConversionOptions options, string engineName, string requiredExtension)
{
if (string.IsNullOrWhiteSpace(options.OcrDb))
{
var displayExt = requiredExtension.TrimStart('.');
throw new InvalidOperationException(
$"{engineName} engine requires --ocr-db=<path-to-Latin{requiredExtension}> (or another {requiredExtension} file). " +
$"Find them in `%AppData%\\Subtitle Edit\\OCR\\` or download from the SE UI.");
}
var path = options.OcrDb;
if (!path.EndsWith(requiredExtension, StringComparison.OrdinalIgnoreCase))
{
path += requiredExtension;
}View on GitHub (pinned to 17a9f07487)
Solutions
- Use one of the listed engines: tesseract, nocr, binaryocr, ollama, llamacpp, paddle.
- Check for trailing whitespace or quotes around the --ocr-engine value.
- If using a settings file, ensure the `ocrEngine` key uses a supported value.
- Run `seconv --help` to confirm the engine list for your seconv version.
Example fix
// before seconv in.sup out.srt --ocr-engine tessaract // after seconv in.sup out.srt --ocr-engine tesseract
Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> ValidEngines = new(StringComparer.OrdinalIgnoreCase)
{ "tesseract", "", "nocr", "binaryocr", "binary", "ollama", "llamacpp", "llama.cpp", "llama", "paddle", "paddleocr" };
if (!ValidEngines.Contains(options.OcrEngine ?? "tesseract"))
throw new ArgumentException("Unsupported OCR engine: " + options.OcrEngine); Type guard
static bool IsValidOcrEngine(string? e) =>
ValidEngines.Contains((e ?? "tesseract").Trim().ToLowerInvariant()); Try / catch
try { var engine = OcrEngineFactory.Create(options); }
catch (InvalidOperationException ex) when (ex.Message.Contains("is not supported"))
{
// print supported list, exit usage error
} Prevention
- Whitelist OCR engine names at CLI parse time.
- Document the canonical lower-case names and normalise input casing before dispatch.
- Add a unit test enumerating each accepted alias.
When it happens
Trigger: Calling `OcrEngineFactory.Create(options)` with `options.OcrEngine` set to a value outside {tesseract, '', nocr, binaryocr, binary, ollama, llamacpp, llama.cpp, llama, paddle, paddleocr}. Example misspellings: 'tessaract', 'ocr', 'google', 'azure'.
Common situations: Typoing the engine name on the command line; copy-pasting a deprecated engine name from old docs; a wrapper script passing an uppercase or differently-cased name that should still work (it is lowercased, so this is rare).
Related errors
- BinaryOCR database not found: {dbPath}. Use --ocr-db to poin
- nOCR database not found: {nOcrDbPath}. Use --ocr-db to point
- {engineName} engine requires --ocr-db=<path-to-Latin{require
- Unknown {ruleKind} rule '{id}'. Run 'seconv {listCommand}' t
- Translate engine '{options.TranslateEngine}' is not supporte
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/3ad1809d22e0a0ee.
Report an issue: GitHub.