This is a tool to align audio files.
The primary application is to create a video file from separately recorded video and audio devices. The steps are as below.
video-cam.mp4
audio.wav
ffmpeg -i video-cam.mp4 video-cam-audio.wav
alignaudio video-cam-audio.wav audio.wav -o audio-aligned.wav
ffmpeg -i video-cam.mp4 -i audio-aligned.wav -map 0:v -map 1:a -c:v copy video.mp4
rm video-cam-audio.wav audio-aligned.wav
Option | Description |
---|---|
-d align-data-file |
Output results of internal calculation. |
-c |
Compensate clock drift |
This program sweeps audio offset and calculates correlation of the two audio files for each offset. The sweep will be performed 3 times, coarse sweep at first time, finer sweep, and fine sweep.
The sweep results can be output as a data file readable by GNUplot.
-d
option to output the data file.
alignaudio -d align.dat ...
set terminal svg
set output 'align.svg'
set multiplot layout 3,1
set xlabel 'time [s]'
plot 'align.dat' index 0 u 1:2 t 'First sweep'
set xlabel 'time [s]'
plot 'align.dat' index 1 u 1:2 t 'Second sweep'
set xlabel 'time [s]'
plot 'align.dat' index 2 u 1:2 t 'Third sweep'
Since consumer products don't have clock synchronization mechanism, some tools might suffer drift of the clock source. This program provides an option to compensate for the clock drift.
This code is released under the General Public License version 3. See the file 'COPYING' for the full license.