Results 1 to 7 of 7

Thread: List chunks on an HLS live stream

  1. #1
    Join Date
    Dec 2009
    Posts
    17

    Default List chunks on an HLS live stream

    Hey guys,

    Is there a way to list chunks on a HLS/cupertino live stream?

    ===

    I have a concrete need where my player will need to know exactly when the live stream is taking place (slide sync, of course). All of this is fairly approachable if only I can build an index up of the chunks along with a timestamp.

    Obviously, I've been playing around in order to get there, but listening to events on the packetizer and the media list renditions isn't really doing the trick -- and at the same time the packetizer seems to be teasing me by writing the exact info that I need to the log file:

    2014-06-06_19:55:13.09204 INFO server comment - LiveStreamPacketizerCupertino.endChunkTS[live/_definst_/dev-3753984-ab701201ab4621b3454b.mp4]: Add chunk: id:11 mode:TS[H264,AAC] a/v/k:151/306/3 duration:10566

    ... and I'd love to get this directly from Wowza instead of parsing log files ;-)

  2. #2
    Join Date
    Dec 2009
    Posts
    17

    Default

    Sorry to push on this one, but does anyone have a good idea? Any events being fired when chunks are created, even if they are private APIs designed to be used only by DVR...?

  3. #3
    Join Date
    May 2013
    Posts
    680

    Default

    You might be able to obtain what you are looking for using IVHostHTTPStreamerRequestValidator and the validateHTTPStreamerRequest event.

  4. #4
    Join Date
    Dec 2009
    Posts
    17

    Default

    Thanks Matt -- but aren't these events fired when the chunks are requested, not when there's generated? If so, the timing would be off with this scheme?

  5. #5
    Join Date
    May 2013
    Posts
    680

    Default

    In 4.0.4 (latest release) we do have IHTTPStreamerCupertinoLiveStreamPacketizerChunkIdHandler interface that implements the init and onAssignChunkId events which may correlate more closely to what you are looking to do. You can create a class that implements this interface then define the handler in your Application.xml within the LiveStreamPacketizers/Properties to turn it on as follows:
    <Property>
                    <Name>cupertinoChunkIdHandlerClass</Name>
                    <Value>[Class-Path]</Value>
    </Property>

  6. #6
    Join Date
    Dec 2009
    Posts
    17

    Default

    Following up on this, the release notes for 4.0.4 state that:

    * Added support to Apple HLS (cupertino) live stream packetizer to provide a IHTTPStreamerCupertinoLiveStreamPacketizerChunkIdHandler class to control how chunks are numbered
    * LiveStreamPacketizerCupertino.setChunkIdHandler(IHTTPStreamerCupertinoLiveStreamPacketizerChunkIdHan dler chunkIdHandler)
    * Added LiveStreamPacketizers/Properties string property cupertinoChunkIdHandlerClass to specify full Java path to a class that implements IHTTPStreamerCupertinoLiveStreamPacketizerChunkIdHandler to control how cupertino chunks are numbered
    * Added IHTTPStreamerCupertinoLiveStreamPacketizerChunkIdHandler interface to control how cupertino chunks are numbered
    * void init(LiveStreamPacketizerCupertino liveStreamPacketizer);
    * long onAssignChunkId(HTTPStreamerCupertinoLiveStreamPacketizerChunkIdContext chunkIdContext);

    This in turn is a way of saying that there's now an interface to handle which number is assigned to an HLS chunk (which were previously just number sequentially). Matt notes that this can be controlled by a property in settings, but it's also fairly easy to do programatically (and I wanted to keep my module structure).

    My code to number chunks by the epoch time in milliseconds of their creation looks like this:

    import com.wowza.wms.module.*;
    import com.wowza.wms.application.*;
    import com.wowza.wms.httpstreamer.cupertinostreaming.livestreampacketizer.*;
    import com.wowza.wms.stream.livepacketizer.*;

    public class MyWowzaModule extends ModuleBase {
    public void onAppStart(IApplicationInstance appInstance) {
    // We want to set chunk numbers for cupertino streaming; this is done first by listening to the live stream packetizers
    appInstance.addLiveStreamPacketizerListener(new LiveActionNotify(appInstance));
    }

    /*** CHUNK NUMBER HANDLING
    Set chunk numbers by the epoch time (in milliseconds) of their creation
    ***/
    class CupertinoChunkIdHandler implements IHTTPStreamerCupertinoLiveStreamPacketizerChunkIdHandler {
    public void init(LiveStreamPacketizerCupertino liveStreamPacketizer) {}
    public long onAssignChunkId(HTTPStreamerCupertinoLiveStreamPacketizerChunkIdContext chunkIdContext) {
    return System.currentTimeMillis();
    }
    }
    class LiveActionNotify implements ILiveStreamPacketizerActionNotify {
    public LiveActionNotify(IApplicationInstance appInstance) {}
    public void onLiveStreamPacketizerCreate(ILiveStreamPacketizer liveStreamPacketizer, String streamName) {}
    public void onLiveStreamPacketizerDestroy(ILiveStreamPacketizer liveStreamPacketizer) {}
    public void onLiveStreamPacketizerInit(ILiveStreamPacketizer liveStreamPacketizer, String streamName) {
    while(true) {
    if (!(liveStreamPacketizer instanceof LiveStreamPacketizerCupertino)) break;
    LiveStreamPacketizerCupertino cupertinoPacketizer = (LiveStreamPacketizerCupertino)liveStreamPacketizer;
    cupertinoPacketizer.setChunkIdHandler(new CupertinoChunkIdHandler());
    break;
    }
    }
    }
    }
    This is awesome. It really is.

    More wants more though: Is there any ways to do the same thing for DVR chunks?

  7. #7

    Default

    Hi,

    Even though you code will create chunks with incrementing id numbers, it may possibly cause problems on playback. THe HLS specification says that the segment ids must be sequential and increment by 1 each time. You would have to return system time / target duration to get this.

    See http://tools.ietf.org/html/draft-pan...e-streaming-13 for details.

    Roger.

Similar Threads

  1. HLS chunks start with brief moment of mono audio
    By jeffwaugh in forum Live Streaming and Encoders
    Replies: 3
    Last Post: 06-04-2014, 03:28 PM
  2. Controlling HLS Media Chunks Naming
    By rubin.gerovski in forum Server-side Modules and Code Samples Discussion
    Replies: 3
    Last Post: 12-28-2013, 09:42 AM
  3. Replies: 5
    Last Post: 03-04-2013, 03:00 PM
  4. Live stream play list stops
    By eotg_ak in forum Live Streaming and Encoder Discussion
    Replies: 0
    Last Post: 03-21-2012, 02:58 PM

Posting Permissions

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