AS3 - 嵌入式 SWF 视频显示 TotalFrames == 0

发布于 2024-09-14 23:00:43 字数 1241 浏览 4 评论 0原文

我有一部 1 分钟长的电影,我想将其编译成 AS3 项目。该电影一开始是 MOV 格式,因此我使用 FFMpeg 将其转换为 FLV,然后再次使用 FFMpeg 将 FLV 转换为 SWF。

我使用 Embed 元数据将此影片嵌入到 AS3 二进制文件中:

[Embed(source="1.swf")]
private var _Vid:Class;

我有一个容器 Sprite,该影片将添加到其中。在添加之前,我将嵌入的影片投射为影片剪辑:

var vid:Object = new _Vid();
return vid as MovieClip;

当我将生成的影片剪辑添加到舞台时,它立即开始播放,并且似乎播放得很好。但是,当我检查影片剪辑的 TotalFrames 属性时,它返回 0。并且影片剪辑似乎没有响应对 stopgotoAndStop 的调用。

我通过将影片嵌入到 Flash IDE 中的 SWF 中,然后以相同的方式嵌入结果,得到了同样的行为,所以看起来我将其添加到舞台的方式有些不正常。有什么想法吗?

编辑:根据产品的要求,as3 电影无法从外部文件加载视频。它必须被编译进去,这样播放的结果.swf就可以完全独立运行,而不必依赖其他外部文件。

编辑 2:经过进一步检查,产生的 MovieClip 实例

[Embed(source="1.swf")]
private var _Vid:Class;
var vid:Object = new _Vid();
return vid as MovieClip;

有一个属于 Loader 类的子对象,并且该子对象没有子对象。我尝试将孩子直接投射为 MovieClip 但无济于事。

编辑3:从我正在阅读的此处此处,NetStream 对象的 10.1 api 公开了一个方法称为追加字节。我仍然需要进一步研究这一点,但我可以将 .flv 文件作为八位字节流嵌入,并将字节手动提供给 Net Stream 对象来播放视频。我将在几天后发布我的测试结果...

I've got this 1 minute long movie that I want to compile into an AS3 project. The movie started out in MOV format, so I used FFMpeg to convert it to FLV, then again with FFMpeg from FLV to SWF.

I'm embedding this movie into the AS3 binary by using Embed metadata:

[Embed(source="1.swf")]
private var _Vid:Class;

I've got a container Sprite that this movie gets added to. Before it's added in, I cast the embedded movie as a MovieClip:

var vid:Object = new _Vid();
return vid as MovieClip;

When I add the resulting movie clip to the stage, it begins playing immediately and seems to play fine. However, when I check the totalFrames property of the movie clip, it returns 0. And the movie clip doesn't seem to respond to calls to stop or gotoAndStop.

I get this same behavior from embedding the movie into an SWF in the Flash IDE then embedding the result in the same manner, so it seems something is out of whack with the way I'm adding it to the stage. Any thoughts?

EDIT: As a requirement of the product, the as3 movie cannot load the video from an external file. It must be compiled in, so the resultant .swf that does the playing can operate completely on its own without having to rely on other external files.

EDIT 2: Upon further inspection, the MovieClip instance that results from:

[Embed(source="1.swf")]
private var _Vid:Class;
var vid:Object = new _Vid();
return vid as MovieClip;

has one child object which is of class Loader, and that child has no children. I tried casting the child directly as MovieClip but to no avail.

EDIT 3: From what I'm reading here and here, the 10.1 api for the NetStream object exposes a method called appendBytes. I still need to look further into this, but I could embed the .flv file as an octet stream and feed the bytes manually to the Net Stream object to play the video. I'll post the result of my tests in a few...

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

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

发布评论

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

评论(2

才能让你更想念 2024-09-21 23:00:43

我最终将视频嵌入为二进制数据:

[Embed(source="1004.flv", mimeType="application/octet-stream")]

然后使用 NetStream.appendBytes() 将视频提供给连接到 Video 对象的 NetStream。这工作得非常好,并且 NetStream 可以暂停和重播。

I ended up embedding the video as binary data:

[Embed(source="1004.flv", mimeType="application/octet-stream")]

Then using NetStream.appendBytes() to feed the video to a NetStream that's hooked up to a Video object. This works beautifully, and the NetStream can be paused and replayed.

日记撕了你也走了 2024-09-21 23:00:43

查看这些教程

http://gotoandlearn.com/play.php?id=46

http://gotoandlearn.com/play.php?id=129

我认为如果视频像您一样嵌入到 MovieClip 中,那么您唯一可以预期的行为就是您当前所获得的行为。它会播放,但您无法控制它。

为什么一定要坚持嵌入呢?它会使您的文件变得更大,并且在 swf 完全加载之前视频不会播放。这是一个简短的视频,但仍然比通过渐进式下载访问它需要更长的时间。

诚然,第二个教程没有太多相关性,但为什么不添加它,它为您提供了更多关于如何处理 Flash 中的媒体的范围。 OSMF 是一个新框架,我认为了解它是有意义的。

Check these tutorials

http://gotoandlearn.com/play.php?id=46

http://gotoandlearn.com/play.php?id=129

I think that if the video is embed in a MovieClip as you did it , the only behavior you can expect is what you're getting at the moment. It will play but you won't have any control over it.

Why do you insist on embedding it? It will make your file bigger and the video won't play until the swf has completely loaded. It's a short video but it still will take far longer than accessing it via progressive download.

Admittedly the second tutorial doesn't have much relevance but why not add it , it gives you more scope on how to deal with media in Flash. OSMF is a new framework and I think it makes sense to know about it.

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