Streamlink2osp is a tool that enables users to stream video content from various sources using Streamlink directly to an Open Streaming Platform (OSP) instance. It is distributed as a Docker image and can be easily run on any machine that has Docker installed.
Warning The paragraph below is generated by the GitHub Copilot AI. It is not guaranteed to be correct, but it sounds nice.
OSP is a great tool for streaming video content to the web, but it does not support streaming from sources other than RTMP. This is where streamlink2osp comes in. It allows users to stream video content from various sources to OSP using Streamlink.
Note This section has been generated with ChatGPT and manually edited afterwards.
Have you ever wanted to pause or rewind a Twitch livestream while it's playing, only to find out that Twitch does not offer this functionality? Or have you come across a streamer who doesn't provide VoDs or has them disabled? This can be frustrating, especially if you miss something important or want to review a section of the stream later.
One solution to this problem is to re-stream the Twitch livestream to an Open Streaming Platform (OSP) instance. By doing so, you can pause, rewind, or even re-watch the livestream at your own pace. Additionally, re-streaming to OSP acts as a recorder, allowing you to capture the livestream in its entirety, even if the streamer doesn't offer VoDs.
This is where streamlink2osp
comes in. By using this tool, you can easily download the Twitch livestream using
Streamlink, and then upload it to your OSP instance. With configurable environment variables, you can customize the
quality, disable ads or reruns, and even retry failed streams. So why wait? Start re-streaming your favorite Twitch
livestreams to OSP today!
Even though Twitch added the ability to pause and rewind livestreams in 2021, it was a limited test phase of 1 month1. And it seems like a streamer have had to manually enable this feature2, meaning they can leave it disabled as well.
The Docker image for streamlink2osp can be found on both DockerHub and GitHub Container Registry:
- DockerHub:
docker pull panzer1119/streamlink2osp:latest
- GitHub Container Registry:
docker pull ghcr.io/panzer1119/streamlink2osp:latest
To use streamlink2osp, simply run the following command:
docker run --rm -d -e OSP_RTMP_FQDN=<FQDN> -e OSP_STREAM_KEY=<KEY> -e LIVESTREAM_URL=<URL> panzer1119/streamlink2osp:latest
When a livestream interrupts or your internet connection drops the container will exit.
To prevent this from happening, you can set the restart policy to on-failure
, unless-stopped
or always
:
docker run --rm -d --restart unless-stopped -e OSP_RTMP_FQDN=<FQDN> -e OSP_STREAM_KEY=<KEY> -e LIVESTREAM_URL=<URL> panzer1119/streamlink2osp:latest
That way, the container will automatically restart when it exits. So you don't have to worry about missing out on your favorite livestreams.
I recommend using on-failure
as it will only restart the container if it exits with a non-zero exit code:
docker run --rm -d --restart on-failure -e OSP_RTMP_FQDN=<FQDN> -e OSP_STREAM_KEY=<KEY> -e LIVESTREAM_URL=<URL> panzer1119/streamlink2osp:latest
Note That way, the container will not restart if
the livestream ends gracefully, oryou stop it manually.
You can set the maximum number of restarts with the on-failure:max-retries
option to not record forever:
docker run --rm -d --restart on-failure:5 -e OSP_RTMP_FQDN=<FQDN> -e OSP_STREAM_KEY=<KEY> -e LIVESTREAM_URL=<URL> panzer1119/streamlink2osp:latest
Environment Variable | Description | Example Value |
---|---|---|
LIVESTREAM_URL |
The URL of the video stream to be downloaded using Streamlink. | https://www.twitch.tv/mychannel |
OSP_RTMP_FQDN |
The FQDN of the OSP RTMP instance to which the video stream should be uploaded. | osp.example.com |
OSP_STREAM_KEY |
The secret stream key to authenticate with the OSP instance. How to find your Stream Key. |
Environment Variable | Description | Default Value | Example Value |
---|---|---|---|
STREAMLINK_QUALITY |
The desired video quality to download the stream in. | best |
720p |
STREAMLINK_TWITCH_DISABLE_ADS |
A flag to disable ads when downloading Twitch streams. If set to true, ads will be skipped. | true |
false |
STREAMLINK_TWITCH_DISABLE_RERUNS |
A flag to disable reruns when downloading Twitch streams. If set to true, reruns will be skipped. | true |
false |
STREAMLINK_RETRY_STREAMS |
The time (in seconds) to wait before attempting to fetch again. | Single try | 120 |
STREAMLINK_RETRY_MAX |
The maximum number of retries to attempt to fetch a stream. Fetch will retry infinitely if this is zero or unset. | None | 0 |
STREAMLINK_RETRY_OPEN |
The maximum number of retries to attempt to open a stream after a successful fetch. | Single try | 2 |
STREAMLINK_ADDITIONAL_OPTIONS |
Additional options to be passed to Streamlink. | "" |
--twitch-low-latency |
FFMPEG_OPTIONS |
Options to be passed to FFmpeg. The input is always set to stdin , and the OSP Stream URL is always appended at the end. |
-c copy -f flv |
-c copy -f flv |
OSP_RTMP_PORT |
The Port of the OSP RTMP instance. Currently can't be proxied to another Port. | 1935 |
1935 |
OSP_DELETE_HLS_FILES_ON_NEW_STREAM |
Deletes old HLS files if the current stream is not the same as before or a new one. Enables TWITCH_ENABLE_API automatically. Requires the tmpfs directory to be mounted at /tmpfs . |
false |
true |
OSP_DELETE_HLS_FILES_AFTER_STREAM_END |
Deletes old HLS files after the stream has ended. Enables TWITCH_ENABLE_API automatically. Requires the tmpfs directory to be mounted at /tmpfs . |
false |
true |
OSP_LIVE_HLS_DIRECTORY |
Directory (inside the container) where the HLS files are stored. | /tmpfs/live |
/tmp/live |
TWITCH_ENABLE_API |
Enables the usage of the Twitch API to retrieve data about the livestream. | false |
true |
TWITCH_CLIENT_ID |
App Client ID to authenticate with the Twitch API. Optional, tries to retrieve it automatically with the TWITCH_BEARER_TOKEN if enabling TWITCH_ENABLE_API . How to create an App. |
"" |
hof5gwx0su6owfnys0yan9c87zr6t |
TWITCH_BEARER_TOKEN |
Access Token to authenticate with the Twitch API. Required if enabling TWITCH_ENABLE_API . How to get your OAuth2 Token. |
"" |
jostpf5q0uzmxmkba9iyug38kjtgh |
TWITCH_USER_NAME |
Twitch User name of streamer. Required if enabling TWITCH_ENABLE_API . |
"" |
mychannel |
DEBUG |
Enables debug output. | false |
true |