Skip to content

biospi/OCRSync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Video OCR Synchronisation Tool

This project extracts timestamp overlays from multi-camera MP4 videos using OCR, repairs and smooths noisy timestamps, exports every frame with a corrected filename timestamp, and finally reconstructs fully synchronised videos (per-camera + a 2×2 grid montage).

The tool is built as a command-line application using Typer, performs OCR using Tesseract, processes frames with OpenCV, and uses FFmpeg to encode output videos.

Features

  • Automatic OCR extraction of timestamp overlays from each video frame

  • Robust cleaning and repair of noisy OCR output

  • Intelligent timestamp smoothing to correct glitches and dropped frames

  • Parallel video processing using ProcessPoolExecutor

  • Frame export with consistent, timestamp-based filenames

  • Automatic detection of synchronisable timestamps across cameras

  • Per-camera MP4 reconstruction using FFmpeg

  • 2×2 synchronised grid video

  • Configurable input folders and parallel workers

Installation (Development)

  1. Clone the repository
git clone <your-repo-url>
cd <your-project>
  1. Create a virtual environment
python -m venv .venv
.\.venv\Scripts\activate    # Windows
source .venv/bin/activate   # macOS/Linux
  1. Install Python dependencies
pip install -r requirements.txt

Required System Dependencies

The tool requires several external binaries:

FFmpeg

Used for video encoding and stitching. Download: https://ffmpeg.org/download.html

Check installation:

ffmpeg -version

Tesseract OCR

Used to read timestamps from frames. Download: https://tesseract-ocr.github.io/tessdoc/

Windows default expected path:

C:\Program Files\Tesseract-OCR\tesseract.exe

Check installation:

tesseract --version

Running the Tool

The main entry point is main.py, which automatically:

Processes all MP4 videos in the default directories:

C:/sync/24/2025Sep12/videos C:/sync/25/2025Sep12/videos C:/sync/26/2025Sep12/videos C:/sync/27/2025Sep12/videos

Extracts and cleans OCR timestamps

Saves frames into frames/ folders

Runs the synchronisation + FFmpeg reconstruction

Generates:

Per-camera MP4 videos

A synced grid video

Basic command

python main.py run

Custom directories

python main.py run --video-dirs "C:/data/camA" "C:/data/camB"

Change worker count

python main.py run --max-workers 6

Output

After running, the output will appear under:

C:/sync/output_videos/

This will include:

24.mp4        # camera 24
25.mp4        # camera 25
26.mp4        # camera 26
27.mp4        # camera 27
sync_grid.mp4 # montage

Project Structure

.
├── main.py               # Main Typer application (OCR, frame extraction)
├── process_frames.py     # Synchronisation + FFmpeg encoding
├── requirements.txt      # Python dependencies
└── README.md             # Project documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages