如何在OSMF中播放flv格式的byteArray?

发布于 2024-10-11 02:01:29 字数 236 浏览 1 评论 0原文

我正在 Flex 中开发一个 Web 应用程序,它具有通过获取每个帧的快照来记录运行时的功能,然后将其编码到 ByteArray 中以进行视频播放。

我目前正在使用 NetStream.appendBytes() 播放 ByteArray FLV。它正在工作,但我刚刚发现 OSMF 并考虑将其集成到我的应用程序中。

OSMF 中可以播放 flv byteArray 吗?如果有一个关于如何做到这一点的例子那就太好了。谢谢!

I am developing an web application in flex which have a feature of recording the runtime by having a snapshot of each frames then encoding it into a ByteArray for video playback.

I am currently using NetStream.appendBytes() for playing the ByteArray FLV. It is working, but I just found out about OSMF and thinking bout integrating it in my application.

It is it possible to play the flv byteArray in OSMF? An example on how can it be done would be totally great. thanks!

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

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

发布评论

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

评论(1

随遇而安 2024-10-18 02:01:29

我现在可以在 OSMF 中播放 flv 字节数组。在此之前,我已经能够通过创建一个扩展 netStream 的新类并重写其 play 方法以使用 appendbytes 来播放 byteArray。所以我所做的就是让 OSMF 使用它。我这样做创建了这些类:
1. ByteStreamElement - 媒体元素
2. ByteStreamLoader - 扩展LoaderBase
3. ByteStreamLoadTrait - 扩展 LoadTrait

覆盖 netstremas 查找/播放方法:

//manually dispatch seek event since we override seek()
dispatchEvent(new NetStatusEvent(NetStatusEvent.NET_STATUS,false,false, {code:"NetStream.Play.Seek", level:"status"})); 

//look for byte position based on _seekTime value
flvStream = _sfw.getFlvStream(false);  
_seekTime = parameters[1] * 1000; //netstream time in milliseconds
_flvParser.parse(flvStream, false, flvTagSeeker);
flvStream.position = _flvParserProcessed;

//append flvtag from the new byte position to end of flv byteArray 
var tmp:ByteArray = new ByteArray();
flvStream.readBytes(tmp, 0, flvStream.bytesAvailable);
_flvParserProcessed = 0;
this.appendBytesAction(NetStreamAppendBytesAction.RESET_SEEK);
appendBytes(tmp)  

并像这样使用它:

 mediaPlayerSprite = new MediaPlayerSprite();
 addChild(mediaPlayerSprite);
 mediaPlayerSprite.media = new  ByteStreamElement();

我真的不确定这是否是最好的方法。不确定我是否最好创建新类,或者我应该为 OSMF 编写某种插件来播放字节数组。另一件事是,我真正需要的是在需要时不断在播放器中追加字节。这就是为什么我仍然没有使用它,同时我会坚持使用我定制的“ByteStream 播放器”,直到我弄清楚这一点。

I am now able to play flv bytearrays in OSMF. Beforehand, I've already been able to play byteArray by creating a new class that extends netStream and overriding its play method to use appendbytes instead. So what I did was to make OSMF use it. I did this creating these classes:
1. ByteStreamElement - media element
2. ByteStreamLoader - extends LoaderBase
3. ByteStreamLoadTrait - extends LoadTrait

overriding netstremas seek/play method:

//manually dispatch seek event since we override seek()
dispatchEvent(new NetStatusEvent(NetStatusEvent.NET_STATUS,false,false, {code:"NetStream.Play.Seek", level:"status"})); 

//look for byte position based on _seekTime value
flvStream = _sfw.getFlvStream(false);  
_seekTime = parameters[1] * 1000; //netstream time in milliseconds
_flvParser.parse(flvStream, false, flvTagSeeker);
flvStream.position = _flvParserProcessed;

//append flvtag from the new byte position to end of flv byteArray 
var tmp:ByteArray = new ByteArray();
flvStream.readBytes(tmp, 0, flvStream.bytesAvailable);
_flvParserProcessed = 0;
this.appendBytesAction(NetStreamAppendBytesAction.RESET_SEEK);
appendBytes(tmp)  

And using it like this:

 mediaPlayerSprite = new MediaPlayerSprite();
 addChild(mediaPlayerSprite);
 mediaPlayerSprite.media = new  ByteStreamElement();

Im really not sure though if this is the best way to do it. Not sure if it is best that i created new classes or I should have written some sort of plugin for OSMF to use to play bytearrays. And another thing is that, what I really need is it to contiually appendbytes in the player in case needed. That's why Im still not using this and for the mean time Ill stick with my custom made "ByteStream player" until I figure this out.

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