nginx-mod-rtmp frontend https://chaos.stream
Go to file
Laura Hausmann 5e55c7fb19
Improve efficiency by passing StatsObject to the StreamUtils helper functions instead of requesting it every time
2021-01-27 22:31:42 +01:00
Controllers Update to reflect nginx-mod-rtmp changes 2021-01-24 17:51:33 +01:00
DataModels Make actual use of the new stats object; remove SrcRes database object 2021-01-25 19:43:05 +01:00
Pages Improve efficiency by passing StatsObject to the StreamUtils helper functions instead of requesting it every time 2021-01-27 22:31:42 +01:00
Properties Make actual use of the new stats object; remove SrcRes database object 2021-01-25 19:43:05 +01:00
wwwroot Rebase all 2021-01-24 04:04:16 +01:00
.gitignore Rebase all 2021-01-24 04:04:16 +01:00
LICENSE.md Rebase all 2021-01-24 04:04:16 +01:00
Program.cs Add stream uptime to Dashboard.cshtml and Admin.cshtml 2021-01-27 22:24:25 +01:00
README.md Update README.md 2021-01-26 00:39:49 +01:00
RTMPDash.csproj Rebase all 2021-01-24 04:04:16 +01:00
RTMPDash.sln Rebase all 2021-01-24 04:04:16 +01:00
RTMPDash.sln.DotSettings.user Rebase all 2021-01-24 04:04:16 +01:00
Startup.cs Make actual use of the new stats object; remove SrcRes database object 2021-01-25 19:43:05 +01:00
StreamUtils.cs Improve efficiency by passing StatsObject to the StreamUtils helper functions instead of requesting it every time 2021-01-27 22:31:42 +01:00
appsettings.Development.json Rebase all 2021-01-24 04:04:16 +01:00
appsettings.json Rebase all 2021-01-24 04:04:16 +01:00
example.db Update profile design; update example.db to reflect recent changes 2021-01-25 19:58:15 +01:00

README.md

RTMPDash

Production instance

Installation

  • Adjust all the const's in Program.cs
  • Copy example.db to app.db
  • Create yourself a user using sqlite3
  • Install nginx-mod-rtmp (arch package: aur/nginx-mod-rtmp-lhaus-git)
  • Configure nginx-mod-rtmp, example config below
  • Start RTMPDash, example systemd unit below

Further setup

  • Customize privacy policy to your environment if you plan on hosting it publicly
  • Set up player, example code below

nginx-mod-rtmp example config

load_module /usr/lib/nginx/modules/ngx_rtmp_module.so; # load our rtmp module
worker_processes 1; # VERY IMPORTANT, otherwise nginx-mod-rtmp breaks

rtmp {
	log_format rtmp '[$time_local] $command -> $app with key "$name" - $bytes_received bytes received ($session_readable_time)';
	server {
		listen 1935;

		access_log /var/log/nginx/rtmp_access.log rtmp;

		max_message 32M;
		ping 1m;
		ping_timeout 10s;
		drop_idle_publisher 10s;
		notify_method get;

		application ingress {
			live on;

			allow play 127.0.0.1;
			deny play all;

			notify_relay_redirect on;

			on_publish http://localhost:60001/api/authenticate;

			hls on;
			hls_path /mnt/ssd_data/hls/src;
			hls_fragment 1s;
			hls_fragment_naming system;
			hls_playlist_length 60s;
			hls_allow_client_cache enabled;
		}
	}
}

RTMPdash example systemd unit (development)

[Unit]
Description=RTMPDash
Wants=network-online.target
After=network-online.target

[Service]
User=rtmpdash
Group=rtmpdash
WorkingDirectory=/opt/rtmpdash
Environment=ASPNETCORE_URLS='http://*:60001'
Environment=ASPNETCORE_ENVIRONMENT=Development
ExecStart=/usr/bin/dotnet watch run --no-launch-profile
Type=simple
TimeoutStopSec=20

# Lets built in updater work well.
Restart=on-failure
KillMode=control-group

[Install]
WantedBy=multi-user.target

RTMPdash example systemd unit (production)

[Unit]
Description=RTMPDash
Wants=network-online.target
After=network-online.target

[Service]
User=rtmpdash
Group=rtmpdash
WorkingDirectory=/opt/rtmpdash
Environment=ASPNETCORE_URLS='http://*:60001'
Environment=ASPNETCORE_ENVIRONMENT=Production
ExecStart=/usr/bin/dotnet run -c Release --no-launch-profile
Type=simple
TimeoutStopSec=20

# Lets built in updater work well.
Restart=on-failure
KillMode=control-group

[Install]
WantedBy=multi-user.target

VideoJS Player example code

<link href="https://unpkg.com/video.js/dist/video-js.min.css" rel="stylesheet" />
<style>
html,
body {
  margin: 0;
  padding: 0;
}
</style>
<div>
<video id='hls-player' class="video-js vjs-default-skin vjs-big-play-centered" controls>
<source type="application/x-mpegURL" src="https://cdn.zotan.stream/hls/<?php echo $_GET["profile"]."/".$_GET["stream"]; ?>.m3u8">
</video>
</div>
<script src="https://unpkg.com/video.js/dist/video.min.js"></script>
<script>
var player = videojs('hls-player', {liveui: true});
player.fill(true);
</script>

accompanying nginx config for VideoJS Player

location ~ ^/(.+)/(.+)$ {
		rewrite ^/(.+)/(.+)$ /watch.php?stream=$1&profile=$2 last;
}

location ~ ^/(.+)$ {
		rewrite ^/(.+)$ /watch.php?stream=$1&profile=src last;
}