Skip to main content
Participating Frequently
November 9, 2009
Question

Multipoint streaming (+ Justin.TV)

  • November 9, 2009
  • 3 replies
  • 2920 views

Hello,

I am trying to get multipoint streaming set up with all of my dedicated boxes + Justin.tv. I have spend hours looking around trying to find a good way to achieve this, but to no avail.

I am very much a noob when it comes to the server side scripting. To give you an example, it took me 2 hours to find out that main.far was a zip file and that main.asc was inside of it. I have looked at all of the documentation on server to server but its just nonsense to me. Here is my snipit for the Justin.TV (I have not even tried the server to server part yet).

application.onPublish = function(client, myStream) {
    trace(myStream.name + " is publishing into application " + application.name);
    // This is an example of using the multi-point publish feature to republish
    // streams to another application instance on the local server.
    if (application.name == "efragtv/_definst_"){
        trace("Republishing the stream into efragtv/anotherinstance");
        nc = new NetConnection();
        nc.connect( "rtmp://live.justin.tv/app" );
        ns = new NetStream(nc);
        // called when the server NetStream object has a status
        ns.onStatus = function(info) {
            trace("Stream Status: " + info.code)
            if (info.code == "NetStream.Publish.Start") {
                trace("The stream is now publishing");
            }          
        }
        ns.setBufferTime(2);
        ns.attach(myStream);
        ns.publish( "live_12345_abc123", "live" );
    }
}

