在 swf 文件中嵌入二进制视频数据

发布于 2024-07-06 19:41:08 字数 226 浏览 10 评论 0原文

是否可以播放编译时嵌入 swf 中的数据的视频(使用 [Embed] 元标记)?

Flash CS3 等提供的“导入视频->嵌入”功能是不可接受的,因为它有许多严重的限制(包括声音同步问题、最大帧数和其他注意事项)

我有兴趣能够捆绑swf 中的 flv 视频数据(以及其他资源),将由 AIR 应用程序播放。

我认为这是不可能的。 有人不同意吗?

Is it possible to play video from data that has been embedded in a swf at compile time (with the [Embed] metatag)?

The "Import Video->Embed" feature provided by Flash CS3 etc. is not acceptable because it has many severe limitations (including sound synchronization issues, a maximum number of frames, and other caveats)

I'm interested in being able to bundle flv video data in a swf (along with other assets), which will be played by an AIR application.

I don't think it can be done. Anyone disagree?

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

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

发布评论

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

评论(5

莫言歌 2024-07-13 19:41:08

只要您的视频是 FLV,那么答案是肯定的 - 您可以使用 NetStream.appendBytes() 来播放嵌入的 ByteArray:

public class Main extends MovieClip
{
    [Embed(source="sample.flv", mimeType="application/octet-stream")]
    private var SampleVideo:Class;

    public function Main():void 
    {
        var video:Video = new Video(320, 240);
        addChild(video);

        var netConnection:NetConnection = new NetConnection();
        netConnection.connect(null);
        var netStream:NetStream = new NetStream(netConnection);
        netStream.client = {};
        video.attachNetStream(netStream);

        var byteArray:ByteArray = new SampleVideo();
        netStream.play(null);
        netStream.appendBytes(byteArray);
    }
}

As long as your video is an FLV, then the answer is yes - you can use NetStream.appendBytes() to play the embedded ByteArray:

public class Main extends MovieClip
{
    [Embed(source="sample.flv", mimeType="application/octet-stream")]
    private var SampleVideo:Class;

    public function Main():void 
    {
        var video:Video = new Video(320, 240);
        addChild(video);

        var netConnection:NetConnection = new NetConnection();
        netConnection.connect(null);
        var netStream:NetStream = new NetStream(netConnection);
        netStream.client = {};
        video.attachNetStream(netStream);

        var byteArray:ByteArray = new SampleVideo();
        netStream.play(null);
        netStream.appendBytes(byteArray);
    }
}
活雷疯 2024-07-13 19:41:08

您可以使用 Flash IDE 将 flv 导入 swf 文件 - 我之前已经这样做过。 您可以将其像声音一样拖放到影片剪辑的时间轴上,然后将该影片剪辑拖放到舞台上以供其播放。 在 Flash CS3 中,执行“文件”>“导入”>“导入视频”并选择 flv。 选择视频,然后在向导的下一站选择“嵌入.....”,这是Adobe 开发人员中心关于将 flv 嵌入到 swf 中的文章

我自己没有这样做,但我看不出为什么您可以从加载的 swf 库访问 flv。

仅供参考:看起来这是一个被推迟的错误。 Adobe 目前似乎不允许使用 Embed 元标记进行嵌入。 这是关于该问题的论坛帖子以及指向<的链接href="https://bugs.adobe.com/jira/browse/SDK-259" rel="nofollow noreferrer">错误跟踪器。

You can import a flv into a swf file using the Flash IDE - I've done that before. You can drop it onto the timeline of a MovieClip just like a sound and then drop that movieclip onto the stage for it to play. In Flash CS3 do File>Import>Import Video and select the flv. Choose the video and then on the next stop of the wizard choose "Embed ..... ", Here is a link to an Adobe Developer center article on embedding flvs into swfs.

I have not done so myself, but I can see no reason why you could access the flv from the library of a loaded swf.

FYI: It looks like this was a bug that was deferred. It doesn't look like Adobe currently allows embedding using the Embed meta tag. Here is a forum post on the issue and a link to the bug tracker.

红颜悴 2024-07-13 19:41:08

可以使用 Flash IDE 将视频嵌入到 SWF 中,但这不是一个很好的选择:

“播放仅限于简单的播放和停止命令,并且视频
帧速率必须与主机的帧速率匹配
电影,一个重要的考虑因素
将需要创作
最小公分母下载
速度。”

“嵌入式的最大限制
video 是最多具有以下内容的电影
16,000 帧且无法同步音频
保持超过大约两分钟。”

这些引用来自这篇文章< /a> 有点旧了,但据我所知,其中关于嵌入视频的说法仍然有效。

It's possible to embed video into SWFs with the Flash IDE but it's not a very good option:

"Playback is limited to simple play and stop commands, and the video
framerate must match that of the host
movie, an important consideration that
will require authoring for the
lowest-common-denominator download
speed."

"The biggest limitations to embedded
video are movies having a maximum of
16,000 frames and audio sync cannot be
maintained beyond about two minutes."

Those quotes are from this article. It's a bit old but as far as I know, what is said there about embedding video still holds true.

祁梦 2024-07-13 19:41:08

哦,是的,显然您可以使用 Embed 元标记将二进制数据嵌入到 swf 中。

[Embed(
    source="local_data_file.flv",
    mimeType="application/octet-stream") ]
private static var __FlvClass123:Class;
protected static var flvData:ByteArray = new __FlvClass123();

是否可以从 ByteArray 播放嵌入视频不是我现阶段无法以某种方式回答的问题......

Oh yeah, so apparently you can embed binary data in a swf using the Embed meta tag.

[Embed(
    source="local_data_file.flv",
    mimeType="application/octet-stream") ]
private static var __FlvClass123:Class;
protected static var flvData:ByteArray = new __FlvClass123();

Whether you can playback embedded video from a ByteArray or not is not something I cannot answer one way or another at this stage ...

心碎的声音 2024-07-13 19:41:08

只是遇到了同样的问题并寻找更“灵活”的解决方案。
看来这些天动态嵌入的工作非常简单:

public function loadSWF(){

 var _assetLdr:Loader;
_assetLdr = new Loader();
_assetLdr.load(new URLRequest("1.swf"));
_assetLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, this.handleComplete);
addChild(_assetLdr); 
}


public function handleComplete(event:Event):void {

    trace("complete");
    var loaderInfo:LoaderInfo=event.target as LoaderInfo;
    var content:MovieClip = loaderInfo.loader.content as MovieClip;
    addChild(content);

}

注意:检查 library.swf 中的屏幕偏移。 就我而言,它们被搞乱了,所以它只是显示在屏幕外。 (感谢上帝赐予咖啡)
祝你今天过得愉快!

just had the same problem and searched for a more "flex"ible solution.
seems these Days dynamic embedding works perfectly simple:

public function loadSWF(){

 var _assetLdr:Loader;
_assetLdr = new Loader();
_assetLdr.load(new URLRequest("1.swf"));
_assetLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, this.handleComplete);
addChild(_assetLdr); 
}


public function handleComplete(event:Event):void {

    trace("complete");
    var loaderInfo:LoaderInfo=event.target as LoaderInfo;
    var content:MovieClip = loaderInfo.loader.content as MovieClip;
    addChild(content);

}

Note: Check the screen offsets within the library.swf. In my case they were messed up, so it simply displayed offscreen. (ThankGodForCoffee)
Have a nice Day!

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