Audio recording to MP3 or WAV files
Audio recording to MP3 or WAV files Recording of the audio stream coming out of the current audio capture device: - disable the current video capture device: set VideoDevice = -1 ( * ) - select the index of the AudioDevice in the AudioDevices list, - invoke StartAudioRecording.
**( * ) otherwise it would be used firstly if it exposes an audio stream, see below. Recording of the audio stream coming out of the current video capture device: For video capture devices that expose an audio output: - select the index of the VideoDevice in the VideoDevices list, - invoke StartAudioRecording.
".WAV" recording By default, if no audio compressor is selected, the recording is made in ".WAV" format, and the ".wav" extension will be added automatically to the recorded file name.
".MP3" recording The default MP3 encoder, that appears as "MPEG Layer-3" in the audio device list, can be used, but it does not make it possible to adjust the MP3 settings.
It is possible to try instead the Elecard MP3 audio encoder, that allows to adjust the MP3 settings by invoking ShowDialog (dlg_AudioCompressor). http://www.elecard.com/ftp/pub/directshow/lame_dshow.zip (this download link appears under "MPEG Layer III Audio Encoder" at the bottom of the download page of Elecard here: http://www.elecard.com/download/index.php)
The "Layer III Audio Encoder 1.0.70111.exe" installs the codec file "lame.ax" under Program Files/Common Files/Elecard.
Simply redistribute the "lame.ax" file and register it by running "regsvr32.exe lame.ax"
After installing the MP3 codec, it will appear as "LAME Audio Encoder" in the "audio devices" list.
Before invoking StartAudioRecording: - set CompressionMode to cm_CompressOnTheFly - set CompressionType to ct_Audio - set AudioCompressor to the index of the MP3 encoder in the AudioCompressors list.
The name of the Elecard's MP3 encoder is "LAME Audio Encoder", so it is possible to use the FindIndexInListByName function to retrieve it programmatically.
E.g.:
procedure TForm1.AudioRecording (AdjustSettings: Boolean; StartAudioRecording: Boolean;); begin VideoGrabber.VideoDevice:= -1; // do not use the video capture device VideoGrabber.AudioDevice:= 0; // e.g. we use the first audio device in the AudioDevices list (1) VideoGrabber.CompressionMode:= cm_CompressOnTheFly; VideoGrabber.CompressionType:= ct_Audio; VideoGrabber.AudioCompressor:= VideoGrabber.FindIndexInListByName (VideoGrabber.AudioCompressors, 'LAME Audio Encoder', false, true); if VideoGrabber.AudioCompressor = -1 then begin // error handling: MP3 audio compressor not found! end else begin if AdjustSettings then begin VideoGrabber.ShowDialog (dlg_AudioCompressor); end; if StartAudioRecording then begin VideoGrabber.StartAudioRecording; end; end; end; Selecting the right or left channel It is possible to convert the right channel or the left channel as "mono" and to mute either the left, right or both channels with AudioChannelRenderMode.
Selecting the audio stream When the clip has multiple audio streams it is possible to select one audio stream, see AudioStreamNumber