Automatically start an OBS stream when the sun rises, and stop it when the sun sets
- Prerequisites
- Installation
- Configuration
- Running
- Download the latest release ZIP file for your operating system and CPU architecture.
- Extract all files from the ZIP file to a directory on your hard drive.
- On Linux and Mac OS, enable the executable bit on the program in a terminal.
- Download the latest release ZIP file for your operating system and CPU architecture.
- Extract the executable file (
sunsupstreamsup
or sunsupstreamsup.exe
) from the ZIP file to your installation directory. Do not overwrite your existing appsettings.json
.
- In the OBS menu bar, go to Tools βΊ WebSocket Server Settings.
- Ensure Enable WebSocket Server is checked.
- Set a password, or copy the generated password using Show Connect Info βΊ Server Password βΊ Copy.
- Press OK.
- In this program's installation directory, open
appsettings.json
in a text editor, and set the following properties in the given objects.
Name |
Values |
Description |
latitude |
[β90.0,90.0] |
Decimal degrees of your location north (+) or south (β) of the equator, used to determine the local time of sunrise and sunset |
longitude |
(β180.0,180.0] |
Decimal degrees of your location east (+) or west (β) of the prime meridian, used to determine the local time of sunrise and sunset |
timeZone |
IANA zone ID |
Time zone for your location, from IANA/Olson tzdb (e.g. "America/Los_Angeles" ), or omit this to use the computer's local zone |
minimumSunlightLevel |
SunlightLevel |
Stream will be up whenever the sunlight is at least this bright; one of Daylight (brightest), CivilTwilight (default, a little dark), NauticalTwilight (medium dark), AstronomicalTwilight (very dark), or Night (useless: always live, totally dark). For example, if you set this to CivilTwilight , the stream will start at civil dawn, continue through daylight, and stop at civil dusk. |
Name |
Values |
Description |
obsHostname |
FQDN or IP address |
The hostname of the computer running OBS, defaults to "localhost" for when OBS and this program are both installed on the same computer |
obsPort |
[1,65535) |
TCP port of the OBS WebSocket server, defaults to 4455 . If OBS is running on a different computer, any firewall protecting it must allow inbound TCP connections to this port. |
obsPassword |
string |
OBS WebSocket server password you set or copied, not URL-encoded, defaults to "" for when authentication is disabled |
replaceExistingStream |
boolean |
Set to false to only start a new stream if your channel is not already live, avoiding interruption of an existing broadcast, or true to always start the stream at the appointed time, even if that means hijacking the channel from a different broadcast. Defaults to false , which requires twitchUsername , twitchClientId , and twitchClientSecret to be provided in order to be effective. Set to true to disable this check, even if it's otherwise configured. |
twitchUsername |
string |
Your channel name on Twitch. Used when you want to avoid starting a new stream from OBS if you're already broadcasting to your channel from a different computer. Requires twitchClientId and twitchClientSecret to also be set. Defaults to null to always start a stream at the appointed time, even if the channel is already live. |
twitchClientId |
string |
Client ID you get after creating a Twitch OAuth application. The redirection URL can be http://localhost , and the Client Type must be Confidential. Defaults to null to always start a stream at the appointed time, even if the channel is already live. |
twitchClientSecret |
string |
Client secret you create on your Twitch application. Defaults to null to always start a stream at the appointed time, even if the channel is already live. |
- Make sure OBS is already running and ready to start a stream.
- Launch this program.
- The program will immediately start the stream if the sun is currently up and the stream is stopped.
- The program will continue running, starting and stopping the stream when the sun rises and sets.
- To stop this program, press Ctrl+C.