FLV 性能和垃圾收集

发布于 2024-08-29 06:24:56 字数 685 浏览 3 评论 0原文

我正在构建一个大型 Flash 网站 (AS3),它使用巨大的 FLV 作为从一个部分到另一个部分的过渡视频。 FLV 为 1280x800,正在缩放至 1680x1050(其中大部分内容无法向屏幕较小的用户显示),每个 FLV 大约 5-8 秒。我使用 On2 的高清编解码器 VP6-S 对视频进行编码,并且使用本机 FLV 播放器、配备 Perian 的 Quicktime 以及 AS3 中内置的简单概念验证 FLV 播放应用程序进行播放效果非常好。

我遇到的问题是,在实际站点的上下文中,播放不太流畅;帧速率没有达到应有的水平,更严重的是,偶尔会出现抖动和丢帧的情况(有时视频会暂停长达四分之一秒左右)。我的猜测是,这是由 Flash 播放器中的垃圾收集引起的,这种情况的发生是不确定的,因此很难测试和控制。

我使用 FLVPlayback 的单个实例来播放视频;我最初直接使用 NetStream 对象等,但切换到 FLVPlayback for 这个原因。有没有人在使用 FLVPlayback(或者更一般地说,使用高清 Flash 视频)时经历过这种不稳定的情况?我关于 GC 是罪魁祸首的说法正确吗?如果是的话,有什么方法可以在播放这些系统密集型转换期间防止它发生吗?

I'm building a large flash site (AS3) that uses huge FLVs as transition videos from section to section. The FLVs are 1280x800 and are being scaled to 1680x1050 (much of which is not displayed to users with smaller screens), and are around 5-8 seconds apiece. I'm encoding the videos using On2's hi-def codec, VP6-S, and playback is pretty good with native FLV players, Perian-equipped Quicktime, and simple proof-of-concept FLV playback apps built in AS3.

The problem I'm having is that in the context of the actual site, playback isn't as smooth; the framerate isn't quite as good as it should be, and more problematically, there's occasional jerkiness and dropped frames (sometimes pausing the video for as long as a quarter of a second or so). My guess is that this is being caused by garbage collection in the Flash player, which happens nondeterministically and is therefore hard to test and control for.

I'm using a single instance of FLVPlayback to play the videos; I originally was using NetStream objects and so forth directly but switched to FLVPlayback for this reason. Has anyone experienced this sort of jerkiness with FLVPlayback (or more generally, with hi-def Flash video)? Am I right about GC being the culprit here, and if so, is there any way to prevent it during playback of these system-intensive transitions?

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

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

发布评论

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

评论(3

半﹌身腐败 2024-09-05 06:24:57

FLV/F4V 播放中的抖动几乎不是垃圾收集的结果 - 视频实际上一直保留在内存中,直到完全卸载,因此根本不会发生垃圾收集(除非您做了一些非正统的 就像将视频放在一个容器上并将cacheAsBitmap 设置为true)。

如果您不需要特定的 FLV 功能(例如 daidai 发布的链接建议 - 免责声明,这是我的博客)会有所帮助,但总的来说,您还必须了解影响屏幕上视频合成的任何因素。由于大尺寸视频会强制重新渲染与其重叠的所有内容,因此任何小对象都可能对性能产生重大影响。

视频上面有东西吗?如果可能的话,尝试摆脱它们,或者将cacheAsBitmap设置为true(如果它们没有动画)。这对于复杂的矢量图形或文本特别有用(位图/图像的绘制速度要快得多)。如果它们有不同的混合模式,你就有点搞砸了 - 你可以使用正常的混合模式吗?

视频下面有什么东西吗?如果是这样,请在视频播放时删除它们(只需将可见性设置为 false)。

要检查不必要的渲染,请以某种方式暂停视频,右键单击,打开“显示重绘区域”(调试播放器)。你看到红色方块在连续绘制吗?然后背景上发生了一些事情,最好摆脱它。

您是否通过 onEnterFrame 或计时器/间隔在后台发生了任何事情?尝试暂停一下。

您的视频是否为 30fps,并且有 CG 渲染(例如,可以使用运动模糊)?如果是,请尝试以 24fps 或介于两者之间的速度渲染 - 质量仍然很好,但需要解码和绘制的数据要少得多。

您可以使用较小的视频吗?即使您仍然以相同的更大尺寸渲染它们,解码和渲染的像素数据更少也会有很大帮助,而且对质量的影响可能非常小。

这几乎概括了一切。不过,摆脱屏幕上的其他所有内容通常是您的第一要务。

Jerkiness in FLV/F4V playback is hardly the result of garbage collection - the video is actually kept in memory until it is fully unloaded, so there's no garbage collection taking place at all (unless you've done something unorthodox like placing the video on a container with cacheAsBitmap set to true).

Switching to F4Vs if you don't need specific FLV features (like the link posted by daidai suggests - disclaimer, it's my blog) would help, but overall, you also have to be aware of anything that's impacting compositing of the video on screen. Because a big size video forces everything that's overlapping it to be re-rendered, any small object can have a big impact on performance.

Do you have things on top of the video? Try getting rid of them, if possible, or setting cacheAsBitmap to true (if they're not animated). This is specially good for complex vector drawings or text (bitmaps/images are much faster to draw). If they have different blending modes, you're sort of screwed - can you use the normal blending mode instead?

Do you have anything below the video? If so, get rid of them while the video is playing (just set visibility to false).

To check on unnecessary renderings, somehow pause the video, right-click, turn on 'show redrawn regions' (debug player). Do you see the red square drawing continuously? Then there's something happening there on the background, better to get rid of it.

Do you have anything happening on the background via onEnterFrame or timers/intervals? Try pausing it.

Is your video 30fps, and a CG rendering (eg, can use motion blur)? If yes, try rendering at 24fps instead, or something between - still good quality, but much less data to decode and draw.

Can you use smaller videos? Even if you're still rendering them at the same bigger size, less pixel data to decode and render helps immensely, and the impact in quality can be pretty small.

That pretty much sums it all. Getting rid of everything else on screen is usually your #1 priority though.

久光 2024-09-05 06:24:57

您是否尝试过以 H.264 编码视频? Flash 播放器支持它们已经有一段时间了,它最终可能会工作得更好。这就是大多数在 Flash 中制作高清视频的人所使用的方式(例如 Youtube、Vimeo 等)。

作为一个测试,尝试在 YouTube 上播放 1080p 高清视频,看看是否会暂停。

Have you tried encoding the videos in H.264 instead? Flash player supports them for some time now, it may end up working better. That's what most people doing HD video in Flash use (eg Youtube, Vimeo, etc).

Just as a test, try plaing a 1080p HD video on youtube and see if that pauses at all for you.

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