Skip to main content

API for monitoring

The API is best used for any live statistic look up, can be somewhat demanding on a system depending on how much is collected. So keep in mind that some calls are heavier than others.

The best method of collecting statistics using the API would be using a combination of apiv2 and our Websocket API. This allows you to collect statistics and have them be live updated as used. An introduction is available at our API control documentation. Full details at our API documentation.

API calls for monitoring

Any API call can receive the field "time":UNIX with a UNIX time, or if a value below 1000 is given it will assume that many seconds back. The stats will then correspond with the requested time, this does improve the accuracy of some API calls as statistics will sometimes need about 3 seconds to fill completely. If no time field is given MistServer will assume "right now".

  • active_streams - To receive current statistics of streams actively serving viewers or receiving data.
  • stats_streams - To generate a list of streams that currently have statistics
  • log - receive a copy of the current server log
  • clients - receive a list of inputs/outputs and their details
  • totals - receive the sum total of clients between two points in time

Websocket live stats

The amount of data available through the websocket live stats is quite broad. It also contains some information specific to MistServer such as the internal track index (idx) or masking of the track. Keep in mind that this output reports all statistics every second and not just when they relevant statistic updates.

A lesser version of this same output can be requested over the JSON http(s) output of MistServer as well over the address: http://address/json_streamname.js This is shown in the embed page of a stream as well.

[
"streammeta",
"livestream",
{
"meta": {
"bframes": 0,
"buffer_window": 25213,
"jitter": 35,
"live": 1,
"maxkeepaway": 45000,
"source": "push://",
"tracks": {
"audio_PCM_2ch_48000hz_3": {
"bps": 384000,
"channels": 2,
"codec": "PCM",
"codecstring": "",
"firstms": 3608233,
"idx": 3,
"init": "",
"jitter": 35,
"lastms": 3631853,
"mask": 5,
"maxbps": 384000,
"nowms": 3631853,
"pid": 141076,
"rate": 48000,
"size": 32,
"source": 1,
"trackid": 1,
"type": "audio"
},
"audio_opus_2ch_48000hz_1": {
"bps": 2618,
"channels": 2,
"codec": "opus",
"codecstring": "opus",
"firstms": 3608233,
"idx": 1,
"init": "OpusHead\u0001\u0002x\u0000€»\u0000\u0000\u0000\u0000\u0000",
"jitter": 11,
"lastms": 3631913,
"mask": 255,
"maxbps": 3231,
"nowms": 3631913,
"pid": 141026,
"rate": 48000,
"size": 16,
"trackid": 66,
"type": "audio"
},
"audio_opus_2ch_48000hz_2": {
"bps": 9426,
"channels": 2,
"codec": "opus",
"codecstring": "opus",
"firstms": 3608226,
"idx": 2,
"init": "OpusHead\u0001\u00028\u0001€»\u0000\u0000\u0000\u0000\u0000",
"jitter": 33,
"lastms": 3631846,
"mask": 3,
"maxbps": 10264,
"nowms": 3631846,
"pid": 141077,
"rate": 48000,
"size": 16,
"source": 1,
"trackid": 1,
"type": "audio"
},
"video_H264_1920x1080_50fps_0": {
"bps": 625073,
"codec": "H264",
"codecstring": "avc1.42c02a",
"efpks": 50000,
"efps": 50,
"firstms": 3606500,
"fpks": 50000,
"fps": 50,
"h264_level": "Unknown",
"h264_profile": "Constrained baseline",
"height": 1080,
"idx": 0,
"init": "\u0001BÀ*ÿá\u0000\u001cgBÀ*Ú\u0001à\bŸ—\u0001j\u0002\u0002\u0002€\u0000\u0000\u0003\u0000€\u0000\u00002GŒ\u0019P\u0001\u0000\u0004hÎ\u001f ",
"jitter": 11,
"keys": {
"frame_ms_max": 20,
"frame_ms_min": 20,
"frames_max": 25,
"frames_min": 25,
"ms_max": 500,
"ms_min": 500
},
"lastms": 3631900,
"mask": 255,
"maxbps": 741474,
"nowms": 3631900,
"pid": 141026,
"trackid": 65,
"type": "video",
"width": 1920
},
"video_JPEG_1920x1080_0fps_5": {
"bps": 54878,
"codec": "JPEG",
"codecstring": "",
"efpks": 1000,
"efps": 1,
"firstms": 3608000,
"fpks": 0,
"fps": 0,
"height": 1080,
"idx": 5,
"init": "",
"issues": [
"unstable connection (1000ms frame)!",
"unstable connection (1 frame(s) in key)!",
"unstable key interval (4900% variance)!"
],
"jitter": 1,
"keys": {
"frame_ms_max": 1000,
"frame_ms_min": 20,
"frames_max": 1,
"frames_min": 1,
"ms_max": 1000,
"ms_min": 20
},
"lastms": 3631000,
"mask": 3,
"maxbps": 71184,
"nowms": 3631860,
"pid": 141078,
"source": 0,
"trackid": 1,
"type": "video",
"width": 1920
},
"video_UYVY_1920x1080_50fps_4": {
"bps": 0,
"codec": "UYVY",
"codecstring": "",
"efpks": 50000,
"efps": 50,
"firstms": 3630060,
"fpks": 50000,
"fps": 50,
"height": 1080,
"idx": 4,
"init": "",
"jitter": 27,
"keys": {
"frame_ms_max": 20,
"frame_ms_min": 20,
"frames_max": 1,
"frames_min": 1,
"ms_max": 20,
"ms_min": 20
},
"lastms": 3631840,
"mask": 5,
"maxbps": 0,
"nowms": 3631840,
"pid": 141079,
"source": 0,
"trackid": 1,
"type": "video",
"width": 1920
}
},
"type": "live",
"unixoffset": 1779276330715,
"version": 4
},
"type": "live",
"unixoffset": 1779276330715
}
]