Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

terminatename

REST query

Body example

Response example

Response state

Desctiption

/hls/startup

Code Block
languagejs
themeRDark
{
  "name":"test"
}

200 - OK

404 - Stream not found

500 - Internal error


Start HLS agent for the stream


/hls/find_all

Code Block
languagejs
themeRDark
{
  "testoffset": {0,
    "handler": "com.flashphoner.server.client.handler.wcs4.WCS4Handler@74dbf27b",
    "statesize":10
}
Code Block
languagejs
themeRDark
[{
    "id": "ACTIVEtest",
    "writerstreamName": "HLS-test",
    "streamStatusstatus": "PLAYINGACTIVE",
    "writerStartedwaitingSize": "true"0,
      "logsprofiles": [
      "2023-07-18T10:22:52.457 WARNING: Playback speed changed to 0.779, segment 49, media type: video""a_test",
      "v_test"
    ],
    "subscribers": 1,
      "2023-07-18T10:22:56.614 WARNING: Gap{from=112000, to=114000, duration=2000}, media type: video"playlist": "...",
      "2023-07-18T10:22:56.615 WARNING: Fps changed from 30 to 27, segment 50 , media type: video",
      "2023-07-18T10:22:56.624 WARNING: Segment 51.1 have no data, pts 112400, duration 400, media type: video",
      ...
    ]
  }"createdDate": 1697605114475,
    "logs": []
}]

200 – OK

404 – Not found

Find all streams having HLS agents

/hls/terminate

Code Block
languagejs
themeRDark
{
  "name":"test"
}

200 – OK

404 – Not found

Find all streams having HLS agentsStop or restart HLS agent for the stream

/hls/profiles
Code Block
languagejs
themeRDark
{
  "
hlsId":"test",
  "profileName":"v_test" }

200 – OK

404 – Not found

Stop or restart HLS agent for the stream

Parameters

...

Description

...

Example

...

name

...

Stream published name

...

test

...

Issues

1. If HLS agent for the stream is started by REST query /hls/startup, and there are no active HLS subscribers, agent will stop after the following timeout in seconds

Code Block
themeRDark
hls_manager_provider_timeout=300

By default, the timeout is 5 minutes. Also it concerns HLS agents which are started automatically for streams published using the following parameter

Code Block
themeRDark
hls_auto_start=true

2. If HLS agent for the stream is stopped by REST query /hls/terminate, and there are active HLS subscribers, this agent will be restarted. In this case, active HLS subscribers must reconnect to the stream.

LL HLS stream issues displaying

...

Code Block
languagejs
themeRDark
{
  "name": "v_test",
  "stream": {
    "appKey": "defaultApp",
    "sessionId": "test-HLS",
    "mediaSessionId": "81b8b278-612e-4b72-9153-454be9df0a34-test-HLS",
    "name": "test",
    "published": false,
    "hasVideo": false,
    "hasAudio": true,
    "status": "PLAYING",
    "sdp": "...",
    "videoCodec": "H264",
    "record": false,
    "width": 1280,
    "height": 720,
    "bitrate": 0,
    "minBitrate": 0,
    "maxBitrate": 0,
    "quality": 0,
    "parentMediaSessionId": "f3401d2e-7e9a-4e18-a353-d323c947ac94",
    "history": false,
    "gop": 0,
    "fps": 0,
    "audioBitrate": 0,
    "codecImpl": "",
    "transport": "UDP",
    "cvoExtension": true,
    "createDate": 1697605114875,
    "mediaType": "play",
    "audioState": {
      "muted": false
    },
    "videoState": {
      "muted": false
    },
    "mediaProvider": "HLS"
  },
  "keyFrameReceived": true,
  "videoProfile": {
    "type": "video",
    "width": 1280,
    "height": 720,
    "fps": 29,
    "bitrate": 1720,
    "codec": "",
    "quality": 0,
    "audioGroupId": "audio"
  },
  "metrics": {
    "minFPS": 29.962547,
    "avgFPS": 30.000088,
    "maxFPS": 30.04292,
    "countGaps": 0,
    "resolutionChanges": 0,
    "queueSize": 10,
    "startPts": 375400,
    "currentPts": 375400
  },
  "subscribers": 1
}

