sergey-dryabzhinsky / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
1.02k stars 214 forks source link

DASH: low dash_playlist_length makes cleanup delete init and manifest files #67

Open farfelu opened 8 years ago

farfelu commented 8 years ago

Trying to stream DASH I found out that the [streamname]-init file gets deleted when having a low dash_playlist_length set

it does not happen with the default of 30s.

my config on nginx 1.9.9

        application live2 {
            live on;
            dash on;
            dash_path /mnt/ramdisk/dash;
            dash_fragment 2s;
            dash_playlist_length 4s;
        }

the manifest and init file vanish on every other cleanup. I couldn't really tell when, it's not happening all the time. on the next chunk the manifest file gets recreated, but the init file stays deleted. no one can connect to the stream afterwards anymore because of it.

sergey-dryabzhinsky commented 8 years ago

Same thing happens for HLS m3u8 playlist.

sergey-dryabzhinsky commented 8 years ago

Yeap. It's wrong cache cleanup logic.

sergey-dryabzhinsky commented 8 years ago

Also if you have set open_file_cache on; - set it off for http location.

sergey-dryabzhinsky commented 8 years ago

Can you try code from 82-fix-playlists-cleanup branch? And try to set keyframe / GOP interval on publusher/encoder to fragment length.

farfelu commented 8 years ago

82-fix-playlists-cleanup seems to work, init/manifest files no longer get deleted.

sergey-dryabzhinsky commented 8 years ago

Merged #82 to master.

heftig commented 7 years ago

I'm still seeing this with the latest master. DASH init files disappear occasionally while the stream is still publishing.

sergey-dryabzhinsky commented 7 years ago

164 seems about same error - wrong full playlist length calculation if keyint/gop interval in stream is not constant.

sergey-dryabzhinsky commented 7 years ago

Try latest dev branch - merged some cleanup fixes for nginx-1.11.5+

heftig commented 7 years ago

Note that I'm still on 1.10. I assume the init segments can get accidentally deleted right after they're written, before the playlist is first created.

So as a workaround I now try to leave them around for another cleanup cycle rather than risk deleting them while still needed.

diff --git a/dash/ngx_rtmp_dash_module.c b/dash/ngx_rtmp_dash_module.c
index 13d6572d662c0a90..1038ae285272fc58 100644
--- a/dash/ngx_rtmp_dash_module.c
+++ b/dash/ngx_rtmp_dash_module.c
@@ -1565,7 +1565,7 @@ ngx_rtmp_dash_cleanup_dir(ngx_str_t *ppath, ngx_msec_t playlen)
                            "dash: cleanup '%V' allowed, mpd missing '%s'",
                            &name, mpd_path);

-            max_age = 0;
+            max_age = playlen / 500;

         } else if (name.len >= 4 && name.data[name.len - 4] == '.' &&
                                     name.data[name.len - 3] == 'm' &&
sergey-dryabzhinsky commented 2 years ago

That line already in latest code from dev branch. Need to re-test cleanup of init segments.