多个 flv 同步问题
可以同步flv视频吗?我同时播放几个视频,它们不一致地不同步。如果我添加一个将所有视频搜索为 0 的按钮,它们可能同步也可能不同步。当它们不同步时,只有几分之一秒,但对于此应用程序来说,几分之一秒是非常明显的。我们可以获得帧精确同步吗?
作为参考,这里是播放视频的精简代码。 (这只是一个标准的 netstream 调用)
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns1:NetStream = new NetStream(nc);
vid_1.attachNetStream(ns1);
ns1.play("vid1.flv");
ns1.pause();
ns1.seek(0);
ns1.addEventListener(NetStatusEvent.NET_STATUS, netstat);
var ns2:NetStream = new NetStream(nc);
vid_2.attachNetStream(ns2);
ns2.play("vid2.flv");
ns2.pause();
ns2.seek(0);
ns2.addEventListener(NetStatusEvent.NET_STATUS, netstat);
function netstat(stats:NetStatusEvent) {
//trace(stats.info.code);
}
var netClient:Object = new Object();
netClient.onMetaData = function(meta:Object){
//trace(meta.duration);
};
ns1.client = netClient;
ns2.client = netClient;
ns1.resume();
ns2.resume();
我有一个按钮:
btn_play.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
ns1.seek(0.0);
ns2.seek(0.0);
};
单击该按钮会重新启动视频,有时同步,有时不同步。
有什么方法可以让它们始终保持同步吗?
谢谢
Is it possible to sync flv videos? I'm playing a few videos simultaneously, and they are inconsistently out of sync. If I add a button that seeks all of the videos to 0, they may or may not be in sync. When they're out of sync, it's only a fraction of a second, but for this application, a fraction of a second is very noticeable. Can we get frame-accurate syncs?
For reference, here's the stripped-down code to play the vids. (It's just a standard netstream call)
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns1:NetStream = new NetStream(nc);
vid_1.attachNetStream(ns1);
ns1.play("vid1.flv");
ns1.pause();
ns1.seek(0);
ns1.addEventListener(NetStatusEvent.NET_STATUS, netstat);
var ns2:NetStream = new NetStream(nc);
vid_2.attachNetStream(ns2);
ns2.play("vid2.flv");
ns2.pause();
ns2.seek(0);
ns2.addEventListener(NetStatusEvent.NET_STATUS, netstat);
function netstat(stats:NetStatusEvent) {
//trace(stats.info.code);
}
var netClient:Object = new Object();
netClient.onMetaData = function(meta:Object){
//trace(meta.duration);
};
ns1.client = netClient;
ns2.client = netClient;
ns1.resume();
ns2.resume();
And I have a button:
btn_play.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
ns1.seek(0.0);
ns2.seek(0.0);
};
Clicking the button restarts the videos, sometimes in sync, sometimes not.
Any way to consistently get them in sync?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以考虑暂停这两个视频,直到这两个视频的“NetStream.Seek.Notify”状态事件触发。当视频完成寻找其预期时间码时它会触发。
You might consider pausing both videos until the "NetStream.Seek.Notify" status event has fired off for both videos. It fires when the video has finished seeking to its intented timecode.