Meet us at PRINT 19. Chicago, IL. Oct. 3 - 5.
This documentation is for the old version. Go to the latest Graphics Mill docs

Extracting Audio Track

As usual AVI files contain two kinds of data - video and audio. If you need to get audio track and save it as a separate WAV file, you can use AVI Processor Add-on as described in this section.

With AVI Processor Add-on it will take only few lines:

  1. Open the reader object on the necessary AVI file.

  2. Get access to the audio manager object using the AviReader.AudioManager property.

  3. Use the AviAudioManager.ExportAudioStream method to save the necessary track to the file.

Note

An AVI file can have several audio streams (e.g. with different translations of the movie). Also, some AVI files are silent (i.e. have no audio streams). Your code should handle it properly.

Code example below demonstrates it. This code extracts only the first audio track for brevity.

Visual Basic
Public Shared Sub GetAudioTrack(ByVal inputAviFilename As String, _
  ByVal outputWavFilename As String)

    Dim reader As New Aurigma.GraphicsMill.Codecs.AviReader
    reader.Open(inputAviFilename)
    If (reader.AudioManager.AudioStreamCount > 0) Then
        ' If there is more audio streams (sound tracks) in the AVI, 
        ' we take the first one here. In this code sample we skip other 
        ' streams for brevity.
        Dim streamIndex As Integer = 0
        reader.AudioManager.ExportAudioStream(streamIndex, _
         outputWavFilename)
    Else
        ' In this case no audio track is presented in the AVI file.
        ' You should insert your version of code which handles this 
        ' situation.
        Console.WriteLine("This AVI file does not have a sound track!")
        reader.Close()
    End If
End Sub
C#
public static void GetAudioTrack(string inputAviFilename, 
    string outputWavFilename)
{
    Aurigma.GraphicsMill.Codecs.AviReader reader = 
        new Aurigma.GraphicsMill.Codecs.AviReader(inputAviFilename);
    
    if (reader.AudioManager.AudioStreamCount > 0)
    {
        // If there is more audio streams (sound tracks) in the AVI, 
        // we take the first one here. In this code sample we skip 
        // other streams for brevity.
        int streamIndex = 0;

        reader.AudioManager.ExportAudioStream(streamIndex, 
            outputWavFilename);
    }
    else
    {
        // In this case no audio track is presented in the AVI file.
        // You should insert your version of code which handles this 
        // situation.
        Console.WriteLine("This AVI file does not have a sound track!");
    }
    reader.Close();
}

See Also

Manual