Code sample - Audio capture to MP3 (using LAME)

Delphi and C# (ActiveX) sample code.

 

Set LAME settings 

VideoCapture1.Audio_LAME_CBR_Bitrate := StrToInt(cbLameCBRBitrate.Items[cbLameCBRBitrate.ItemIndex]);
VideoCapture1.Audio_LAME_VBR_Min_Bitrate := StrToInt(cbLameVBRMin.Items[cbLameVBRMin.ItemIndex]);
VideoCapture1.Audio_LAME_VBR_Max_Bitrate := StrToInt(cbLameVBRMax.Items[cbLameVBRMax.ItemIndex]);
VideoCapture1.Audio_LAME_Sample_Rate := StrToInt(cbLameSampleRate.Items[cbLameSampleRate.ItemIndex]);
VideoCapture1.Audio_LAME_VBR_Quality := tbLameVBRQuality.Position;
VideoCapture1.Audio_LAME_Encoding_Quality := tbLameEncodingQuality.Position;

if rbLameStandardStereo.Checked then
  VideoCapture1.Audio_LAME_Channels_Mode := CH_Standard_Stereo
else if rbLameJointStereo.Checked then
  VideoCapture1.Audio_LAME_Channels_Mode := CH_Joint_Stereo
else if rbLameDualChannels.Checked then
  VideoCapture1.Audio_LAME_Channels_Mode := CH_Dual_Stereo
else
  VideoCapture1.Audio_LAME_Channels_Mode := CH_Mono;

VideoCapture1.Audio_LAME_VBR_Mode := rbLameVBR.Checked;
VideoCapture1.Audio_LAME_Copyright := cbLameCopyright.Checked;
VideoCapture1.Audio_LAME_Original := cbLameOriginalCopy.Checked;
VideoCapture1.Audio_LAME_CRC_Protected := cbLameCRCProtected.Checked;
VideoCapture1.Audio_LAME_Force_Mono := cbLameForceMono.Checked;
VideoCapture1.Audio_LAME_Strictly_Enforce_VBR_Min_Bitrate := cbLameStrictlyEnforceVBRMinBitrate.Checked;
VideoCapture1.Audio_LAME_Voice_Encoding_Mode := cbLameVoiceEncodingMode.Checked;
VideoCapture1.Audio_LAME_Keep_All_Frequencies := cbLameKeepAllFrequencies.Checked;
VideoCapture1.Audio_LAME_Strict_ISO_Compilance := cbLameStrictISOCompilance.Checked;
VideoCapture1.Audio_LAME_Disable_Short_Blocks := cbLameDisableShortBlocks.Checked;
VideoCapture1.Audio_LAME_Enable_Xing_VBR_Tag := cbLameEnableXingVBRTag.Checked;
VideoCapture1.Audio_LAME_Mode_Fixed := cbLameModeFixed.Checked;
VideoCapture1.Audio_LAME_CBR_Bitrate = Convert.ToInt32(cbLameCBRBitrate.Text);
VideoCapture1.Audio_LAME_VBR_Min_Bitrate = Convert.ToInt32(cbLameVBRMin.Text);
VideoCapture1.Audio_LAME_VBR_Max_Bitrate = Convert.ToInt32(cbLameVBRMax.Text);
VideoCapture1.Audio_LAME_Sample_Rate = Convert.ToInt32(cbLameSampleRate.Text);
VideoCapture1.Audio_LAME_VBR_Quality = tbLameVBRQuality.Value;
VideoCapture1.Audio_LAME_Encoding_Quality = tbLameEncodingQuality.Value;

if (rbLameStandardStereo.Checked)
  VideoCapture1.Audio_LAME_Channels_Mode = VisioForge_Video_Capture_3.TxVFLameChannelsMode.CH_Standard_Stereo;
else if (rbLameJointStereo.Checked)
  VideoCapture1.Audio_LAME_Channels_Mode = VisioForge_Video_Capture_3.TxVFLameChannelsMode.CH_Joint_Stereo;
else if (rbLameDualChannels.Checked)
  VideoCapture1.Audio_LAME_Channels_Mode = VisioForge_Video_Capture_3.TxVFLameChannelsMode.CH_Dual_Stereo;
else
  VideoCapture1.Audio_LAME_Channels_Mode = VisioForge_Video_Capture_3.TxVFLameChannelsMode.CH_Mono;

VideoCapture1.Audio_LAME_VBR_Mode = rbLameVBR.Checked;
VideoCapture1.Audio_LAME_Copyright = cbLameCopyright.Checked;
VideoCapture1.Audio_LAME_Original = cbLameOriginal.Checked;
VideoCapture1.Audio_LAME_CRC_Protected = cbLameCRCProtected.Checked;
VideoCapture1.Audio_LAME_Force_Mono = cbLameForceMono.Checked;
VideoCapture1.Audio_LAME_Strictly_Enforce_VBR_Min_Bitrate = cbLameStrictlyEnforceVBRMinBitrate.Checked;
VideoCapture1.Audio_LAME_Voice_Encoding_Mode = cbLameVoiceEncodingMode.Checked;
VideoCapture1.Audio_LAME_Keep_All_Frequencies = cbLameKeepAllFrequences.Checked;
VideoCapture1.Audio_LAME_Strict_ISO_Compilance = cbLameStrictISOCompilance.Checked;
VideoCapture1.Audio_LAME_Disable_Short_Blocks = cbLameDisableShortBlocks.Checked;
VideoCapture1.Audio_LAME_Enable_Xing_VBR_Tag = cbLameEnableXingVBRTag.Checked;
VideoCapture1.Audio_LAME_Mode_Fixed = cbLameModeFixed.Checked;

Use MP3 (LAME) format for output 

VideoCapture1.OutputFormat := Format_LAME;
VideoCapture1.OutputFormat = VisioForge_Video_Capture_5.TxVFOutputFormat.Format_LAME;

Set audio capture mode 

VideoCapture1.Mode := Mode_Audio_Capture;
VideoCapture1.Mode = VisioForge_Video_Capture_5.TxVFMode.Mode_Audio_Capture;

Start capture 

VideoCapture1.Start;
VideoCapture1.Start();

VisioForge © 2006-2019

  • GitHub-Mark-64px
  • Twitter Социальные Иконка
  • VisioForge Facebook page
  • YouTube channel