Skip to content

This tool grew out of the need for better synchronization between foreign language video (eg Hindi NTSC DVDs) and higher-quality reference videos (R2 Japanese DVDs or UK PAL DVDs), particularly for preserving the viewing experience across different language versions of the same content, where there are multi issues for sync.

License

Notifications You must be signed in to change notification settings

stinkybread/avsync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

31 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

AVSync Desktop - Audio-Video Synchronization Tool

Electron React TypeScript Python License

A powerful desktop application for automatically synchronizing foreign audio tracks to reference videos. Built with Electron, React, and TypeScript, powered by the AVSync Python engine with advanced visual anchor detection and precise audio timing algorithms.

AVSync Night AvSync Day

โœจ Features

Desktop Application

  • ๐ŸŽจ Modern UI: Beautiful, intuitive interface with dark/light theme support
  • ๐Ÿ“น Video Preview: Frame-by-frame navigation with visual sync point definition
  • ๐Ÿ”„ Batch Processing: Process multiple videos with automatic file matching
  • ๐Ÿ“Š Job Queue: Manage multiple processing jobs with real-time progress tracking
  • ๐Ÿ’พ Persistent Settings: All parameters saved between sessions
  • ๐ŸŽฏ Manual Sync Points: Define precise synchronization points visually
  • ๐Ÿ“ Real-time Logs: Monitor processing with live log output

Processing Engine

  • ๐ŸŽฏ Visual Anchor Detection: Scene change detection and template matching
  • ๐Ÿ”Š Precise Audio Timing: Iterative audio processing with millisecond-level precision
  • ๐ŸŒ Multi-language Support: Automatic audio stream detection by language codes
  • ๐Ÿ“Š Quality Control: Generate side-by-side comparison images and CSV reports
  • โšก Parallel Processing: Multi-threaded frame matching for faster processing
  • ๐ŸŽ›๏ธ Flexible Configuration: Extensive customization options
  • ๐Ÿ’พ Smart Caching: Cache visual anchors for faster re-processing

๐ŸŽฌ How It Works

  1. Image Pairing Stage: Extracts scene change frames and matches them between reference and foreign videos
  2. Audio Synchronization Stage: Processes audio segments iteratively to match reference timing precisely
  3. Muxing Stage: Combines reference video, original audio, and synchronized foreign audio into final output

๐Ÿ“‹ Requirements

System Dependencies

  • Node.js 18+ and npm (for building the desktop app)
  • Python 3.8+ with pip
  • FFmpeg (full build with SoxR support)
  • FFprobe
  • MKVToolNix (mkvmerge, mkvextract)

๐Ÿš€ Installation

1. Clone the Repository

git clone https://github.com/stinkybread/avsync.git
cd avsync

2. Install Node Dependencies

npm install

3. Setup Python Environment

# Create virtual environment (recommended)
python -m venv venv

# Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate

# Install Python dependencies
pip install -r requirements.txt

4. Download External Binaries

Download FFmpeg (full build with SoxR) and MKVToolNix binaries and place them in resources/bin/:

FFmpeg (Recommended):

MKVToolNix:

Your resources/bin/ folder should contain:

resources/bin/
โ”œโ”€โ”€ ffmpeg.exe
โ”œโ”€โ”€ ffprobe.exe
โ”œโ”€โ”€ mkvmerge.exe
โ””โ”€โ”€ mkvextract.exe

5. Build Python Engine

# Activate venv if not already active
# Build AVSync executable with PyInstaller
python -m PyInstaller avsync.spec -y

# Copy built executable to resources
# Windows PowerShell:
Remove-Item -Path resources\avsync -Recurse -Force
Copy-Item -Path dist\avsync -Destination resources\avsync -Recurse -Force

6. Build Desktop Application

npm run build

๐ŸŽฎ Usage

Development Mode

npm run dev

This starts the Vite dev server and launches Electron in development mode with hot reload.

Production Build

npm run build
npm run electron

Creating Distributable Package

npm run package

This creates a distributable application in the release folder.

๐Ÿ’ก Application Guide

New Job Tab

  • Select reference video (the video with correct timing)
  • Select foreign video (the video with audio to sync)
  • Choose output location
  • Adjust parameters as needed
  • Add manual sync points if desired (optional)
  • Click "Add to Queue"

Batch Tab

  • Select folders containing reference and foreign videos
  • Configure file matching patterns
  • Review matched files in the staging table
  • Adjust per-job settings if needed
  • Add all to queue

Queue Tab

  • View all queued jobs
  • Start processing
  • Monitor real-time progress and logs
  • Abort, retry, or remove jobs as needed