200 – OK

400 – Bad request

404 – Not found

Get HLS profile statistics
/hls/subscribers
Code Block
languagejs
themeRDark
{
  "hlsId":"test"
}
Code Block
languagejs
themeRDark
[
  {
    "id": "192.168.0.83-59000-Mozilla/5.0 (X11; Linux x86_64) Chrome/118.0.0.0",
    "ip": "192.168.0.83",
    "port": 59000,
    "userAgent": "Mozilla/5.0 (X11; Linux x86_64) Chrome/118.0.0.0",
    "active": true,
    "metrics": {
      "profileTime": {
        "test": 71,
        "v_test": 541353
      },
      "requestsNumber": 5930,
      "requestsStatuses": {
        "200 OK": 5930
      },
      "profileSwitches": 1,
      "maxResponseTime": 29,
      "minResponseTime": 0,
      "avgResponseTime": 0.4436762225969646
    }
  }
]

200 – OK

400 – Bad request

404 – Not found

Get HLS subscribers statistics

Parameters

Parameter name

Description

Example

name

Stream published name

test

logsMessages about stream issues[]

Issues

1. If HLS agent for the stream is started by REST query /hls/startup, and there are no active HLS subscribers, agent will stop after the following timeout in seconds

Code Block
themeRDark
hls_manager_provider_timeout=300

By default, the timeout is 5 minutes. Also it concerns HLS agents which are started automatically for streams published using the following parameter

Code Block
themeRDark
hls_auto_start=true

2. If HLS agent for the stream is stopped by REST query /hls/terminate, and there are active HLS subscribers, this agent will be restarted. In this case, active HLS subscribers must reconnect to the stream.

LL HLS stream issues displaying

Since build 5.2.1709 LL HLS stream issues are displaying in response on /hls/find_all REST API query:

Code Block
languagejs
themeRDark
{
   "test": {
    "handler": "com.flashphoner.server.client.handler.wcs4.WCS4Handler@74dbf27b",
    "state": "ACTIVE",
    "writer": "HLS-test",
    "streamStatus": "PLAYING",
    "writerStarted": "true",
    "logs": [
      "2023-07-18T10:22:52.457 WARNING: Playback speed changed to 0.779, segment 49, media type: video",
      "2023-07-18T10:22:56.614 WARNING: Gap{from=112000, to=114000, duration=2000}, media type: video",
      "2023-07-18T10:22:56.615 WARNING: Fps changed from 30 to 27, segment 50 , media type: video",
      "2023-07-18T10:22:56.624 WARNING: Segment 51.1 have no data, pts 112400, duration 400, media type: video",
      ...
    ]
  }
}

By default, up to 50 last issues are displayed for every stream. This value may be changed with the following parameter

Code Block
themeRDark
hls_metrics_log_size=50

The following issues are detected:

  • Fps changed from x to y - stream FPS leap over 10 %
  • Segment x does not start with keyframe - stream keyframe interval is more than one segment duration
  • Playback speed changed to x - stream playback speed has changed
  • Segment interval is too big - an interval in milliseconds between a subsequent segments is too big
  • Video resolution changed from x to y - stream resolution has changed
  • Gap{from=x, to=y, duration=z} - stream gap detected, EXT-X-GAP tag is added to the playlist

Any of those issues means a source stream publishing quality degradation and may lead to freezes, out of audio and video sync and even HLS playback stopping in some browsers. In this case, a possible packets loss or bandwidth issues should be resolved, or pablishing technology shuld be changed from WebRTC to a more noise-resistant, RTMP or SRT for example.

HLS statistics displaying

