Audio synchronisation / alignement

It should be great to implement “Audio alignment” in order to replace a poor ‘live’ sound by a better one from mixing audio desk. it is possible with Audacity but manually i guess.

I am really, really new to Shotcut. I have been using Kdenlive to edit my videos. I am a professor of mathematics.

I just saw some videos about Shotcut and decided promptly to migrate. What a slick interface!!! What a clean MLT file!!! It would be great to have Kdenlive’s automatic audio alignment, though.

Right now, I am studying Kdenlive’s code. I’d like to try implementing it. Help would be very nice! I don’t really know anything about Shotcut.

I guess that usually one has a AV file and and audio file. I thought that, instead of Kdenlive’s “set audio reference”/“align audio to reference”, we could simply create a brand new producer with the audios aligned. This way, we avoid lots of click, click.

For example, when right-clicking the video in the main playlist (project bin), there could be an option to “replace the audio track”.

Or, if one selects both, the audio file and the AV file in the playlist, there could be an option to “merge both”. That is, replace the AV file audio.

Any suggestions, any recommendations, any volunteers? :slight_smile:

I think you are saying to create an MLT file with only the video and replaced audio joined by an audio mix transition. Then, open that MLT file as a clip in Shotcut? That might be a clever way to do it. But I think some people might have multiple video angles as well that they would want to synchronize.

I think it would be good to have a way to set one track as the “reference” audio track and then align all video clips on other tracks according to the reference. As long as you edit with “ripple” enabled, the clips will say synchronized as you edit.

Actually, since I do not really know Shotcut and I do not know much about MLT, I thought about doing it inline, as a producer/tractor defined on the same file. Then, I thought about having some dialog with some options.

Can a single AV file have lots of audio tracks in Shotcut?

This sounds a lot more like a Shotcut-ish way to do it!!! If I understood things correctly, I guess yours is the way to go. It is a lot more “magic”, demands less interaction and less GUI.

Does “ripple” have a formal definition? :slight_smile:

So, given a reference track, when you drag an audio clip “below” a reference “track”, the “ripple” magic chooses the correct reference clip and aligns to it? It could even “group” both, and even “trim”, so they have the same length…

There could also be a “menu entry” / “button” / “shortcut key” to align the currently selected clips (or the whole “current” track) to the reference track.

Sorry for all this wandering… I guess we need to specify precisely the behaviour for this feature. My lack of familiarity with Shotcut is not helping either… :slight_smile:

By the way, I read somewhere about “assigning copyright”. But the Kdenlive code is not mine (and could never be… I have no idea how it does its fft magic). Can it be used? It seems it is GPLv3, but I am not sure it allows for “any later GPL”. I guess it does, because it also (seems to) accepts any KDE accepted GPL.

I think that could also work, but would need a way to indicate that the producer is actually two producers joined with a tractor.

Yes. But Shotcut only uses one track at a time, currently.

Just thinking out loud here… Here is an idea how how it could work:

  • User places reference audio on track 1.
  • Users adds video/audio clips to other tracks - maybe one track for each camera
  • User right-clicks on a clip and chooses an option to “Align with audio in Track 1”. Maybe this option could also exist on each track
  • When the users chooses “Align with audio in Track 1”, a process kicks off to analyze the audio in each clip and compare it to the audio in Track 1. Then, the process sets the position of the clip to align it. This alignment process would be the “magic”.

I do not know how Kdenlive aligns clips or if that could be adapted to my suggestion above.

Wow!!! There is a glossary!!! You Shotcut guys are amazing!!!

The hard part (the magic) is done by a “lib”

the code looks quite independent of Kdenlive itself. It depends on MLT, because it reads the audio tracks. And it also depends on Qt, because of the signal slot/emit infrastructure.

Kdenlive just calls it on

The timeline has a “global” AudioCorrelation (m_audioCorrelator)
https : / /
(new users are not allowed to post more than two links)
But I think we should have one correlator for each clip in the reference timeline. And one “envelope” for each audio clip “to be synchronized”.

I guess that even the “reference clip” could be automagically selected. Imagine this scenario:

  1. There is one “reference track”.
  2. Then, you drag a bunch of “clips” to the track (not the timeline… the “track head” on the right of the timeline).
  3. The added clips are automatically assigned to and aligned to their corresponding clips on the “reference track”.
  4. Optionally, the audios can be trimmed (just set in and out) to fit the reference clip.

Looks promising. The license is GPLv3 - which is currently compatible with Shotcut. But it does not include the “or later” clause which could possibly cause a problem in the future. It might be good to think about creating a generic project for that feature that could be shared by Shotcut and Kdenlive (and any other project that would like to use it).

Seems like that could work.

The license identifier also includes LicenseRef-KDE-Accepted-GPL. So, it seems it actually is “any later”. :slight_smile: