Results 1 to 5 of 5

Thread: Wowza module to start stream on HLS request

  1. #1
    Join Date
    Mar 2013
    Posts
    11

    Default Wowza module to start stream on HLS request

    Hi,

    I want to start a stream automatically when a HLS request is made.
    For this, I wrote a server side module with the following code:

    public class LiveModule extends ModuleBase {
    	public void onHTTPSessionCreate(IHTTPStreamerSession httpSession)
    	{
    		IApplicationInstance appInstance = httpSession.getAppInstance();
    		String streamName = httpSession.getStreamName();
    		
    		appInstance.startMediaCasterStream(streamName, "rtp");
    	}
    }
    I use VLC for playing the HLS stream from Wowza. So, when I acces this url in VLC http://wowza-ip:1935/live/appInst/sa.../playlist.m3u8 it happens the following:
    - the stream starts (I see it in the Wowza log and also in the StreamManager web interface)
    - the VLC starts to play but it stops after 3-4 seconds
    - if I press play button in VLC one more time, the video plays nicely in VLC without any problems

    What should I do in order for the video to play properly in VLC from the first attempt? I guess there is some kind of delay I should implement somewhere. But I don't know where: server side (in some config files or in the code) or at the player (VLC) level.

    Thanks,
    Ciprian

  2. #2

    Default

    I would suggest you sniff traffic out of VLC to understand why it fails. I guess it could be related to HLS design, which requires at least 3 chunks in the playlist. At the moment you create it, you won't have those chunks available (depending how long you have the chunks to be set, it's the time you'll have to wait)
    Not all players process HLS the same. IPAD won't play if there's no 3 chunks in the list. VLC might start, but when request the manifest again, there's nothing new, so it stops.

    Technically speaking, as HLS requires those 3 chunks per definition of a live stream, starting the stream on first connection will require more than just a delay, but a checking if the manifest received is good enough to start a live playback

  3. #3
    Join Date
    Dec 2007
    Posts
    22,013

    Default

    I think you are running into the same limitation that iOS devices have trying to playback cupertino streams that has just been started, a requirement for 3 chunks in the case of iOS. You might cupertinoPlaylistChunkCount to "1", but that is probably not a good idea for iOS

    Richard

  4. #4
    Join Date
    Mar 2013
    Posts
    11

    Lightbulb Solution found

    Hi,

    Finally I've found a solution to this issue and I would like to share it here.
    I've just added the following code to my example above. That delay allowed Wowza to prepare the cupertino chunks in order for the VLC to play smooth. It is a little bit of delay when the user first accesses the url in VLC, but at least it works.

    public class LiveModule extends ModuleBase {
    	public void onHTTPSessionCreate(IHTTPStreamerSession httpSession)
    	{
    		IApplicationInstance appInstance = httpSession.getAppInstance();
    		String streamName = httpSession.getStreamName();
    		
    		appInstance.startMediaCasterStream(streamName, "rtp");
    		
    		try {
    			Thread.sleep(15000);
    		} catch (InterruptedException e) {
    			e.printStackTrace();
    		}
    	}
    }
    Regards,
    Ciprian

  5. #5
    Join Date
    Dec 2014
    Posts
    16

    Default

    Salut Ciprian,

    This is exactly the same quick fix that I'm forced to use right now. However Thread.sleep() is not really safe to use in onHTTPSessionCreate, as reported in another forum discussion.

    If you can't handle all this in the client, another solution would be to have a pre-roll stream that is always up and running (like a local file in a loop for eg.). When a user connects and demands a stream that is not yet started the server will play the pre-roll video while your actual stream starts. When the other stream is live the server switches without the client having to disconnect/reconnect. You can do all this by implementing a stream listener.

    One more thing, in your example you should at least check if the stream is already started before sleeping.

    appInstance.getStreams().getStream(streamName) != null
    There's no point having another concurrent user wait too.

    Hope this helps.

Similar Threads

  1. Start stream on request and stop when nobody is viewing
    By aegeli in forum Live Streaming and Encoders
    Replies: 4
    Last Post: 04-07-2014, 12:31 PM
  2. Replies: 23
    Last Post: 02-21-2013, 05:41 PM
  3. Start / Publish Stream Module
    By optics in forum Server-side Modules and Code Samples Discussion
    Replies: 0
    Last Post: 12-10-2012, 04:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •