srs 推流结束时hls正好切片会导致on_hls被中断

w6lpcovy  于 2022-12-31  发布在  其他
关注(0)|答案(1)|浏览(344)

描述(Description)

依赖srs的hls回调做录制业务, rtmp推流停止时, 如果此时正好有一个ts文件切片出来, 在unpublish时有概率打断on_hls回调.
在异常情况下hls模块会drop一个时长过短的ts(例如Drop ts segment, sequence_no=2, uri=0304b9d3-a105-4347-b1cb-742f9bf38c5a_main-2.ts, duration=0ms)并打断前面一个ts的回调

  1. SRS版本(Version): SRS/4.0.206(Leo)
  2. SRS的日志如下(Log):

异常时的日志

[2021-12-28 07:30:42.867][Trace][1][99227700] Hybrid cpu=0.00%,11MB, cid=1,0, timer=62,0,0, clock=0,46,2,0,0,0,0,0,0
[2021-12-28 07:30:43.076][Trace][1][y1218fe9] RTMP client ip=192.168.99.152:58078, fd=14
[2021-12-28 07:30:43.079][Trace][1][y1218fe9] complex handshake success
[2021-12-28 07:30:43.119][Trace][1][y1218fe9] connect app, tcUrl=rtmp://192.168.99.152:1935/record, pageUrl=, swfUrl=, schema=rtmp, vhost=192.168.99.152, port=1935, app=record, args=null
[2021-12-28 07:30:43.119][Trace][1][y1218fe9] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2021-12-28 07:30:43.199][Trace][1][y1218fe9] client identified, type=fmle-publish, vhost=record, app=record, stream=dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra, param=?vhost=record, duration=0ms
[2021-12-28 07:30:43.199][Trace][1][y1218fe9] connected stream, tcUrl=rtmp://192.168.99.152:1935/record, pageUrl=, swfUrl=, schema=rtmp, vhost=record, port=1935, app=record, stream=dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra, param=?vhost=record, args=null
[2021-12-28 07:30:43.199][Trace][1][y1218fe9] new source, stream_url=record/record/dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra
[2021-12-28 07:30:43.200][Trace][1][y1218fe9] source url=record/record/dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra, ip=192.168.99.152, cache=1, is_edge=0, source_id=/
[2021-12-28 07:30:43.315][Trace][1][y1218fe9] http: on_publish ok, client_id=y1218fe9, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/publish, request={"server_id":"vid-1t84a55","action":"on_publish","client_id":"y1218fe9","ip":"192.168.99.152","vhost":"record","app":"record","tcUrl":"rtmp://192.168.99.152:1935/record","stream":"dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra","param":"?vhost=record"}, response={"code":0,"data":""}
[2021-12-28 07:30:43.315][Trace][1][y1218fe9] hls: win=60000ms, frag=10000ms, prefix=, path=./objs/nginx/html, m3u8=[app]/[stream].m3u8, ts=[app]/[stream]-[seq].ts, aof=2.00, floor=0, clean=1, waitk=1, dispose=30000ms, dts_directly=1
[2021-12-28 07:30:43.315][Trace][1][y1218fe9] ignore disabled exec for vhost=record
[2021-12-28 07:30:43.315][Trace][1][y1218fe9] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=0
[2021-12-28 07:30:43.359][Trace][1][y1218fe9] got metadata, width=1280, height=720, vcodec=7, acodec=10
[2021-12-28 07:30:43.359][Trace][1][y1218fe9] 4B audio sh, codec(10, profile=LC, 1channels, 0kbps, 48000HZ), flv(16bits, 2channels, 44100HZ)
[2021-12-28 07:30:43.359][Trace][1][y1218fe9] 42B video sh,  codec(7, profile=Baseline, level=3.1, 1280x720, 0kbps, 0.0fps, 0.0s)
[2021-12-28 07:30:44.526][Trace][1][r5068027] RTMP client ip=192.168.99.152:58082, fd=16
[2021-12-28 07:30:44.528][Trace][1][r5068027] complex handshake success
[2021-12-28 07:30:44.567][Trace][1][r5068027] connect app, tcUrl=rtmp://192.168.99.152:1935/record, pageUrl=, swfUrl=, schema=rtmp, vhost=192.168.99.152, port=1935, app=record, args=null
[2021-12-28 07:30:44.567][Trace][1][r5068027] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2021-12-28 07:30:44.647][Trace][1][r5068027] client identified, type=fmle-publish, vhost=record, app=record, stream=0304b9d3-a105-4347-b1cb-742f9bf38c5a_main, param=?vhost=record, duration=0ms
[2021-12-28 07:30:44.647][Trace][1][r5068027] connected stream, tcUrl=rtmp://192.168.99.152:1935/record, pageUrl=, swfUrl=, schema=rtmp, vhost=record, port=1935, app=record, stream=0304b9d3-a105-4347-b1cb-742f9bf38c5a_main, param=?vhost=record, args=null
[2021-12-28 07:30:44.647][Trace][1][r5068027] new source, stream_url=record/record/0304b9d3-a105-4347-b1cb-742f9bf38c5a_main
[2021-12-28 07:30:44.648][Trace][1][r5068027] source url=record/record/0304b9d3-a105-4347-b1cb-742f9bf38c5a_main, ip=192.168.99.152, cache=1, is_edge=0, source_id=/
[2021-12-28 07:30:44.765][Trace][1][r5068027] http: on_publish ok, client_id=r5068027, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/publish, request={"server_id":"vid-1t84a55","action":"on_publish","client_id":"r5068027","ip":"192.168.99.152","vhost":"record","app":"record","tcUrl":"rtmp://192.168.99.152:1935/record","stream":"0304b9d3-a105-4347-b1cb-742f9bf38c5a_main","param":"?vhost=record"}, response={"code":0,"data":""}
[2021-12-28 07:30:44.766][Trace][1][r5068027] hls: win=60000ms, frag=10000ms, prefix=, path=./objs/nginx/html, m3u8=[app]/[stream].m3u8, ts=[app]/[stream]-[seq].ts, aof=2.00, floor=0, clean=1, waitk=1, dispose=30000ms, dts_directly=1
[2021-12-28 07:30:44.766][Trace][1][r5068027] ignore disabled exec for vhost=record
[2021-12-28 07:30:44.766][Trace][1][r5068027] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=0
[2021-12-28 07:30:44.771][Trace][1][r5068027] got metadata, width=1920, height=1084, vcodec=7, acodec=10
[2021-12-28 07:30:44.771][Trace][1][r5068027] 4B audio sh, codec(10, profile=LC, 1channels, 0kbps, 48000HZ), flv(16bits, 2channels, 44100HZ)
[2021-12-28 07:30:44.771][Trace][1][r5068027] 46B video sh,  codec(7, profile=Baseline, level=4, 1920x1080, 0kbps, 0.0fps, 0.0s)
[2021-12-28 07:30:47.868][Trace][1][99227700] Hybrid cpu=4.00%,11MB, cid=3,1, timer=62,0,0, clock=0,43,4,0,1,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:126,oth:0,buf:0)
[2021-12-28 07:30:52.868][Trace][1][99227700] Hybrid cpu=4.00%,11MB, cid=3,1, timer=62,0,0, clock=0,43,4,0,1,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:126,oth:0,buf:0)
[2021-12-28 07:30:57.868][Trace][1][99227700] Hybrid cpu=4.00%,11MB, cid=1,0, timer=61,0,0, clock=0,39,9,1,0,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:462,oth:0,buf:0)
[2021-12-28 07:30:59.210][Trace][1][r5068027] -> HLS time=14549542ms, sno=1, ts=0304b9d3-a105-4347-b1cb-742f9bf38c5a_main-0.ts, dur=0.00, dva=14667p
[2021-12-28 07:30:59.336][Trace][1][y1218fe9] http: on_hls ok, client_id=y1218fe9, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/ts_gen, request={"server_id":"vid-1t84a55","action":"on_hls","client_id":"y1218fe9","ip":"192.168.99.152","vhost":"record","app":"record","stream":"dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra","param":"?vhost=record","duration":16.19,"cwd":"/usr/local/srs","file":"./objs/nginx/html/record/dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra-0.ts","url":"record/dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra-0.ts","m3u8":"./objs/nginx/html/record/dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra.m3u8","m3u8_url":"record/dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra.m3u8","seq_no":0}, response={"code":0,"data":""}
[2021-12-28 07:30:59.553][Trace][1][r5068027] http: on_hls ok, client_id=r5068027, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/ts_gen, request={"server_id":"vid-1t84a55","action":"on_hls","client_id":"r5068027","ip":"192.168.99.152","vhost":"record","app":"record","stream":"0304b9d3-a105-4347-b1cb-742f9bf38c5a_main","param":"?vhost=record","duration":15.00,"cwd":"/usr/local/srs","file":"./objs/nginx/html/record/0304b9d3-a105-4347-b1cb-742f9bf38c5a_main-0.ts","url":"record/0304b9d3-a105-4347-b1cb-742f9bf38c5a_main-0.ts","m3u8":"./objs/nginx/html/record/0304b9d3-a105-4347-b1cb-742f9bf38c5a_main.m3u8","m3u8_url":"record/0304b9d3-a105-4347-b1cb-742f9bf38c5a_main.m3u8","seq_no":0}, response={"code":0,"data":""}
[2021-12-28 07:31:02.869][Trace][1][99227700] Hybrid cpu=5.00%,11MB, cid=1,0, timer=61,0,0, clock=0,39,9,1,0,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:462,oth:0,buf:0)
[2021-12-28 07:31:04.765][Trace][1][r5068027] <- CPB time=0, okbps=1,0,0, ikbps=2143,0,0, mr=0/350, p1stpt=20000, pnt=5000
[2021-12-28 07:31:07.869][Trace][1][99227700] Hybrid cpu=3.00%,11MB, cid=1,0, timer=61,0,0, clock=0,39,9,1,0,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:462,oth:0,buf:0)
[2021-12-28 07:31:08.317][Trace][1][y1218fe9] <- CPB time=19998959, okbps=1,0,0, ikbps=899,0,0, mr=0/350, p1stpt=20000, pnt=5000
[2021-12-28 07:31:09.719][Trace][1][r5068027] Drop ts segment, sequence_no=2, uri=0304b9d3-a105-4347-b1cb-742f9bf38c5a_main-2.ts, duration=0ms
[2021-12-28 07:31:09.719][Warn][1][r5068027][4] ignore task failed code=1018 : callback on_hls http://192.168.99.152:8024/ms/v1/srs/callback/record/ts_gen : http: post http://192.168.99.152:8024/ms/v1/srs/callback/record/ts_gen with {"server_id":"vid-1t84a55","action":"on_hls","client_id":"r5068027","ip":"192.168.99.152","vhost":"record","app":"record","stream":"0304b9d3-a105-4347-b1cb-742f9bf38c5a_main","param":"?vhost=record","duration":10.30,"cwd":"/usr/local/srs","file":"./objs/nginx/html/record/0304b9d3-a105-4347-b1cb-742f9bf38c5a_main-1.ts","url":"record/0304b9d3-a105-4347-b1cb-742f9bf38c5a_main-1.ts","m3u8":"./objs/nginx/html/record/0304b9d3-a105-4347-b1cb-742f9bf38c5a_main.m3u8","m3u8_url":"record/0304b9d3-a105-4347-b1cb-742f9bf38c5a_main.m3u8","seq_no":1}, status=200, res= : http: client post : http: connect server : http: tcp connect http 192.168.99.152:8024 to=30000ms, rto=30000ms : tcp: connect 192.168.99.152:8024 to=30000ms : connect to 192.168.99.152:8024
thread [1][r5068027]: call() [src/app/srs_app_hls.cpp:122][errno=4]
thread [1][r5068027]: on_hls() [src/app/srs_app_http_hooks.cpp:351][errno=4]
thread [1][r5068027]: do_post() [src/app/srs_app_http_hooks.cpp:505][errno=4]
thread [1][r5068027]: post() [src/protocol/srs_service_http_client.cpp:322][errno=4]
thread [1][r5068027]: connect() [src/protocol/srs_service_http_client.cpp:447][errno=4]
thread [1][r5068027]: connect() [src/protocol/srs_service_st.cpp:642][errno=4]
thread [1][r5068027]: srs_tcp_connect() [src/protocol/srs_service_st.cpp:193][errno=4]
[2021-12-28 07:31:09.720][Trace][1][r5068027] cleanup when unpublish
[2021-12-28 07:31:09.723][Trace][1][y1218fe9] Drop ts segment, sequence_no=2, uri=dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra-2.ts, duration=0ms
[2021-12-28 07:31:09.724][Warn][1][y1218fe9][4] ignore task failed code=1018 : callback on_hls http://192.168.99.152:8024/ms/v1/srs/callback/record/ts_gen : http: post http://192.168.99.152:8024/ms/v1/srs/callback/record/ts_gen with {"server_id":"vid-1t84a55","action":"on_hls","client_id":"y1218fe9","ip":"192.168.99.152","vhost":"record","app":"record","stream":"dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra","param":"?vhost=record","duration":10.43,"cwd":"/usr/local/srs","file":"./objs/nginx/html/record/dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra-1.ts","url":"record/dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra-1.ts","m3u8":"./objs/nginx/html/record/dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra.m3u8","m3u8_url":"record/dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra.m3u8","seq_no":1}, status=200, res= : http: client post : http: connect server : http: tcp connect http 192.168.99.152:8024 to=30000ms, rto=30000ms : tcp: connect 192.168.99.152:8024 to=30000ms : connect to 192.168.99.152:8024
thread [1][y1218fe9]: call() [src/app/srs_app_hls.cpp:122][errno=4]
thread [1][y1218fe9]: on_hls() [src/app/srs_app_http_hooks.cpp:351][errno=4]
thread [1][y1218fe9]: do_post() [src/app/srs_app_http_hooks.cpp:505][errno=4]
thread [1][y1218fe9]: post() [src/protocol/srs_service_http_client.cpp:322][errno=4]
thread [1][y1218fe9]: connect() [src/protocol/srs_service_http_client.cpp:447][errno=4]
thread [1][y1218fe9]: connect() [src/protocol/srs_service_st.cpp:642][errno=4]
thread [1][y1218fe9]: srs_tcp_connect() [src/protocol/srs_service_st.cpp:193][errno=4]
[2021-12-28 07:31:09.724][Trace][1][y1218fe9] cleanup when unpublish
[2021-12-28 07:31:09.754][Trace][1][y1218fe9] http: on_unpublish ok, client_id=y1218fe9, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/unpublish, request={"server_id":"vid-1t84a55","action":"on_unpublish","client_id":"y1218fe9","ip":"192.168.99.152","vhost":"record","app":"record","stream":"dd058d2a-541b-4751-9a6f-7d6e36d4de55_extra","param":"?vhost=record"}, response={"code":0,"data":""}
[2021-12-28 07:31:09.754][Trace][1][y1218fe9] TCP: before dispose resource(RtmpConn)(0x12fb460), conns=2, zombies=0, ign=0, inz=0, ind=0
[2021-12-28 07:31:09.754][Warn][1][y1218fe9][11] client disconnect peer. ret=1009
[2021-12-28 07:31:09.754][Trace][1][6852w00c] TCP: clear zombies=1 resources, conns=2, removing=0, unsubs=0
[2021-12-28 07:31:09.754][Trace][1][y1218fe9] TCP: disposing #0 resource(RtmpConn)(0x12fb460), conns=2, disposing=1, zombies=0
[2021-12-28 07:31:09.775][Trace][1][r5068027] http: on_unpublish ok, client_id=r5068027, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/unpublish, request={"server_id":"vid-1t84a55","action":"on_unpublish","client_id":"r5068027","ip":"192.168.99.152","vhost":"record","app":"record","stream":"0304b9d3-a105-4347-b1cb-742f9bf38c5a_main","param":"?vhost=record"}, response={"code":0,"data":""}
[2021-12-28 07:31:09.775][Trace][1][r5068027] TCP: before dispose resource(RtmpConn)(0x13d0fa0), conns=1, zombies=0, ign=0, inz=0, ind=0
[2021-12-28 07:31:09.775][Warn][1][r5068027][11] client disconnect peer. ret=1009
[2021-12-28 07:31:09.775][Trace][1][6852w00c] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
[2021-12-28 07:31:09.775][Trace][1][r5068027] TCP: disposing #0 resource(RtmpConn)(0x13d0fa0), conns=1, disposing=1, zombies=0

