This documentation is for the old version. Go to the latest Graphics Mill docs

Adding Audio Track

When you generate new video file or copy frames from another video, you may need to add an audio track to this movie from the external file. Below you will find how to do it using AVI Processor Add-on.

To add an audio track, you need to use the AudioManager property of the writer object. It returns an instance of the Aurigma.GraphicsMill.Codecs.AviAudioManager class. This class exposes the AddAudioStream method which adds specified WAV file as a sound track. You glue several WAV files together by calling the AppendAudioStream method after you add the audio stream.

You can add more than one audio track to one movie. It is widely used to provide, say, translations to several languages, etc. In this case you should call the AviAudioManager.AddAudioStream method for each audio stream.

The code example below takes video data from another movie and adds the audio track from the external WAV file.

Visual Basic
Public Shared Sub AddSoundTrack(ByVal sourceFilename As String, _
 ByVal destinationFilename As String, _
 ByVal sound1Filename As String, _
 ByVal sound2Filename As String)

    Dim reader As New Aurigma.GraphicsMill.Codecs.AviReader

    Dim writer As New Aurigma.GraphicsMill.Codecs.AviWriter
    writer.FramesPerSecond = reader.FramesPerSecond

    Dim frame As Aurigma.GraphicsMill.Codecs.AviFrame
    For Each frame In reader

    writer.AudioManager.AddAudioStream(sound1Filename, True)

    ' Uncomment if you want to append one more WAV file to the 
    ' audio stream. 
    'writer.AudioManager.AppendAudioStream(0, sound2Filename, True)

End Sub
public static void AddSoundTrack(string sourceFilename, 
    string destinationFilename,    
    string sound1Filename,
    string sound2Filename)
    Aurigma.GraphicsMill.Codecs.AviReader reader = 
        new Aurigma.GraphicsMill.Codecs.AviReader(sourceFilename);

    Aurigma.GraphicsMill.Codecs.AviWriter writer = 
        new Aurigma.GraphicsMill.Codecs.AviWriter();

    writer.FramesPerSecond = reader.FramesPerSecond;
    foreach (Aurigma.GraphicsMill.Codecs.AviFrame frame in reader)

    writer.AudioManager.AddAudioStream(sound1Filename, true);

    // Uncomment if you want to append one more WAV file to the 
    // audio stream. 
    //writer.AudioManager.AppendAudioStream(0, sound2Filename, true)


See Also