使用 FMOD 从 Internet 流式传输 MP3

发布于 2024-12-01 00:58:40 字数 1420 浏览 3 评论 0原文

我认为使用 FMOD 之类的东西这将是一个相对简单的任务,但我无法让它工作。即使示例代码 netstream 似乎也没有达到目的。无论我尝试使用 netstream 示例程序播放什么 mp3,我都会收到此错误:

FMOD error! (20) Couldn't perform seek operation.  This is a limitation of the medium (ie netstreams) or the file format.

我不太明白这意味着什么。这不正是 netstream 示例程序的用途吗?从互联网上传输一些文件?

我无法通过 createSound 方法

result = system->createSound(argv[1], FMOD_HARDWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_NONBLOCKING,  0, &sound);

编辑:

这是我在阅读 Mathew 的答案后修改的内容,

FMOD_CREATESOUNDEXINFO soundExInfo;
memset(&soundExInfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
soundExInfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
soundExInfo.suggestedsoundtype = FMOD_SOUND_TYPE_MPEG;

result = system->createSound(argv[1], FMOD_HARDWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_NONBLOCKING | FMOD_IGNORETAGS,  &soundExInfo, &sound);

根据我使用的文件,我收到两个不同的错误。

测试1 URL:http://kylegobel.com/test.mp3

测试 1 错误:(25) 不支持的文件或音频格式。


测试 2 URL:http://kylegobel.com/bullet.mp3

测试 2 错误:(20) 无法不执行查找操作。这是媒体(即网络流)或文件格式的限制。

在进行更改之前,我可以使用 netstream 播放“C:\test.mp3”,该文件与网络上名为 test.mp3 的文件相同,但在进行上述更改后不再适用。也许这些文件只是格式错误或者其他原因?抱歉,我在这方面缺乏知识,我真的对声音了解不多,但试图弄清楚。

谢谢, 凯尔

I thought this would be a relatively simple task with something like FMOD, but I can't get it to work. Even the example code netstream doesn't seem to do the trick. No matter what mp3 I try to play with the netstream example program, I get this error:

FMOD error! (20) Couldn't perform seek operation.  This is a limitation of the medium (ie netstreams) or the file format.

I don't really understand what this means. Isn't this exactly what the netstream example program was for? to stream some file from the internet?

I can't get passed the createSound method

result = system->createSound(argv[1], FMOD_HARDWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_NONBLOCKING,  0, &sound);

EDIT:

This is what I modified after reading Mathew's answer

FMOD_CREATESOUNDEXINFO soundExInfo;
memset(&soundExInfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
soundExInfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
soundExInfo.suggestedsoundtype = FMOD_SOUND_TYPE_MPEG;

result = system->createSound(argv[1], FMOD_HARDWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_NONBLOCKING | FMOD_IGNORETAGS,  &soundExInfo, &sound);

I get two different errors depending on which files I use.

Test 1
URL: http://kylegobel.com/test.mp3

Test 1 Error: (25) Unsupported file or audio format.


Test 2 URL: http://kylegobel.com/bullet.mp3

Test 2 Error: (20) Couldn't perform seek operation. This is a limitation of the medium (ie netstreams) or the file format.

Before I made the change, I could use netstream to play "C:\test.mp3" which is the same file named test.mp3 on the web, but that no longer works with the above changes. Maybe these files are just in the wrong formats or something? Sorry for my lack of knowledge in this area, I really don't know much about sound, but trying to figure it out.

Thanks,
Kyle

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

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

发布评论

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

评论(1

捶死心动 2024-12-08 00:58:40

MP3 的开头可能有大量标签,因此 FMOD 会读取它们,然后尝试返回到开头(它不能这样做,因为它是网络流)。您可以尝试使用 FMOD_IGNORETAGS 和 FMOD_CREATESOUNDEXINFO 并将 suggestsoundtype 设置为 FMOD_SOUND_TYPE_MPEG 吗?

如果这不起作用,您能否将 URL 发布到已知无法工作的 MP3 流?

编辑:
该文件有大约 60KB 的标签数据,FMOD 很乐意阅读这些内容,但为了使 MPEG 编解码器正常工作,它需要进行一些小的搜索。由于您无法查找网络流,因此所有查找都必须包含在低级文件缓冲区内。如果您调整文件缓冲区大小,使其大一点,您就可以克服此限制。请参阅 System::setFileSystem“blockalign”参数。

It's possible the MP3 has a large amount of tags at the start, so FMOD reads them then tries to seek back to the start (which it can't do because it's a net stream). Can you try using FMOD_IGNORETAGS and perhaps FMOD_CREATESOUNDEXINFO with suggestedsoundtype set to FMOD_SOUND_TYPE_MPEG?

If that does't work could you post the url to a known not working MP3 stream?

EDIT:
The file in question has around 60KB of tag data, FMOD is happy to read over that stuff but for the MPEG codec to work it needs to do some small seeks. Since you cannot seek a netstream all the seeks must be contained inside the low level file buffer. If you tweak the file buffer size, make it a bit larger you can overcome this restriction. See System::setFileSystem "blockalign" parameter.

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