正常结束的日志

[2021-12-28 07:42:32.966][Trace][1][99227700] Hybrid cpu=1.00%,11MB, cid=1,0, timer=62,0,0, clock=0,46,2,0,0,0,0,0,0
[2021-12-28 07:42:34.724][Trace][1][8gdru3ic] RTMP client ip=192.168.99.152:58180, fd=14
[2021-12-28 07:42:34.726][Trace][1][8gdru3ic] complex handshake success
[2021-12-28 07:42:34.766][Trace][1][8gdru3ic] connect app, tcUrl=rtmp://192.168.99.152:1935/record, pageUrl=, swfUrl=, schema=rtmp, vhost=192.168.99.152, port=1935, app=record, args=null
[2021-12-28 07:42:34.767][Trace][1][8gdru3ic] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2021-12-28 07:42:34.846][Trace][1][8gdru3ic] client identified, type=fmle-publish, vhost=record, app=record, stream=9a056982-651d-4867-86f1-57a8a1d7ecb4_extra, param=?vhost=record, duration=0ms
[2021-12-28 07:42:34.846][Trace][1][8gdru3ic] connected stream, tcUrl=rtmp://192.168.99.152:1935/record, pageUrl=, swfUrl=, schema=rtmp, vhost=record, port=1935, app=record, stream=9a056982-651d-4867-86f1-57a8a1d7ecb4_extra, param=?vhost=record, args=null
[2021-12-28 07:42:34.847][Trace][1][8gdru3ic] new source, stream_url=record/record/9a056982-651d-4867-86f1-57a8a1d7ecb4_extra
[2021-12-28 07:42:34.847][Trace][1][8gdru3ic] source url=record/record/9a056982-651d-4867-86f1-57a8a1d7ecb4_extra, ip=192.168.99.152, cache=1, is_edge=0, source_id=/
[2021-12-28 07:42:34.941][Trace][1][8gdru3ic] http: on_publish ok, client_id=8gdru3ic, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/publish, request={"server_id":"vid-1t84a55","action":"on_publish","client_id":"8gdru3ic","ip":"192.168.99.152","vhost":"record","app":"record","tcUrl":"rtmp://192.168.99.152:1935/record","stream":"9a056982-651d-4867-86f1-57a8a1d7ecb4_extra","param":"?vhost=record"}, response={"code":0,"data":""}
[2021-12-28 07:42:34.942][Trace][1][8gdru3ic] hls: win=60000ms, frag=10000ms, prefix=, path=./objs/nginx/html, m3u8=[app]/[stream].m3u8, ts=[app]/[stream]-[seq].ts, aof=2.00, floor=0, clean=1, waitk=1, dispose=30000ms, dts_directly=1
[2021-12-28 07:42:34.942][Trace][1][8gdru3ic] ignore disabled exec for vhost=record
[2021-12-28 07:42:34.942][Trace][1][8gdru3ic] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=0
[2021-12-28 07:42:35.007][Trace][1][8gdru3ic] got metadata, width=1280, height=720, vcodec=7, acodec=10
[2021-12-28 07:42:35.007][Trace][1][8gdru3ic] 4B audio sh, codec(10, profile=LC, 1channels, 0kbps, 48000HZ), flv(16bits, 2channels, 44100HZ)
[2021-12-28 07:42:35.007][Trace][1][8gdru3ic] 42B video sh,  codec(7, profile=Baseline, level=3.1, 1280x720, 0kbps, 0.0fps, 0.0s)
[2021-12-28 07:42:37.967][Trace][1][99227700] Hybrid cpu=2.00%,11MB, cid=1,0, timer=62,0,0, clock=0,46,2,0,0,0,0,0,0
[2021-12-28 07:42:39.094][Trace][1][8o044832] RTMP client ip=192.168.99.152:58186, fd=16
[2021-12-28 07:42:39.094][Trace][1][8o044832] complex handshake success
[2021-12-28 07:42:39.134][Trace][1][8o044832] connect app, tcUrl=rtmp://192.168.99.152:1935/record, pageUrl=, swfUrl=, schema=rtmp, vhost=192.168.99.152, port=1935, app=record, args=null
[2021-12-28 07:42:39.134][Trace][1][8o044832] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2021-12-28 07:42:39.214][Trace][1][8o044832] client identified, type=fmle-publish, vhost=record, app=record, stream=fe6debbb-89c2-454c-903c-0c5043c17fa4_main, param=?vhost=record, duration=0ms
[2021-12-28 07:42:39.214][Trace][1][8o044832] connected stream, tcUrl=rtmp://192.168.99.152:1935/record, pageUrl=, swfUrl=, schema=rtmp, vhost=record, port=1935, app=record, stream=fe6debbb-89c2-454c-903c-0c5043c17fa4_main, param=?vhost=record, args=null
[2021-12-28 07:42:39.214][Trace][1][8o044832] new source, stream_url=record/record/fe6debbb-89c2-454c-903c-0c5043c17fa4_main
[2021-12-28 07:42:39.214][Trace][1][8o044832] source url=record/record/fe6debbb-89c2-454c-903c-0c5043c17fa4_main, ip=192.168.99.152, cache=1, is_edge=0, source_id=/
[2021-12-28 07:42:39.362][Trace][1][8o044832] http: on_publish ok, client_id=8o044832, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/publish, request={"server_id":"vid-1t84a55","action":"on_publish","client_id":"8o044832","ip":"192.168.99.152","vhost":"record","app":"record","tcUrl":"rtmp://192.168.99.152:1935/record","stream":"fe6debbb-89c2-454c-903c-0c5043c17fa4_main","param":"?vhost=record"}, response={"code":0,"data":""}
[2021-12-28 07:42:39.362][Trace][1][8o044832] hls: win=60000ms, frag=10000ms, prefix=, path=./objs/nginx/html, m3u8=[app]/[stream].m3u8, ts=[app]/[stream]-[seq].ts, aof=2.00, floor=0, clean=1, waitk=1, dispose=30000ms, dts_directly=1
[2021-12-28 07:42:39.362][Trace][1][8o044832] ignore disabled exec for vhost=record
[2021-12-28 07:42:39.362][Trace][1][8o044832] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=0
[2021-12-28 07:42:39.362][Trace][1][8o044832] got metadata, width=1920, height=1084, vcodec=7, acodec=10
[2021-12-28 07:42:39.362][Trace][1][8o044832] 4B audio sh, codec(10, profile=LC, 1channels, 0kbps, 48000HZ), flv(16bits, 2channels, 44100HZ)
[2021-12-28 07:42:39.362][Trace][1][8o044832] 46B video sh,  codec(7, profile=Baseline, level=4, 1920x1080, 0kbps, 0.0fps, 0.0s)
[2021-12-28 07:42:42.968][Trace][1][99227700] Hybrid cpu=5.00%,11MB, cid=5,1, timer=61,0,0, clock=0,40,7,0,0,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:282,oth:0,buf:0)
[2021-12-28 07:42:47.968][Trace][1][99227700] Hybrid cpu=4.00%,11MB, cid=5,1, timer=61,0,0, clock=0,40,7,0,0,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:282,oth:0,buf:0)
[2021-12-28 07:42:51.484][Trace][1][8gdru3ic] http: on_hls ok, client_id=8gdru3ic, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/ts_gen, request={"server_id":"vid-1t84a55","action":"on_hls","client_id":"8gdru3ic","ip":"192.168.99.152","vhost":"record","app":"record","stream":"9a056982-651d-4867-86f1-57a8a1d7ecb4_extra","param":"?vhost=record","duration":16.68,"cwd":"/usr/local/srs","file":"./objs/nginx/html/record/9a056982-651d-4867-86f1-57a8a1d7ecb4_extra-0.ts","url":"record/9a056982-651d-4867-86f1-57a8a1d7ecb4_extra-0.ts","m3u8":"./objs/nginx/html/record/9a056982-651d-4867-86f1-57a8a1d7ecb4_extra.m3u8","m3u8_url":"record/9a056982-651d-4867-86f1-57a8a1d7ecb4_extra.m3u8","seq_no":0}, response={"code":0,"data":""}
[2021-12-28 07:42:52.969][Trace][1][99227700] Hybrid cpu=4.00%,11MB, cid=1,0, timer=61,0,0, clock=0,38,9,0,1,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:460,oth:0,buf:0)
[2021-12-28 07:42:54.146][Trace][1][8o044832] http: on_hls ok, client_id=8o044832, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/ts_gen, request={"server_id":"vid-1t84a55","action":"on_hls","client_id":"8o044832","ip":"192.168.99.152","vhost":"record","app":"record","stream":"fe6debbb-89c2-454c-903c-0c5043c17fa4_main","param":"?vhost=record","duration":15.00,"cwd":"/usr/local/srs","file":"./objs/nginx/html/record/fe6debbb-89c2-454c-903c-0c5043c17fa4_main-0.ts","url":"record/fe6debbb-89c2-454c-903c-0c5043c17fa4_main-0.ts","m3u8":"./objs/nginx/html/record/fe6debbb-89c2-454c-903c-0c5043c17fa4_main.m3u8","m3u8_url":"record/fe6debbb-89c2-454c-903c-0c5043c17fa4_main.m3u8","seq_no":0}, response={"code":0,"data":""}
[2021-12-28 07:42:57.969][Trace][1][99227700] Hybrid cpu=3.00%,11MB, cid=1,0, timer=61,0,0, clock=0,38,9,0,1,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:460,oth:0,buf:0)
[2021-12-28 07:42:58.413][Trace][1][8o044832] http: on_hls ok, client_id=8o044832, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/ts_gen, request={"server_id":"vid-1t84a55","action":"on_hls","client_id":"8o044832","ip":"192.168.99.152","vhost":"record","app":"record","stream":"fe6debbb-89c2-454c-903c-0c5043c17fa4_main","param":"?vhost=record","duration":4.33,"cwd":"/usr/local/srs","file":"./objs/nginx/html/record/fe6debbb-89c2-454c-903c-0c5043c17fa4_main-1.ts","url":"record/fe6debbb-89c2-454c-903c-0c5043c17fa4_main-1.ts","m3u8":"./objs/nginx/html/record/fe6debbb-89c2-454c-903c-0c5043c17fa4_main.m3u8","m3u8_url":"record/fe6debbb-89c2-454c-903c-0c5043c17fa4_main.m3u8","seq_no":1}, response={"code":0,"data":""}
[2021-12-28 07:42:58.413][Trace][1][8o044832] cleanup when unpublish
[2021-12-28 07:42:58.444][Trace][1][8gdru3ic] http: on_hls ok, client_id=8gdru3ic, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/ts_gen, request={"server_id":"vid-1t84a55","action":"on_hls","client_id":"8gdru3ic","ip":"192.168.99.152","vhost":"record","app":"record","stream":"9a056982-651d-4867-86f1-57a8a1d7ecb4_extra","param":"?vhost=record","duration":6.96,"cwd":"/usr/local/srs","file":"./objs/nginx/html/record/9a056982-651d-4867-86f1-57a8a1d7ecb4_extra-1.ts","url":"record/9a056982-651d-4867-86f1-57a8a1d7ecb4_extra-1.ts","m3u8":"./objs/nginx/html/record/9a056982-651d-4867-86f1-57a8a1d7ecb4_extra.m3u8","m3u8_url":"record/9a056982-651d-4867-86f1-57a8a1d7ecb4_extra.m3u8","seq_no":1}, response={"code":0,"data":""}
[2021-12-28 07:42:58.444][Trace][1][8o044832] http: on_unpublish ok, client_id=8o044832, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/unpublish, request={"server_id":"vid-1t84a55","action":"on_unpublish","client_id":"8o044832","ip":"192.168.99.152","vhost":"record","app":"record","stream":"fe6debbb-89c2-454c-903c-0c5043c17fa4_main","param":"?vhost=record"}, response={"code":0,"data":""}
[2021-12-28 07:42:58.444][Trace][1][8o044832] TCP: before dispose resource(RtmpConn)(0x1403b50), conns=2, zombies=0, ign=0, inz=0, ind=0
[2021-12-28 07:42:58.444][Warn][1][8o044832][11] client disconnect peer. ret=1009
[2021-12-28 07:42:58.444][Trace][1][6852w00c] TCP: clear zombies=1 resources, conns=2, removing=0, unsubs=0
[2021-12-28 07:42:58.444][Trace][1][8o044832] TCP: disposing #0 resource(RtmpConn)(0x1403b50), conns=2, disposing=1, zombies=0
[2021-12-28 07:42:58.444][Trace][1][8gdru3ic] cleanup when unpublish
[2021-12-28 07:42:58.461][Trace][1][8gdru3ic] http: on_unpublish ok, client_id=8gdru3ic, url=http://192.168.99.152:8024/ms/v1/srs/callback/record/unpublish, request={"server_id":"vid-1t84a55","action":"on_unpublish","client_id":"8gdru3ic","ip":"192.168.99.152","vhost":"record","app":"record","stream":"9a056982-651d-4867-86f1-57a8a1d7ecb4_extra","param":"?vhost=record"}, response={"code":0,"data":""}
[2021-12-28 07:42:58.461][Trace][1][8gdru3ic] TCP: before dispose resource(RtmpConn)(0x12fb460), conns=1, zombies=0, ign=0, inz=0, ind=0
[2021-12-28 07:42:58.461][Warn][1][8gdru3ic][11] client disconnect peer. ret=1009
[2021-12-28 07:42:58.461][Trace][1][6852w00c] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
[2021-12-28 07:42:58.461][Trace][1][8gdru3ic] TCP: disposing #0 resource(RtmpConn)(0x12fb460), conns=1, disposing=1, zombies=0
  1. SRS的配置如下(Config):
