SubtitleEdit/subtitleedit · error · FileNotFoundException
BinaryOCR database not found: {dbPath}. Use --ocr-db to poin
Error message
BinaryOCR database not found: {dbPath}. Use --ocr-db to point to a .db file (typically %AppData%\Subtitle Edit\OCR\Latin.db or similar). What it means
FileNotFoundException from the BinaryOcrOcrEngine constructor: the dbPath argument does not point to an existing file. The message names the path and suggests using --ocr-db to point at a .db (typically %AppData%\Subtitle Edit\OCR\Latin.db).
Source
Thrown at src/seconv/Core/BinaryOcrOcrEngine.cs:25
/// In-process OCR via Subtitle Edit's BinaryOCR matcher. Requires a <c>.db</c>
/// database file (typically shipped with SE under <c>%AppData%\Subtitle Edit\OCR\</c>;
/// pass the path via <c>--ocr-db</c>). BinaryOCR uses fast bitmap-hash matching and
/// is a useful alternative to nOCR — different accuracy profile, similar speed.
/// </summary>
internal sealed class BinaryOcrOcrEngine : IOcrEngine
{
public string Name => "binaryocr";
private readonly BinaryOcrDb _db;
private readonly BinaryOcrMatcher _matcher;
private const int PixelsAreSpaceDefault = 12;
private const double MaxErrorPercent = 0.5;
public BinaryOcrOcrEngine(string dbPath)
{
if (!File.Exists(dbPath))
{
throw new FileNotFoundException(
$"BinaryOCR database not found: {dbPath}. Use --ocr-db to point to a .db file " +
"(typically %AppData%\\Subtitle Edit\\OCR\\Latin.db or similar).", dbPath);
}
_db = new BinaryOcrDb(dbPath, loadCompareImages: true);
if (_db.AllCompareImages.Count == 0)
{
throw new InvalidOperationException($"BinaryOCR database is empty: {dbPath}");
}
_matcher = new BinaryOcrMatcher
{
IsLatinDb = Path.GetFileNameWithoutExtension(dbPath).Contains("Latin", StringComparison.OrdinalIgnoreCase),
};
}
public string Recognize(SKBitmap bitmap)
{
if (bitmap is null || bitmap.Width == 0 || bitmap.Height == 0)
{View on GitHub (pinned to 17a9f07487)
Solutions
- Run Binary/OCR in the SE GUI once to generate Latin.db, then point --ocr-db at it.
- Pass --ocr-db:<absolute path to .db> explicitly.
- Confirm the path resolves under the current user profile (the %AppData% placeholder must be expanded).
Example fix
// before
if (!File.Exists(dbPath))
throw new FileNotFoundException($"BinaryOCR database not found: {dbPath}. ...", dbPath);
// after
var resolved = Environment.ExpandEnvironmentVariables(dbPath);
if (!File.Exists(resolved))
throw new FileNotFoundException($"BinaryOCR database not found: '{resolved}'. Use --ocr-db:<path.db>.", resolved); Defensive patterns
Strategy: validation
Validate before calling
var resolved = Environment.ExpandEnvironmentVariables(dbPath);
if (!File.Exists(resolved))
throw new FileNotFoundException($"BinaryOCR db not found: '{resolved}'. Pass --ocr-db:<path.db>.", resolved); Type guard
static bool IsExistingOcrDb(string path) => File.Exists(Environment.ExpandEnvironmentVariables(path));
Try / catch
null
Prevention
- Expand %AppData% in user-supplied paths before checking existence.
- Default the OCR-db path to the standard SE location and only override via --ocr-db.
- Generate the db in the SE GUI once on first install.
When it happens
Trigger: Constructing BinaryOcrOcrEngine with a dbPath whose file does not exist; default OCR-db lookup returned a path that was never populated.
Common situations: First-time use before any BinaryOCR db was created in the SE GUI; moved SE to a new machine; user pointed --ocr-db at the wrong file.
Related errors
- nOCR database not found: {nOcrDbPath}. Use --ocr-db to point
- BinaryOCR database is empty: {dbPath}
- OCR engine '{options.OcrEngine}' is not supported. Use one o
- {engineName} engine requires --ocr-db=<path-to-Latin{require
- Settings file not found: {path}
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/7ad564d666f24665.
Report an issue: GitHub.