Delphi:BASS.dll - 如何将 MP3 流的一部分复制到另一个文件

发布于 2024-12-15 11:48:14 字数 208 浏览 4 评论 0原文

我正在使用 BASS.dll 库,我想做的就是使用 BASS_StreamCreateFile 等将正在播放的 MP3 部分“重定向”到另一个文件(可能是 MP3 或 WAVe)。我不知道如何开始?我试图使用帮助来找到答案,但仍然一无所获。我可以播放这个流。读取一些我需要的数据。现在我需要复制文件,例如从 2:00 到 2:10(或按位置)。 有什么想法我应该如何开始?

问候, 杰康

Im using BASS.dll library and all I want to do is to "redirect" part of MP3 Im playing using for example BASS_StreamCreateFile to another file (may be MP3 or WAVe). I dont know how to start? Im trying to use help to find an answer, but still nothing. I can play this stream. Read some data I need. Now I need to copy ile for example from 2:00 to 2:10 (or by position).
Any ideas how should I start?

Regards,
J.K.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘦怹 2024-12-22 11:48:14

嗯,我不太了解 BASS,但我对音乐播放和压缩数据格式有一点了解,并且正确复制数据涉及中间解码步骤。您需要执行以下操作:

  1. 打开文件并找到正确的位置。
  2. 将音频解码到内存缓冲区中。缓冲区的大小应为 (LengthInSeconds * SamplesPerSecond * Channels * BytesPerSample) 字节。因此,如果是 10 秒的 CD 品质音频,则为 10 * 44100 * 2(立体声)* 2(16 位音频)= 1764000 字节。
  3. 获取此解码数据缓冲区并将其输入 MP3 编码函数,并将生成的 MP3 保存到文件中。

如果 BASS 具有解码到外部缓冲区以及将缓冲区编码为 MP3 的功能,那就很好了;您所要做的就是弄清楚要使用哪些。如果没有,您将不得不寻找另一个 MP3 编码和解码库。

另外,请注意世代损失。 MP3 使用有损压缩,因此如果多次解压缩和重新压缩数据,会损害音质。

Well, I don't know BASS specifically, but I know a little about music playing and compressed data formats in general, and copying the data around properly involves an intermediate decoding step. Here's what you'll need to do:

  1. Open the file and find the correct position.
  2. Decode the audio into an in-memory buffer. The size of your buffer should be (LengthInSeconds * SamplesPerSecond * Channels * BytesPerSample) bytes. So if it's 10 seconds of CD quality audio, that's 10 * 44100 * 2 (stereo) * 2 (16-bit audio) = 1764000 bytes.
  3. Take this buffer of decoded data and feed it into an MP3 encoding function, and save the resulting MP3 to a file.

If BASS has functions for decoding to an external buffer and for encoding a buffer to MP3, you're good; all you have to do is figure out which ones to use. If not, you'll have to find another library for MP3 encoding and decoding.

Also, watch out for generational loss. MP3 uses lossy compression, so if you decompress and recompress the data multiple times, it'll hurt the sound quality.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文