Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ecdye/macsubtitleocr

Tool to convert HDMV/PGS subtitles into SubRip format using the macOS OCR engine
https://github.com/ecdye/macsubtitleocr

macos ocr subtitles swift

Last synced: about 7 hours ago
JSON representation

Tool to convert HDMV/PGS subtitles into SubRip format using the macOS OCR engine

Awesome Lists containing this project

README

        

# macSubtitleOCR
[![License](https://img.shields.io/github/license/ecdye/macSubtitleOCR)](https://github.com/ecdye/macSubtitleOCR/blob/main/LICENSE.md)
[![CodeQL](https://github.com/ecdye/macSubtitleOCR/actions/workflows/codeql.yml/badge.svg)](https://github.com/ecdye/macSubtitleOCR/actions/workflows/codeql.yml)
[![Build](https://github.com/ecdye/macSubtitleOCR/actions/workflows/build.yml/badge.svg)](https://github.com/ecdye/macSubtitleOCR/actions/workflows/build.yml)
[![Lint](https://github.com/ecdye/macSubtitleOCR/actions/workflows/lint.yml/badge.svg)](https://github.com/ecdye/macSubtitleOCR/actions/workflows/lint.yml)

## Overview

macSubtitleOCR is used to convert a file containing a PGS Subtitle stream to SubRip subtitles using OCR.
Currently the supported input file types are `.mkv` and `.sup`.
It uses the built in OCR engine in macOS to perform the text recognition, which works really well.
For more information on accuracy, see [Accuracy](#accuracy) below.

### Options

- Ability to export `.png` images of the subtitles to allow manual refinement of the OCR output
- Ability to use language recognition (i.e. seeing if a sequence of characters actually makes a valid word) in the macOS OCR engine to improve OCR accuracy
- Ability to export raw JSON output from OCR engine for inspection

### Building

> [!IMPORTANT]
> This project requires Swift 6 to work properly!

To get started with macSubtitleOCR, clone the repository and then build the project with Swift.

``` shell
git clone https://github.com/ecdye/macSubtitleOCR
cd macSubtitleOCR
swift build
```

The completed build should be available in the `.build/debug` directory.

### Testing

Tests compare the output to a know good output.
We target a match of at least 90% as different machines will produce different output.

``` shell
swift test
```

### Accuracy

In simple tests against the Tesseract OCR engine the accuracy of the macOS OCR engine has been significantly better.
This improvement is especially noticeable with words like 'I', especially when italicized.
The binary image compare method used in projects like [SubtitleEdit](https://github.com/SubtitleEdit/subtitleedit) may be slightly more accurate, but it depends on the use case.

## TODO / Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for guidance on how to contribute to the project.
To help with a specific project on the TODO list please view issues tagged as [enhancements](https://github.com/ecdye/macSubtitleOCR/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement).

## Reference