A Python tool that automatically synchronizes audio tracks with video files by analyzing waveform patterns and finding optimal alignment points.
- Automatic audio waveform analysis
- Cross-correlation based synchronization
- Confidence scoring for sync quality
- Support for MP3, WAV, and various video formats
- Preserves original video quality
- Python 3.x
- FFmpeg
- NumPy
- SciPy
- Install FFmpeg:
# macOS
brew install ffmpeg
# Ubuntu/Debian
sudo apt-get install ffmpeg
# Windows
# Download from https://ffmpeg.org/download.html- Install Python dependencies:
pip install numpy scipy-
Place your video file and audio file in the same directory as
sync_audio.py -
Update the filenames in the script if needed (default expects
video_audio.wavand audio file) -
Run the synchronization:
python sync_audio.pyThe script will:
- Extract audio from the video
- Analyze both audio waveforms
- Find the optimal synchronization offset
- Create a new video file with synchronized audio
The tool uses cross-correlation to find matching patterns between two audio signals:
- Audio Extraction: Extracts audio from the video file
- Waveform Analysis: Loads and normalizes both audio signals
- Cross-Correlation: Computes correlation between audio segments
- Offset Detection: Identifies the time offset with highest correlation
- Video Generation: Creates new video with properly aligned audio
synchronized_video.mp4- Video with synchronized audio- Console output showing offset and confidence score
MIT