All Projects → faryon93 → hlswatch

faryon93 / hlswatch

Licence: GPL-3.0 license
keep track of hls viewer stats

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to hlswatch

Starrysky
🔥A Powerful and Streamline MusicLibrary(一个丰富的音乐播放封装库,支持多种音频格式,完美解决你的问题。)
Stars: ✭ 1,022 (+2222.73%)
Mutual labels:  hls, rtmp
Rtmp Ts Dash Webrtc
👾 音视频解决方案 Audio and video solutions(AV1)
Stars: ✭ 129 (+193.18%)
Mutual labels:  hls, rtmp
Javelin
[Mirror] RTMP streaming server written in Rust
Stars: ✭ 77 (+75%)
Mutual labels:  hls, rtmp
Docker Nginx Rtmp
🐋 A Dockerfile for nginx-rtmp-module + FFmpeg from source with basic settings for streaming HLS. Built on Alpine Linux.
Stars: ✭ 608 (+1281.82%)
Mutual labels:  hls, rtmp
Media Server
A brpc-based server to host and proxy live streams
Stars: ✭ 175 (+297.73%)
Mutual labels:  hls, rtmp
Ffmpeg
Mirror of https://git.ffmpeg.org/ffmpeg.git
Stars: ✭ 27,382 (+62131.82%)
Mutual labels:  hls, rtmp
Ffplayout Engine
python and ffmpeg based playout
Stars: ✭ 128 (+190.91%)
Mutual labels:  hls, rtmp
Lal
🔥 Golang live stream lib/client/server. support RTMP/RTSP/HLS/HTTP[S]-FLV/HTTP-TS, H264/H265/AAC, relay, cluster, record, HTTP API/Notify, GOP cache. 官方文档见 https://pengrl.com/lal
Stars: ✭ 480 (+990.91%)
Mutual labels:  hls, rtmp
Srs
SRS is a simple, high efficiency and realtime video server, supports RTMP, WebRTC, HLS, HTTP-FLV, SRT and GB28181.
Stars: ✭ 16,734 (+37931.82%)
Mutual labels:  hls, rtmp
Docker Streaming Server
Live streaming server
Stars: ✭ 141 (+220.45%)
Mutual labels:  hls, rtmp
Go Oryx
The go-oryx is SRS++, focus on real-time live streaming load-balancer.
Stars: ✭ 608 (+1281.82%)
Mutual labels:  hls, rtmp
Blss
NGINX-based Live Media Streaming Server
Stars: ✭ 187 (+325%)
Mutual labels:  hls, rtmp
Janus Webrtc Gateway Docker
Perfect Docker Image for Media Streaming Expert User ( https://github.com/meetecho/janus-gateway )
Stars: ✭ 582 (+1222.73%)
Mutual labels:  hls, rtmp
Gpuhaishinkit.swift
Camera and Microphone streaming library via RTMP, HLS for iOS. Powered by GPUImage + HaishinKit.
Stars: ✭ 35 (-20.45%)
Mutual labels:  hls, rtmp
Livego
live video streaming server in golang
Stars: ✭ 7,312 (+16518.18%)
Mutual labels:  hls, rtmp
Media Server
RTSP/RTP/RTMP/FLV/HLS/MPEG-TS/MPEG-PS/MPEG-DASH/MP4/fMP4/MKV/WebM
Stars: ✭ 1,363 (+2997.73%)
Mutual labels:  hls, rtmp
Easyplayer Rtsp Android
An elegant, simple, fast android RTSP/RTMP/HLS/HTTP Player.EasyPlayer support RTSP(RTP over TCP/UDP)version & Pro version,cover all kinds of streaming media!EasyPlayer是一款精炼、高效、稳定的流媒体播放器,分为RTSP版和Pro版本,支持各种各样的流媒体音视频播放!
Stars: ✭ 437 (+893.18%)
Mutual labels:  hls, rtmp
Owncast
Take control over your live stream video by running it yourself. Streaming + chat out of the box.
Stars: ✭ 5,382 (+12131.82%)
Mutual labels:  hls, rtmp
Html5 Dash Hls Rtmp
🌻 HTML5播放器、M3U8直播/点播、RTMP直播、低延迟、推流/播流地址鉴权
Stars: ✭ 1,805 (+4002.27%)
Mutual labels:  hls, rtmp
Haishinkit.swift
Camera and Microphone streaming library via RTMP, HLS for iOS, macOS, tvOS.
Stars: ✭ 2,237 (+4984.09%)
Mutual labels:  hls, rtmp

hlswatch - keep track of hls viewer stats

hlswatch is a simple program to keep track of the concurrent viewer count of a HLS live stream. This piece of software is intended to be placed in front of a NGINX server with the nginx-rtmp-module installed and HLS encoding enabled. The NGINX server is used as a transcoding instance to translate an incoming RTMP stream into HLS compatible video fragments. Delivering the fragments and playlists to the clients is handled by hlswatch.

To count the number of concurrent viewers hlswatch monitors the m3u8 playlist accesses per client. If the client does not issue a playlist reload in a certain amount of time it is considered as "not watching anymore".

The gathered data can be obtained in two different ways:

  1. The viewer counts are written to an InfluxDB database every second, if the the [influxdb] section is present in the config file. The tags node and stream are automatically populatet with the hostname and the stream name. The current count of concurrent viewers is stored in the value viewers.

  2. A REST endpoint is exposed on the address/port configured in common.listen. A JSON object can be accessed at /stats, which contains the current viewer numbers for each stream.

Keep in mind that this piece of software hasn't been tested in production!

Building

The Go application is built as part of the Docker image build process. In order to build a fresh copy of hlswatch you just have to enter:

$: docker build -t faryon93/hlswatch .

Configuration

Per default hlswatch uses /etc/hlswatch/hlswatch.conf as configuration file. If you want to change this path, just call hlswatch with your configuration file as the first argument.

[common]
listen = "0.0.0.0:3000"        # listen port/address for REST interface
hls_path = "/tmp/hls/"         # path where nginx-rtmp stores the HLS fragments
viewer_timeout = 15            # time in seconds when a viewer is considered not watching anymore

[influx]
address = "http://localhost:8086"   # address of the influxdb server
database = "hlswatch"               # database name
user = "hlswatch"                   # database user
password = "hlswatch"               # database password

Some configuration parameters can be overriden by environment variables. See config/config.go for valid variable names. Note: Not all parameters can be replaced by environment variables.

NGINX Setup

Because this software is responsible for delivering all data to the client it is not necessary to serve the HLS fragments via nginx to the public. If you want all NGINX features like access control, compression, TLS Termination, ... you can reverse proxy incoming requests by NGINX to hlswatch. This software relies on some configuration option the nginx-rtmp-module offers. The settings hls_cleanup and hls_nested need to be enabled:

rtmp {
    server {
        listen 1935;
        chunk_size 4000;

        application live {
            live on;
            hls on;
            hls_fragment_naming system;
            hls_fragment 5s;
            hls_path /tmp/hls;
            hls_nested on;
        }
    }
}

Tested Players

The application was tested with the following web players:

Player Working
clappr

Docker

This repository contains a Dockerfile, which builds a container which contains an NGINX webserver compiled with the nginx-rtmp-module. The current version contained in the master branch is automatically pushed to Docker Hub. Some configuration files to enable live streaming via RTMP and pass all HTTP requests to hlswatch is included by default. For production use you should consider adding SSL termination in NGINX and secure the access to hlswatchs statistics page.

Running the container:

$: docker run --rm -t -i \
              --name nginx-hls \
              -p 1935:1935 \
              -p 80:80 \
              -e HLS_INFLUX_ADDR=http://localhost:8086 \
              -e HLS_INFLUX_DB=hlswatch \
              -e HLS_INFLUX_USER=hlswatch \
              -e HLS_INFLUX_PASSWORD=hlswatch \
              faryon93/hlswatch

ToDo

  • Caching of m3u8 playlist and video fragments in RAM
  • Disable directory listing in hlswatch
  • Execute hlswatch as unprivileged user (proper process supervision)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].