Parameters

Image Pairing

  • Scene Threshold: Scene change detection sensitivity (0.0-1.0, default: 0.25)
  • Match Threshold: Template matching threshold (0.0-1.0, default: 0.7)
  • Similarity Threshold: Perceptual hash difference (default: 4, -1 to disable)

Audio Processing

  • Reference Language: Language code for reference audio (default: eng)
  • Foreign Language: Language code for foreign audio (default: spa)
  • dB Threshold: Audio detection threshold (default: -40.0 dB)
  • Min Segment Duration: Minimum segment length (default: 0.5s)
  • Auto-detect: Automatically detect audio streams

Muxing

  • Foreign Audio Codec: Output codec (default: aac)
  • Foreign Audio Bitrate: Output bitrate (default: 192k)

Advanced

  • Use Cache: Cache visual anchors for faster re-processing
  • Skip Subtitles: Don't include subtitles in output

๐Ÿ”ง Project Structure

avsync/
โ”œโ”€โ”€ electron/           # Electron main and preload scripts
โ”œโ”€โ”€ src/               # React frontend source
โ”‚   โ”œโ”€โ”€ components/    # React components
โ”‚   โ”œโ”€โ”€ App.tsx       # Main application component
โ”‚   โ””โ”€โ”€ main.tsx      # React entry point
โ”œโ”€โ”€ resources/        # Application resources
โ”‚   โ”œโ”€โ”€ bin/         # External binaries (FFmpeg, etc.)
โ”‚   โ””โ”€โ”€ avsync/      # PyInstaller bundle
โ”œโ”€โ”€ AVSync_v12.py    # Python processing engine
โ”œโ”€โ”€ avsync.spec      # PyInstaller specification
โ””โ”€โ”€ package.json     # Node.js dependencies

๐ŸŽฏ Tips for Best Results

Video Content

  • โœ… Use videos with clear scene changes and visual landmarks
  • โœ… Ensure good video quality for accurate frame matching
  • โœ… Both videos should be essentially the same (same scenes, different audio)
  • โŒ Avoid videos with different intros, extra ads, or missing scenes

Audio Content

  • โœ… Ensure clear content boundaries in audio tracks
  • โœ… Use similar audio quality between reference and foreign tracks
  • โœ… Define manual sync points for problematic sections

Parameter Tuning

  • Lower scene threshold: Detects more frames (more anchor points)
  • Higher match threshold: Stricter frame matching (fewer false positives)
  • Longer min segment duration: Fewer, longer segments (more stable sync)

๐Ÿ› Troubleshooting

"FFmpeg/FFprobe not found"

  • Ensure binaries are in resources/bin/
  • Rebuild PyInstaller bundle: python -m PyInstaller avsync.spec -y
  • Copy to resources: See Installation step 5

"No matches found"

  • Try lowering scene threshold (e.g., 0.15)
  • Try lowering match threshold (e.g., 0.6)
  • Verify videos actually correspond to each other
  • Add manual sync points

"SoxR resampler unavailable"

Build Errors

# Clean and rebuild
rm -rf node_modules dist dist-electron build
npm install
npm run build

๐Ÿ—๏ธ Development

Prerequisites

  • Node.js 18+
  • Python 3.8+
  • Git

Setup Development Environment

# Clone and install
git clone https://github.com/stinkybread/avsync.git
cd avsync
npm install

# Setup Python
python -m venv venv
venv\Scripts\activate  # Windows
pip install -r requirements.txt

# Download binaries (see Installation step 4)

# Build Python engine
python -m PyInstaller avsync.spec -y
# Copy dist/avsync to resources/avsync

# Run in dev mode
npm run dev

Tech Stack

  • Frontend: React 18, TypeScript, Vite
  • Desktop: Electron 29
  • Processing: Python 3.8+, OpenCV, SciPy, NumPy
  • Bundling: PyInstaller, electron-builder

๐Ÿค Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Credits

Developer: Vaibhav Bhat

UI Design & Implementation: Claude (Anthropic)

Special Thanks:

  • FFmpeg team for the multimedia framework
  • OpenCV community for computer vision tools
  • SciPy contributors for audio processing capabilities
  • Electron and React teams

๐Ÿ“ž Support


Made with โค๏ธ by Vaibhav Bhat

About

This tool grew out of the need for better synchronization between foreign language video (eg Hindi NTSC DVDs) and higher-quality reference videos (R2 Japanese DVDs or UK PAL DVDs), particularly for preserving the viewing experience across different language versions of the same content, where there are multi issues for sync.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •