SubtitleEdit/subtitleedit · error · FileNotFoundException

nOCR database not found: {nOcrDbPath}. Use --ocr-db to point

Error message

nOCR database not found: {nOcrDbPath}. Use --ocr-db to point to a .nocr file (typically %AppData%\Subtitle Edit\OCR\Latin.nocr or similar).

What it means

Thrown by the NOcrOcrEngine constructor when the supplied nOCR database path does not exist on disk. nOCR is a lightweight, image-template OCR engine bundled with Subtitle Edit that needs a prebuilt .nocr database file to recognize glyphs. Without that file the engine has no character definitions and cannot function, so construction fails fast rather than producing garbage output.

Source

Thrown at src/seconv/Core/NOcrOcrEngine.cs:23

/// <summary>
/// In-process OCR via Subtitle Edit's nOCR matcher. Requires a <c>.nocr</c> database file
/// (typically shipped with SE under <c>%AppData%\Subtitle Edit\OCR\</c>; pass the path
/// via <c>--ocr-db</c>).
/// </summary>
internal sealed class NOcrOcrEngine : IOcrEngine
{
    public string Name => "nocr";
    private readonly NOcrDb _db;
    private readonly NOcrCaseFixer _caseFixer = new();
    private const int MaxWrongPixels = 25;
    private const int PixelsAreSpaceDefault = 12;

    public NOcrOcrEngine(string nOcrDbPath)
    {
        if (!File.Exists(nOcrDbPath))
        {
            throw new FileNotFoundException(
                $"nOCR database not found: {nOcrDbPath}. Use --ocr-db to point to a .nocr file " +
                "(typically %AppData%\\Subtitle Edit\\OCR\\Latin.nocr or similar).", nOcrDbPath);
        }
        _db = new NOcrDb(nOcrDbPath);
        if (_db.TotalCharacterCount == 0)
        {
            throw new InvalidOperationException($"nOCR database is empty: {nOcrDbPath}");
        }
    }

    public string Recognize(SKBitmap bitmap)
    {
        if (bitmap is null || bitmap.Width == 0 || bitmap.Height == 0)
        {
            return string.Empty;
        }

        var parent = new NikseBitmap2(bitmap);

View on GitHub (pinned to 17a9f07487)

Solutions

  1. Supply a valid .nocr file via `--ocr-db=/path/to/Latin.nocr`.
  2. Download or copy `Latin.nocr` from a Subtitle Edit installation (GUI: Options -> Settings -> OCR) into the project and point --ocr-db at it.
  3. If you do not need nOCR, switch engines with `--ocr-engine tesseract` (default, no db required).
  4. Verify the path resolves from the working directory seconv runs in; use an absolute path to remove ambiguity.

Example fix

// before
seconv in.sup out.srt --ocr-engine nocr
// after
seconv in.sup out.srt --ocr-engine nocr --ocr-db=/home/user/SE/OCR/Latin.nocr
Defensive patterns

Strategy: validation

Validate before calling

string db = options.OcrDb;
if (options.OcrEngine == "nocr")
{
    if (string.IsNullOrWhiteSpace(db))
        throw new InvalidOperationException("--ocr-db is required for nocr");
    if (!File.Exists(db.EndsWith(".nocr", StringComparison.OrdinalIgnoreCase) ? db : db + ".nocr"))
        throw new FileNotFoundException("nOCR db not found: " + db);
}

Type guard

static bool IsNocrDbReady(string? path) =>
    !string.IsNullOrWhiteSpace(path) && File.Exists(path) && path.EndsWith(".nocr", StringComparison.OrdinalIgnoreCase);

Try / catch

try { var engine = new NOcrOcrEngine(dbPath); }
catch (FileNotFoundException ex) when (ex.FileName == dbPath)
{
    // report missing db, prompt user for path, abort this input
}

Prevention

When it happens

Trigger: Constructing `new NOcrOcrEngine(nOcrDbPath)` (directly, or via OcrEngineFactory when `--ocr-engine nocr` is passed) with a path that fails `File.Exists`. Also triggered if `ResolveOcrDbPath` appends `.nocr` to a base path whose full form does not exist.

Common situations: Passing `--ocr-engine nocr` without `--ocr-db`; typoing the db path; the file living under `%AppData%\Subtitle Edit\OCR\Latin.nocr` which is absent on a fresh non-Windows install; copying a project to a machine that never had the Subtitle Edit GUI install its OCR assets.

Related errors


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