Using (a modified version of) "Align Audio to Reference" on CLI

Hi all,

I’ve found the ‘Set Audio Reference’ and ‘Align Audio to Reference’ feature to be incredibly useful so far, and I was wondering if it would be able to extract part of the feature where I could obtain the offset between the reference and the selected audio clip.

As an example, suppose I have two audio files: one that has been recorded as a WAV file typically 1 hour long and is the reference), and another one that has been recorded as a short WAV file (typically 4 minutes long). After I set the long WAV file as the reference and align the short WAV file to the reference, I would notice that the short WAV file is now aligned and starts at 00:31:38:09 (assuming the project is configured to be working with 30fps).

Given this, I would like to create a script that can return the offset between the two audio files – something of the following:


$ find-offset file1_reference.wav file2.wav

offset : 00:31:38:09

Would this be feasible? For the time being, I’m looking at the implementation of alignAudio in src/timeline2/view/timelinecontroller.cpp, but I thought it would be best to ask about this before proceeding any further…

There exists other tools that do exactly the above, (for example, audio-offset-finder), but unfortunately, it seems like the output generated is incorrect for my use cases. I guess looking further into such tools would also be an option, but kdenlive’s align audio feature has just been more reliable so far.