Copyright © 2006-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 recorder 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 StartFromFile 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.

 

 

This method can only work with the EncodeFormats.ResampleMode property set to RESAMPLE_MODE_CUSTOM_FORMAT.

 

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

 

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

 

A successful call to this method will fire the AudioExtractFromVideoStart event followed by a number of AudioExtractFromVideoPerc events and finally by the AudioExtractFromVideoDone event.

 

 

Syntax

 

[Visual Basic]

control.ExtractAudioFromVideoFile (

nFrequency as Long,

nChannels as Long,

strOutputPath as String,

strInputPath as String

) as enumErrorCodes


 

[C++]

short control.ExtractAudioFromVideoFile (

long nFrequency,

long nChannels,

LPCTSTR strOutputPath

LPCTSTR strInputPath

);


 

 

Parameter

Description

 

 

nFrequency

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

the EncodeFormats.ForRecording property is set to ENCODING_FORMAT_WMA and the EncodeFormats.WMA.EncodeMode property is set to WMA_ENCODE_PROFILE
the EncodeFormats.ForRecording 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.ForRecording property is set to ENCODING_FORMAT_WMA and the EncodeFormats.WMA.EncodeMode property is set to WMA_ENCODE_PROFILE
the EncodeFormats.ForRecording 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 error code meaning

enumErrorCodes.ERR_NOERROR (0)

The method call was successful.