Monday, August 20, 2012

HLS update

HLS module has been updated recently. Muxdelay parameter has been introduced to escape problems with audio. I've encountered a case when (audio) sample PTS was less than current PCR which caused choppy audio. After the fix it's now OK. Sample PTS are always ahead of PCR. The config setting is hls_muxdelay with default value of 700ms. The same setting with the same default exists in ffmpeg.


  1. Wanted to ask you this, don't know if commenting is right place to do.
    How does "hls on" and "live on" go together?
    Can you plz also elaborate on the latest ffmpeg commit which make "hls" submodule redundant

    Many Thanks

  2. 1) "hls on" and "live on" are absolutely unrelated and can go together or apart.

    2) I didn't analyze the patch itself, but it should be simple. We've done that with bash script few weeks ago (with the old ffmpeg segmenter) and it worked perfectly with iPhone. It's only about 2 lines in m3u8 file.

    Now you can use exec command to run ffmpeg ... -f segment ... to automatically generate HLS from RTMP with the new ffmpeg.

    However there's a couple of issues about the segmenter. It calls write_header/write_tail on each segment restart. That causes MPEG-TS stream discontinuities which can be discovered with ffplay. The good news is iPhone does not care about that.

    Another issue is ffmpeg does not delete the old segments. It's on you to delete them.

  3. Thanks. So no need to compile the hls module anymore. We can use the exec command with segment option.
    I was curious to know your thoughts on one more issue.
    As you know, HLS playlist could either be a "live event" or "VOD". If we gonna use ffmpeg to generate the m3u8 playlist, that means every new user connecting to the stream will alwasy start from the first segment as listed in the playlist file. I understand that the playlist ENDTAG will be generated after stream is finished.
    But how do we achieve a "sliding window" effect with HLS stream to make people jump into latest segement and continue from there itself.
    There are couple more interesting questions I have if you would like to discuss

    Thanks again

  4. Question, are all the Notify directives available for a HLS stream?

  5. Notification have nothing to do with HLS. HLS is just output module. Notifications work with live streams.

  6. I thought "hls on" would work whenever a "live" stream is published to generate respective live hls playlist and segments.
    similar to having an exec on publish. I personally like hls submodule method better than having to exec ffmpeg binary

    if not then what does "hls on" will do in other than "live" publish cases


  7. It's not about receiving live stream.
    'live on' toggles stream retransmission to subscribers.
    'hls on' toggles hls playlist & fragment generation.

    'hls on' without 'live on' means 'receive stream from publisher and create hls playlist/fragment but not send stream to subscribers'

  8. Is it possible to publish rtmp or hls live stream from user webcam to server and broadcast live hls?