Skip to main content
Participant
November 7, 2010
Question

How to understand live stream is online

  • November 7, 2010
  • 2 replies
  • 1825 views

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);

}

    This topic has been closed for replies.

    2 replies

    Participant
    November 9, 2010

    Thanks  for all quick replies , firstly I’m sorry for not being able to clarify,

    We have more than 400 cameras and these cameras are not in our internal network, streams are carried via TELEKOM’s (natioanal carrier company) G.SHDSL lines. Communication infrastructure  is very bad, we have to use multicast protocol, so we have a lot of problems. We can display all our cameras in our network, and partners’ network. All networks multicast protocol is available. Pelco could hardly believe that multicast enabled network  where we publish more than 400 streams could sustain. A camera stream when coming from area to our center, hops from more than 10 nodes
    We also publish 100 camera videos on our website using Flash Media Server, our camera system is Pelco endura, but we can’t get rtsp streams of cameras. Pelco says that this is because of  multicast protocol and network problems. So to publish streams on the web, we convert digital videos to analog using decoders. These decoders are often get locked . When they get locked, they publish only black screen.  With Flash Media Live Encoders, we convert analog videos to rtmp. In order to do this, we use capture cards and a lot of PCs.

    So, I get snapshots of all cameras to publish them on web. But also, i publish 100 cameras’ live video stream. I would like to detect problems in live streaming. If there is a problem, I provide snapshots to users. We have 2 common problems, if FMLE or PC get locked, there is no livestream on FMS, and other is if decoder gets locked, I get only black video, so all frames are same, is there is a way to understand  these problems...
    Thank you..

    Known Participant
    November 9, 2010

    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")
            }       
        }   
    }

    Participant
    November 19, 2010

    sory i am to late for answering,

    i was working hard to finish a project.

    thank you, for your answer,

    yes, with your code and i can save png

    Participating Frequently
    November 9, 2010

    Since you are subscribing to livestream, you will never get "NetStream.Play.StreamNotFound" - this message is meant for VOD/DVR Streams.

    What i would suggest is, you use Admin API command called "getLiveStreams" - this will return set of live streams which are publishing to any particular application - so that client subscribes only to one of these live streams which are publishing.

    You can find documentation related to getLiveStreams in Admin API here: http://help.adobe.com/en_US/flashmediaserver/adminapi/WSa4cb07693d12388431df580a12a34991ebc-8000.html#WS5b3ccc516d4fbf351e63e3d11a0d3edb98-7fe7

    Participant
    November 9, 2010

    Thank for your reply,

    getLiveStreams is long solution for me, because, my plan was this,

    if there is a problem with stream -maybe proxy problem, maybe problem with my FME, decoder...

    i will give cam snap shots to client.

    we have problems with our decoders, they crush to much, in this position our decoder gives black screen, and so FME, publish black screen. Can i understand automaticly  this black screen

    Known Participant
    November 9, 2010

    Hi,

    You are talking about live video steaming and your code is looking some progressive video. so please tell us your proper requirement.

    Are you looking some progressive video through FMS or looking for live streaming, if you are looking live video streaming then you have to make some changes into your code so clarify you question that what you are looking for.