Wednesday, August 28, 2013

HLS full urls in nginx-rtmp-module

In the latest master of nginx-rtmp-module I have added a new directive hls_base_url which makes it possible to have full urls in HLS playlists. With this feature enabled you can download playlist and play it locally since it references remote files. The feature is supported in master(variant) and slave playlists.


location /hls {
    root /tmp;
}
...
application mystream {
    live on;
    hls on;
    hls_path /tmp/hls;
    hls_base_url http://localhost:8080/hls/;
}

Here's the contents of HLS playlist for mystream stream

$ cat /tmp/hls/mystream.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-TARGETDURATION:15
#EXT-X-DISCONTINUITY
#EXTINF:9.333,
http://localhost:8080/hls/mystream-0.ts
#EXTINF:7.167,
http://localhost:8080/hls/mystream-1.ts
#EXTINF:5.417,
http://localhost:8080/hls/mystream-2.ts
#EXTINF:5.500,
http://localhost:8080/hls/mystream-3.ts
#EXTINF:15.166,
http://localhost:8080/hls/mystream-4.ts
#EXTINF:9.584,
http://localhost:8080/hls/mystream-5.ts
#EXTINF:9.333,
http://localhost:8080/hls/mystream-6.ts

8 comments:

  1. Hi,
    Is there a way to check whether a stream is active (being pulished live) ?

    Thing is, I want make a ip camera mjpeg stream pull and publish as rtmp (using ffmepg) only when first viewer for stream comes in

    Thanks

    ReplyDelete
  2. is record_lock right way or the stats xml?

    ReplyDelete
  3. There's no way to start exec when first client comes in and kill it when the last one leaves. You can only pull RTMP stream with "pull" directive.

    ReplyDelete
  4. I am doing the pull using ffmpeg and not from rtmp module. I pushing this mjpeg as rtmp
    ffmpeg -i http://ip/cgi/x.mjpeg -flv rtmp://localhost/app/stream

    found a solution via a perl wrapper and using my own lock file for each unique stream.

    Thanks

    ReplyDelete
  5. Roman,
    Would it be possible to generate an "EVENT" type hls playlist? where EXT-X-MEDIA-SEQUENCE remains 0,
    and new segments are appended to playlist in hls_continuous mode?

    #EXT-X-PLAYLIST-TYPE:EVENT header is needed as well

    Thanks

    ReplyDelete
  6. Hey everyone! I just had an amazing experience with the Phonak Connector for TV, and I wanted to share it with you all. I visited a local hearing aid service center recently and was recommended this device. Setting it up was a breeze, and it connected effortlessly to my hearing aids. The sound quality is fantastic, and I can now enjoy my favorite shows and movies without cranking up the volume. It's such a relief to hear everything clearly without disturbing my family. If you're using hearing aids and love watching TV, this is a must-have device. For more details, visit phonak connector for tv.

    ReplyDelete