Cross-correlation is definitely the answer. And it is basically a one-liner in any common DSP package (MATLAB, Python, Julia...).
To make it more practical for your particular scenario, I would suggest using shorter pieces of the audio tracks rather than the full tracks, otherwise you'll be waiting a loooong time!
Steps:
- Take a short chunk of one of the tracks as the piece you want to look for in the other track
- Take a chunk of the other track centered around the center time of the first one, but longer than the first (up to the longest delay you reasonably expect between the tracks in either direction)
- Cross-correlate the two (e.g., with
xcorr
in MATLAB), and find the point the max occurs at. This will give you the time offset in samples.
If you want a more precise measurement, I'd suggest repeating the above several times at different points in the long track, and averaging the results.
Edit
Here's an example in Python (largely borrowed from this answer to save time):
import numpy as np
from scipy.signal import correlate
from scipy.signal import correlation_lags
# Make 2 vectors to test, 1 being a shifted version of the other
x = np.asarray([1,2,3,4])
y = np.asarray([.5,1,2,3])
# Cross-correlate
correlation = correlate(x, y, 'full')
# Get the lag vector that corresponds to the correlation vector
lags = correlation_lags(x.size, y.size, mode="full")
# Find the lag at the peak of the correlation
lag = lags[np.argmax(correlation)]
print(lag)