Skip to content

Commit 376d1b2

Browse files
committed
feat: add multi streaming
1 parent 06bd4d0 commit 376d1b2

File tree

8 files changed

+94
-4
lines changed

8 files changed

+94
-4
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ config.json
55
cookies.json
66

77
music.mp3
8-
image.png
8+
image.png
9+
10+
streamer.conf

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM tiangolo/nginx-rtmp
2+
3+
RUN apt-get update && \
4+
apt-get install -y stunnel4 ca-certificates && \
5+
mkdir -p /etc/stunnel && \
6+
chmod 600 /etc/stunnel/stunnel.conf
7+
8+
COPY streamer.conf /etc/nginx/nginx.conf
9+
COPY stunnel.conf /etc/stunnel/stunnel.conf
10+
11+
CMD sh -c "stunnel /etc/stunnel/stunnel.conf && nginx -g 'daemon off;'"

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Potat Streamer
2+
3+
It streams the 24/7 grafana for [PotatBotat](https://potat.app)
4+
5+
## 🐳 Docker Compose
6+
7+
### 1. Prerequisites
8+
9+
- [Docker](https://www.docker.com/products/docker-desktop) and [Docker Compose](https://docs.docker.com/compose/) installed.
10+
- [Node.js](https://nodejs.org/) and [npm](https://www.npmjs.com/).
11+
- Rename `streamer.example.conf` to `streamer.conf` and enter your stream url and stream keys.
12+
13+
### 2. Create Container
14+
15+
```sh
16+
docker compose up -d --build
17+
```
18+
19+
- This will start the NGINX RTMP server and stunnel proxy.
20+
- Build the NGINX RTMP image (with stunnel for Kick support).
21+
- Copy your `streamer.conf` and `stunnel.conf` into the image.
22+
- The RTMP server will listen on port `1935` (default RTMP port).
23+
- Uses stunnel to stream to kick which requires rtmps, which nginx struggles with.
24+
- The configuration will push your stream to Twitch, YouTube, and Kick.
25+
26+
## Start Streamer
27+
28+
```sh
29+
npm install && npm run start
30+
```
31+

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3.8'
2+
3+
services:
4+
nginx:
5+
build: .
6+
image: tiangolo/nginx-rtmp
7+
ports:
8+
- "1935:1935"
9+
volumes:
10+
- ./streamer.conf:/etc/nginx/nginx.conf:ro
11+
- ./src:/usr/share/nginx/html

src/broker.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ export class NatsClient {
5656
throw new Error('NATS client not initialized');
5757
}
5858

59-
setInterval(() => this.page?.reload(), 10 * 60 * 60 * 1000);
60-
6159
return this.#client;
6260
}
6361

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class Streamer {
147147
'-c:a', 'aac',
148148
'-b:a', '128k',
149149
'-f', 'flv',
150-
`rtmp://live.twitch.tv/app/${this.config.streamKey}`,
150+
`rtmp://127.0.0.1:1935/live/potato`,
151151
]);
152152

153153
this.pid = ffmpeg.pid;
@@ -275,6 +275,8 @@ class Streamer {
275275
await page.addStyleTag({ content: this.config.injectedCss });
276276
}
277277

278+
setInterval(() => page.reload(), 10 * 60 * 60 * 1000);
279+
278280
return page.createCDPSession();
279281
}
280282

streamer.example.conf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
worker_processes auto;
2+
rtmp_auto_push on;
3+
events {}
4+
5+
rtmp {
6+
server {
7+
listen 1935;
8+
chunk_size 4096;
9+
10+
application live {
11+
live on;
12+
record off;
13+
14+
# Twitch
15+
push rtmp://live.twitch.tv/app/your_stream_key;
16+
17+
# YouTube
18+
push rtmp://a.rtmp.youtube.com/live2/your_stream_key;
19+
20+
# Kick: Have to proxy with stunnel due to rtmps + nginx not being supported
21+
push rtmp://127.0.0.1:19452/app/your_stream_key;
22+
}
23+
}
24+
}

stunnel.conf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pid = /var/run/stunnel.pid
2+
output = /var/log/stunnel.log
3+
4+
5+
[kick]
6+
client = yes
7+
accept = 127.0.0.1:19452
8+
connect = fa723fc1b171.global-contribute.live-video.net:443
9+
verifyChain = yes
10+
checkHost = fa723fc1b171.global-contribute.live-video.net
11+
CAfile = /etc/ssl/certs/ca-certificates.crt

0 commit comments

Comments
 (0)