You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Go application that captures live website content (both visual and audio) and streams it to an RTMP endpoint using Chrome headless browser and FFmpeg.
3
+
A containerized application to stream a webpage live over RTMP. Just pass a `WEBSITE_URL`and a `RTMP_URL` and the container will open a browser, capture the video and audio, and send it to the specified location. It can even be configured to automatically restart the stream for supported services.
4
4
5
-
## Features
5
+
## Uses
6
6
7
-
-**Website Capture**: Captures any website content including dynamic content, videos, and audio
8
-
-**Live Streaming**: Streams captured content to RTMP endpoints in real-time
9
-
-**Configurable Resolution**: Supports 720p and 1080p output resolutions
10
-
-**Docker Support**: Fully containerized with multi-stage builds
- Quickly spinning up a test stream without needing to install anything other than a container runtime.
8
+
- Setting up a long running stream for a [Twitch Extension Review](https://dev.twitch.tv/docs/extensions/life-cycle/#review) when a test stream is needed.
9
+
- Setting up a way to broadcast an overlay [like YarpBot does for its status page](https://www.twitch.tv/yarpbot) without a GUI client.
10
+
- Other.... stuff (you figure it out).
13
11
14
-
## How It Works
15
-
16
-
1.**Chrome Browser**: Launches a Chrome browser instance to render the target website
17
-
2.**Screen Capture**: Uses FFmpeg's x11grab to capture the browser window
18
-
3.**Audio Capture**: Captures system audio using PulseAudio
19
-
4.**Encoding**: Encodes video with H.264 and audio with AAC
20
-
5.**Streaming**: Streams the encoded content to the specified RTMP endpoint
21
-
22
-
## Environment Variables
23
-
24
-
| Variable | Description | Default |
25
-
|----------|-------------|---------|
26
-
|`WEBSITE_URL`| URL of the website to capture |`https://example.com`|
27
-
|`RTMP_URL`| RTMP endpoint to stream to |`rtmp://localhost:1935/live/stream`|
28
-
|`RESOLUTION`| Output resolution (720p or 1080p) |`1080p`|
29
-
30
-
## Quick Start
12
+
## Running From Source
31
13
32
14
### Using Docker Compose
33
15
34
-
1. Clone the repository and navigate to the stream-website directory:
2. Set environment variables (through copying [`.env.example`](./.env.example) to `.env` or other methods)
45
19
46
20
3. Start the application:
47
21
```bash
48
22
docker-compose up --build
49
23
```
50
24
51
-
### With RTMP Test Server
25
+
### Local Development With RTMP Test Server
52
26
53
27
To test with a local RTMP server:
54
28
55
29
```bash
56
30
# Start with the included RTMP server
57
-
docker-compose --profile rtmp-server up --build
31
+
docker-compose --profile dev up --build
58
32
59
33
# The RTMP server will be available at:
60
-
# - RTMP: rtmp://localhost:1935/live/stream
61
-
# - Web interface: http://localhost:8080
62
-
# - Stream stats: http://localhost:8080/stat
34
+
# rtmp://localhost:1935/live/stream
63
35
```
64
36
37
+
You can then use a program like VLC to view the stream to ensure it works (use `Media` -> `Open Network Stream` and use the address `rtmp://localhost:1935/live/stream` for this example).
2. FFmpeg captures the Chrome window using x11grab
185
-
3. FFmpeg captures system audio using PulseAudio
186
-
4. FFmpeg encodes and streams to RTMP endpoint
187
-
188
-
## Contributing
189
-
190
-
1. Fork the repository
191
-
2. Create a feature branch
192
-
3. Make your changes
193
-
4. Test with Docker
194
-
5. Submit a pull request
195
-
196
-
## License
197
-
198
-
This project is part of the Stream Website ecosystem.
52
+
> [!WARNING]
53
+
> While you **can** run this locally by compiling the go code and executing it, I wouldn't recommend it as you need to make sure all the dependencies such as Chrome and [ffmpeg](https://ffmpeg.org) are there and reachable. Plus, having this be a container's kind of the point.
54
+
55
+
## Status Checking
56
+
57
+
If an environmental variable such as `TWITCH_CHANNEL` (see below) is set, then the container will check that channel to make sure the stream is live and attempt to restart the stream if it is not. This is so the stream can automatically be restarted for platforms that have maximum stream lengths (such as Twitch's [being 48 hours per stream](https://help.twitch.tv/s/article/broadcasting-guidelines?language=en_US)).
58
+
59
+
### Twitch
60
+
61
+
To enable status checking for Twitch, provide a `TWITCH_CHANNEL`, `TWITCH_CLIENT_ID`, and `TWITCH_CLIENT_SECRET` environmental variable (see below for details).
62
+
63
+
> [!NOTE]
64
+
> Currently Twitch is the only supported platform but you can always file a PR if you want another platform.
65
+
66
+
## Environmental Variables
67
+
68
+
-`FRAMERATE`
69
+
- Enum
70
+
-`30`
71
+
-`60`
72
+
- Default: `30`
73
+
- Sets the framerate of the stream. Currently supports `30` or `60` frames per second.
74
+
-`LOG_FORMAT`
75
+
- Enum
76
+
-`json`
77
+
-`console`
78
+
- Default: `json`
79
+
- Sets the format for logs printed.
80
+
-`LOG_LEVEL`
81
+
- Enum
82
+
-`debug`
83
+
-`info`
84
+
-`warn`
85
+
-`warning`
86
+
-`error`
87
+
-`dpanic`
88
+
-`panic`
89
+
-`fatal`
90
+
- Default: `info`
91
+
- Level of logs that are printed. Defined by [`zap` log levels](https://pkg.go.dev/go.uber.org/zap/zapcore#Level).
92
+
-`PORT`
93
+
- String
94
+
- Default: `8080`
95
+
- Port to run the health and metrics endpoint on.
96
+
-`STATUS_CRON_SCHEDULE`
97
+
- String
98
+
- Default: `*/10 * * * *` (every 10 minutes)
99
+
- Cron string to define how often to check the status of the stream if status checking is enabled.
100
+
-`RESOLUTION`
101
+
- Enum
102
+
-`720p`
103
+
-`1080p`
104
+
-`2k`
105
+
- Default: `720p`
106
+
- What resolution the RTMP stream should be.
107
+
-`RTMP_URL`
108
+
- String
109
+
- Default: `rtmp://localhost:1935/live/stream`
110
+
- RMTP endpoint to send the stream to. If using a service such as [Twitch](https://help.twitch.tv/s/twitch-ingest-recommendation?language=en_US), be sure your stream key is at the end of it.
111
+
-`TWITCH_CHANNEL`
112
+
- String
113
+
- If provided a value, the application will attempt to check the status of the stream at the provided channel as per the `STATUS_CRON_SCHEDULE` and will restart the stream if it is detected to not be live.
114
+
- Requires the `TWITCH_CLIENT_ID` and `TWITCH_CLIENT_SECRET` to be defined to work properly.
115
+
-`TWITCH_CLIENT_ID`
116
+
- String
117
+
- Twitch Client ID obtained from the [Twitch Developer Console](https://dev.twitch.tv/console) for checking stream status if the `TWITCH_CHANNEL` environmental variable is set.
118
+
- Checking for the stream status on Twitch will not work without this and `TWITCH_CLIENT_SECRET` being set.
119
+
- For more information about registering an app on Twitch, see [the developer documentation](https://dev.twitch.tv/docs/authentication/register-app/).
120
+
-`TWITCH_CLIENT_SECRET`
121
+
- String
122
+
- Twitch Client ID obtained from the [Twitch Developer Console](https://dev.twitch.tv/console) for checking stream status if the `TWITCH_CHANNEL` environmental variable is set.
123
+
- Checking for the stream status on Twitch will not work without this and `TWITCH_CLIENT_ID` being set.
124
+
- For more information about registering an app on Twitch, see [the developer documentation](https://dev.twitch.tv/docs/authentication/register-app/).
125
+
-`WEBSITE_URL`
126
+
- String
127
+
- Default: `https://google.com`
128
+
- The website to stream.
129
+
130
+
## About
131
+
132
+
Cobbled together by [Zac Lovoy](https://bsky.app/profile/zwlovoy.bsky.social) (aka [BigZoz on Twitch](https://www.twitch.tv/bigzoz)). If you're interested in some of other streaming adjacent stuff, check out [YarpBot](https://yarpbot.com) or the [Filters Extension for Twitch](https://dashboard.twitch.tv/extensions/npqfekui52xl3nuuk91h2pmrszod57). Or whatever; I'm not your dad.
0 commit comments