{"record":{"id":"de35f2e2c4d3cdc0","repo":"SubtitleEdit/subtitleedit","slug":"nocr-database-not-found-nocrdbpath-use-ocr-d","errorCode":null,"errorMessage":"nOCR database not found: {nOcrDbPath}. Use --ocr-db to point to a .nocr file (typically %AppData%\\Subtitle Edit\\OCR\\Latin.nocr or similar).","messagePattern":"nOCR database not found: (.+?)\\. Use --ocr-db to point to a \\.nocr file \\(typically %AppData%\\\\Subtitle Edit\\\\OCR\\\\Latin\\.nocr or similar\\)\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/seconv/Core/NOcrOcrEngine.cs","lineNumber":23,"sourceCode":"\n/// <summary>\n/// In-process OCR via Subtitle Edit's nOCR matcher. Requires a <c>.nocr</c> database file\n/// (typically shipped with SE under <c>%AppData%\\Subtitle Edit\\OCR\\</c>; pass the path\n/// via <c>--ocr-db</c>).\n/// </summary>\ninternal sealed class NOcrOcrEngine : IOcrEngine\n{\n    public string Name => \"nocr\";\n    private readonly NOcrDb _db;\n    private readonly NOcrCaseFixer _caseFixer = new();\n    private const int MaxWrongPixels = 25;\n    private const int PixelsAreSpaceDefault = 12;\n\n    public NOcrOcrEngine(string nOcrDbPath)\n    {\n        if (!File.Exists(nOcrDbPath))\n        {\n            throw new FileNotFoundException(\n                $\"nOCR database not found: {nOcrDbPath}. Use --ocr-db to point to a .nocr file \" +\n                \"(typically %AppData%\\\\Subtitle Edit\\\\OCR\\\\Latin.nocr or similar).\", nOcrDbPath);\n        }\n        _db = new NOcrDb(nOcrDbPath);\n        if (_db.TotalCharacterCount == 0)\n        {\n            throw new InvalidOperationException($\"nOCR database is empty: {nOcrDbPath}\");\n        }\n    }\n\n    public string Recognize(SKBitmap bitmap)\n    {\n        if (bitmap is null || bitmap.Width == 0 || bitmap.Height == 0)\n        {\n            return string.Empty;\n        }\n\n        var parent = new NikseBitmap2(bitmap);","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/seconv/Core/NOcrOcrEngine.cs#L5-L41","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Supply a valid .nocr file via `--ocr-db=/path/to/Latin.nocr`.","Download or copy `Latin.nocr` from a Subtitle Edit installation (GUI: Options -> Settings -> OCR) into the project and point --ocr-db at it.","If you do not need nOCR, switch engines with `--ocr-engine tesseract` (default, no db required).","Verify the path resolves from the working directory seconv runs in; use an absolute path to remove ambiguity."],"exampleFix":"// before\nseconv in.sup out.srt --ocr-engine nocr\n// after\nseconv in.sup out.srt --ocr-engine nocr --ocr-db=/home/user/SE/OCR/Latin.nocr","handlingStrategy":"validation","validationCode":"string db = options.OcrDb;\nif (options.OcrEngine == \"nocr\")\n{\n    if (string.IsNullOrWhiteSpace(db))\n        throw new InvalidOperationException(\"--ocr-db is required for nocr\");\n    if (!File.Exists(db.EndsWith(\".nocr\", StringComparison.OrdinalIgnoreCase) ? db : db + \".nocr\"))\n        throw new FileNotFoundException(\"nOCR db not found: \" + db);\n}","typeGuard":"static bool IsNocrDbReady(string? path) =>\n    !string.IsNullOrWhiteSpace(path) && File.Exists(path) && path.EndsWith(\".nocr\", StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try { var engine = new NOcrOcrEngine(dbPath); }\ncatch (FileNotFoundException ex) when (ex.FileName == dbPath)\n{\n    // report missing db, prompt user for path, abort this input\n}","preventionTips":["Validate --ocr-db with File.Exists before constructing the engine.","Ship a known-good Latin.nocr with your deployment and reference it by absolute path.","Fail fast in CLI arg parsing: if engine is nocr, require a non-empty --ocr-db."],"tags":["ocr","nocr","file-not-found","configuration","cli"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}