listen              1935 [::]:1935;
max_connections     3000;
daemon              off;
pid                 objs/srs.pid;
srs_log_tank        file;
srs_log_file        ./logs/srs.log;

stats {
    network    0;
    disk    sda sdb xvda xvdb;
}

http_api{
    enabled    on;
    listen    1985;
    crossdomain    on;
}

http_server {
    enabled         on;
    listen          8025;
    dir             ./objs/nginx/html;
}

vhost record {
    hls {
        enabled         on;
        hls_fragment    10;
        hls_window      60;
        hls_wait_keyframe       on;
        hls_path        ./objs/nginx/html;
        hls_m3u8_file   [app]/[stream].m3u8;
        hls_ts_file     [app]/[stream]-[seq].ts;
        hls_cleanup     on;
        hls_dispose     30;
    }
    http_hooks {
        enabled         on;
        on_publish      http://192.168.99.152:8024/ms/v1/srs/callback/record/publish;
        on_unpublish    http://192.168.99.152:8024/ms/v1/srs/callback/record/unpublish;
        on_hls          http://192.168.99.152:8024/ms/v1/srs/callback/record/ts_gen;
    }
}

重现(Replay)

  1. 向srs推流
  2. 等待srs切片ts
  3. 在即将切片时结束推流, 有概率出现on_hls被打断

期望行为(Expect)

  1. 在推流结束时, 全部on_hls回调能够正确发送不被打断
pokxtpni

pokxtpni1#

这个属于边界条件,难点在于如何测试覆盖它,不然支持后,总有一天会改坏掉。

相关问题