从闪存传输大量数据

发布于 2024-09-30 16:44:13 字数 628 浏览 8 评论 0原文

我目前正在开发一个项目,生成大量音频数据以存储在用户计算机上。

它适用于少量数据,但随着内存使用量的增加,闪存应用程序开始陷入困境并最终死亡。

我一直在考虑克服这个问题的可能方法,我在想,不是将所有数据存储在内存中(有时高达 100mb),一个可能的解决方案可能是将数据流式传输到服务器(每秒 44100 个浮点数),如下所示一旦数据积累结束,就会生成它,然后将其发送回客户端。

1)你能看出这个想法有什么问题吗?如果有的话你能提供更好的替代方案吗?

2)你能推荐一种好的服务器技术来实现这一点吗?

编辑 1

添加更多详细信息。

我正在使用 sound.extract 方法在客户端上生成音频。当音频发送到扬声器时,我还将它发送到字节数组。

一旦用户按下停止按钮,我就会在字节数组中的音频数据前面添加一个 wav 标头,并允许用户下载他们刚刚正在收听的音频的 wav。

理想情况下,我不想对用户可以保存的数据量施加限制。这可能是不可能的。

将所有这些音频数据存储在内存中会导致闪存出现严重的性能问题。我不知道有什么方法可以将这些数据增量存储在客户端计算机上,因此我认为解决方案可能是将数据增量流式传输到某处的服务器以减少内存负载。

I'm currently working on a project where I generate a large amount of audio data to be stored on a users machine.

It works fine for small amounts of data but as the memory usage grows the flash application begins to struggle and eventually dies.

I've been thinking about possible ways to overcome this problem and I was thinking instead of storing all the data in memory (sometimes up to 100mb) a possible solution may be to stream the data to a server (44100 float numbers per second) as it is is being generated then once the accumulation of data has ended sending it back to the client.

1) can you see any problem with this idea and if so could you offer a better alternative?

2) could you reccommend a good server technology to achieve this?

Edit 1

To add more detail.

I am generating audio on the client using the sound.extract method. As the audio is being sent to the speaker I also send it to a byte array.

Once the user has hit a stop button I prepend a wav header to the audio data in the bytearray and allow the user to download a wav of the audio they have just being listening to.

Ideally I didnt want to impose a limit of how much data the user could save. This may not be possible.

Storing all this audio data in memory was causing severe performance problems in flash. I don't know of any way to incrementally store this data on the client machines so I was thinking a solution may be to incrementally stream the data to a server somewhere to reduce the memory load.

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

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

发布评论

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

评论(2

成熟稳重的好男人 2024-10-07 16:44:13

我找到了一个想要实现这一目标的线程。
提出了多种解决方案。

http://drupal.org/node/69242

编辑:好的,不完全一样,但类似。也许您可以从其他人的经验中收集一些东西并提出合适的解决方案。

I found a thread that is wanting to accomplish just that.
There are a number of solutions proposed.

http://drupal.org/node/69242.

EDIT: Ok, not exactly that but similar. Maybe you can glean something from others experience here and come up with a suitable solution.

花海 2024-10-07 16:44:13

我刚刚尝试加载和提取 mp3 文件:

持续时间:09:18
mp3 字节:22345728
提取的字节:178765824

从 22mb 生成的 178mb 真的很可怕。

我认为可以避免如此严重的内存使用,但我需要更多信息:
如果您使用 Sound.extract() 您可能有 mp3 源,是吗?
您能描述一下应用程序中的数据流(加载、卸载、转换、保存)吗?
还有一个愚蠢的问题:如何保存 .wav 以及是否可以保存 .mp3?

UPD:此时我认为解决方案是为加载的声音创建一个快速包装器来检索(和创建)样本(存储为两个数字 - 开始时间和停止时间)。恕我直言,这是可能的(我喜欢编码媒体包装器,希望我能找到一些时间进行研究),并且如果此类将提供可接受的速度 - 所有混合都将在没有单个 extract() 的情况下完成当样本的最终时间线开始播放(生成必须保存的声音)时,可以通过 SoundMixer.computeSpectrum() 轻松提取 byteArray 并将其传递给 SampleDataEvent 或直接传递给用户本地文件系统。它将是唯一的 ByteArray :)

i just tried loading and extracting an mp3 file:

duration : 09:18
mp3 bytes : 22345728
extracted bytes : 178765824

178mb generated from 22mb is really frightening.

i think it's possible to avoid such severe memory usage, but i need more information:
if you are using Sound.extract() you possibly have an mp3 source, do you?
could you describe the data flow in your app (loading, unloading, conversion, saving)?
and a stupid question: how do you save .wav and is it possible to save .mp3?

UPD: at this point i think the solution is in creating a fast wrapper for a loaded sound to retrieve (and create) samples (stored as two numbers - start and stop time) from it. imho it's possible (i love coding media wrappers, hope i'll find some time for the research) and if this class will provide acceptable speed - all the mixing will be done without a single extract() and when the final timeline of samples starts playing (generating the sound that must be saved) byteArray can be easily extracted by SoundMixer.computeSpectrum()and passed to the SampleDataEvent or directly to the users local filesystem. it will be the only ByteArray :)

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