Since build 5.2.1777 it is possible to get HLS statistics via REST API

HLS common data

In the response to the /hls/find_all query HLS agents list is returned containing a common HLS data:

Code Block
languagejs
themeRDark
[{
    "id": "test",
    "streamName": "test",
    "status": "ACTIVE",
    "waitingSize": 0,
    "profiles": [
      "a_test",
      "v_test"
    ],
    "subscribers": 1,
    "playlist": "#EXTM3U\n#EXT-X-VERSION:9\n#EXT-X-INDEPENDENT-SEGMENTS\n#EXT-X-MEDIA:TYPE=AUDIO,URI=\"a_test/a_test.m3u8\",GROUP-ID=\"audio\",NAME=\"none\",DEFAULT=YES,AUTOSELECT=YES,CHANNELS=\"2\"\n#EXT-X-STREAM-INF:BANDWIDTH=1761281,CODECS=\"avc1.640028,mp4a.40.2\",RESOLUTION=1280x720,FRAME-RATE=29.0,AUDIO=\"audio\"\nv_test/v_test.m3u8\n",
    "createdDate": 1697605114475,
    "logs": []
}]

Where

  • id - HLS stream identifier
  • streamName - a source stream name which is cut to a segments
  • waitingSize - HTTP requests count waiting for response
  • profiles - audio and video profiles list
  • subscribers -  HLS subscribers count
  • playlist - HLS manifest content
  • createdDate - HLS agent creation date as integer
  • logs - HLS stream issues log

if there are a much HLS streams on the server, the list may be limited by the following parameters

Code Block
languagejs
themeRDark
{
  "offset":0,
  "size":10
}

Where

  • offset - from which item the list should be dispalyed, 0 by default
  • size - a maximum list items to display, 10 by default

Audio and video profiles data

In the response to the /hls/profiles query an audio or video HLS profile statistics is returned:

Code Block
languagejs
themeRDark
{
  "name": "v_test",
  "stream": {
    "appKey": "defaultApp",
    "sessionId": "test-HLS",
    "mediaSessionId": "81b8b278-612e-4b72-9153-454be9df0a34-test-HLS",
    "name": "test",
    "published": false,
    "hasVideo": false,
    "hasAudio": true,
    "status": "PLAYING",
    "sdp": "v=0\r\no=- 1988962254 1988962254 IN IP4 0.0.0.0\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\na=sdplang:en\r\nm=video 0 RTP/AVP 112\r\na=rtpmap:112 H264/90000\r\na=fmtp:112 packetization-mode=1; profile-level-id=42001f\r\na=recvonly\r\n",
    "videoCodec": "H264",
    "record": false,
    "width": 1280,
    "height": 720,
    "bitrate": 0,
    "minBitrate": 0,
    "maxBitrate": 0,
    "quality": 0,
    "parentMediaSessionId": "f3401d2e-7e9a-4e18-a353-d323c947ac94",
    "history": false,
    "gop": 0,
    "fps": 0,
    "audioBitrate": 0,
    "codecImpl": "",
    "transport": "UDP",
    "cvoExtension": true,
    "createDate": 1697605114875,
    "mediaType": "play",
    "audioState": {
      "muted": false
    },
    "videoState": {
      "muted": false
    },
    "mediaProvider": "HLS"
  },
  "keyFrameReceived": true,
  "videoProfile": {
    "type": "video",
    "width": 1280,
    "height": 720,
    "fps": 29,
    "bitrate": 1720,
    "codec": "",
    "quality": 0,
    "audioGroupId": "audio"
  },
  "metrics": {
    "minFPS": 29.962547,
    "avgFPS": 30.000088,
    "maxFPS": 30.04292,
    "countGaps": 0,
    "resolutionChanges": 0,
    "queueSize": 10,
    "startPts": 375400,
    "currentPts": 375400
  },
  "subscribers": 1
}

