Handling Audio

A. Disabling Audio

When importing video into AviSynth another important thing to consider is if you want your output to have audio. If you decide not have audio in your output, there are several approaches you can take. One way to prevent your output from having audio is by telling the plugin used to import the video not to import the audio. Not all plugins import audio by default, but it is important to specify for ones do.

Example (A-1):

AviSource("video.avi", audio=false)

B. Removing Audio

Another way to prevent the output from having audio is by using the KillAudio function built into AviSynth.

Example (B-1):

AviSource("video.avi)
KillAudio()

OR

KillAudio(AviSource("video.avi"))

C. Importing Videos with Audio

There are several ways to handle audio in AviSynth and the first is importing it with the video. Some functions, such as AviSource, will import the audio and video together by default, while others may require you to manually specify.

D. Importing Audio Separately

Another way of handling audio in AviSynth is by importing it separately then using AudioDub to create an output with both video and audio. This is useful if you want to either swap out the audio or if the plugin you decide to use does not allow for importing the audio and video together. Here are some examples of how to use AudioDub after separately importing the audio and video.

Example (D-1):

AudioDub(AviSource("video.avi"), WavSource("audio.wav"))

Example (D-2):

Video = LWLibavVideoSource("video.mp4")
Audio = LWLibavAudioSource("video.mp4")
return AudioDub(Video,Audio)

E. Modifying Audio

Sometimes you may need to to alter the audio source, but this is rarely necessary and is not recommended unless you are combining clips that have audio with different specs. While there are a lot of different functions that can be used to modify the audio, the two main ones you should be familiar with are ConvertAudioTo() and ResampleAudio(). Most audio sources with be 16-bit and be either 44,100Hz or 48,000Hz. Here is an example of how to convert an audio source to 16-bit 48,000Hz audio:

Example (E-1):

######################################################################################
Audio = WavSource("Audio_8bit_44100HZ.wav").ConvertAudioTo16bit().ResampleAudio(48000) ######################################################################################

NOTE: Increasing audio specs will not improve the audio quality and should only be done if necessary to combine sources, however lowering audio specs will decrease the quality!