Skip to main content
December 19, 2008
Question

Need help on application to stream movie

  • December 19, 2008
  • 5 replies
  • 681 views
I have used Flash Media Encoder and can stream to my account, but I want to do the same thing with Flash Media Server instead. I did not need scripts with FME as Justin provides a config file for FME including paths and user names so it just works.

I have an app folder built and a main.asc, and the app fired up and says it is loaded, but it does not connect nor serve anything, I hacked a script together but am clueless.

All I want it to do is to connect up to Justin and server any movies in the folder, and if the connection were to drop, to keep trying to reconnect forever (although this part is not in my hacked script yet).

I'm sure my script is wrong, I have no experience with the language but read some and hacked the following together.

Please take a minute and glance at it, I have posted on numerous other sites and have not gotten even one bad response yet.

Thanks

In this example I am just trying to get one file, test.flv to stream, but I want any files in the folder to stream and when done repeat, and if the connection drops, to try to reconnect.

----------------------------

application.onAppStart = function() {
var myStream = Stream.get("test");
var nc = new NetConnection;
nc.connect("rtmp://live.justin.tv/app");
var ns = new NetStream(nc);
ns.attach(myStream);
ns.publish(myStream,"live_1230456_12ab3e4k");
}

----------------------------

the content in the ns.publish line after "live" is required (perhpas not as I have provided here) by Justin.TV, it is my username and password I guess although I have altered it for public posting here.

Thanks
    This topic has been closed for replies.

    5 replies

    December 22, 2008
    Sorry... not sure what I was thinking in m last post. My brain kept telling me Stream class instead of NetStream class.

    The publish method is looking for two arguments, a stream and a howtopublish flag. Try changing:

    ns.publish(myStream,"live_1230456_12ab3e4k");

    to

    ns.publish("live_1230456_12ab3e4k", "live");

    Also, you might want to wait for the onStatus event of the netconnection before trying to publish a stream to it.


    December 21, 2008
    In the developer it says...

    Write the server-side code
    1 In your main.asc file on the server, define an application.onPublish() event handler that accepts the stream
    name and connects to the remote server:
    // called when the client publishes
    application.onPublish = function( client, myStream ) {
    trace(myStream.name + " is publishing" );
    nc = new NetConnection();
    nc.onStatus = function (info) {
    if (info.code == "NetConnection.Connect.Success") {
    ns = new NetStream(nc);
    ns.setBufferTime(2);
    ns.attach(myStream);
    ns.publish( myStream.name, "live" );
    }
    nc.connect( "rtmp://xyz.com/myApp" );
    }
    }
    Calling NetStream.publish() publishes the stream from your server to the remote server.

    So it seems to imply (to me) that it will PUSH this content if ONPUBLISH is called by the client (which would be a server with hundreds of people on it) surely, it does not have 100 people on the main server, and it then "calls" my server and makes 100 redundant connections from my server (live feed) to that server then to the consumers.

    And I would assume that it is making the connection due to ONPUBLISH from the CDNB server, so can't I simply change the trigger from ONPUBLISH to ONAPPSTART, there will only ever be one instance.

    I dont know, this is a lot harder than it should be. I have posted this all over the next and zero replies really. It cant be that hard to do.

    Take a file from my dev server running FMS and whenever FMS is started up it connects to the CDN servers at Justin using my Justin logon and starts streaming the fuile regardless of whether anyone is there or not, FME does it no problem.
    December 21, 2008
    In the FMS 3 server overview it states...

    Use Flash Media Interactive Server or Flash Media Development Server to "PUSH" live streams to additional origin
    servers that distribute the streams to users. This is useful for streaming data to a Content Delivery Network (JUSTIN TV) capable
    of delivering your stream to millions of users.
    December 21, 2008
    Also, I currently use FME to send streams to Justin no problem, but I need to replace it with FMS because I am not sendling live I am sending vid files and that then requires I add a fame virtual camera so the FME has hardware to connect to for the feed.

    Using FME Justin does not initiate, I do on my end.
    December 20, 2008
    FMS can't push streams. It can only request them. There is no publish method on the server side Stream class.

    So, Justin.tv's FMS app would need to make a Stream.play request of your application. (acutally... I'm not entirely sure they use FMS... I seem to remember reading something about a python media server they use)
    December 21, 2008
    Thanks, but I don't think that is correct.

    A number of "movie" channels by regular users are using the developer edition to do just this, but they won't say how. Also, it is my understanding that this indeed is a new never before available functionality that has only just been added via the use of FMS 3, or have I been misinformed ?

    My understanding is that FMS 3 supports server to server connections to support CDN apps like Justin TV, but perhaps they are saying it still requires a request from the client ot initiate the stream ?

    Anyhow, all I want is one instance of one file to stream to my account there, so even if it takes a client request, can't I "connect" to it with a client but have it stream to my justin account ?

    I also thought you would use the following although I have no idea how to code FMS scripts, when I run this it loads but nothing happens

    I am trying to send test.flv from my Flash Media Server 3.5 to Justin.TV servers

    I used Flash Encoder and a virtual camera to play the file and got it there fine, now I want to use Flash Media Server instead of the encoder and virtual cam software as it is just added overhead.

    I created an app folder, put the main.asc in it, and created a subfolder and put the flv file in there

    When I start the app there are no errors, the admin console says the app is loaded, but nothing is streaming

    Here is the main.asc I hacked together to do this, I am sure it is not right, I want it to stream this file when the app is loaded by me using the admin interface

    main.asc - file to stream is test.flv

    ----------------------------

    application.onAppStart = function() {
    var myStream = Stream.get("test");
    var nc = new NetConnection;
    nc.connect("rtmp://live.justin.tv/app");
    var ns = new NetStream(nc);
    ns.attach(myStream);
    ns.publish(myStream,"live_1230456_12ab3e4k");
    }

    ----------------------------

    the content in the ns.publish line after "live" is required by Justin.TV, it is my username and password I guess although I have altered it for public posting here.

    Thanks