Tool to calculate the time offset (delay) between two audio files, ideal for synchronization.
- Precise delay detection: Uses audio fingerprints (MFCC) and cross-correlation
- Multi-segment validation: Analyzes delay consistency over time
- Multi-format support: Works with audio and video files
- Track selection: Interactive handling of multiple audio tracks
- Flexible configuration: All parameters adjustable via JSON
- Logging: Detailed logging of all operations
- Robust error handling: Specific exceptions and clear messages
- Python 3.10 or higher
- FFmpeg: Required for audio extraction and conversion
git clone <repository-url>
cd delay-check
# Editable installation (recommended for development)
pip install -e .
# Or direct installation
pip install .delay-check --help
# or
python -m delay_check --helpWindows:
- Download FFmpeg from ffmpeg.org
- Add it to your system PATH
Ubuntu/Debian:
sudo apt update
sudo apt install ffmpegmacOS:
brew install ffmpegdelay-check <reference_file> <dubbed_file>Or as a Python module:
python -m delay_check <reference_file> <dubbed_file># Compare two audio files
delay-check original.wav dubbed.wav
# Compare two videos
delay-check original.mkv dubbed.mkv
# The program will ask to select the audio track if there are multipleVideo containers: .mkv, .mp4, .mka, .m4a
Audio files: .wav, .eac3, .e-ac3, .ac3, .ec3, .aac, .dts, .dtshd, .flac, .thd, .mp3
The config.json file inside the package allows you to customize all program parameters.
default_analysis_time_sec: Maximum analysis time for the first segment (seconds)segment_analysis_time_sec: Duration of each additional segment (seconds)confidence_threshold: Minimum correlation threshold for validity (0-100)drift_tolerance_ms: Drift tolerances in millisecondssample_rate: Sampling frequency for processing (Hz)n_mfcc: Number of MFCC coefficients for audio fingerprinting
- Extracts the first 300 seconds (configurable) from both files
- Computes audio fingerprints using MFCC
- Applies cross-correlation to find the optimal offset
- Reports the estimated delay and correlation score
- Analyzes 4 additional segments (25%, 50%, 75%, end)
- Calculates the delay for each segment
- Compares consistency over time
- Compares delays across all segments
- Applies penalties for time drift
- Generates a confidence score (0-100%)
- Detects potential issues (VFR, different versions, etc.)
- > 80%: Good initial correlation
- < 80%: Audio files may be different or have significant modifications
- >= 95%: Constant and reliable delay
- < 95%: Variable delay, possible sync issue
- <= 25ms: Excellent consistency
- 26-50ms: Good consistency
- 51-75ms: Acceptable consistency
- 76-100ms: Poor consistency
- > 100ms: Out of sync (possible VFR or editing)
Install FFmpeg and add it to your system PATH.
Possible causes:
- The audio files are fundamentally different
- One of the audio files has additional effects or music
- Significant differences in equalization or volume
- The files are not related
Possible causes:
- VFR (Variable Frame Rate): The video has a variable frame rate
- Different versions: The files come from different sources
- Edits: One of the files has been edited or cut
- Sampling issues: Different original sample rates
delay-check/
├── src/
│ └── delay_check/
│ ├── __init__.py # Version and metadata
│ ├── __main__.py # Entry point as a module
│ ├── cli.py # CLI, arguments and main flow
│ ├── config.py # Configuration management
│ ├── commons.py # General utilities
│ ├── utils.py # Audio-specific utilities
│ ├── fgp.py # Fingerprinting and correlation
│ ├── fileinfo.py # Multimedia file information
│ └── config.json # Default configuration
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_config.py
│ └── test_utils.py
├── pyproject.toml
├── LICENSE
└── README.md
pip install pytest
pytest tests/Contributions are welcome.
- Fork the repository
- Create a branch for your feature (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Sicuskyle