Live stream switching

hi!
I have a problem. I want to set up a live streaming experience, where streams will be switched live by a server side application written in .NET. The flash clients will have no control over what stream they want to watch.the setup is such: video streams from two cameras are encoded in Live Encoder. FMS should stream only a single stream to the clients and which stream should be shown should be chosen by a .NET application
How do I go about accomplishing such a task? As I understand the FMS uses RTMP to communicate with clients. Are there any other ways to contact the FMS and tell it to switch between two streams, i.e. an XMLSocket connection? This would be perfect since it would integrate with the .NET server perfectly. I do not like the prospect of using RTMP to contact the FMS and tell it to switch between streams. Is it even possible, or can the stream switching be performed only per client?

You can use an XML socket, but the FMS application will need to initiate the connection, as FMS has no support for listening for anything other than RTMP and HTTP requests.
Stream switching can happen on the FMS side. In your FMS application, you'll create a server side stream, and use the Stream.play method for playing other sources (live streams or recorded flv/h.264 files) over that stream. Your subscribers will connect to the server side stream
See the FMS docs for the Stream class and the XMLSocket class.

Similar Messages

  • Does FMS support live stream switching

    I read a blog article (
    http://www.peachpit.com/articles/article.aspx?p=665127)
    talking about switching between different bit rate video streams of
    the same video content on fly. But I can not find such ability in
    RTMP's specification. I am wondering if such function has to be
    implemented by users with ActionScript? Thanks!
    Yue

    Yes FMS does support live stream switching but its not at protocol level hence you are not finding it in RTMP specification.
    please read details about it here:
    http://help.adobe.com/en_US/FlashMediaServer/3.5_Deving/WS5b3ccc516d4fbf351e63e3d11a0773d5 6e-7fea.html
    Hope you find it useful.

  • Dynamic Bitrate Switching on Live Stream

    I have FMIS 3.5.  I've installed it with pretty much all the default values.  I haven't changed any of the settings in either the  LIVE or the VOD applications.
    Dynamic Bitrate Switching is working well for VOD, but not working at all for LIVE streams. Doing a regular bandwidth detection on both the LIVE and the VOD applications give similar, high bandwidth results.  However, the LIVE application  NetStreamInfo.maxBytesPerSecond is showing a very low bandwidth capability of around maxBytesPerSecond = 19016, where as for the VOD its achieving around 637110. I can play a single LIVE stream of a high quality smoothly without any error.
    I don't know if this is relevent but I'm getting some error messages occassionally in the log of the live application saying : Dropping application (live/_definst_) message. Clients not allowed to broadcast message.  These messages aren't consistent, and don't coincide with trying to use bitrate switching.
    I have tried downloading the Adobe sample StreamSwitching.fla and it won't play the LIVE streams at all.  Using the opensource Longtail Video player it just always defaults to the lowest stream.  Here is an example: http://www.ltscotland.org.uk/testbed/live/livestream2.asp
    Can anyone suggest what the problem might be here?  And any possible solutions?

    Thanks,I have read that article.  Based on that article the NetStreamInfo.maxBytesPerSecond is not an accurate measurement to base dynamic switching on. This seems to be the basis of the bitrate switching in both the longtail player, and the adobe examples that I have tried.   That article suggests using the dropped frames property, in conjunciton with bufferlength to determine if switching is neccessary.  Unfortunately I can't seem to find a player online which handles this successfully.  That being said, I can't believe I'm the only person trying to implement dynamic bitrate switching for live streams so surely there are some players out there which can do this successfully?  If anyone knows of any code available which does this successfully I would appreciate knowing where!  The examples provided by Adobe https://www.adobe.com/cfusion/entitlement/index.cfm?e=fms35 unfortunately don't work either.

  • Flash Media Player which handles bitrate switching for live streams?

    Hello.  I've got a very short timescale to find a solution for a way to display livestreams with bitrate switching. Does anyone
    know of any opensource players which can do this effectively?  Or do the inbuilt components in CS4 deal with this ok?

    Thanks,I have read that article.  Based on that article the NetStreamInfo.maxBytesPerSecond is not an accurate measurement to base dynamic switching on. This seems to be the basis of the bitrate switching in both the longtail player, and the adobe examples that I have tried.   That article suggests using the dropped frames property, in conjunciton with bufferlength to determine if switching is neccessary.  Unfortunately I can't seem to find a player online which handles this successfully.  That being said, I can't believe I'm the only person trying to implement dynamic bitrate switching for live streams so surely there are some players out there which can do this successfully?  If anyone knows of any code available which does this successfully I would appreciate knowing where!  The examples provided by Adobe https://www.adobe.com/cfusion/entitlement/index.cfm?e=fms35 unfortunately don't work either.

  • Running a live stream from an XML playlist

    I have just successfully installed Adobe FMS on my server.
    I would now like to know how to program a script to run a continuous live stream, of MP4 videos, from an XML playlist.
    Can anyone tell me how to do this? ...or provide me a good tutorial? (I am a complete newbie to ActionScript.)
    Thanks in advance...

    application.allowDebug = true;
    application.onAppStart = function(){
    this.userID =0;
    this.playObj = new Object();
    this.timObj = new Object();
    this.passCli = new Object();
    this.couObj = new Object();
    this.couObj.count = 1;
    application.so0 = SharedObject.get("so",false);
    this.dates = new Object;
    this.dates.dat0 = new Date().valueOf()+"a";
    this.dates.dat1 = new Date().valueOf()+"b";
    this.dates.dat2 = new Date().valueOf()+"c";
    this.dates.dat3 = new Date().valueOf()+"d";
    this.myStream = new Object;
    this.myStream.st = Stream.get (this.dates.dat0.toString());
    this.myStream.st1 = Stream.get (this.dates.dat1.toString());
    this.myStream.st2 = Stream.get (this.dates.dat2.toString());
    this.myStream.st3 = Stream.get (this.dates.dat3.toString());
    this.int0
    this.int1
    this.int2
    this.int3
    this.int4
    this.lock0=0;
    this.lock1=0;
    this.lock2=0;
    this.lock3=0;
    this.lock4=0;
    listen();
    function listen(){
    clearInterval(application.int3);
    application.int0 = setInterval(time,1000,application.myStream.st);
    application.myStream.st.onStatus = function(info){
    if(info.code == "NetStream.Play.Stop"&&application.lock0==0){
      trace("code0"+info.code);
      clearInterval(application.int0);
      application.timObj.tim = 0;
      application.int1 = setInterval(time,1000,application.myStream.st1);
      application.couObj.count = 2;
      playcurr(application.passCli.cli);
      switchStream(application.so0);
      listen1(application.myStream.st1);
      application.lock0=1;
      function listen1(mystreamst1){
      mystreamst1.onStatus = function(info){
    if(info.code == "NetStream.Play.Stop"&&application.lock1==0){
      trace("code1"+info.code);
      mystreamst1 = null;
      clearInterval(application.int1);
      application.timObj.tim = 0;
      application.int2 = setInterval(time,1000,application.myStream.st2);
      application.couObj.count = 3;
      playcurr(application.passCli.cli);
      switchStream(application.so0);
      listen2(application.myStream.st2);
      application.lock1=1
      function listen2 (mystream2){
    mystream2.onStatus = function(info){
    trace("code2"+info.code);
    if(info.code == "NetStream.Play.Stop"&&application.lock2==0){
      clearInterval(application.int2);
      application.mystream2 = null;
      application.timObj.tim = 0;
      //application.int3 = setInterval(time,1000,application.myStream.st3);
      application.couObj.count = 4;
      playcurr(application.passCli.cli);
      switchStream(application.so0);
         application.lock2=1;
      listen3(application.myStream.st3);
      function listen3(mystream3){
    mystream3.onStatus = function(info){
    trace("code3"+info.code);
    if(info.code == "NetStream.Play.Stop"&&application.lock3==0){
      trace("yes yes yes yes yes yes");
      clearInterval(application.int3);
      application.couObj.count = 1;
      mystream3 = null;
      application.timObj.tim = 0;
      //application.int4 = setInterval(time,1000,application.myStream.st);
      playcurr(application.passCli.cli);
      switchStream(application.so0);
      application.lock0=0;
      application.lock1=0;
      application.lock2=0;
      application.lock3=0;
    application.dates.dat0 = new Date().valueOf()+"e";
    application.dates.dat1 = new Date().valueOf()+"f";
    application.dates.dat2 = new Date().valueOf()+"g";
    application.dates.dat3 = new Date().valueOf()+"h";
    application.myStream.st = Stream.get (application.dates.dat0.toString());
    application.myStream.st1 = Stream.get (application.dates.dat1.toString());
    application.myStream.st2 = Stream.get (application.dates.dat2.toString());
    application.myStream.st3 = Stream.get (application.dates.dat3.toString());
    application.myStream.st.play(application.playObj.vid[0],0,-1,0);
    application.myStream.st1.play(application.playObj.vid[1],0,-1,0);
    application.myStream.st2.play(application.playObj.vid[2],0,-1,0);
    application.myStream.st3.play(application.playObj.vid[3],0,-1,0);
    listen();
    ///here next
    application.onConnect = function(client){
    application.acceptConnection(client);
    application.passCli.cli = client;
    client.call("setUserID",null,this.userID);
    this.userID++;
    if(application.clients.length == 1 ){
    videoArray = new Array();
    var playlist = new XML();
    playlist.ignoreWhite = true;
    //parse xml play list for individual elements
    playlist.onLoad = function( success ) {
    if(playlist.loaded == true) {
    if (playlist.firstChild.hasChildNodes()) {
    for (var aNode = playlist.firstChild.firstChild; aNode != null; aNode=aNode.nextSibling) {
    if (aNode.nodeType == 1) {
    //create array from parsed xml elements.
    videoArray[aNode.attributes.id] = aNode.attributes.name ;
    //pass array out of onload function
    application.playObj.vid = videoArray;
    application.myStream.st.play(application.playObj.vid[0],0,-1,0);
    application.myStream.st1.play(application.playObj.vid[1],0,-1,0);
    application.myStream.st2.play(application.playObj.vid[2],0,-1,0);
    application.myStream.st3.play(application.playObj.vid[3],0,-1,0);
    pass0(videoArray);
    //play first video on playlist
    playlist.load("http://www.privatechatnow.com/fmsuser/playlist.xml");
    }//end onetime if statement
    function pass0(videoArray){
      //receive array
      //play intial video
      if(application.clients.length == 1){
    // application.playObj.vid=videoArray;
    playcurr(application.passCli.cli);
    for (var key in application.playObj){
    trace(key + ": " + application.playObj[key]);
       //put currently playing videio into object
      //isolate playlist switching loop for each connected client
      //listen to currently playing stream with onStatus
      //change to next video in playlist
      //use onStatus and current duration and seek to scrub to cuurently playin video each time a user connects.
      //continue untill playlist is played then loop back to first video in playlist.
        //onConnect play currently playing video
    if (application.clients.length >1){
    playcurr(application.passCli.cli);
    //message client with currently play flv
    //message client when flv changes
    //message client with metadata
    application.onPublish = function(clientObject, streamObject){
    trace("Stream name :: "+streamObject.name);
    function switchStream(so0){
    if(application.couObj.count == 1){
        clength = application.timObj.tim-3;
    currlen = application.playObj.vid[0].length;
        nextlen = application.playObj.vid[1].length;
    so0.send("playSecond",application.playObj.vid[0],clength,currlen,nextlen);
    if(application.couObj.count == 2){
        clength = application.timObj.tim-3;
    currlen = application.playObj.vid[1].length;
    nextlen = application.playObj.vid[2].length;
        so0.send("playSecond",application.playObj.vid[1],clength,currlen,nextlen);
    if(application.couObj.count == 3){
    clength = application.timObj.tim-3;
    currlen = application.playObj.vid[2].length;
      nextlen = application.playObj.vid[3].length;
        so0.send("playSecond",application.playObj.vid[2],clength,currlen,nextlen);
    if(application.couObj.count == 4){
        clength = application.timObj.tim-3;
    currlen = application.playObj.vid[3].length;
      nextlen = application.playObj.vid[0].length;
        so0.send("playSecond",application.playObj.vid[3],clength,currlen,nextlen);
    function playcurr(client){
    trace("count = "+application.couObj.count.toString());
    if(application.couObj.count ==1){
        clength = application.timObj.tim-3;
    currlen = application.playObj.vid[0].length;
      nextlen = application.playObj.vid[1].length;
        client.call("playZero",null,application.playObj.vid[0],clength,currlen,nextlen); 
    if(application.couObj.count ==2){
        clength = application.timObj.tim-3;
    currlen = application.playObj.vid[1].length;
      nextlen = application.playObj.vid[2].length;
        client.call("playZero",null,application.playObj.vid[1],clength,currlen,nextlen); 
    if(application.couObj.count ==3){
        clength = application.timObj.tim-3;
    currlen = application.playObj.vid[2].length;
      nextlen = application.playObj.vid[3].length;
        client.call("playZero",null,application.playObj.vid[2],clength,currlen,nextlen); 
    if(application.couObj.count ==4){
        clength = application.timObj.tim-3;
    currlen = application.playObj.vid[3].length;
      nextlen = application.playObj.vid[0].length;
        client.call("playZero",null,application.playObj.vid[3],clength,currlen,nextlen); 
    application.onDisconnect = function(oldclient){
    if(application.clients.length ==0){
    this.userID--;
    function time(myStream){
    application.timObj.tim = myStream.time;

  • Trying to add metadata to a live stream completely fails

    Hi.  I've been following this document http://help.adobe.com/en_US/flashmediaserver/devguide/WS5b3ccc516d4fbf351e63e3d11a0773d56e -7ff6Dev.html for adding metadata to an FMS live stream from a Flash widget.
    I've created a stripped-down version of the code (listed below); the same as the original code except the controls are removed.  It works fine only if I comment out the ns.send calls.  If I leave in the ns.send calls, no clients are ever able to view anything.  I'm using a stock FMS 4.5 install on Amazon EC2 -- the AMI is ami-904f08c2.  And I'm compiling the swf using Flex SDK 4.6 on Linux with the command "mxmlc -compiler.library-path+=./playerglobal11_0.swc -swf-version=13 -static-link-runtime-shared-libraries Broadcaster.as".
    package {
        import flash.display.MovieClip;
        import flash.net.NetConnection;
        import flash.events.NetStatusEvent; 
        import flash.events.MouseEvent;
        import flash.events.AsyncErrorEvent;
        import flash.net.NetStream;
        import flash.media.Video;
        import flash.media.Camera;
        import flash.media.Microphone;
        public class Broadcaster extends MovieClip {
            private var nc:NetConnection;
            private var ns:NetStream;
            private var nsPlayer:NetStream;
            private var vid:Video;
            private var vidPlayer:Video;
            private var cam:Camera;
            private var mic:Microphone;
            private var myMetadata:Object;
            public function Broadcaster(){
                setupUI();
                nc = new NetConnection();
                nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                nc.connect("rtmp://myserver/live");
             *  Clear the MetaData associated with the stream
            private function clearHandler(event:MouseEvent):void {
                if (ns){
                    trace("Clearing MetaData");
                    ns.send("@clearDataFrame", "onMetaData");
            private function startHandler(event:MouseEvent):void {
                displayPlaybackVideo();
            private function onNetStatus(event:NetStatusEvent):void {
                trace(event.target + ": " + event.info.code);
                switch (event.info.code)
                    case "NetConnection.Connect.Success":
                        publishCamera();
                        displayPublishingVideo();
                        break;
                    case "NetStream.Publish.Start":
                        sendMetadata();
                        break;
            private function asyncErrorHandler(event:AsyncErrorEvent):void {
                trace(event.text);
            private function sendMetadata():void {
                trace("sendMetaData() called")
                myMetadata = new Object();
                myMetadata.customProp = "Welcome to the Live feed of YOUR LIFE, already in progress.";
                ns.send("@setDataFrame", "onMetaData", myMetadata);
            private function publishCamera():void {
                cam = Camera.getCamera();
                mic = Microphone.getMicrophone();
                ns = new NetStream(nc);
                ns.client = this;
                ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                ns.attachCamera(cam);
                ns.attachAudio(mic);
                ns.publish("livestream", "live");
            private function displayPublishingVideo():void {
                vid = new Video(cam.width, cam.height);
                vid.x = 10;
                vid.y = 10;
                vid.attachCamera(cam);
                addChild(vid); 
            private function displayPlaybackVideo():void {
                nsPlayer = new NetStream(nc);
                nsPlayer.client = this;
                nsPlayer.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                nsPlayer.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                nsPlayer.play("myCamera", 0);
                vidPlayer = new Video(cam.width, cam.height);
                vidPlayer.x = cam.width + 100;
                vidPlayer.y = 10;
                vidPlayer.attachNetStream(nsPlayer);
                addChild(vidPlayer);
            private function setupUI():void {
            public function onMetaData(info:Object):void {

    Also, emitting other events in the ns.send calls works; eg. if I do ns.send("blah", "onMetaData", myMetadata), nothing happens (because there's no "blah" function to do anything), but at least this doesn't cause the entire stream to fail.

  • Flex mobile live streaming

    Hi All,
      I am trying to display a live stream from rtmp server. Below is my code.
    <?xml version="1.0" encoding="utf-8"?>
    <s:Group height="100%" width="100%"
             xmlns:fx="http://ns.adobe.com/mxml/2009"
             xmlns:s="library://ns.adobe.com/flex/spark"
             xmlns:mx="library://ns.adobe.com/flex/mx">
        <fx:Script>
            <![CDATA[
                import mx.core.FlexGlobals;
                private const URL:String    = "rtmp://eigr2.flashlive.bigCDN.com/20175D";//"http://www.helpexamples.com/flash/video/cuepoints.flv";
                private const STREAM_KEY:String = "eigr8";
                private var _video:Video = new Video();
                private var _nc:NetConnection;
                private var _custClient:Object;
                private var _ns:NetStream;
                private var _streamKey:String;
                public function playVideo():void
                    var  url:String = URL;
                    if(videoHandler.numChildren == 0)
                        _nc    = new NetConnection();
                        _nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                        _nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                        _nc.connect(URL);
                private function netStatusHandler(event:NetStatusEvent):void
                    trace("NC " + event.info.code);
                    switch (event.info.code)
                        case "NetConnection.Connect.Success":
                            _video                    = new Video();
                            _video.smoothing        = true;
                            var custClient:Object    = new Object();
                            custClient.onMetaData    = metaDataHandler;
                            _ns                = new NetStream(_nc);
                            _ns.client        = custClient;
                            _ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                            _ns.addEventListener(DRMErrorEvent.DRM_ERROR, drmerror);
                            _ns.addEventListener(DRMStatusEvent.DRM_STATUS, drmStatus);
                            _ns.addEventListener(StatusEvent.STATUS, status);
                            _ns.addEventListener(NetStatusEvent.NET_STATUS, target);
                            _ns.bufferTime = 2;
                            _ns.receiveVideo(true);
                            var net:NetStreamPlayOptions = new NetStreamPlayOptions();
                            //net.len = 1;
                            //net.transition = NetStreamPlayTransitions.APPEND;
                            net.streamName = STREAM_KEY;
                            _ns.play(STREAM_KEY);
                            _video.attachNetStream(_ns);
                            videoHandler.addChild(_video);
                            videoHandler.visible = true;
                            //background.visible = true;
                            break;
                        case "NetConnection.Connect.Failed":    //shownoVideoText();
                            break;
                        case "NetStream.Play.StreamNotFound":    trace("Unable to locate video: ");
                            break;
                private function status(event:StatusEvent):void
                    trace("Status Event : " + event.toString());
                private function drmerror(event:DRMErrorEvent):void
                    trace("DRM Error : " + event.toString());
                private function drmStatus(event:DRMStatusEvent):void
                    trace("DRM Status : " + event.toString());
                private function videoStates(event:Event):void
                    trace(event.toString());
                public function stopVideo():void
                    _nc.close();
                    _nc = null;
                    _ns = null;
                    this.videoHandler.removeChild(_video);
                private function asyncErrorHandler(event:AsyncErrorEvent):void
                    trace("Async errrorrrrrrrrrrrrrrrrrrrr");
                private function target(e:NetStatusEvent):void
                    trace("Started playing : " + e.info.code);           
                private function metaDataHandler(infoObject:Object):void
                    this.setVideoSize(infoObject.height, infoObject.width);
                /*public function playVideo():void
                    custClient    = new Object();
                    custClient.onMetaData    = metaDataHandler;
                    nc    = new NetConnection();
                    nc.connect(null);
                    nc.client = { onBWDone: function():void{} };
                    //nc.addEventListener(NetStatusEvent.NET_STATUS, target);
                    nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                    ns        = new DynamicCustomNetStream(nc);
                    ns.client                = custClient;
                    ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                    ns.addEventListener(NetStatusEvent.NET_STATUS, target);
                    ns.play(URL);
                    videoPlayer.attachNetStream(ns);
                    videoPlayer.smoothing        = true;
                    if(!videoHandler.contains(videoPlayer))
                        videoHandler.addChild(videoPlayer);
                private function metaDataHandler(infoObject:Object):void
                    this.setVideoSize(infoObject.height, infoObject.width);
                override public function set currentState(value:String):void
                    super.currentState = value;
                    this.videoHandler.percentHeight = value == "fullScreen" ? 100 : 50;
                public function onFCSubscribe(info:Object):void
                    trace("onFCSubscribe - succesful");
                protected function goBack():void
                    FlexGlobals.topLevelApplication.showVideo(false);
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <s:Button click="goBack()"
                  horizontalCenter="0"
                  label="Go Back" bottom="50"/>
        <mx:UIComponent width="100%"
                        height="50%"
                        top="0" left="0"
                        id="videoHandler"/>
    </s:Group>
    When I try to run this, I could successfully connect to server but not getting the data. If I open the url in browser PublishNotify gets dispatched and I get the stream. As soon as I close UnpublishNotify gets dispatched and I wont get the stream. Can I know the possible reasons and solution?

    Unless I am mistaken here, you must implement Apple's HTTP Live protocol for streams over ten minutes in length. There is a few options you can take:
    1. Split your streams into 9 minute segments and feed them consecutively in groups. (Apple actually offers a segmenting tool that even generates an index file via there Developer tools)
    2. Only enable full length streaming over WiFi
    3. Fully implement HTTP Live....
    Also, do not forgot that not only are you going to have to implement HTTP Live but you are going to have to ALSO include an audio only stream.

  • Help understand Visual Communicator Live Streaming

    Up to know I run live streaming through our Steaming server using FMS and Flash Media Live Encoder as we only needed one camera for live video feeds.
    We are looking at the ability now to use 2 live cameras and also the ability to snap in pre recorded video during live feeds and also provide lower third titles.
    I am looking at:
    Adobe Visual Communicator 3
    Wirecast 4
    CutFour
    All of these provide the possible live switching I need.
    I'm at the moment looking at the Trial version of Visual communicator and I am struggling getting my head around a few things.
    I can hook up 2 -3 Sony A1 HD cameras in SD no problem and running it though FMS is fine. During test streams clicking on the cameras using the mini switcher is straight forward.
    howevr I am struggling to work out how to do the following:
    Add prerecorded video clips to Camera 3? ( in the Setup Tab it says " No Camera found - please connect a camera or replace with Photo or video Clip) How do I replace with a Video Clip?
    How do I add premade titles, so that during the live feed I can put lower third titles in?
    Finally, How do Provide an intro looping video to play before the live feed starts?
    Any instructions would be appreciated

    Hi there
    The forums are user-to-user. The older incarnation of the forums used to have a disclaimer on each page. Now there is one that appears at:
    http://forums.adobe.com/index.jspa
    If you want to bring something to Adobe's attention, you need to use the proper channel. That channel is the Wish Form/Bug Reporting form.
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • Remove Lag from Live Streams

    I am publishing 2 live streams from a computer with 2 video capture cards in it and I get a lag every 30 seconds or so on the subscribers side. I have tried adjusting the camera quality and setMode properties but still the lag persists inside and outside the LAN, is there a way to create a buffer on the server or adjust the way the live stream is received on the subscribers side so there is no noticeable lag? I saw something about editing application.xml to adjust the queue and a suggested bitrate but not sure if this is applicable, here is the link:
    http://www.adobe.com/devnet/flashmediaserver/articles/dynstream_live.html
    Here is my setup:
    The publishing computer:
    2 PCI-e x1 cards, one takes S-Video (480i) and the other DVI (720p)
    Windows 7 64bit
    Intel i7
    6 GB RAM'
    GB NIC and Switch
    From the switch is one hop to a GB router and out to a 10 MB pipe which leads to our datacenter 30 miles away. The swf on this side just gets the 2 cameras, sets the quality to (0,80) and mode to (640,480,25,false) (I have played with these settings a little) and creates 2 lives streams on the FMS.
    The FMS:
    I am running Flash Media Interactive Server 3.5 on my own server with two 3.6 Dual Core Xeon processors and 4 GB RAM. This server resides in a Datacenter and has a 100 MB burstable pipe. From the FMS administration console I am barely using 4MB total bandwidth, 1% CPU usage, 2% RAM.
    The subscribing computer:
    I have used many different types of hardwired PC's within the same LAN and outside the LAN, results are the same.
    The swf on this side just creates 2 new video instances and attaches the 2 netstreams to them. They are placed side by side and the height and width of these videos are undefined.
    Does anyone know where this lag could be coming from, is there any settings I can adjust to improve performance while maintaining a minimum S-Video quality level?
    Thanks

    Hi,
    Thanks for the detailed information in your first post.
    Coming to the latency... It gets affected by various factors. The stream bitrate, FMS server side settings, subscriber's client side setting and on top of these the network bandwidth.
    I need to know the NetStream.bufferTime set at the subscriber's application. Try setting it to 3 when you issue the play, later you can increase it to 8 or so to stabilize the play back.
    Also can you try to subscribe to single stream and check if your client bandwidth is able to play back isngle stream?
    The link which you have mentioned below is a good reference to tune your server side settings.
    Regards,
    Janaki L

  • IOS RTMP live stream audio

    Hi guys hopefully some of you will be able to help me.
    I am trying to stream audio from a live RTMP feed using the NetConnection and NetStream classes. I've managed to get my app running no problem on Android, however I am having some major difficulties getting it to play the audio back on iPad. Interestingly it works in the device emulators when debugging, however I'm assuming this is not really an accurate representation. I've tried streaming the RTMP in both AAC and MP3, but with no luck from either. I can verify through debug that it has connected to the stream, however I just get no audio playing.
    Everything I've read about seems to suggest that this is possible on IOS as I'm only interested in audio and not video. Can anyone help?
    Code sample below (it's quick and dirty! ).
    THanks in advance!
    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:s="library://ns.adobe.com/flex/spark" title="Audio" creationComplete="init()">
              <s:layout>
                        <s:VerticalLayout paddingLeft="10" paddingRight="10"
                                                                  paddingTop="10" paddingBottom="10"/>
              </s:layout>
              <fx:Script>
                        <![CDATA[
                                  import flash.media.Video;
                                  import flash.net.NetConnection;
                                  import flash.net.NetStream;
                                  import mx.core.UIComponent;
                                  private var vid:Video;
                                  private var videoHolder:UIComponent;
                                  private var nc:NetConnection;
                                  private var defaultURL:String="[STREAM]";
                                  private var streamName:String="[STREAMNAME]";
                                  private var ns:NetStream;
                                  private var msg:Boolean;
                                  private var intervalMonitorBufferLengthEverySecond:uint;
                                  private function init():void
                                            vid=new Video();
                                            vid.width=864;
                                            vid.height=576;
                                            vid.smoothing = true;                           
                                            //Attach the video to the stage             
                                            videoHolder = new UIComponent();
                                            videoHolder.addChild(vid);
                                            addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
                                            grpVideo.addElement(videoHolder);
                                            connect();
                                  public function onSecurityError(e:SecurityError):void
                                            trace("Security error: ");
                                  public function connect():void
                                            nc = new NetConnection();
                                            nc.client = this;
                                            nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                                            nc.objectEncoding = flash.net.ObjectEncoding.AMF0;
                                            nc.connect(defaultURL);      
                                  public function netStatusHandler(e:NetStatusEvent):void
                                            switch (e.info.code) {
                                                      case "NetConnection.Connect.Success":
                                                                trace("audio - Connected successfully");
                                                                createNS();                
                                                                break;
                                                      case "NetConnection.Connect.Closed":
                                                                trace("audio - Connection closed");                
                                                                //connect();
                                                                break; 
                                                      case "NetConnection.Connect.Failed":
                                                                trace("audio - Connection failed");                
                                                                break;
                                                      case "NetConnection.Connect.Rejected":
                                                                trace("audio - Connection rejected");                                  
                                                                break; 
                                                      case "NetConnection.Connect.AppShutdown":
                                                                trace("audio - App shutdown");                                 
                                                                break;         
                                                      case "NetConnection.Connect.InvalidApp":
                                                                trace("audio - Connection invalid app");                                   
                                                                break; 
                                                      default:
                                                                trace("audio - " + e.info.code + "-" + e.info.description);
                                                                break;                                                                                                    
                                  public function createNS():void
                                            trace("Creating NetStream");
                                            ns=new NetStream(nc);
                                            //nc.call("FCSubscribe", null, "live_production"); // Only use this if your CDN requires it
                                            ns.addEventListener(NetStatusEvent.NET_STATUS, netStreamStatusHandler);
                                            vid.attachNetStream(ns);
                                            //Handle onMetaData and onCuePoint event callbacks: solution at http://tinyurl.com/mkadas
                                            //See another solution at http://www.adobe.com/devnet/flash/quickstart/metadata_cue_points/
                                            var infoClient:Object = new Object();
                                            infoClient.onMetaData = function oMD():void {};
                                            infoClient.onCuePoint = function oCP():void {};        
                                            ns.client = infoClient;
                                            ns.bufferTime = 0;   
                                            ns.play(streamName);  
                                            ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                                            function asyncErrorHandler(event:AsyncErrorEvent):void {
                                                      trace(event.text);
                                            intervalMonitorBufferLengthEverySecond = setInterval(monPlayback, 1000);
                                  public function netStreamStatusHandler(e:NetStatusEvent):void
                                            switch (e.info.code) {
                                                      case "NetStream.Buffer.Empty":
                                                                trace("audio - Buffer empty: ");
                                                                break;
                                                      case "NetStream.Buffer.Full":
                                                                trace("audio - Buffer full:");
                                                                break;
                                                      case "NetStream.Play.Start":
                                                                trace("audio - Play start:");
                                                                break;
                                                      default:
                                                                trace("audio - " + e.info.code + "-" + e.info.description);
                                                                break;
                                  public function monPlayback():void {
                                            // Print current buffer length
                                            trace("audio - Buffer length: " + ns.bufferLength);
                                            trace("audio - FPS: " + ns.currentFPS);
                                            trace("audio - Live delay: " + ns.liveDelay);
                                  public function onBWDone():void {
                                            //Do nothing
                                  public function onFCSubscribe(info:Object):void {      
                                            // Do nothing. Prevents error if connecting to CDN.    
                                  public function onFCUnsubscribe(info:Object):void {    
                                            // Do nothing. Prevents error if connecting to CDN.    
                        ]]>
              </fx:Script>
              <s:Group id="grpVideo">
              </s:Group>
    </s:View>

    Just an update on this for anyone coming along after me.
    I've managed to get this working on MP3 but not AAC (I guess AAC just isn't supported?).
    My problem was the buffertime. The docs seemed to indicate it shoudl be set to 0 for live streaming, however switching it to "1" solved my problem on the particular stream I was pointing at.
    So essentially justchanged the above line:
                                            ns.bufferTime = 0;  
    to
                                            ns.bufferTime = 1;  
    Would be great to find out if anyone has gotten AAC working however...

  • How to understand live stream is online

    Hi,
    First sorry about my english, i search my problem, but i couldnt find my answer,
    We have more then 80 live stream videos. More than 20 PC with capture cards, send cam streams to FSM with FME,
    Problems,
    PC can crush, capture card can crush, fme can crush, camera connection can crush,
    so with below code, i can unterstand if FMS server is alive, "NetConnection.Connect.Success"
    but is my stream  alive? How i can understand "1test1" is alive,
    for example i can unterstand with onMetaData info, if there is no meta info, no stream,
    but i am a noob, what is the true way to understand live stream is alive, meta info isn't true way i think
    i change var videoURL:String ="1test1" to a false value
    but no error i get, it never says "NetStream.Play.StreamNotFound":
    my goal is, i will make a web page, it will find all livestreams from xml, and cheack them, so systemadmin will see problem easly,
    last question, if there is a camera problem, livestream gives a blank black screen, can i understand automaticly  this screen
    var videoURL:String ="1test1"
    var nc:NetConnection = new NetConnection();
    nc.client = this;
    nc.connect("rtmp://myFMS/live/");
    nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
    function netStatusHandler(event:NetStatusEvent):void{
    trace(" trace netStatusHandler: " +event.info.code);  
    switch (event.info.code)
    case "NetConnection.Connect.Success":
    connectStream();
    break;
    case "NetStream.Play.StreamNotFound":
    trace("Stream not found: " + videoURL);
    break;
    function connectStream():void
    var vid:Video = new Video(640,480);
    var ns:NetStream = new NetStream(nc);
    ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
    var meta:Object = new Object();
    meta.onMetaData = function(info:Object){
    trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate)}        
    ns.client = meta;
    addChild(vid);     
    vid.attachNetStream(ns);
    ns.play(videoURL);

    thanks, now i am able to understand what's your requirement.
    first you create a sample live chat application. just for testing purpose. 
    1- create video object.; 
    2- create camera object; 
    3- attache camera object to video object; 
    4- create a button and register a event and listener function write below code. 
    5- download adobe.image.PNGEncoder class 
    hope, you can capture photo from video object into you testing application 
    package
        import com.adobe.image.PNGEncoder;
        import flash.display.Sprite;
        import flash.display.DisplayObject;
        import flash.events.*;
        import flash.display.Bitmap;
        import flash.display.BitmapData;
        import flash.media.Video;
        import flash.media.Camera;
        import flash.geom.*;
        import flash.net.FileReference;
        import flash.utils.ByteArray;
        public class SavePng extends Sprite
            private var cam:Camera;
            private var video:Video;
            private var ab:FileReference;
            public function SavePng()
                cam = Camera.getCamera();
                cam.setMode(800,600,25);
                cam.setQuality(0, 90);
                video = new Video(1024,768);
                video .smoothing=true;
                video.attachCamera(cam);
                addChild(video);
                btn.addEventListener(MouseEvent.CLICK,saveImage);
                ab=new FileReference();
            private function saveImage(evt:MouseEvent):void
                var count:int = 0;
                var scaleW:Number = .5;
                var scaleH:Number = .5;
                var m:Matrix = new Matrix();
                m.scale(scaleW,scaleH);
                var bmd:BitmapData = new BitmapData(320,240,true);
                bmd.draw(video);
                var img:Bitmap=new Bitmap(bmd);
                img.x=250;
                img.y=200;
                addChild(img);
                var ba:ByteArray = PNGEncoder.encode(bmd);
               ab.save(ba,"sushil.png")

  • AS3 - 1) Countdown Timer to the designated Date for Live-Broadcast-Event yet to take place; 2) Detect End of Live Stream on FLVPlayback with FLVPlayback.isLive = true - ActionScript 3 - flash cs3 cs4

    Hi folks,
    Ronny's here again on forums, having particularly 2 (two) questions/problems to resolve:
    1) Countdown Timer to the designated Date for Live-Broadcast-Event yet to take place
    2) Detect End of Live Stream on FLVPlayback with FLVPlayback.isLive = true
    attached is the .zip file (as3_Countdown Timer_ver 1.0.1_by Ronny Depp.zip) with all flash source files containing:
    a) The FLash Source (file: timer_module.fla) - (FLA flash source file - Flash CS3 Professional, Flash Player 9, actionscript 3.0)
    b) com.othenticmedia.utils.dateAndTimeManagement package including 2 .as actionscript 3.0 Class files.
           i) com.othenticmedia.utils.dateAndTimeManagement.DateAndTimeManager Class in the said package. (file: DateAndTimeManager.as)
           ii) com.othenticmedia.utils.dateAndTimeManagement.CountdownTimer Class in the package. (file: CountdownTimer.as)
    c) The compiled SWF file version of this Application's blueprint. (file: timer_module.swf).
    What i need to confirm is: ........................................................ see the next post of mine. (for Problems  need to be Resolved)

    Problems to Resolve:
    Problem#1) - Countdown Timer to the designated Date for Live-Broadcast-Event yet to take place.
    Problem#2) - Detect End of Live Stream on FLVPlayback with FLVPlayback.isLive = true;
    Problem#1 Description:
    I need to pinpoint the Logical TimeSync Exception, i am still unable to figure out. That is I'm using a webservice in my Application to Synchronize the Time with the actual ET (eastern time) with accomodation of auto-adjustment for EDT GMT-4 (eastern daylight time) & EST GMT-5 (eastern standard time), times. I am using the zipcode: "10012" to pass it to the Web Service in urlRequest object, to retrieve the Current ET eastern time according to EDT & EST time settings for Manhattan/Brooklyn areas or others within  New York, NY 10012.
    Currently the Web Service is returning accurate date/time based on local EDT GMT-4 daylight time.
    Is there some defined set of dates for EDT & EST times for New York region that I can check for to ensure the correct Dates/Times for Eastern Time in New York area ??? I am using NY zipcodes because i am sure to get correct ET values.
    The Major Problem Part: is I need to correct the time by 2 seconds or approx. 2 secs, some millisecs.
    When I retrieve the Time Value from WebService, it lags behind for 2 seconds as compared to DateObj i create using computer's local time, on my Windows XP Service Pack 2 with Automatic Updates turned-on. And I'm sure about my Windows will be having latest updates for Time Management already installed. I also added the 2 secs. to the TimeSync(ed) Date to make correction to this Date obj.
    I call my custom fucntion addSeconds(dateObj:Date, secs:int) to add 2 seconds to the Date by Converting Seconds to Milliseconds.
    Please comb through the as code in files attached and Help Me Out !!!
    Problem#2 Description:
    Secondly I need to Detect the End of Stream state while using FLVPlayback component, an rtmp:// live Stream from FLASH MEDIA SERVER.
    I need to Play a YuMe Post-Roll Ad when Steam Finishes/Ends.
    Live Broadcast Stream Event starts every night on Wednesdays & Saturdays exactly  at 10:59 PM EDT GMT-4.
    Live Events only Streams/Broadcasts the stream for 50secs. exactly. When [playback stopped] it plays a PostRoll Ad and after the CountdownTimer again comes back to life. The Next upcoming Event is calculated & the Countdown begins until Next Event's time/date is reached.
    Here is the  code on the frame 1 on the MainTimeline: (rest of the params like source, volume, skinAutoHide are Set using Property Inspector for FLVPlayback instance on Stage)
    //myStream instance of FLVPlayback is on the Stage
    myStream.isLive = true;// Frame 1 Actions in the FLA
    myStream.addEventListener(VideoEvent.COMPLETE, onEndOfStream);
    myStream.addEventListener(VideoEvent.STATE_CHANGE, onState);
    myStream.addEventListener(String(VideoError.NO_CONNECTION), onStreamError);
    myStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
    /*if(myStream.stopped){
         trace("tracy: "+myStream.state);
    } else if(myStream.state == VideoState.STOPPED){
         trace("tracy: "+myStream.state);
    function onStreamError(event:VideoError) {
         trace(event.code + "\n\t" + event);
    function onState(event:VideoEvent) {
         trace(event.state + "\n\t" + event.toString());
    function onEndOfStream(event:VideoEvent) {
         trace(event.state + "\n\t" + event.toString());
    function netStatusHandler(event:NetStatusEvent):void {
         switch (event.info.code) {
              case "NetConnection.Connect.Success":
                   //connectStream();
                   break;
              case "NetStream.Play.StreamNotFound":
                   trace("Stream not found: "/* + myStream.source*/);
                   break;

  • Looping to Live Stream - onPublish?

    Hello everyone,
    I'm an extreme newbie, and I finally have my videos looping, but I want them to stop looping and cut to a live stream whenever we go live with our broadcast. Can someone go into detail as to the code I need to switch from the looping videos to the live stream? I'm pretty sure it's done with onPublish, but again, I'm a newbie so I need all the help I can get.
    Here is my main.asc. Thanks in advance!
    application.onAppStart = function(){
    this.clientStream = Stream.get("clientPlayStream");
    this.clientStream.play("myfile", 0, -1);
    application.onStatus = function(info){
    if(info.code=="NetStream.Play.Stop") {
    //do some code in here to restart the stream
    this.clientStream.play("myfile", 0, -1);
    }

    Yes... you can use application.onPublish and application.onUnpublish to handle it.
    application.onPublish = function(client, stream){
    if(stream.name == "therightlivestream"){
    this.clientStream.play("therightlivestream", -1, -1);
    application.onUnpublish = function(client, stream){
    if(stream.name == "therightlivestream"){
    this.clientStream.play("myfile", 0, -1);

  • Recording H.264 Live Stream on the Server

    I have seen several questions which were close to what I am looking for, but haven't found an answer that worked. I work at a school, and we use a NewTek TriCaster to stream live events through FMS 3.5, which I am hoping to upgrade to AMS 5 to allow HLS. We have been streaming a single H.264 encoded feed through the server as a live stream which works well. They have recently asked if it is possible to archive that recording on the server. I was able to get everything to work correctly when I switched to using the VP6 codec, but as long as we were streaming with H.264, I could not get the server to record it correctly. Here's what I have tried:
    This code works for the VP6, but the H.264 doesn't record the video:
    application.onPublish = function (clientObj, streamObj)
         var s = new Stream("archive");
         s.record();
         s.play(streamObj.name);
    This worked and created an flv file, but caused a few other issues due to the encoding of the VP6 and having to re-encode the video to H.264 before putting the file online.
    Based on suggestions I was reading, I tried this with the H.264 stream:
    application.onPublish = function (clientObj, streamObj)
         var s = new Stream("mp4:archive.f4v");
         s.record();
         s.play(streamObj.name);
    This created an f4v file, but I could not play it. When I tried to open it in Adobe Media Encoder, it gave an error that it did not support the compression type.
    Thanks.

    You should use a H.264 compitable encoder..
    FMS only delivery content, player only player the stream..
    Flix Engine, from On2, have the H.264 encoder..

  • Clearing application buffer after a live stream ends

    Hi there, I'm sure this has been asked and answered a million times, but searching for "application" "buffer" "cache" "live" and "hls" isn't giving me any answers, so let's get to it...
    After I end a live stream (which I do using FMLE 3.2 and FMS 4.5) and I then start a new live stream with the same application name, the HLS stream just loops the last 30 seconds of the old stream. To prevent this, after I end a stream, I have to go to applications\livepkg\streams\_definst_\ and delete the buffered data there. Only then can I start a new stream with the same name as the old stream. Now... that can't be normal, can it? Is there a switch somewhere I can set to tell FMS to cut it out and stop buffering old streams?
    Thanks,
    Raul

    You can use "record" mode rather than default mode of "append". You just need to publish using streamname - livestream%i?adbe-live-event=liveevent&adbe-record-mode=record.
    Though "append" should also work - can you let me know what do you see in FMS core logs / application logs. Also are you changing encoding settings when you republish/restart?

Maybe you are looking for

  • How do I sync Exhange agenda (work) with my Macbook at home?

    I have upgraded my operatingsystem from Leopard to Snow Leopard to be able to go to Lion, so i could go on with my mobile me account to iCloud. I've been a mobile me user since 2006. Now I have been forced to swich to Lion to keep my syncronisation a

  • Standard text in transaction...

    Hi i'm new in sdn, and i must tell you that my English is not so good by this days. Im learning little more every day. My problem is that i need to change some standard text in transaction FCH5. i wonder if i can change for example a text in a field

  • Re install Adobe Flash 10.3 ?

    Could someone tell me how to get Adobe Flash 10.3 back working? I did something wrong, trying to remove it for the 11.3 version for this program I've been using. I did not remove it by Uninstaller, this keeps aborting and reinstalling 10.3 keeps fail

  • Resolution question/observation

    HI all, I have my ATV paired with a Sony Bravia, which natively displays 1080p signals. Until recently, I was using component video cables to connect. Yesterday, I hooked the TV up via HDMI, and the difference in picture quality was detectable, but s

  • ITS 6.2 on Netweaver 04 for ESS Life and events

    Hi ERP 2004 webdynpro bus package does not support the life and events for ESS. So I got to use teh ITS version for this one. I see that none of the ITS services PZML_01, PZML_02 are published to ITS. Also the recommended version is a standalone ITS