Skip to content

Audio recording to MP3 or WAV files

Recording the audio stream of the current audio capture device

To record the audio stream coming out of the current audio capture device:

  1. Disable the current video capture device by setting VideoDevice = -1 (*), then select the index of the AudioDevice in the AudioDevices list.
  2. Invoke StartAudioRecording.

(*) Otherwise, the video capture device would be used first if it exposes an audio stream, see below.

Recording the audio stream of the current video capture device

To record the audio stream coming out of the current video capture device, for the video capture devices that expose an audio output:

  1. Select the index of the VideoDevice in the VideoDevices list.
  2. Invoke StartAudioRecording.

".WAV" recording

By default, if no audio compressor is selected, the recording is made in ".WAV" format, and the ".wav" extension is added automatically to the recorded file name.

".MP3" and ".WMA" recording

The recording is made in MP3 when RecordingMethod = rm_MP3 (or when the RecordingFileName extension is ".mp3"), and in WMA when RecordingMethod = rm_WMA (or when the extension is ".wma"), with the Microsoft MP3 / WMA encoders (MP3: Windows 8 or later), at 128 kb/s by default. The bit rate can be set with AudioCompression_SetInt (ac_BitRate, in bits per second), e.g. AudioCompression_SetInt (ac_BitRate, 192000): the nearest bit rate supported by the encoder is used. For WMA, ASFAudioBitRate can also be used.

E.g.:

procedure TForm1.MP3AudioRecording;
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
  VideoGrabber.RecordingMethod:= rm_MP3; // or rm_WMA
  VideoGrabber.StartAudioRecording;
end;

Selecting the right or left channel

AudioChannelRenderMode can convert the right channel or the left channel to "mono", and mute either the left, right or both channels.

Selecting the audio stream

When the clip has multiple audio streams, one audio stream can be selected, see AudioStreamNumber.