Skip to content

Commit e4f8962

Browse files
committed
Initial release
0 parents  commit e4f8962

File tree

10 files changed

+2118
-0
lines changed

10 files changed

+2118
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
build
3+
config.json

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2020 Max Goodhart
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Streamdelay
2+
3+
![A pixelated stream filtered using streamdelay](screenshot.png)
4+
5+
Streamdelay enables streams to have ["broadcast delay"](https://en.wikipedia.org/wiki/Broadcast_delay) for content redaction/filtering. Stream upload is delayed by a customizable duration, allowing a pixelization and audio blocking filter to be applied ahead of unacceptable content being broadcast.
6+
7+
Streamdelay accepts an input stream using the [SRT protocol](https://www.haivision.com/products/srt-secure-reliable-transport/) (supported by OBS and ffmpeg), and can output to either an SRT or RTMP endpoint (such as twitch.tv or restream.io).
8+
9+
A UI is currently not provided. The `streamdelay` package is designed to run as a local service, controlled via its built-in API server. This is meant to be integrated into a larger stream management dashboard, such as [`streamwall`](https://github.com/chromakode/streamwall).
10+
11+
## Setup
12+
13+
### Binaries
14+
15+
Binaries may be available via the [releases page](https://github.com/chromakode/streamdelay/releases). You will need to [install the GStreamer runtime](https://gstreamer.freedesktop.org/download/) for your platform.
16+
17+
### Source
18+
19+
1. Ensure you have the buildchain for your platform installed necessary to [build binary node modules using node-gyp](https://github.com/nodejs/node-gyp#installation).
20+
1. Install [GStreamer](https://gstreamer.freedesktop.org/download/). You will need both the runtime and development headers installed.
21+
1. Run `npm install`. This will install dependencies and build the `node-gstreamer-superficial` library.
22+
23+
## Usage
24+
25+
### Starting Streamdelay
26+
27+
1. Copy `example.config.json` to `config.json` and customize to suit your needs.
28+
1. Configure your streaming software to output to the SRT endpoint specified in `"srtInUri"`.
29+
1. Run (binary) `streamdelay --config=config.json` or (development) `npm start -- --config=config.json`.
30+
1. Start streaming.
31+
32+
## HTTP API
33+
34+
Streamdelay runs an HTTP server on the hostname and port you configure.
35+
36+
### Authentication
37+
38+
Requests must either contain:
39+
40+
- a `Streamdelay-API-Key` header equal to the `apiKey` value configured
41+
- a `?key=API_KEY` query param equal to the `apiKey` value configured
42+
43+
All responses are `Content-Type: application/json`.
44+
45+
### Get current state
46+
47+
```
48+
GET /state
49+
```
50+
51+
returns:
52+
53+
```
54+
{
55+
censored: bool,
56+
status: {... full state object ...}
57+
}
58+
```
59+
60+
The `status` object can be matched using [`xstate`'s `State.from` constructor](https://xstate.js.org/api/classes/state.html#from):
61+
62+
```js
63+
// Check if the stream is waiting for a connection
64+
State.from(status).matches('stream.running.waiting')
65+
66+
// Check if the stream is connected and rolling
67+
State.from(status).matches('stream.running.started')
68+
69+
// Check if we're in the process of deactivating the censorship mode
70+
State.from(status).matches('censorship.censored.deactivating')
71+
```
72+
73+
### Set state
74+
75+
Set the stream state to censored (redacted) or not. When transitioning from censored to uncensored state, Streamdelay will wait the configured `delaySeconds` before turning off the censored state. This helps prevent early release of the censored mode before the delayed content has been broadcast.
76+
77+
```
78+
PATCH /state
79+
```
80+
81+
body:
82+
83+
`{censored: false}` or `{censored: true}`
84+
85+
returns: same as `/status`
86+
87+
## Websocket API
88+
89+
```
90+
GET /ws?key=API_KEY
91+
Upgrade: websocket
92+
```
93+
94+
Upon initial connection, the current state will be sent in JSON format. It will be sent again whenever the state changes.
95+
96+
Sending a JSON message has the same behavior as `PATCH /state`.

example.config.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"apiHostname": "localhost",
3+
"apiPort": 8404,
4+
"apiKey": "change-me",
5+
"srtInUri": "srt://:5000?mode=listener",
6+
"outUri": "srt://:5001?mode=listener",
7+
"delaySeconds": 15,
8+
"width": 1920,
9+
"height": 1080,
10+
"x264Bitrate": 4000,
11+
"x264Preset": "slow",
12+
"pixelizeScale": 20,
13+
"overlayImg": "change-me.png"
14+
}

0 commit comments

Comments
 (0)