| Discussion Home | About | Threads By Date | Search |
Title
Video Streaming & Flash Media Server
Content
Does any body have idea on how to synchronize two related videos?
I am making a video player which will stream the content using Flash Media Server (2 or 3). This video player have single seek bar and two video object for two separate video files. The single seek bar is being used to control both the videos.
Now my main concern is to synchronize the two different streams so that it can play simultaneously. Because, when the streams get buffered, both streams have major difference in buffering thus one video gets played earlier than the other one.
NOTE: This needs to be done in Flash CS3 and ActionScript 3.0. FMS version does not matter. It can be either 2 or 3.
Please help me on this issue...
Help will be appreiciated.
thanks in advance.
|
|
posted 01/01/09 by FMSer.cn | Report Abuse <p>I think you can use NetStream.seek() to seek two streams to the specified location at first,if one stream is buffering and the other stream has buffered over,you can waiting for the buffering-stream's buffer complete,then use NetStream.play() to play two streams simultaneously.</p> |
|
|
posted 01/02/09 by Kumar.Anand | Report Abuse Hello FMSer.cn!!! yes thats right but the thing is when i am writing the logic for waiting for the buffering stream when other has buffered, application hangs when executed. As i know, i have to write play/resume based on the net stream's NetStatusEvent, but its not working. could you please explain a bit more with some example so that i can help me Thanks for reply |
|
|
posted 01/03/09 by FMSer.cn | Report Abuse <p>There is a simple method to synchronize two related videos:</p> <p>main.asc:</p> <p>application.onAppStart = function() { <br /> myStream1 = Stream.get("video1");<br /> myStream1.play("1");<br /> <br /> myStream2 = Stream.get("video2");<br /> myStream2.play("2");<br />};</p> <p>application.onConnect = function(newClient) { <br /> this.acceptConnection(newClient);<br />};</p> <p>application.onDisconnect = function(oldClient) {<br /> <br />};</p> <p> </p> <p>synStream.as:</p> <p>package {<br /> import flash.display.MovieClip;<br /> import flash.net.NetConnection;<br /> import flash.net.NetStream;<br /> import flash.net.ObjectEncoding;<br /> import flash.events.NetStatusEvent;<br /> import flash.events.SecurityErrorEvent;<br /> public class synStream extends MovieClip {<br /> private var fmsPath:String;<br /> private var myNC:NetConnection;<br /> private var myNS1:NetStream;<br /> private var myNS2:NetStream;<br /> public function synStream() {<br /> init();<br /> }<br /> private function init() {<br /> myNC=new NetConnection ;<br /> myNC.objectEncoding=ObjectEncoding.AMF3;<br /> myNC.addEventListener(NetStatusEvent.NET_STATUS,netStatus);<br /> myNC.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityError);<br /> fmsPath="rtmp://www.fmser.cn/synStream";<br /> myNC.connect(fmsPath);<br /> }<br /> private function netStatus(e:NetStatusEvent):void {<br /> switch (e.info.code) {<br /> case "NetConnection.Connect.Success" :<br /> play1();<br /> play2();<br /> break;<br /> case "NetConnection.Connect.Failed" :</p> <p> break;<br /> case "NetConnection.Connect.Rejected" :</p> <p> break;<br /> case "NetConnection.Connect.Closed" :</p> <p> break;<br /> }<br /> }<br /> private function securityError(e:SecurityErrorEvent):void {</p> <p> }</p> <p> private function streamStatus(e:NetStatusEvent):void {<br /> trace(e.info.code);<br /> }</p> <p><br /> private function play1() {<br /> myNS1=new NetStream(myNC);<br /> myNS1.addEventListener(NetStatusEvent.NET_STATUS,streamStatus);<br /> myNS1.bufferTime=0<br /> liveVideo1.attachNetStream(myNS1);<br /> myNS1.play("video1");</p> <p> }<br /> private function play2() {<br /> myNS2=new NetStream(myNC);<br /> myNS2.addEventListener(NetStatusEvent.NET_STATUS,streamStatus);<br /> myNS2.bufferTime=0<br /> liveVideo2.attachNetStream(myNS2);<br /> myNS2.play("video2");<br /> }<br /> public function onMetaData(){}</p> <p> }</p> <p>}</p> |
|
|
posted 01/05/09 by Kumar.Anand | Report Abuse Hello FMSer.cn!! Thanks for your concern and example. I have two things to say: 1. I already tried this thing and it does not work. 2. The example provided by you, plays the recorded stream like live stream and plays it from server. This is not the exact requirement that i am looking for. I want to play the streams from client side and want to synchronize it. Anyway, thanks for you reply. |
|
|
posted 01/05/09 by David_RealEyes | Report Abuse <p>Best that I could think of off the top of my head client side is start 2 streams with the same amount of buffer and immediately pause them. Wait until the buffer is full for both video then start playing them. I doubt it will be really accurate but it may be good enough. If you are still having issues let me know and I can try and get some more info.</p> |
|
|
posted 01/06/09 by Kumar.Anand | Report Abuse Hello David!!! Thanks for your response. I tried the same thing by pausing and resuming the streams based on the NetStream's status event but application gets crash when compiled. Any Reason??? I have attached the files here...if you want to have a look. |
|
|
posted 01/08/09 by David_RealEyes | Report Abuse <p>Thanks for posting the files. I am real slammed this week but will try and take a look for you this weekend. WHat kind of accuracy are you needing?</p> |
|
|
posted 01/09/09 by Kumar.Anand | Report Abuse <p>Hello David.</p> <p>thanks for reply.</p> <p>OK, no problem, but please look for the solution as i am really in problem. As per the accuracy is concerned, i need 98-99% accuracy as it is the requirement.</p> <p>thanks.</p> |