Skip to main content
pleqtron
Inspiring
May 18, 2015
Answered

How to publish HLS Streams for existing Application

  • May 18, 2015
  • 2 replies
  • 2122 views

Dear Adobe Community,

I am currently working on a dynamic webstream application where multiple person can start their own streams. They are connecting to our custom AMS Application (lets say "camchat").

Now I want to publish mobile ready streams as well for each stream. I got this to work while Streaming over the FMLE directly to the "livepkgr" Application but not to my own "camchat".

What I am not sure about is, in what way do I have to make my custom application ("camchat") publish HLS ready streams as well?

Is that possible or do I always have to use the default "livepkgr" application? If so, what is necessary to combine my application to provide streams over the livepkgr application.

I hope you got my point.

Thanks in advance,

Patrick

This topic has been closed for replies.
Correct answer pleqtron

So finally I got it to work by myself but I want to spread the "solution" because as I mentioned there are not many topics regarding this special needs. So maybe it will help anybody else:

1.  My main.asc was actually correct:

  1. application.onPublish = function (client, streamObj)
  2. {
  3.     //var s = Stream.get("f4f:" + streamObj.name)
  4.     var s = Stream.get(streamObj.name)
  5.     if(client.id == 221){
  6.         application.mobilenc = new NetConnection();
  7.         application.mobilenc.connect( "rtmp://xxxxxxxxx/livepkgr/" );
  8.         application.mobilenc.onStatus = function(info) {
  9.           trace(info.code+"   livepkgr");
  10.           if(info.code == "NetConnection.Connect.Success"){
  11.               application.mobilens = new NetStream(application.mobilenc);
  12.               application.mobilens.setBufferTime(3);
  13.               application.mobilens.attach(streamObj);
  14.               application.mobilens.publish("livestream2?adbe-live-event=myliveevent","live");
  15.           }
  16.         }
  17.     }
  18. }

2. On Serverside I had to remove my previous generated Liveevent folders. However after deleting these contents, the stream worked as expected.

3. I think the problem was, that my custom application does not take care about canceling the livepkgr liveevent as it should be. So I will go ahead and do some clean ups and take care about the correct unpublishing.

4. Also I have to implement a way to provide unique stream names - maybe this will help out aswell instead of using the same eventname all the time while testing. Never the less, thanks to Joseph for your help!

Best, patrick

2 replies

pleqtron
pleqtronAuthorCorrect answer
Inspiring
May 19, 2015

So finally I got it to work by myself but I want to spread the "solution" because as I mentioned there are not many topics regarding this special needs. So maybe it will help anybody else:

1.  My main.asc was actually correct:

  1. application.onPublish = function (client, streamObj)
  2. {
  3.     //var s = Stream.get("f4f:" + streamObj.name)
  4.     var s = Stream.get(streamObj.name)
  5.     if(client.id == 221){
  6.         application.mobilenc = new NetConnection();
  7.         application.mobilenc.connect( "rtmp://xxxxxxxxx/livepkgr/" );
  8.         application.mobilenc.onStatus = function(info) {
  9.           trace(info.code+"   livepkgr");
  10.           if(info.code == "NetConnection.Connect.Success"){
  11.               application.mobilens = new NetStream(application.mobilenc);
  12.               application.mobilens.setBufferTime(3);
  13.               application.mobilens.attach(streamObj);
  14.               application.mobilens.publish("livestream2?adbe-live-event=myliveevent","live");
  15.           }
  16.         }
  17.     }
  18. }

2. On Serverside I had to remove my previous generated Liveevent folders. However after deleting these contents, the stream worked as expected.

3. I think the problem was, that my custom application does not take care about canceling the livepkgr liveevent as it should be. So I will go ahead and do some clean ups and take care about the correct unpublishing.

4. Also I have to implement a way to provide unique stream names - maybe this will help out aswell instead of using the same eventname all the time while testing. Never the less, thanks to Joseph for your help!

Best, patrick

Joseph Labrecque
Community Expert
Community Expert
May 18, 2015

Hi, pleqtron.

I've done this by editing httpd.conf to add a mapping to the particular application storage:

<Location /hls-custom>

    HLSHttpStreamingEnabled true

    HLSMediaFileDuration 8000

    HttpStreamingContentPath "//windows.share.name/path"

    HLSFmsDirPath ".."

    Options -Indexes FollowSymLinks

</Location>

In my case, it is tapping into old files we serve over both RTMP and now, HLS if need be. Points to the streams directory in the app, basically.

pleqtron
pleqtronAuthor
Inspiring
May 18, 2015

Hi Joseph,

tanks for your quick response!

Okay, so that would be a configuration for a storage location. But does the AMS then automatically create HLS Parts to provide to iOS Users? Or do I have to do anything on my application side as well.

Currently I am not doing anything than connecting to the application (No recording of the stream or whatever).

As far as I can see on the server, some chunk files were created as soon as I connect to my and the livepkgr Application as well. But not seeing any data if I enter the URL (which is valid and gives me a positive response).

This is my main.asc (camchat Application):

  1. application.onPublish = function (client, streamObj)
  2. {
  3.     //var s = Stream.get("f4f:" + streamObj.name)
  4.     var s = Stream.get(streamObj.name)
  5.     if(client.id == 221){
  6.         application.mobilenc = new NetConnection();
  7.         application.mobilenc.connect( "rtmp://xxxxxxxxx/livepkgr/" );
  8.         application.mobilenc.onStatus = function(info) {
  9.           trace(info.code+"   livepkgr");
  10.           if(info.code == "NetConnection.Connect.Success"){
  11.               application.mobilens = new NetStream(application.mobilenc);
  12.               application.mobilens.setBufferTime(3);
  13.               application.mobilens.attach(streamObj);
  14.               application.mobilens.publish("livestream2?adbe-live-event=myliveevent","live");
  15.           }
  16.         }
  17.     }
  18. }

So if a User connects to a Webcam Session, and the Stream is published, I do a second connect to the livepkgr Application. As I said, I can see traces on the livepkgr Application side. Same as when connecting directly over Flash Media Live Encoder to this application.

Here is the trace when Connecting over the camchat -> main.asc (see above code snippet):

  1. Stream name is: livestream2 and live event is: myliveevent
  2. f4f:livestream2 - NetStream.Record.Stop
  3. f4f:livestream2 - NetStream.Play.Stop
  4. f4f:livestream2 - NetStream.Unpublish.Success
  5. f4f:livestream2 - NetStream.Data.Start
  6. f4f:livestream2 - NetStream.Play.Reset
  7. f4f:livestream2 - NetStream.Publish.Start
  8. f4f:livestream2 - NetStream.Record.Start


Trace when connecting directly over FMLE (withour camchat Application):

  1. onPublish : livestream1
  2. Stream name is: livestream1 and live event is: myliveevent
  3. f4f:livestream1 - NetStream.Publish.Start
  4. f4f:livestream1 - NetStream.Play.Reset
  5. f4f:livestream1 - NetStream.Data.Start
  6. f4f:livestream1 - NetStream.Record.Start


I am quite confused because I can not find any documentation for that special need.


Thanks in advance!

Joseph Labrecque
Community Expert
Community Expert
May 18, 2015

Oh, I thought you were just streaming VOD over HLS. If doing a webcam chat app or something you will need to stick with RTMP. If doing a live non-interactive video stream - you just use livepkg app on the AMS side.

What URL are you using to access the live HLS stream?