如何在FMX Windows上使用Delphi 10.4.2将麦克风录制到MP3? [英] How to record microphone to MP3 with Delphi 10.4.2 on FMX Windows?

查看:134
本文介绍了如何在FMX Windows上使用Delphi 10.4.2将麦克风录制到MP3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在FMX Delphi 10.4.2中,我正在使用以下代码录制音频:

In FMX Delphi 10.4.2 I'm recording audio with this code:

  var
        fMicrophone: TAudioCaptureDevice;
begin

  fMicrophone := TCaptureDeviceManager.Current.DefaultAudioCaptureDevice;

  if fMicrophone = nil
    then
      begin
        ShowMessage('Audio capturing device not available');
        Exit;
      end;

  MicFilterStringLabel.Text := fMicrophone.FilterString;  // filter is *.wav

  RecordButton.Enabled := False;
  StopButton.Enabled := True;

      // Sets the name of the file to save the recorded data
  fMicrophone.FileName := TPath.Combine(gPreferences.TemporaryFolder, 'samplefile.mp3');

  fMicrophone.StartCapture;
end;

    // later the stop button calls fMicrophone.StopCapture;

这似乎无法创建真实的MP3文件.也许它仍在制作WAV文件,只是带有MP3扩展名.

This does not seem to create an authentic MP3 file. Perhaps it's still making a WAV file but just with the MP3 extension.

此组件可以制作MP3文件吗?失败了,有没有可以制作MP3文件的组件?(mitov组件似乎未安装在Delphi 10.4.2上,我还没有收到有关此问题的电子邮件回复.)

Can this component make an MP3 file? Failing that, is there a component that will make MP3 files? (The mitov components don't seem to install on Delphi 10.4.2 and I don't have an email answer back from him about that yet.)

推荐答案

根据文档(请参阅音频录制),支持的捕获格式为:

According to the documentation (see Audio-Video in FireMonkey and Audio Recording), the supported capture formats are:

  • Windows上的WAV
  • iOS和Mac上的CAF
  • Android上的3GP

在Windows上, TAudioCaptureDevice 使用DirectShow,它不支持捕获 MP3,仅支持播放.

On Windows, TAudioCaptureDevice uses DirectShow, which does not support capturing MP3, only playing it.

因此,如果要录制MP3文件,则必须在录制后转换WAV文件.您可以使用很多第三方库.否则,您将必须自己捕获并保存麦克风音频,例如直接使用平台API而不是使用FireMonkey.

So, if you want to record an MP3 file, you will have to convert the WAV file after recording it. There are plenty of 3rd party libraries you can use for that. Otherwise, you will have to capture and save the microphone audio yourself, such as by using platform APIs directly instead of using FireMonkey.

这篇关于如何在FMX Windows上使用Delphi 10.4.2将麦克风录制到MP3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