Tuesday, May 14, 2013

Optional HLS cleanup

Today I've added a new directive hls_cleanup toggling HLS fragment and playlist cleanup from nginx cache manager process. By default cleanup is on. Now you can turn it off and have plain MPEG-TS chunked recorder.


application myapp {
live on;
hls on;
hls_path /tmp/hsls;
hls_cleanup off;
}

17 comments:

  1. Hi, great work!

    Is there any reasonable way to get playlist which plays all "recorded" .ts files? Now I have about million .ts files, and one index.m3u8, which plays few last .ts..

    ReplyDelete
  2. The simplest way is set HLS playlist to a big value like 10 years: hls_playlist_length 10y;
    On stream restart old playlist is parsed unless hls_continuous is off. That may take long time
    when you have millions of entries.

    ReplyDelete
  3. Thank you for good application.
    Can put timestamp on segment file? or Can find date time of old segment?

    Thank

    ReplyDelete
  4. if I got you right "hls_fragment_naming timestamp;" does what you want

    ReplyDelete
  5. Thank you, look it work but How to read it?
    I found fragment file is


    live-37043550.ts
    #EXTINF:16.367,
    live-38417490.ts
    #EXTINF:15.967,
    live-39890520.ts

    I'm sorry for ask, but I try to convert digit to unix date/time but it not correct.
    Now this time date on server is "Wed Jun 12 00:42:47 ICT 2013"

    Thank

    ReplyDelete
  6. These are incoming timestamps. If you want your system timestamps then use "hls_fragment_naming system".

    ReplyDelete
  7. Thank you very much.

    ReplyDelete
  8. I'm try convert digit in fragment file to date time.
    But not success, Can you tell me what method convert fragments time?

    This is my fragments list.

    live-911572788.ts live-920955885.ts live-930456268.ts live-939865827.ts
    live-911588713.ts live-920971650.ts live-930474137.ts live-939884294.ts

    Thank you very much.

    ReplyDelete
  9. It should be unixtime in milliseconds. However there might be 32-bit overflow if you have 32-bit system. What is your system?

    ReplyDelete
  10. My system is Ubuntu 32bit.

    ReplyDelete
  11. Ok now I try on 64 bit it work. Thank you very much.

    ReplyDelete
  12. Fixed that in master. Please try again on 32- bit system. Thanks for the report.

    ReplyDelete
  13. Thank you. I will test on 32-bit again.

    But fragments file will be delete (clean) after restart?
    I found after restart machine, all fragments will be deleted.

    my config.

    application live {
    live on;
    hls on;
    hls_path /tmp/live;
    hls_fragment 15s;
    hls_fragment_naming system;
    hls_cleanup off;
    hls_playlist_length 3d;
    allow play all;
    }

    ReplyDelete
  14. Fragments are deleted when expired.

    ReplyDelete
  15. I think in my confic will keep frangments 3 days.
    But after i restart server all frangments will be lost. No any frangments in /tmp.

    ReplyDelete
  16. This is happening because the /tmp file system is cleaned at reboot ...

    ReplyDelete