Jun 212013
 

Sometimes, we might require to edit somehow the audio track of a video file: to add a special effect, to equalize the sound, or to completely replace it with a different audio source. This post explains how to do it with open source tools: Audacity (audio editor) and VirtualDub or Avidemux (video editors).

Introduction

It is possible to find integrated tools for audio and video editing. However, the procedure explained in this post performs a series of independent steps:

  • Extract the audio to a .mp3 file
  • edit the audio with an audio editor (Audacity)
  • Generate a new video file, combining the video track in the original file with the new audio.

The advantage of this approach is in that we are free to choose whatever audio editing tool we want. The next sections explain in detail each of these steps.

1. Download and install Audacity

It is is not already installed in our computer, we can download Audacity from sourceforge. We have downloaded version 2.0.3, compatible with Windows 2000, XP, Vista, Windows 7 and Windows 8. The name of the executable file downloaded is audacity-win-2.0.3.exe, and is 20,3 MB in size. The installation is done by executing this file.

2. Installing lame and ffmpeg libraries

The “lame_enc.dll” library needs to be added to the base installation of Audacity, to add the possibility to export audio to a file in mp3 format. We need to add also the ffmpeg library, give Audacity the ability to work with MPEG video files. To install these libraries, open Audacity and select “Edit > Preferences” from the top menu. In the dialog box displayed, select “Libraries”:

 

audacity-edit-preferences


The dialog box includes links to download, if necessary, the required libraries:

 

audacity-install-libraries


  In the example image above, we can see that Audacity has located the LAME 3.98.2 library,  and FFmpeg  library.

In case you need to install FFmpeg, click on the corresponding “Download” button. In the page that opens in the browser, locate and download    http://lame3.buanzo.com.ar/FFmpeg_v0.6.2_for_Audacity_on_Windows.exe. Then, run this executable to perform the installation.

3. Extract and edit the audio track from a video file.

Once both libraries have been installed, we can directly open an MPEG file in Audacity. We do this by selecting “File > Open…” in the top menu. Then, in the dialog box displayed, choose “Files of type: FFmpeg compatible files”. In the example image below we can see that an mp4 file “oceans-clip.mp4” is available to be selected.

audacity-open-video


Audacity extracts the audio track from the input file, and shows it on screen. Now we can use some of the many possibilities offered by Audacity to edit the audio, and finally we save it to a file selecting “File > Export…”, and choosing “MP3 Files” as the export format.

 

audacity-export-mp3

 

 

4. Install the video editor

Now we must replace the original audio track in the video file with the new audio. To do this, we are going to use the open source video editor “VirtualDub”. Alternatively, for some video formats not supported by VirtualDub, we can use Avidemux, as explained later in this post.

If it is not already available in our computer, we can download VirtualDub from sourceforge. In our case, we download a zip file from the link: Download V1.9.11 (x86 / 32-bit) release build (VirtualDub-1.9.11.zip)

Note: Although there is a 64 bit version available, there is a recommendation in the download page that suggests to use the 32 bit version, because it is compatible with a more codecs.

When the content of the zip file is extracted, a folder “VirtualDub-1.9.11” is created. The executable “VirtualDub.exe” is located under this folder.

If we chose to use Avidemux instead of VirtualDub, we can download the windows versionof Avidemux from sourceforge.

5. Merge the new audio using VirtualDub

Using VirtualDub, the video file is opened selecting in the top menu “File > Open video file…”. Next, select “Audio > Audio from other file…”, and choose the audio file exported from Audacity:

virtualdub-cambiar-audio

 

We must change also the video processing option (the default is “Full processing mode”) selecting “Video > Direct stream copy”. With Direct stream copy, VirtualDub will not perform any processing on the video track, and will just replace the audio track.

Now we just need to save the new file selecting “File > Save as AVI…”

5. Merge the new audio using Avidemux

The the format of the video file is not supported by VirtualDub, Avidemux can be used instead. Select “File > Open”, to open the video file, and change the audio source selecting “Audio > Select Track”. In the dialog box displayed, select “…Add audio track” in the audio source selector, and then choose the audio file exported from Audacity:

avidemux-cambiar-audio

 

Finally, generate the new video file selecting “File > Save”, and that’s it!

 Posted by at 10:56 am

  2 Responses to “How to edit the audio track in a video file”

  1. Thank you !
    You are much … much better with this post than… the rest == which is the information about too much complicated and not free and not working video software

    Avidemux worked for me perfectly like the last case explained here (I know and used the rest in the past )

    Be healthy in the future !

  2. Wonderfully done!. Several other write-ups left me hanging with no way to get the edited audio back into my MP4. You hit a home run here!!!

 Leave a Reply

(required)

(required)