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;
}

Advertisements
  1. #1 by Trong Le on May 15, 2013 - 3:17 am

    Work great!
    Thanks.

  2. #2 by afastecs on May 16, 2013 - 2:14 am

    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..

    • #3 by rarut on May 16, 2013 - 3:40 am

      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.

  3. #4 by soon01 on June 11, 2013 - 12:02 pm

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

    Thank

    • #5 by rarut on June 11, 2013 - 1:24 pm

      if I got you right “hls_fragment_naming timestamp;” does what you want

  4. #6 by soon01 on June 11, 2013 - 5:57 pm

    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

    • #7 by rarut on June 11, 2013 - 9:34 pm

      These are incoming timestamps. If you want your system timestamps then use “hls_fragment_naming system”.

  5. #8 by soon on June 12, 2013 - 12:26 am

    Thank you very much.

  6. #9 by soon01 on June 12, 2013 - 11:31 am

    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.

    • #10 by rarut on June 12, 2013 - 12:51 pm

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

  7. #11 by soon on June 12, 2013 - 1:08 pm

    My system is Ubuntu 32bit.

  8. #12 by soon on June 12, 2013 - 1:28 pm

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

    • #13 by rarut on June 12, 2013 - 4:47 pm

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

      • #14 by soon01 on June 13, 2013 - 3:37 am

        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;
        }

      • #15 by rarut on June 13, 2013 - 3:49 am

        Fragments are deleted when expired.

  9. #16 by Soon01 on June 13, 2013 - 5:33 am

    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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: