ActionScript3 中循环视频缓冲区

发布于 2024-12-05 01:28:12 字数 865 浏览 0 评论 0原文

我正在尝试创建一个具有循环、无缝视频背景的 AS3 应用程序。背景是从 flv 加载的。到目前为止,问题在于无缝位,因为我遇到的有关 AS3 的所有视频循环策略似乎总是在视频末尾有短暂但明显的暂停,然后再返回开头并再次播放。

我确定处理此问题的最佳方法是播放视频并将视频帧作为 BitmapData 对象缓冲到定义长度的队列中(无需将视频添加到舞台)。这样,渲染视频实际上涉及将每个 BitmapDatas 弹出到 Bitmap 中 对象以定时方式附加到我的舞台上,然后被绘制。

有点像:

/*VideoBufferer loops the input video and queues frames and then updates*/
var vidbuffer:VideoBufferer = new MyVideo("video.flv",outputImage)

var outputImage:Bitmap = new Bitmap();
stage.addChild(outputImage);

//forgive syntax, this is pseudoCode
timed process that happens X times per second{
  outputImage.bitmapData = vidbuffer.popBitmapData(); //returns bitmap data from the queue
}

我不在乎声音。

然而,我似乎不知道如何实现这个所需的 VideoBufferer 类,因为我不知道如何在不将视频添加到舞台并从中抓取帧的情况下播放视频。任何人都知道任何这样的类已经做到了这一点,或者有人可以给我关于如何实现 VideoBufferer 的帧抓取方面的指示吗?

谢谢

I'm trying to create an AS3 app with looping, seamless video background. The background is loaded from an flv. The problem thus far is with the seamless bit, because all the video looping tactics I've come accross regarding AS3 always seem to have that short but noticeable pause at the end of the video before going back to the beginning and playing again.

The best way I've determined to deal with this is to play a video and buffer the video frames as BitmapData objects into a queue of a defined length (without adding the video to stage). This way Rendering the video would then really involve popping each of those BitmapDatas into a Bitmap
object attached to my stage in a timed manner, which then gets drawn.

Sort of like:

/*VideoBufferer loops the input video and queues frames and then updates*/
var vidbuffer:VideoBufferer = new MyVideo("video.flv",outputImage)

var outputImage:Bitmap = new Bitmap();
stage.addChild(outputImage);

//forgive syntax, this is pseudoCode
timed process that happens X times per second{
  outputImage.bitmapData = vidbuffer.popBitmapData(); //returns bitmap data from the queue
}

I don't care about sound.

However I seem to not know how to implement this desired VideoBufferer class as I don't know how to play a video without adding it to stage and grabbing frames from it. Dows anyone know of any such class out there that already does this or could someone give me pointers on how to implement the frame grabbing side of VideoBufferer?

Thanks

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

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

发布评论

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

评论(2

我做我的改变 2024-12-12 01:28:12

我知道这是一个很晚的答案,但我有一个无缝 flv 播放的解决方案,如下所述: http://blog.redannick.com/seamless-looping-video-files-in-as3-with-netstream-appendbytes/

上的示例代码要点如下: https://gist.github.com/redannick/7772246

I know this is a very late answer, but I have a solution for seamless flv playback, described here: http://blog.redannick.com/seamlessly-looping-video-files-in-as3-with-netstream-appendbytes/

example code on a gist here: https://gist.github.com/redannick/7772246

笑脸一如从前 2024-12-12 01:28:12

你和我最好的开源朋友:Doob 先生来救援。

http://code .google.com/p/mrdoob/source/browse/trunk/libs/net/hires/utils/display/BitmapDataSequence.as

它旨在加载 SWF 并转换帧到一系列 BitmapData 对象。它应该更新为使用向量等,因为它自 2008 年以来就没有更新过,但这就是答案。

即时处理视频肯定比较棘手,但如果您可以在时间轴上嵌入视频(确保帧速率正确!)并导出 SWF 以便稍后加载,那么这是值得的并且效果很好。

Yours and my best friend for open source: Mr. Doob, to the rescue.

http://code.google.com/p/mrdoob/source/browse/trunk/libs/net/hires/utils/display/BitmapDataSequence.as

It's designed to load a SWF and convert the frames to a sequence of BitmapData objects. It should be updated to use Vectors, etc. as it hasn't been updated since 2008, but it's the answer.

It's definitely trickier to do it on the fly with video, but if you have the luxury of embedding the video on the timeline ( get those frame rates correct! ) and exporting a SWF to load later on, it's worth it and works well.

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