SubtitleEdit/subtitleedit · error · FileNotFoundException
nOCR database not found
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.
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.
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
- 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.
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
- BinaryOCR database not found
- engine requires --ocr-db=<path-to-Latin > (or another…
- OCR engine ' ' is not supported. Use one of: tesseract…
- Settings file not found
- BinaryOCR database is empty
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/de35f2e2c4d3cdc0.
Report an issue: GitHub.
Appendix: 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)