Where:

  • name - profile name
  • stream - profile stream data in /stream/find like form
  • keyFrameReceived - is there any key frame received
  • audioProfile, videoProfile - audio or video profile settings
    • type - profile type: video or audio
    • width - profile picture width as defined
    • height - profile picture width as defined
    • fps - profile video frame rate as defined
    • bitrate - profile bitrate as defined
    • codec - profile codec as defined
    • quality - profile quality as defined
    • audioGroupId - audio profile id used in video profile
    • rate - audio profile samplerate
    • channels - audio profile channels number
    • groupId - audio profile id to bind to video profile
  • metrics - current profile metrics:
    • minFPS - minimal FPS
    • avgFPS -  average FPS
    • maxFPS - maximum FPS
    • countGaps - gaps count inserted to the stream
    • resolutionChanges - video resolution changes count
    • queueSize - stream frame queue size
    • startPts - start MPEG timestamp
    • currentPts - current MPEG timestamp
  • subscribers - HLS subscribers to the profile count

HLS subscribers count

n the response to the /hls/subscribers query an HLS stream subscribers list is returned:

Code Block
languagejs
themeRDark
[
  {
    "testid": {"192.168.0.83-59000-Mozilla/5.0 (X11; Linux x86_64) Chrome/118.0.0.0",
    "handlerip": "com192.flashphoner168.server.client.handler.wcs4.WCS4Handler@74dbf27b"0.83",
    "port": 59000,
    "stateuserAgent": "ACTIVEMozilla/5.0 (X11; Linux x86_64) Chrome/118.0.0.0",
    "writeractive": true,
    "HLS-test",
metrics": {
      "streamStatusprofileTime": "PLAYING",
{
        "writerStartedtest": "true"71,
    "logs": [
      "2023-07-18T10:22:52.457 WARNING: Playback speed changed to 0.779, segment 49, media type: video""v_test": 541353
      },
      "requestsNumber": 5930,
      "2023-07-18T10:22:56.614 WARNING: Gap{from=112000, to=114000, duration=2000}, media type: video",
      "2023-07-18T10:22:56.615 WARNING: Fps changed from 30 to 27, segment 50 , media type: video""requestsStatuses": {
        "200 OK": 5930
      },
      "profileSwitches": 1,
      "2023-07-18T10:22:56.624 WARNING: Segment 51.1 have no data, pts 112400, duration 400, media type: video",
maxResponseTime": 29,
      "minResponseTime": 0,
      "avgResponseTime": 0...4436762225969646
    ]}
  }
}

By default, up to 50 last issues are displayed for every stream. This value may be changed with the following parameter

Code Block
themeRDark
hls_metrics_log_size=50

The following issues are detected:

  • Fps changed from x to y - stream FPS leap over 10 %
  • Segment x does not start with keyframe - stream keyframe interval is more than one segment duration
  • Playback speed changed to x - stream playback speed has changed
  • Segment interval is too big - an interval in milliseconds between a subsequent segments is too big
  • Video resolution changed from x to y - stream resolution has changed
  • Gap{from=x, to=y, duration=z} - stream gap detected, EXT-X-GAP tag is added to the playlist

...

]

Where:

  • id - subscriber identifier
  • ip - subscriber IP address
  • port -  subscriber source port
  • userAgent - User-Agent header sent by subscriberпереданные подписчиком
  • active - subscriber is active
  • metrics - current subscriber metrics:
    • profileTime - the time the subscriber requested the profile shown by profile
    • requestsNumber - subscribers requests number
    • requestStatuses - response status codes count sent to the subscriber shown by response status code
    • profileSwitches - HLS ABR profile switches count for the subscriber
    • maxResponseTime - maximum response time
    • minResponseTime - minimum response time
    • avgResponseTime - average response time

HLS ABR support

For a streams with video track (video only or audio+video) WCS supports HLS ABR in CDN (a qualities are encoded on a dedicated Transcoder node) and on a single node.

...