Skip to main content
Participating Frequently
September 17, 2010
Question

How to read or extract cuepoints created live, with Nestream.send()?

  • September 17, 2010
  • 2 replies
  • 2905 views
Im doing live streaming directly from webcam like Ustream.TV. Im  using Flash Media Server 3.5, and I record cuepoints of broadcaster with  the method

ns = new NetStream(); ns.send('functionName' , 'value');

I publish the content and record it in a .flv file. However when I  download this FLV file and extract the metadata with tools like  FLVTOOL2, or FLVMETA, the cuepoints that I recorded with ns.send()  method doesn`t show.

I know they are there since when I play the FLV file in another client, I  can receive the calls for the 'functionName' in the exact time that I  call while recording.

What I`m doing wrong?

I would like to encode recorded video with Flash Media Encoder and  insert into it CuePoints that can call to the same function that I do  with live streaming. To do that, first I need to know how the CuePoints  are created and fixed into the FLV file that I record directly from  webcam. I need to know how they are stored to do it manually in Flash  Media Encoder. Thanks
    This topic has been closed for replies.

    2 replies

    September 27, 2010

    You aren't going to be able to extract these events with the third party software you mentioned.

    Events recorded using netstream.send are not included in the top-of-file metadata as cuepoints. Events are saved as data describing AMF types and values, and the data is in the file data itself at the point where the event is to be dispatched. The flv spec actually calls for using the same data structure for metadata... it just reserves the name "onMetaData" for the event, and that onMetadata event is typically found at the top of the file.

    I don't know of any third party tools for extracting data other than that with the onMetaData event name, but if you're comforatable working at the byte level, i imagine you could build a tool to read through the bytes and look for the data tags in the file.

    You can read more in the file specification:

    http://www.adobe.com.gt/devnet/f4v.html

    The pdf linked on that page contains information for both FLV and F4V.

    thilmkt2Author
    Participating Frequently
    September 27, 2010

    Hi, thanks again for helping

    JayCharles you got my point.

    Now imagine the follow scenario: I encoded a file using Flash Player and I recorded the events sent using netStream.send. If I understood well, I can extract or view this events with those FLV Data Extractor. I can deal with it, but is it possible to know how is it stored?

    What I need to know is to get a FLV that wasn`t encoded with my application and insert into it these metadatas that I insert when I`m recording live streaming. So the point is to inject metadata into an existing FLV file and this metadata should be able to call for the function doSomething() in the watcher player.

    I`ll use Flash Media Encoder to inject the metadata, I try to, but when a run the encoded FLV file, it doesn`t call for the doSomething() function as the FLV live recorded does.

    Thank you very much. I really appreciate both help I receive here.

    September 27, 2010

    Hmm... well, I guess that depends on your workflow.

    About this .flv you want to inject the events into, is it being played on the fms side during the live event? If so, you could play the flv over a server side stream, and record that server side stream. You could then invoke stream.send on the server side to inject the send events into the newly recorded flv

    ... or did i not understand the question?

    Adobe Employee
    September 20, 2010

    Hi,

    You can go through the below working code for sending cuepoint. After recording it try to play it by attaching appropriate handler on client side:

    Client code : Cuepoint.fla

    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.events.*;
    import flash.media.*;

    var nc=new NetConnection();
    nc.addEventListener(NetStatusEvent.NET_STATUS, onNCStatus);
    nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, netSecurityError);
    var pub_ns;

    //Attaching live feed to video object.
    var Cam = Camera.getCamera();
    var Mic = Microphone.getMicrophone();
    pub_video.attachCamera(Cam);

    //Handlers for buttons
    pub_btn.addEventListener(MouseEvent.CLICK, doPublish);
    stop_btn.addEventListener(MouseEvent.CLICK, doStop);
    send_btn.addEventListener(MouseEvent.CLICK, doSend);

    // Start publishing live feed.
    function onNCStatus(event:NetStatusEvent):void {
    logs.text += "Publisher Connection Status: " + event.info.code + "\n";
    if (event.info.code=="NetConnection.Connect.Success") {
      pub_ns = new NetStream(nc);
      pub_ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
      pub_ns.publish(stream_name.text);
     
    }
    }

    function netSecurityError(event:SecurityErrorEvent):void {
    logs.text += "netSecurityError: " + event + "\n";
    }

    function netStatusHandler(event:NetStatusEvent):void
    {
    logs.text+="Publish Code : " + event.info.code + "\n";
    if(event.info.code == "NetStream.Publish.Start"){
      pub_ns.attachCamera(Cam);
      pub_ns.attachAudio(Mic);
    }
    }

    function doPublish(e:MouseEvent) {  
    nc.connect(conn_uri.text);
    }

    function doStop(e:MouseEvent) {  
    pub_ns.publish(false);
    }

    function doSend(e:MouseEvent) {
    logs.text += "Sending the streamInfo for stream : " + stream_name.text + "\n";
    var dsSet:Array = new Array();
    var streamInfo:Object = new Object();
    streamInfo.streamName = stream_name.text;
    pub_ns.send("onStreamInfo",streamInfo);
    }

    Server Code :

    application.onPublish = function(clientObj,streamObj){

      trace("          in application publish : " + streamObj.name);
      streamFullName = streamObj.type + ":" + streamObj.name;
      streamObj.record("record");
    }

    While Playing it do the following :

    if(info.code=="NetConnection.Connect.Success"){
      ns = new NetStream(nc);
      ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
      client = new Object();
      ns.client = client;
      client.onStreamInfoAck = onStreamInfoHandler;       
    }


    function onStreamInfoHandler(info){
    trace("onStreamInfoAck : " + info.streamName + "\n");
    }

    From FMLE as far as I know you cant do the similar thing as you dont have the access for publishing stream which is required to call and insert cuepoint.

    Regards,

    Amit

    thilmkt2Author
    Participating Frequently
    September 25, 2010

    Hi Amit, thanks for helping

    But it still not working. I have the follow code:

    Broadcaster.fla

    public function sendMessage():void
    {
        var myMetadata:Object = new Object();
        myMetadata.customProp = "Welcome to the Live feed of YOUR LIFE, already in progress." + message;
        ns.send("@setDataFrame", "changeScreen", myMetadata);
       
    }

    Client.fla

    public funcion changeScreen():void

    {

    trace("changed");

    }

    Serverside

    Main.asc

    application.onPublish = function( client, stream )
    {
        stream.changeScreen = function(info)
        {
             streamFullName = streamObj.type + ":" + streamObj.name;
             streamObj.record("record");
        }
    }

    I`m able to send the metadata. There is no problem with Client.fla since it receive the calls for it. However this metadata isn`t being record with the FLV file.

    Adobe Employee
    September 26, 2010

    If you are using FMS 3.5 then I know where is the problem. I will suggest you to go through the following forum post which I had replied sometime back you will get a fair idea on what may be happening and also how to solve it.

    http://forums.adobe.com/message/2792318#2792318

    Regards,

    Amit