Closed zh19900725 closed 1 year ago
curl -v http://127.0.0.1:1985/api/v1/streams/ There is a number of clients curl -v -X DELETE "http://127.0.0.1:1985/api/v1/clients/streamID
TRANS_BY_GPT3
curl -v http://127.0.0.1:1985/api/v1/streams/ There is a client count curl -v -X DELETE "http://127.0.0.1:1985/api/v1/clients/streamID
I am currently using this interface, and there are no issues with rtmp and flv, but there is a problem with hls. It seems that this interface does not include hls in the client count statistics.
TRANS_BY_GPT3
@kyhx1984 This plan is very good, thank you. 👍
@zh19900725 HLS is supported to be counted to clients in version 4.0, but if your HLS is not distributed through SRS, it will not be counted. There is a configuration called hls_ctx
that you should pay attention to.
# Whether enable hls_ctx for HLS streaming, for which we create a "fake" connection for HTTP API and callback.
# For each HLS streaming session, we use a child m3u8 with a session identified by query "hls_ctx", it simply
# work as the session id.
# Once the HLS streaming session is created, we will cleanup it when timeout in 2*hls_window seconds. So it
# takes a long time period to identify the timeout.
# Now we got a HLS stremaing session, just like RTMP/WebRTC/HTTP-FLV streaming, we're able to stat the session
# as a "fake" connection, do HTTP callback when start playing the HLS streaming. You're able to do querying and
# authentication.
# Note that it will make NGINX edge cache always missed, so never enable HLS streaming if use NGINX edges.
# Overwrite by env SRS_VHOST_HLS_HLS_CTX for all vhosts.
# Default: on
hls_ctx on;
TRANS_BY_GPT3
How to achieve on-demand streaming with HLS
> After recording ts with SRS, HLS playback actually goes through nginx for downloading. I would like to know how to automatically disconnect the streaming when there are no viewers, that is, how to determine that HLS has no clients and then disconnect the camera's streaming. For RTMP, the number of clients can be determined by querying the /api/v1/streams/ interface, but HLS playback does not increase the number of clients through this interface.
1. SRS Version (版本):
srs4
1. SRS Log (日志):
1. SRS Config (Configuration):
Expect (Expected Behavior)
TRANS_BY_GPT3