How to stretch a shorter audio track to fit longer video with Audacity

11,132

I was able to accomplish this using the Change Speed filter and then adding an initial delay to the track using the MKVToolNix GUI.

Note: This method does come with the downside of changing the pitch of the audio track slightly.

You may be able to minimise or even entirely eliminate this change of pitch by determining the delay to be added, manually adding it using Audacity's Silence filter and then using the Change Speed filter, but because I was dealing with a relatively unimportant audio commentary track, a slightly deeper pitch wasn't enough of a deal-breaker for me to warrant spending the extra time on.


How to stretch an audio track with Audacity

  1. Import the audio track you want to stretch into Audacity using File > Import > Audio, or CtrlAltI.

  2. Select the entirety of the imported audio track using CtrlA.

  3. Select Effect > Change Speed. In the dialogue that appears, select the new desired length of your audio track (i.e. the length that you want the audio track to be stretched to):

enter image description here

  1. Click OK and wait for Audacity to process the track - this shouldn't take more than a minute to complete.

Chances are that your newly-stretched audio track will now be out of sync with your original video stream. Due to the stretched audio no longer matching the timestamps of the original video, it'll be impossible to sync both together as precisely as the original. This makes the entire process of stretching audio to fit a video unsuitable for millisecond-dependent audio content like dubs, but it can be sufficient enough for scores and audio commentaries once adequately synced up.

Note that the rest of this guide assumes that you're muxing the stretched audio track along with the original video stream into an .mkv container. If muxing to a container other than .mkv, you'll need to look for a tool that supports adding a delay to that container.

Syncing the stretched audio track with MKVToolNix GUI

Download MKVToolNix from here. After installing, make sure to follow the links to download and install MKVToolNix GUI if necessary.

Once installed, launch MKVToolNix GUI. Click Add Source Files to import any streams you want to mux into your output video, making sure to include your original video stream and the audio track you stretched in Audacity. Once the stretched audio track appears in the list of tracks to be muxed into the output video, select it.

In the Properties pane to the right, add a delay to the track in milliseconds, where 1 second = 1000 ms:

enter image description here

Note that the exact value you need to enter here will be entirely dependent on your video, so will take some trial-and-error to determine. I recommend first muxing your stretched audio track into the video with no delay, then watching the resulting output to determine how much of a delay is needed to sync up the stretched audio with what you see on-screen.

To finish, give a name to the output video in the Destination file field, then click Start multiplexing to mux all of your tracks into a final .mkv video.

Share:
11,132

Related videos on Youtube

Hashim Aziz
Author by

Hashim Aziz

Updated on September 18, 2022

Comments

  • Hashim Aziz
    Hashim Aziz over 1 year

    I've demuxed an audio commentary track from a DVD release of a movie. My plan is to mux this commentary track back into a Blu-Ray version of the movie. However, the problem is that the Blu-Ray is 4 minutes and 15 seconds longer than the original.

    Therefore, I want to edit the original audio track so that it is gradually stretched out to accommodate the extra few minutes of footage, ensuring that it doesn't cut out before the movie does. However, I also need to make sure that doing so doesn't alter the sound too much.

    How can I do this in Audacity? I've come across both the Change Tempo and Paulstretch filters, but I'm not sure how or even whether I can use these to accomplish what I'm looking for.

    • Giacomo1968
      Giacomo1968 about 5 years
      Have you compared the frame-rates of the source and destination?
    • Hashim Aziz
      Hashim Aziz about 5 years
      @JakeGould It hadn't occurred to me to do so. I just checked, and FFmpeg reports that the DVD source that the audio track is taken from has an FPS of 25, and the destination Blu-Ray has an FPS of 23.98.
    • Giacomo1968
      Giacomo1968 about 5 years
      That kind of difference in length could be an offset issue as well as the slight FPS difference. I would see if you can line up the beginning of the audio and video and see how that plays. Then see if you can downsample the audio to 23.98 FPS. This stuff gets complicated.
    • Hashim Aziz
      Hashim Aziz about 5 years
      @JakeGould When you say line up the audio and video and "see how it plays", what exactly am I aiming for? To get the audio in sync? If so, what would be the purpose of then downsampling the audio to 23.98 FPS? Also I'm not sure exactly how I would downsample audio since to my knowledge audio tracks don't have framerates.
  • Larsen
    Larsen about 4 years
    Why not use "Change Tempo" instead of "Change Speed", so pitch is not affected?
  • Hashim Aziz
    Hashim Aziz about 4 years
    @Larsen I experimented with a few of Audacity's effects at the time, definitely including Change Tempo, and if I remember correctly the change of pitch resulting from Change Tempo was significantly more than that resulting from Change Speed, which is why I went with Change Speed in the end.
  • Larsen
    Larsen about 4 years
    According to the docs this shouldn't be the case, but ok if that's what you noticed.
  • mgutt
    mgutt almost 4 years
    An other solution could be SoX (Pitch) and FFMPEG (Speed). Calculator: toolstud.io/video/framerate.php