Hi Huy,
Please find the zip attached where I have written the scripts for you to deploy on your local FMS server, in context of option 2:
You may like to follow these steps:
1. unzip the folder.
2. deploy FLVpublishonLoad (in case your recorded file is a FLV use case) on your lcoal server
3. deploy toPublish on your remote aws server
4. make sure to correct the path for aws in FLVPublishonLoad application @ line#19:
| // Please mention your aws instance hostname instead of localhost , and application name .... |
| nc.connect("rtmp://localhost/toPublish"); |
5. go to admin console of your local development server and load the instance of FLVPublishonLoad as shown in the howtoLoadfromAdminConsole.png image attached for refrence purpose.
6. it will automatically connect to the "toPublish" app on your remote server and start publishing your local vod file as a live stream to your aws instance
7. start your subscriber app and subscribe to the stream you have used in FLVPublishonLoad app for Stream.get() method, see line#29 and the subscriberScreenExample.png file attached for the illustration purpose.
few points to note here:
1. I have removed the sample.flv and "sample1_1500kbps.f4v" for keeping the zip size lower.
2. You need to put your stream name at line#55 where you call mystream.play()
3. The stream name that you specify in Stream.get() will be used by subscribers.
4. if your use case is mp4, then please use "MP4PublishonLoad" instead of "FLVPublishonLoad" application.
=============
As I am unable to attach the files here therefore copy-pasting the code for you and others to be re-used:
=======
main.asc code for FLVPublishonLoad:
--------------------------------------
var nc;
var ns;
application.onAppStart = function()
{
trace("hello client: ");
publishIt();
}
function publishIt()
{
trace("publishing");
nc = new NetConnection();
// Please mention your aws instance hostname instead of localhost , and application name ....
nc.connect("rtmp://localhost/toPublish");
nc.onStatus = function(info)
{
trace(info.code);
}
ns = new NetStream(nc);
// Exact stream name available for subscribers .....
mystream = Stream.get("myvodfile");
mystream.onStatus = function(sinfo)
{
trace("mystream.onStatus: "+sinfo.code);
if(sinfo.code == "NetStream.Publish.Start")
{
attach_retVal = ns.attach(mystream);
if(attach_retVal==true)
{
trace("stream attach was successful ...");
startPublish();
}
else
{
trace("The attempt to attach stream source to NetStream failed");
}
}
}
// Please put the stream name here inside double-quotes that you want to publish and is available there in streams/_definst_ folder ......
mystream.play("sample",0,-1,true);
}
function startPublish()
{
ns.publish(mystream.name,"live");
}
--------------------------------------
main.asc code for MP4PublishonLoad:
--------------------------------------
var nc;
var ns;
application.onAppStart = function()
{
trace("hello client ");
publishIt();
}
function publishIt()
{
trace("publishing");
nc = new NetConnection();
// Please mention your aws instance hostname instead of localhost , and application name ....
nc.connect("rtmp://localhost/toPublish");
nc.onStatus = function(info)
{
trace(info.code);
}
ns = new NetStream(nc);
// Exact stream name available for subscribers .....
mystream = Stream.get("mp4:myvodfile.f4v");
mystream.onStatus = function(sinfo)
{
trace("mystream.onStatus: "+sinfo.code);
if(sinfo.code == "NetStream.Publish.Start")
{
attach_retVal = ns.attach(mystream);
if(attach_retVal==true)
{
trace("stream attach was successful ...");
startPublish();
}
else
{
trace("The attempt to attach stream source to NetStream failed");
}
}
}
// Please put the stream name that you want to publish and is available there in streams/_definst_ folder ......
mystream.play("mp4:sample1_1500kbps.f4v",0,-1,true);
}
function startPublish()
{
trace("#### " + mystream.name);
ns.publish("mp4:" + mystream.name,"live");
}
--------------------------------------
main.asc code for "toPublish" app
=====================
application.onPublish = function(clientObj, streamObj)
{
trace("published: " + streamObj.name);
}
=====================
Please revert back to me in case of further query.
Regards,
Shiraz Anwar
