A containerized application to stream a webpage live over RTMP. Just pass a WEBPAGE_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 when the service stops the stream.
- Quickly spinning up a test stream without needing to install anything other than a container runtime.
- Setting up a long running stream for a Twitch Extension Review when a test stream is needed.
- Setting up a way to broadcast an overlay like YarpBot does for its status page without a GUI client.
- Other.... stuff (you figure it out).
- Docker (or some other container runtime like containerd)
- .....That's it. Why did we make this a list?
docker run -e WEBPAGE_URL=https://url-of-website-i-want-to-stream.com -e RTMP_URL=rtmp://rtmp-endpoint.to/stream/to ghcr.io/zozman/stream-webpage-container
docker run -e WEBPAGE_URL=https://url-of-website-i-want-to-stream.com -e RTMP_URL=rtmp://rtmp-endpoint.to/stream/to -e RESOLUTION=720p -e FRAMERATE=60 ghcr.io/zozman/stream-webpage-container
Note
All available images can be found on the repo's container package page.
latest
- Represents the latest release and should be what you use if you don't know what to use.
v*
- Example:
v1.0.0
- Represents a specific release and is the right choice if you want to update versions manually.
- Example:
edge
- Represents the latest commit to
main
and is not recommended for daily use unless you want the latest build NOW.
- Represents the latest commit to
sha-*
- Examples:
sha-df87ff2ac624eb2de65861dfa3b09844a3f0f3db
,sha-df87ff2
- Every commit to
main
will have a tag corresponding to that commit's long and short SHA.
- Examples:
Note
For the following make
commands, you should have Docker installed since they use docker
and docker compose
under the hood.
-
Clone the repository
-
Set environment variables (through copying
.env.example
to.env
or other methods) -
Start just the application:
make run
To test with a local RTMP server:
# Start with the included RTMP server
make dev
# The RTMP server will be available at:
# rtmp://localhost:1935/live/stream
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).
To run unit tests within a dockerized environment, run the following:
make test
This command will save coverage results to the coverage
directory.
Note
If you have go installed, you can also run go test -v -coverprofile=coverage/coverage.out ./... && go tool cover -html=coverage/coverage.out -o coverage/coverage.html
to do the same thing locally.
# Build the image
docker build -t stream-webpage .
# Run the container
docker run -e WEBPAGE_URL="https://example.com" \
-e RTMP_URL="rtmp://your-server/live/stream" \
-e RESOLUTION="1080p" \
stream-webpage
Warning
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 are there and reachable. Plus, having this be a container's kind of the point.
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).
To enable status checking for Twitch, provide a TWITCH_CHANNEL
, TWITCH_CLIENT_ID
, and TWITCH_CLIENT_SECRET
environmental variable (see below for details).
Note
Currently Twitch is the only supported platform but you can always file a PR if you want another platform.
FRAMERATE
- Enum
30
60
- Default:
30
- Sets the framerate of the stream. Currently supports
30
or60
frames per second.
- Enum
LOG_FORMAT
- Enum
json
console
- Default:
json
- Sets the format for logs printed.
- Enum
LOG_LEVEL
- Enum
debug
info
warn
warning
error
dpanic
panic
fatal
- Default:
info
- Level of logs that are printed. Defined by
zap
log levels.
- Enum
PORT
- String
- Default:
8080
- Port to run the health and metrics endpoint on.
STATUS_CRON_SCHEDULE
- String
- Default:
*/10 * * * *
(every 10 minutes) - Cron string to define how often to check the status of the stream if status checking is enabled.
RESOLUTION
- Enum
720p
1080p
2k
- Default:
720p
- What resolution the RTMP stream should be.
- Enum
RTMP_URL
- String
- Default:
rtmp://localhost:1935/live/stream
- RMTP endpoint to send the stream to. If using a service such as Twitch, be sure your stream key is at the end of it.
TWITCH_CHANNEL
- String
- 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. - Requires the
TWITCH_CLIENT_ID
andTWITCH_CLIENT_SECRET
to be defined to work properly.
TWITCH_CLIENT_ID
- String
- Twitch Client ID obtained from the Twitch Developer Console for checking stream status if the
TWITCH_CHANNEL
environmental variable is set. - Checking for the stream status on Twitch will not work without this and
TWITCH_CLIENT_SECRET
being set. - For more information about registering an app on Twitch, see the developer documentation.
TWITCH_CLIENT_SECRET
- String
- Twitch Client ID obtained from the Twitch Developer Console for checking stream status if the
TWITCH_CHANNEL
environmental variable is set. - Checking for the stream status on Twitch will not work without this and
TWITCH_CLIENT_ID
being set. - For more information about registering an app on Twitch, see the developer documentation.
WEBPAGE_REFRESH_INTERVAL
- String
- If set to a positive integer, the browser will automatically refresh the webpage at the specified interval in seconds. This can help prevent issues with stale content or memory leaks during long streaming sessions, as a memory usage can build if the
WEBPAGE_URL
location has memory leaks. - If not set or set to an invalid value, automatic refresh is disabled.
WEBPAGE_URL
- String
- Default:
https://google.com
- The webpage to stream.
Cobbled together by Zac Lovoy (aka BigZoz on Twitch). If you're interested in some of other streaming adjacent stuff, check out YarpBot or the Filters Extension for Twitch.
Or whatever; I'm not your dad.