Builds a beat-synced music video from an input audio track and a folder of source video clips.
AV-Sync analyzes source audio files with Librosa, separates harmonic and percussive content, detects onsets and divides the track into musical segments using different segmentation modes.
For each audio segment, AV-Sync computes detailed rhythmic, loudness and novelty features, then classifies the segment as slow, medium or fast. It also analyzes each candidate video with OpenCV by sampling motion over time, building timelines and grouping clips into motion buckets so the visual pacing can follow the energy of the music.
Finally, AV-Sync selects diverse video regions to best match each audio segment’s motion profile and timing. It then builds an FFmpeg filter graph which trims clips, applies zooms, pans, pulse effects, motion trails and audio mapping before rendering the final synchronized video.
The program also writes a JSON manifest containing the audio analysis, clip choices, timing offsets, feature measurements and placement metadata.
Below are the required software programs and instructions for installing and using this application on a Linux machine.
-
Install the above programs
-
Open a terminal
-
Clone this repository:
git clone git@github.com:devbret/av-sync.git -
Navigate to the repo's directory:
cd av-sync -
Create a virtual environment:
python3 -m venv venv -
Activate your virtual environment:
source venv/bin/activate -
Install the needed dependencies:
pip install -r requirements.txt -
Place your source files into the
inputandvideosdirectories -
Run the program:
python3 app.py -
Locate your results in the
outputdirectory -
Exit the virtual environment:
deactivate
This project repo is intended to demonstrate an ability to do the following:
-
Turn an audio track and a folder of video clips into a beat-synced music video
-
Analyze tempo, onsets, energy and tonal features of the source audio file
-
Score videos by motion and select clip regions to match the pace and intensity of each audio segment
-
Save a JSON manifest of the audio analysis, clip choices, timing and placement data
If you have any questions or would like to collaborate, please reach out either on GitHub or via my website.
AV-Sync can be an exceptionally resource heavy application, particularly with regards to the CPU and RAM. So please start small with your projects and have a good time.