Copyright © 2011-2018 MultiMedia Soft

ExtractAudioFromVideoFile method

Previous pageReturn to chapter overviewNext page

Remarks

 

Starts extraction of the audio track from a video clip into an output sound file: in this case contents of the resulting output file is not loaded into the editor directly so, in case you should need to edit the output sound file, once extraction will be completed, you will have to load it with a call to the LoadSound method.

 

 

Loading of video clips is implemented through interaction with DirectShow so, in order to open some specific video format, there may be the need of a specific DirectShow filter.

By default, DirectShow includes a limited number of filters for decoding some common media file formats such as MPEG-1, MP3, Windows Media Audio, Windows Media Video, MIDI, media containers such as AVI, ASF, WAV, some splitters/demultiplexers, multiplexers, source and sink filters and some static image filters. However, DirectShow's standard format repertoire can be easily expanded by means of a variety of commercial and open source filters. Such filters enable DirectShow to support virtually any container format and any audio or video codec. One of the best packages containing most audio and video codecs for DirectShow is K-Lite Codec Pack, available in both x86 and x64 versions, and can be downloaded for free from the following link.

IMPORTANT NOTE ABOUT X86 AND X64 VERSIONS OF WINDOWS: When the container application is compiled for "Any CPU" or for "x64" and run on a x64 versions of Windows, in order to create the filters graph DirectShow automatically searches for x64 versions of the codecs; K-Lite Codec Pack comes with both x86 and x64 versions of its binaries so, when running on a x64 version of Windows, it's very important being sure that the x64 version is installed.

 

 

An extraction session can be stopped at any time through a call to the ExtractAudioAbort method.

 

As seen for exporting sessions, the format of the output sound file can be set through the EncodeFormats.FormatToUse property.

 

During the execution of the audio extraction session the CallbackPercentage delegate is invoked, with the nOperation parameter set to OPERATION_AUDIO_EXTRACT, in order to notify about the percentage of advancement of the audio extraction session.

 

For further details about callback delegates see the How to synchronize the container application with the API tutorial.

 

 

Syntax

 

[Visual Basic]

Public Function ExtractAudioFromVideoFile (

nFrequency as Int32,

nChannels as Int32,

strOutputPath as string,

strInputPath as string

) as enumErrorCodes


 

[C#]

public enumErrorCodes ExtractAudioFromVideoFile (

Int32 nFrequency,

Int32 nChannels,

string strOutputPath

string strInputPath

);


 

[C++]

public: enumErrorCodes ExtractAudioFromVideoFile (

Int32 nFrequency,

Int32 nChannels,

string strOutputPath

string strInputPath

);


 

 

Parameter

Description

 

 

nFrequency

Frequency used to resample the sound to export (44100, 22050, etc.). This parameter is ignored when:

the EncodeFormats.FormatToUse property is set to ENCODING_FORMAT_WMA and the EncodeFormats.WMA.EncodeMode property is set to WMA_ENCODE_PROFILE
the EncodeFormats.FormatToUse property is set to ENCODING_FORMAT_ACM

nChannels

Number of channels used to resample the sound to export (1 for Mono or 2 for Stereo). This parameter is ignored when:

the EncodeFormats.FormatToUse property is set to ENCODING_FORMAT_WMA and the EncodeFormats.WMA.EncodeMode property is set to WMA_ENCODE_PROFILE
the EncodeFormats.FormatToUse property is set to ENCODING_FORMAT_ACM

strOutputPath

String containing the absolute pathname of the destination audio file. If this pathname should contain invalid characters, they would be automatically changed into an underscore '_' character.

strInputPath

String containing the absolute pathname of the source video file. If this pathname should contain invalid characters, they would be automatically changed into an underscore '_' character.

 

 

Return value

 

Value

Meaning

 

 

Negative value

An error occurred. Check the LastError property value in order to see the last error.

enumErrorCodes.ERR_NOERROR (0)

The method call was successful.