I dont even know where to begin when it comes to dedicated box to dedicated box, so any help you can provide would be great. I have been at this for 5 hours now so i am going to bed and start fresh in the morning. Thanks in advance for you help.

    This topic has been closed for replies.

    3 replies

    Participating Frequently
    June 14, 2010

    Thank you for the quick reply se.

    I finaly got it working with justinTV was just a small bug i had.

    What I´m trying to do now is to stream to ustream but it doesnt work. I used the script like that:

    // Called when the client publishes


    application.onPublish = function(client, myStream) {

    if (application.name == "livestreams/_definst_"){
       trace("Republishing the stream to ustream");

           nc = new NetConnection();
       trace("step2")
           nc.connect( "rtmp://flash56.ustream.tv/ustreamVideo/727399" );
       trace("step3")
           ns = new NetStream(nc);
       trace("step4")
           // called when the server NetStream object has a status
          // ns.onStatus = function(info) {
        //trace("Stream Status: " + info.code)
        //if (info.code == "NetStream.Publish.Start") {
          //   trace("The stream is now publishing to ustream");
        //}          
          // }
      
           ns.setBufferTime(2);
           ns.attach(myStream);
           ns.publish( "ustreamchannelname", "live" );
    }
    }

    On the serverinfo i can see the following:

    Republishing the stream to ustream
    step2
    step3
    step4
    Sending error message: Method not found (moduleInit).
    Sending error message: Method not found (moduleInfo).

    The problem is that you normaly start your stream to ustream(e.g. with fme) and you can see a button coming up on the ustream page that you need to press and than it starts. This button never appears when i try to stream with fms.

    I know my rtmp link is right(testet with fme), i know the script should work(working with justinTV).

    Any idea what to do?

    Thx allready

    Participating Frequently
    June 15, 2010

    What prompt do you get when you publish to FMLE - you said you get some prompt and you press the button and then it starts. Does it ask for some username and password? If yes then there is some authentication involved here. I think you should check with ustream how can you authenticate when you publish via server-side script. I will try to see if i can repro such scenario here using Authentication Plug-in of FMLE. But meanwhile do check with ustream.

    Participating Frequently
    June 15, 2010

    I will do that. But the button that comes up is not for authentification. I´ll explain abit more:

    Ustream is using his own browserbased streamingtool. You go there, login and than klick to start that tool. Now you can start FME. Than you can see a green button coming up on that tool saying something like "do you want to switch to FME?". If you click yes the stream starts.

    That never happens when i push the stream with FMS.

    I will try to talk to ustream today.

    Participating Frequently
    June 14, 2010

    Hallo,

    could somebody finaly finish the script and get it working?

    I´m trying to do the same right now and cant get it working.

    Participating Frequently
    June 14, 2010

    What is the issue you are facing? I mean what errors are you getting while you are running in the script?

    JMMCJOHNAuthor
    Participating Frequently
    November 10, 2009

    Alright i after hours of testing and playing i got it to somewhat work. But I am having a problem where when i stream to both my dedicated servers and Justin.TV the stream going to the dedi servers will die after about 5mins. Here is my code....
     
    -----------------------------------------
     
    //Website
      if (application.name == "All/chan1"){
     
           trace("Republishing the stream the LIVE page.");
     
           nc = new NetConnection();
           nc.connect( "rtmp://******.com/live" );
       
           ns = new NetStream(nc);
       
           // called when the server NetStream object has a status
           ns.onStatus = function(info) {
        trace("Stream Status: " + info.code)
        if (info.code == "NetStream.Publish.Start") {
             trace("The stream is now publishing to the site.");
        }           
           }
       
           ns.setBufferTime(2);
           ns.attach(myStream);
           ns.publish( "chan1", "live" );
     
     
     
    //Justin TV
           trace("Republishing the stream to Justin.TV");
     
           nc = new NetConnection();
           nc.connect( "rtmp://live.justin.tv/app" );
       
           ns = new NetStream(nc);
       
           // called when the server NetStream object has a status
           ns.onStatus = function(info) {
        trace("Stream Status: " + info.code)
        if (info.code == "NetStream.Publish.Start") {
             trace("The stream is now publishing to Justin TV");
        }           
           }
       
           ns.setBufferTime(2);
           ns.attach(myStream);
           ns.publish( "live_******_******", "live" );
      }

    Participating Frequently
    November 12, 2009

    I did not get your use case properly but let me try to answer it anyhow. Let me assume few things (my assumptions might be wrong and you can correct me later)

    You have two dedicated servers let them say S1 and S2. You want to use one of them say S1 to publish to other dedicated server S2 and Justin TV. . Let name of your application be "MPPApp" on S1 where you will be publishing from your source (it may be your encoder , Flash Player Publisher or FMLE). So try following code in MPPApp.

    main.asc of MPPApp

    var nc1=null;

    var nc2=null;

    var ns1=null;

    var ns2=null;

    //I am just creating connections to other server (also NetStreams) and Justin TV here and keeping them ready

    //You can move this code in app publish also with some changes

    application.onAppStart = function(){

        //This code is for you another dedicated server

         nc1 = new NetConnection();

         nc1.onStatus = function(info){

                   if (info.code == "NetConnection.Connect.Success"){

                        ns1 = new NetStream(nc1);

                        ns1.onStatus = function(info){

                              if (info.code == "NetStream.Publish.Start") {

                                      trace("The stream is now publishing to the site.");
                                }     

                        }

                   }

         }

         //below connect url can be anythign , as of now its S2 as dedicated server and subApp as application where clients would connect to view

         nc1.connect("rtmp://S2/subApp"); 

         //This code is for Justin TV

         nc2 = new NetConnection();

         nc2.onStatus = function(info){

                   if (info.code == "NetConnection.Connect.Success"){

                        ns2 = new NetStream(nc2);

                        ns2.onStatus = function(info){

                              if (info.code == "NetStream.Publish.Start") {

                                      trace("The stream is now publishing to the site.");
                                }     

                        }

                   }

         }

         nc2.connect(""rtmp://live.justin.tv/app"");

    }

    application.onPublish = function(myClient,myStream){

         //Say your streamname is liveStream for your internal server publish

         if(myStream.name == "liveStream"){

               ns1.setBufferTime(2);

               ns1.attach(myStream);
               ns1.publish( "chan1", "live" );

        }

        if(myStream.name == "justinStream"){

               ns2.setBufferTime(2);

               ns2.attach(myStream);
               ns2.publish( "live_******_******", "live" );

        }

    }

    Assuming that you are publishing two different livestream , one for Justin TV and other for another live event. If say both are same then you can use remove check for myStream.name

    So in summary you need to do the following:

    on S1, create application by name "MPPApp" and place above code in its main.asc. Place other apps on another server in my example , place "subApp" on S2 and i assume Justin TV Server will have application by name "app". Now publish to "MPPApp" using your publisher , in my example you basically publish two live streams to MPPApp with name "liveStream" and "justinStream" , which gets republished to S1 and Justin TV respectively. Your clients should connect to "subApp" on S2 and "app" on Justin TV to get the feed.

    Please try and let me know , if it works for you. We can discuss further and also request to put in detail about what exactly is your use case.