Flash 播放器渲染动画太慢 - 有没有办法加速它?

发布于 2024-11-07 03:21:32 字数 586 浏览 1 评论 0原文

我正在制作一个项目(在 Flash CS5 中) - 我使用 midi 文件可视化音乐 - 这意味着我在舞台上有很多简单的影片剪辑(矩形),它们有不同的 z-index、不透明度、高度、宽度、模糊等。问题

是——它渲染得太慢了!当闪光灯难以渲染时,我可以看到帧速率从 30 F/S 变为 10 甚至 5 F/S。现在,我的动画并不那么复杂 - 我在网络或游戏上看到过令人惊奇的东西 - 我只尝试移动简单的形状。

因为我不知道该怎么做 - 我的问题是是否有办法:

  1. 以某种方式使用计算机图形硬件?使用 openGL 引擎?我有这样的想法,如果我将它连接到一个强大的引擎,它会工作吗?

  2. 有办法逐帧记录它吗?我不必实时查看它(尽管这会很好) - 我可以妥协将其制作为 . mov 文件。但我发现将其导出为电影没有帮助(它会像实时播放一样记录它)。我尝试了一些方法来“手动”减慢每个影片剪辑的速度 - 但由于一切都变慢了..屏幕现在有更多的影片剪辑要渲染,并且变得更慢。

有人能想出解决办法吗?我做错了什么吗? (我真的不认为我渲染的东西如此复杂以至于它太慢)

I am making a project (in Flash CS5) - I visualize music using a midi file - that means I have on stage lot's of simple movieclips (rectangles) and they have different z-index, opacity, height, width, blur etc...

The thing is - it renders too slow! I can see the frame rate goes from 30 F/S to 10 or even 5 F/S when it is hard for the flash to render it. now, my animations are NOT THAT COMPLICATED - I have seen on the web or on games amazing things - I only try to move simple shapes.

Since I don't know what to do - my questions are if there is a way:

  1. to use the computer graphics hardware in someway? Using openGL engine? I have this thought that if I would connect it to a powerful engine it would work?

  2. Is there a way to record it frame-by-frame? I don't have to see it in real time (although it would be nice) - I can compromise in making it a .mov file. but I found that exporting it as a movie won't help (it records it as if it plays in realtime). I tried ways to "manually" slow down the speed of every movieclip - but since everything slows down.. the screen has now more movieclips to render and it becomes even more slow.

Can anyone think of a solution? am I doing something wrong? (I really don't think I render somthing so complicated for it to be too slow)

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

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

发布评论

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

评论(2

望她远 2024-11-14 03:21:32

您可以通过 Flash 插件的标志来使用硬件加速:
http://www.adobe.com/devnet/flashplayer/articles/fplayer10_1_hardware_acceleration.html
然而,它并不适用于所有平台,它几乎只适用于 Windows :(
此外,您将获得的性能改进(如果有的话)很大程度上取决于您的动画的组成部分。

逐帧记录内容是可行的,但很烦人。您可以使用 PNGEncoder 或 JPEGEncoder 类并将它们写入文件。
http://blog.everythingflex.com/2008/ 10/01/filereferencesave-in-flash-player-10/
如果将其放入 onEnterFrame 的处理程序中,它每次都会将一帧保存到硬盘驱动器中。然后,您可以使用 mencoder 等标准工具从图像创建电影。

现在我的建议是,尝试分析您的 swf 并找出速度如此之慢的原因。有可能不是渲染,而是您的代码。如果确实是渲染的问题,请尝试找出为什么它如此慢 - 例如,您正在传输数千个启用 Alpha 的影片剪辑,并且您正在更改每一帧。 Flash 播放器对于它可以缓存的内容非常聪明,但您必须给它一个机会。如果您的场景并不复杂并且仍然很慢,则总是意味着您做错了什么。尝试不使用 Alpha,使用绘制方法而不是使用数百个影片剪辑。

You can use hardware acceleration through a flag to your flash plugin :
http://www.adobe.com/devnet/flashplayer/articles/fplayer10_1_hardware_acceleration.html
However, it does not work on all platforms, it's pretty much windows-only :(
Besides, the performance improvement that you're gonna get, if any, is heavily variable depending on what your animation consists of.

Record the stuff frame-by-frame is feasible, but annoying. You can use PNGEncoder or JPEGEncoder classes and write them to files.
http://blog.everythingflex.com/2008/10/01/filereferencesave-in-flash-player-10/
If you put that in the handler for onEnterFrame, it will save a frame to the hard drive each time. You can then create a movie from your images using standard tools like mencoder.

Now my advice would be, try to profile your swf and find out what is so slow. There is a chance it's not the rendering but your code. If it really is the rendering, try to find out why it's so slow - like, you're blitting thousands of alpha-enabled movie clips that you are changing every frame. Flash player is pretty clever about what it can cache and all, but you have to give it a chance to. If your scene is not complicated and it's still slow, it always means you're doing something wrong. Experiment with no alpha, and with draw methods rather than using hundreds of movie clips.

信仰 2024-11-14 03:21:32

您提到了模糊。这会显着减慢你的动画速度。几乎所有过滤器都不是需要动画处理的对象的推荐伴侣 - 至少不会同时处理多个对象。如果您打算这样做,那么至少将 BlurFilter 应用于容器而不是单个子项。

还有其他性能明显更好的方法可以将过滤器应用于许多对象,例如将元素绘制到 BitmapData 上并使用 BitmapData.applyFilter() 对其应用过滤器

。你的过滤器,看看是否有帮助。如果没有,请提供更多代码/信息,我会看一下:)

You mentioned blur. This will slow down your animation significantly. Almost any filter is not a recommended companion for objects that need to be animated - at least not many simultaneously. If you're going to do this then at least apply the BlurFilter to the container rather than the individual children.

There's other significantly better performing ways to have filters applied to many objects, such as drawing your elements onto BitmapData and applying a filter to that using BitmapData.applyFilter()

Remove all of your filters and see if that helps. If not, provide some more code/info and I'll take a look at it :)

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