When you watch a live show on TV, its never really live. Its not only the foregone latency made by the different machines - but a very intended delay designed to let the editor a way to stop the transmitting if they fill such need.

You can use your imagination to complete the possible scenario.

Unfortunately, Adobe's Encoder or Flash Media Server don't have live stream delay feature out of the box. So, if you want to have such delay with Adobe FMS, you will need some server-side scripting. (Go ahead, fill a request to adobe's wish list)

On the other hand, this will be quite simple.

[NOTE: The code here is not real tested code.]

Step 1: Record your stream.

  • Method 1:
    You can use SSAS (Server Side ActionScript) to the live stream. Adobe's documentation is fairly descriptove: Stream.record()
    What you actually do is adding the recording functionality to the Application.onPublish event. Your final code will be similar to:


    application.onAppStart = function()
    {
     trace("Starting recoding application");
    };
     
    application.onConnect = function(clientObj)
    {
     this.acceptConnection(clientObj);
    };
     
    application.onPublish = function (clientObj , stream)
    {
     trace("Publish: "+stream.name);
     stream.record();
    };
    application.onUnpublish = function(clientObj, stream)
    {
     trace("Unpublish: "+stream.name);
     stream.record(false);
    };
    
    


    NOTE: Recording using this method will save the file with its default name:
    "When you record a stream, the server creates a file with the
    name you passed to the Stream.get() method. The
    server automatically creates a “streams” directory and subdirectories
    for each application instance name. If a stream isn’t associated
    with an application instance, it is stored in a subdirectory called “_definst_”
    (default instance). For example, a stream from the default lecture application
    instance would be stored here: applications\lectures\streams\_definst_.
    A stream from the monday lectures application instance would be
    stored here: applications\lectures\streams\monday. "
  • Method 2:
    If you are using Adobe's Flash Media Live Encoder - you can simply tick the record checkbox.
Step 2: Play it on your own time (Delayed)
Now, when you start your broadcasting - use the Stream.play() method to stream the recoded file to everyone.

The play function can link one file after another.. so we can add a preliminary video file as a place holder for the delayed time and than add the recorded file right afterward.
Doing that - we can easily use the "onPublish" event to make it all work so our code will be similar to this one:


    
application.onPublish = function (clientObj , stream)
{
 trace("Publish: "+stream.name);
 stream.record() 

stream.play("placeHolder.flv", -1, -1);

stream.play("recorded.flv", -1, -1);

};

application.onUnpublish = function(clientObj, stream)
{
 trace("Unpublish: "+stream.name);
 stream.record(false);

stream.play(false);
};



Enjoy!