srs icon indicating copy to clipboard operation
srs copied to clipboard

HLS Files Not Deleted After hls_dispose Duration Ends

Open nomsho opened this issue 11 months ago • 2 comments

Hello, Thank you for this amazing project and all the hard work you’ve put into it. I truly appreciate the efforts of the community and developers behind SRS.

Describe the bug The behavior was confirmed where the ts/m3u8 files were not deleted after the stream ended because the hls_dispose duration had not been reached. Disk or RAM space may be overwhelmed, and HLS files to continue being played even after the stream has ended.

Version Ubuntu build version 6.0.158

To Reproduce Steps to reproduce the behavior:

  1. Streaming with RTMP and playback with HLS.
  2. Disconnect the stream from the encoder side.
  3. Check the directory containing the HLS files after the hls_dispose duration has passed.

Expected behavior

The possible cause is the flag check for enabling within the cycle in src/app/srs_app_hls.cpp. This seems to prevent dispose() from being called. And this issue could likely be resolved by either removing the flag check or delete the part where Enabled is set to false in unpublish().

The following is a portion of the log



#cat objs/srs.log | egrep 'hls_test|7m244z87'

---
[2025-01-06 10:08:48.755][INFO][1021015][7m244z87] -> HLS time=110436603ms, sno=14, ts=hls_test_13.ts, dur=467ms, dva=0p
[2025-01-06 10:08:55.548][INFO][1021015][7m244z87] cleanup when unpublish
[2025-01-06 10:08:55.548][INFO][1021015][7m244z87] TCP: before dispose resource(RtmpConn)(0x612000051640), conns=1, zombies=0, ign=0, inz=0, ind=0
[2025-01-06 10:08:55.548][WARN][1021015][7m244z87][32] client disconnect peer. ret=1009
[2025-01-06 10:08:55.548][INFO][1021015][7m244z87] TCP: disposing #0 resource(RtmpConn)(0x612000051640), conns=1, disposing=1, zombies=0
[2025-01-06 10:09:01.466][INFO][1021015][6j96fy31] Live: cleanup die source, id=[7m244z87], total=1
[2025-01-06 10:09:01.467][INFO][1021015][6j96fy31] free live source id=[7m244z87]
---

#echo "$(date):" && ls objs/nginx/html/live/hls_test/
Mon Jan  6 10:10:52 AM JST 2025:
hls_test_12.ts  hls_test_13.ts  hls_test.m3u8

srs.conf


# main config for srs.
# @see full.conf for detail config.

listen              1935;
max_connections     1000;
srs_log_file        ./objs/srs.log;
daemon              on;
http_api {
    enabled         on;
    listen          1985;
}
http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}

vhost __defaultVhost__ {
    hls {
        enabled         on;
        hls_fragment    4;
        hls_td_ratio   1.0;
        hls_window      11;
        hls_ctx         off;
        hls_ts_ctx      off;
        hls_m3u8_file   [app]/[stream]/[stream].m3u8;
        hls_ts_file     [app]/[stream]/[stream]_[seq].ts;
        hls_dispose 21;
        hls_acodec an;
    }
}

Please consider this issue. If there is any missing information, I would be happy to provide it, so please let me know.

TRANS_BY_GPT4

nomsho avatar Jan 06 '25 01:01 nomsho

#4161 can fix this issue, try it.

suzp1984 avatar Jan 06 '25 01:01 suzp1984

@suzp1984

Thank you. It seems that the enabled check was indeed the issue.


  if (!enabled) {
        return err;
    }

nomsho avatar Jan 06 '25 03:01 nomsho