Skip to content

IP cameras

Skynet can serve live video from cameras at your site — a pier cam aimed at the mount, an all-sky cam, a dome/room cam — to anyone with permission to view the telescope, straight in the browser.

The design follows the same posture as SkyNode itself: your site only ever makes outbound connections. A publisher on your LAN pulls each camera once and pushes it out to a UNC-operated streaming origin (stream.skynetgo.org), which fans the stream out to as many web viewers as connect. No inbound firewall rule, no port-forward, no static IP — the same as the SkyNode link you already run. Your uplink carries exactly one stream per camera regardless of how many people are watching.

This page covers the owner tasks: adding an IP Camera (in SkyNode, which also issues itself the camera’s publish credentials), publishing it (with SkyNode, which runs and supervises the publisher for you, or without it, with ffmpeg and/or Blue Iris), and its owner settings, which you edit on its SkyNode card or on the website.

IP Cameras attach to either a telescope (e.g. a pier cam) or an observatory (e.g. an all-sky or room cam), and are added in SkyNode, like every other device: on the node, open Settings → IP Cameras and use Add IP Camera.

Field Notes
Name A label, e.g. “Dome cam”.
Role pier (aimed at the telescope), all_sky, finder/guide, room/interior, or other.
Vendor Optional, e.g. “Amcrest”.
Host The camera’s address on the LAN. It is the camera’s one address: the control driver reaches it there, and so does the video when it comes from the camera.
Mounted on The node’s telescope, or its observatory for a site camera (shown when the node has both).

You do not enter a URL. SkyNode registers the IP Camera on Skynet, which creates its webrtc + hls playback streams, then asks Skynet for the camera’s publish secret and stores the publish URL in the Windows credential store, so nobody copies a secret. If that second step fails (the hub was unreachable for a moment), the IP Camera is kept and its card offers Issue publish URL. SkyNode keeps the hardware fields (name, role, vendor, host) current, from the card’s IP Camera section, and Remove IP Camera deletes it. You do not say whether the camera pans, tilts or zooms: once its control driver connects, SkyNode reports what the driver found, and the card shows it.

A new IP Camera starts with its IR light Always off and every other owner setting at its default (private, not primary, owner-only control); change them on its card or on the website (§1.1).

1.1 Owner settings, in SkyNode and on the website

Section titled “1.1 Owner settings, in SkyNode and on the website”

The owner settings live on the IP Camera’s Skynet record, so they follow the camera to whichever SkyNode drives it. SkyNode edits them like every other device’s settings, in the Owner settings section of the camera’s card; the website edits the same settings, under the telescope’s or observatory’s IP Cameras tab, where every IP Camera plays live and Settings opens them:

Setting Notes
IR light The light policy, see The IR light and the policy.
Allow the light while a task runs inside the closed dome Only under On only inside a closed dome.
Home preset Where a PTZ camera returns when its last control session ends.
Control access Owner (today’s rule). Public is reserved for public PTZ control and does nothing yet.
Publicly viewable Off by default. See Making a camera public.
Order and Primary The order on the Live wall, and the IP Camera shown first for its parent.

Changing an owner setting needs manage permission on the telescope or observatory: owners hold it implicitly, and so does the SkyNode bound to that telescope or observatory, the same trust that already lets the node open the dome. A changed IR light asks for confirmation first, in SkyNode as on the website, and the confirmation says what the new policy lets the light do. On the website the hardware fields show read-only, since SkyNode sets them, and the settings dialog stays for an IP Camera that no SkyNode drives (one published by an ffmpeg script, §3); public viewing and the Live wall order are the website’s concern too. Delete is for an IP Camera whose SkyNode is gone: SkyNode removes the IP Cameras it manages itself.

SkyNode issues its own. For an IP Camera published outside SkyNode (an ffmpeg script, Blue Iris), the website’s Publish credentials issues a new publish secret and shows, once, everything the publisher needs:

Item Example What it is
SRT URL srt://stream.skynetgo.org:8890?streamid=publish:<uid>:publisher:<secret>&passphrase=<passphrase>&pbkeylen=16 The full URL to paste into a publisher.
Host / Port stream.skynetgo.org / 8890 The streaming origin’s SRT ingest.
Stream ID publish:<uid>:publisher:<secret> Identifies the camera path and carries the secret.
Passphrase (10–79 chars) Encrypts the SRT link. The same passphrase is used for all publishers; the per-camera secret is what actually authorizes this camera.
Publish secret (per-camera) The credential the origin checks. Embedded in the Stream ID.

The publish secret is shown only once and stored only as a hash — it cannot be retrieved again. Copy the SRT URL now. Issuing credentials again replaces the secret: whatever publishes with the old one (a SkyNode included) is refused from its next connect. To issue a new URL to a camera SkyNode publishes, use Issue publish URL on its card in SkyNode instead.

The SRT URL already encodes everything the publisher needs, so copying that single field is normally sufficient.

By default a camera is visible only to people with view permission on its telescope or observatory. Turning on Publicly viewable opts the camera into anonymous viewing: it appears in the Cameras view of the public Live page, and anyone on the internet can watch it without signing in.

Two things to know before flipping the switch:

  • The parent must also be public. A public camera on a private telescope or observatory stays private — the flag only takes effect when the parent is itself publicly visible. The camera list shows a hint when a camera is opted in but its parent isn’t.
  • Anyone means anyone. There is no rate of viewers you approve — while the flag is on, the stream is watchable worldwide, around the clock. Think carefully before making a room/interior camera public: people working at the site will be on the internet. Sky, dome, and pier views are usually the right candidates.

Publishing is unaffected — the same single stream leaves your site regardless of how many people watch (fan-out happens on Skynet’s streaming origin), so making a camera public costs you no extra upload bandwidth.

If a SkyNode runs at your site, let it publish the camera. The node fetches a pinned ffmpeg build itself, runs one supervised publisher per camera, and restarts a publisher that exits, stalls or loses its camera, with a retry delay that starts at one second and never exceeds a minute. There is nothing else to install and no script to edit, and the stream comes back on its own after a camera reboot, a network blip or a host reboot.

On the node, open Settings → IP Cameras. Every IP Camera on the node’s telescope, and on its observatory, appears as a card; Add IP Camera adds one (§1).

  1. Install ffmpeg once, from the strip at the top of the page. SkyNode downloads the pinned build (gyan.dev’s GPL essentials build; the license and the source are hosted beside it), verifies its checksum, and re-verifies it on every start. If you already run your own ffmpeg, enter its path in Override path instead; the node probes it for the srt protocol and the libx264 and libopus encoders.
  2. Managed by (observatory cameras only). A site camera reaches every node at the observatory, so exactly one should publish it. A telescope node defaults to Another node publishes it; switch it to This SkyNode publishes it on the one PC that should, typically the observatory node on the Blue Iris box. A telescope’s own camera is always published by that telescope’s node.
  3. Camera login. The camera’s one login, its username and password (the password goes into the Windows credential store and is never shown again). The control driver uses it, and so does the video when it comes from the camera.
  4. Video source. From the IP Camera: only the RTSP port and path, since the host and login are the camera’s (leave the path empty for the driver’s default, /cam/realmonitor?channel=1&subtype=0 on an Amcrest or Dahua camera). From a re-stream (Blue Iris or an NVR): the re-stream’s own host, port, path and login. USB webcam: click List devices, pick the video device (and a microphone if you want audio), then the capture format, frame size and frame rate. The card shows the RTSP address it will read, without the password. Under Advanced: leave Video on Copy for an H.264 source and pick Encode to H.264 only for an H.265 camera (webcams are always encoded); Audio, where Opus plays everywhere (see Audio); and the timeouts.
  5. Publish URL. SkyNode stored it when it added the IP Camera; Issue publish URL gets a new one from Skynet (it replaces the old secret and restarts the publisher). It is in the credential store and never shown. Set still takes a URL pasted from the website’s Publish credentials, for a camera added before SkyNode could issue its own.
  6. Publish. The one switch that publishes the camera, whenever SkyNode runs. The publisher starts within a second and the pill beside the switch reads Publishing. Open the camera on the website; live video appears within a second or two. Saving any of the camera’s settings restarts its publisher on them.

Test source probes the camera and shows what it sends (codec, resolution, whether it carries audio). Test publish sends a three-second test pattern to the origin at full verbosity, the quickest way to tell a blocked outbound UDP port 8890 from a wrong URL. The last fifty lines of ffmpeg’s output are on the card.

What the pill means.

State Meaning
Off Publish is off, or another node publishes this camera.
Needs setup Enabled, but something is missing; the card says what. Nothing is retried until you fix it.
Starting ffmpeg is running; no video has left the node yet.
Publishing Video is leaving the node.
Retrying The publisher ended; the card shows the attempt, the countdown to the next try and the last line ffmpeg printed. A hint says whether the camera (source) or the origin (origin) is the likely cause.
Stopping The publisher is being stopped (Publish switched off, a setting saved, or SkyNode quitting).

The retry delay doubles from one second to a minute and resets after ten minutes of healthy publishing, so a camera that is off for the night is probed once a minute rather than hammered. If a second publisher pushes the same camera (a leftover script, or two nodes both set to publish it), the origin refuses the newcomer and that node shows the origin hint: stop the other publisher.

The website shows its own pill on every camera card and tile, written by the streaming origin rather than by the node: Live while the origin is receiving the stream (confirmed once a minute), otherwise Last seen … with how long ago it last was, or Never seen.

The node writes each camera’s ffmpeg output to %LOCALAPPDATA%\SkyNode\logs\ip-camera-<uid>.log. Publishing stops when SkyNode quits and resumes when it starts; the publishers are the last thing stopped, so you can watch the dome close.

A SkyNode can also drive a camera: pan, tilt and zoom, presets, and the infrared light. Once the node has a control driver connected to the camera, the camera’s player on the website shows a control overlay, and the node’s own Controls page gains a Cameras tab with the same buttons. Both go through the node under the same rules as every other manual command: from the website you need the camera’s own control lease, on the node you need MANUAL control. The overlay offers Take control, which takes that one camera’s lease for as long as the player is open, renewing a three-minute lease that lapses within three minutes of closing it; it never takes the telescope and never pauses its automation, so the telescope that drives the camera keeps observing. Control on an IP Cameras page opens the camera’s own console, a window with its video and its controls; opening it takes nothing, and its Take control takes the camera’s lease, kept while the window is open. A telescope’s own camera is also covered by that telescope’s lease: while you hold it in the telescope console you drive the telescope’s cameras under it, and while another user holds it nobody else can take one of them. A site camera (an all-sky or exterior camera that belongs to the observatory) is covered by no telescope’s lease, even the one whose SkyNode drives it: in the telescope console its dock offers its own Take control, kept for as long as the console is open. Only one person controls a camera at a time; while someone else holds its lease, the controls say so. Pan, tilt and zoom work under any control session, even while an observation runs or a shutdown lock is held: a moving camera cannot spoil a frame, and the home preset puts it back. The IR light is different: a shutdown interlock or an observation that is driving the hardware refuses it, and on top of that it follows the camera’s light policy, below.

On the card’s Control section:

  1. Driver. Pick Amcrest / Dahua CGI for an Amcrest or Dahua camera (the cameras at the UNC sites): it drives the IR light as well as PTZ, and learns at connect whether the camera can move at all, so a fixed pier camera gets only the light control and a PTZ unit gets the arrows too. Pick ONVIF for any other camera that speaks ONVIF (most do). The driver reaches the camera at its host with its login (§2, step 3), so its options, shown on the card under the driver, are only its own: the port, HTTPS, the channel, PTZ (auto, yes or no), box zoom, the PTZ speed and the timeout for Amcrest / Dahua; the port, the media profile, whether the IR-cut filter controls the light and the timeout for ONVIF. Save options keeps them.
  2. Connect. Once a Connect succeeds, the node connects the camera on its own whenever SkyNode starts and reconnects it after a failure, as it does every device. Changing the driver or its options asks for one more Connect first; Disconnect keeps the camera disconnected until the next Connect or restart.
  3. PTZ. Whether the camera pans, tilts or zooms is what the connected driver finds: SkyNode writes it to the camera’s Skynet record, and the card shows it beside the driver’s PTZ option, which overrides the answer when a camera gets it wrong (auto treats a fixed camera as no PTZ).

The buttons follow what the connected driver reports, never a setting on the website. The state line under the Connect button says what the driver found: PTZ when the camera can move, which IR modes it can set, the presets it read, and whether it is moving. The node re-reads the presets about once a minute, so a preset added, renamed or deleted on the camera shows up within a minute without reconnecting. Two presets the camera gives the same name are listed as Name and Name (2), and each moves to its own position; the first keeps the plain name, so a home preset that names it keeps working. Prefer a plain name for the home preset: the numbering follows the camera’s order and shifts if a preset is renamed. The arrows move the camera for as long as they are held and stop on release; if the release never arrives (the connection dropped, the page closed) the camera stops on its own within about three seconds. Speed chooses how fast pan and tilt move, Slow, Normal or Fast (a quarter, half or all of the camera’s speed); the browser remembers the choice, and zoom is not affected. A PTZ camera slows its own panning as it zooms in, so Fast at full zoom-out and Slow when zoomed in is the usual pairing. On an Amcrest or Dahua camera the driver’s PTZ speed setting (1 to 8) is the camera’s full speed, the cap that Fast reaches.

Drag a box to zoom. On a camera that supports it, drag a box on the video while you have control, in the website player or on the console’s Cameras tab in the Single view: the camera centers on the box and zooms in until the box fills the picture. A plain click does nothing. The state line shows box zoom when the driver offers it. An ONVIF camera offers it when the camera itself says it can (its PTZ settings list the field-of-view spaces); the node’s log says which at connect. An Amcrest or Dahua camera does not report it, so the driver’s Box zoom setting decides: leave it at auto (off) until the camera has been seen to obey a test request, then set it to yes; no keeps it off.

The IR light. What the control can do depends on the camera’s API:

Driver IR modes offered Why
ONVIF Off, Auto ONVIF reaches only the camera’s IR-cut filter: Off puts the camera in day mode, Auto lets it switch by light level. Most cameras switch their illuminator with the filter, but some do not, so the control is offered only once you tick IR-cut filter controls the light in the driver’s settings. There is no way to force the light on through ONVIF.
Amcrest / Dahua CGI On, Off, Auto The CGI API addresses the illuminator itself. The camera keeps a light setting for each of its day, night and normal profiles: Off switches the light off in every one of them, so it stays off whichever profile the camera runs. A camera lights its IR LEDs only in black and white, so On also sets the profile it runs to black and white, and Off puts back the color setting it found.

A camera whose node runs an older SkyNode build refuses every camera command as not supported by this SkyNode build; update the node. A site camera that several nodes can see is driven by the node whose card says This SkyNode publishes it; the other nodes answer this node does not drive that camera.

Every camera has an IR light policy on its Skynet record, edited on its SkyNode card or on the website (§1.1), after a confirmation that says what the new policy lets the light do. The SkyNode that drives the camera enforces it on every poll, so the light follows the rule whether or not anyone is watching, and a request to switch it on that the rule does not allow is refused in place with the reason: the light is disabled on this camera, the telescope is observing, the dome is open. The rungs, strictest first:

Policy The light may be switched on SkyNode switches it off
Always off (a new IP Camera’s setting) never, by anyone, the node’s own operator included whenever it is found on, within one poll
Off under automation while someone holds the telescope: its manual-control lease (in the telescope console), or MANUAL control on the node; a camera’s own lease is not enough, so a site camera on this rung can only be lit by the operator at its node whenever automation is in control
On only inside a closed dome under any control session on the camera (its own lease included) while every enclosure covering the camera is observed closed, and no task is running on the telescope (unless you allow the light during tasks for this camera) when a covering shutter is no longer observed closed, or a task starts
Unmanaged under any control session on the camera never: SkyNode does not touch the light

Always off is the setting for a site where the light must never come on, which at CTIO means every camera: an open slit lights the whole site, and a lit dome ruins frames. Software bounds a camera that reboots into its own automatic mode to one poll, not to zero, so where “never” is the requirement also disable the illuminator in the camera’s own configuration, in every profile (day, night and normal), and physically if the risk warrants it. The policy is the second layer, not the only one.

A managed policy (anything but Unmanaged) never accepts the camera’s own Auto mode or leaves the camera in it: that is a light that switches itself on at dusk. The website and the node offer Auto only for an unmanaged camera, and a managed camera found in Auto is written to Off.

Under On only inside a closed dome, an unknown or stale shutter reading counts as open, a pier camera is covered by its telescope’s dome and a site camera by every dome at the observatory, and a camera with no covering enclosure cannot use this rung (it runs as Off under automation, and the node’s card says so). Closed-dome nights are calibration nights: the pier camera’s light is unavailable while each bias and dark sequence runs, unless you tick Allow the light while a task runs inside the closed dome, which is only safe for an imager whose shutter is light-tight. Off is the default because the node cannot know the shutter.

A control session holds one camera: the node’s MANUAL control holds every camera it drives, a telescope’s lease holds that telescope’s own cameras, and a camera’s own lease holds that camera. When the last control session on a camera ends, the light goes off and the operator’s request is forgotten (the next session asks again); if the camera can move and has a home preset, it returns there thirty seconds later, never while a session is active, and a failed return is retried the next time a session ends. On the node, the IP Cameras card shows the policy in force beside the IR light setting, and the state line says why the light is held.

The policy lives in one place, the Skynet record. SkyNode builds before the end of October 2026 had a node-local switch, Always off on this node, that could only tighten it; the switch is gone. On its first start, a newer SkyNode writes Always off to the record of every camera that had the switch on and whose policy was anything else, and keeps the light off on the node until Skynet has that policy (if Skynet cannot be reached, it keeps it off and tries again at the next sync). To keep a different policy on such a camera, turn the switch off before updating, or set the policy again afterwards.

Sites without a SkyNode, or that prefer their own tooling, publish with ffmpeg directly, with the auto-restarting script below, or with Blue Iris as the aggregator. The requirements are the same either way: the origin accepts SRT only (not inbound RTSP/RTMP), the video must be H.264 (§5), and the audio must be Opus to play on WebRTC (§4).

A publisher takes each camera’s video on your LAN and pushes it outbound to the SRT URL as MPEG-TS. ffmpeg does this in one line. Something on your side has to speak SRT to the origin — ffmpeg is that bridge.

ffmpeg publishes two kinds of source:

  • An RTSP camera (an IP camera or a Blue Iris re-stream) that already emits H.264 — forwarded untouched with -c:v copy, no CPU/GPU cost. This is the common case.
  • A USB / DirectShow webcam plugged into the control PC (Windows). Webcams output MJPEG or raw frames, not H.264, so ffmpeg encodes the video to H.264 before pushing — see USB webcams.

Paste your camera’s RTSP URL and the SRT URL from the website’s Publish credentials (§1.2):

Terminal window
ffmpeg -rtsp_transport tcp -i "rtsp://USER:PASS@192.168.1.50:81/cam1" `
-c:v copy -c:a libopus -b:a 64k -ac 1 -f mpegts `
"srt://stream.skynetgo.org:8890?streamid=publish:<uid>:publisher:<secret>&passphrase=<passphrase>&pbkeylen=16"

-c:v copy forwards the video untouched (no re-encode, no CPU/GPU cost). -c:a libopus transcodes the audio to Opus — see Audio for why. Then open the camera on the telescope/observatory page; you should see live video within a second or two.

A plain USB webcam on the control PC works too — it just needs a couple of changes from the RTSP recipe, because a webcam outputs MJPEG/raw frames rather than H.264.

1. Find the device’s exact name and its capture modes:

Terminal window
ffmpeg -list_devices true -f dshow -i dummy
ffmpeg -f dshow -list_options true -i video="Webcam C110"

Copy the video device string exactly as printed. -list_options shows the resolutions, frame rates, and pixel formats it supports.

2. Capture and encode to H.264, then push:

Terminal window
ffmpeg -f dshow -rtbufsize 100M -vcodec mjpeg -framerate 30 -video_size 640x480 -i video="Webcam C110" `
-c:v libx264 -preset veryfast -tune zerolatency -pix_fmt yuv420p -g 60 -b:v 2M `
-an -f mpegts `
"srt://stream.skynetgo.org:8890?streamid=publish:<uid>:publisher:<secret>&passphrase=<passphrase>&pbkeylen=16"

Three things differ from an RTSP camera, and they matter:

  • -c:v libx264 … -pix_fmt yuv420p (encode, not copy). WebRTC needs H.264/yuv420p and the origin doesn’t transcode, so the webcam’s MJPEG/raw frames must be encoded here. -g 60 sets a keyframe every ~2 s.
  • Quote the device name. -i video="Webcam C110" — the quotes keep the space in the name together, or ffmpeg fails with “Could not find video device with name [Webcam]”. If a build rejects -vcodec mjpeg, drop it and use -framerate 15 (the raw mode is slower).
  • The webcam is single-consumer. Quit any app already showing it (YawCam, Windows Camera, a browser tab) first, or ffmpeg reports “Could not open video device”.

-an streams video only; add -c:a libopus -b:a 64k -ac 1 and an :audio=<mic name> on the input if you want a microphone (see Audio).

Many cameras — auto-restarting PowerShell script

Section titled “Many cameras — auto-restarting PowerShell script”

For more than one camera, this PowerShell script runs one ffmpeg publisher per camera and automatically restarts any that stop — a camera reboot, a network blip, or a dropped connection no longer means restarting things by hand. Each entry sets Type = 'rtsp' or Type = 'usb', so one script drives a mix of RTSP cameras and USB webcams; the script picks copy-vs-encode and the right input flags per type. Each camera’s ffmpeg output goes to logs\<Name>.log next to the script, so the console stays readable. Fill in the $Cameras list and run it; press Ctrl+C to stop every publisher.

Terminal window
<#
Resilient ffmpeg SRT publisher for RTSP cameras and USB webcams. A supervisor
loop restarts any publisher that exits, so streams recover on their own. Run:
powershell -ExecutionPolicy Bypass -File .\start-cameras.ps1
Ctrl+C stops every publisher. Per-camera fields:
- Name : label for console messages and the log file name.
- Type : 'rtsp' or 'usb'.
- Srt : the full SRT URL from the website's "Publish credentials" (single-quoted,
so '&' isn't treated specially).
- Audio : 'opus' (default, transcode), 'copy' (HLS-only), or 'none'.
rtsp: Source (H.264 RTSP URL); Reencode = $true for an H.265 source.
usb : Device (exactly as -list_devices prints it), InputCodec ('mjpeg' or
'' for raw), FrameSize, FrameRate, VideoBitrate, optional AudioDevice.
#>
$FfmpegPath = 'ffmpeg' # or the full path, e.g. 'C:\ffmpeg\bin\ffmpeg.exe'
# Supervisor timing, and the RTSP read timeout (microseconds) that makes ffmpeg
# exit on a stalled feed. The matching ffmpeg option is detected below.
$PollSeconds = 3
$RestartDelaySeconds = 5
$ReadTimeoutMicros = 5000000
$Cameras = @(
@{ Name = 'pier'; Type = 'rtsp' # RTSP camera / Blue Iris re-stream
Source = 'rtsp://USER:PASS@192.168.1.50:81/cam1'
Srt = 'srt://stream.skynetgo.org:8890?streamid=publish:UID-1:publisher:SECRET-1&passphrase=PASSPHRASE&pbkeylen=16' }
@{ Name = 'allsky'; Type = 'usb' # USB / DirectShow webcam (encoded here)
Device = 'Webcam C110'; InputCodec = 'mjpeg'; FrameSize = '640x480'; FrameRate = 30; VideoBitrate = '2M'; Audio = 'none'
Srt = 'srt://stream.skynetgo.org:8890?streamid=publish:UID-2:publisher:SECRET-2&passphrase=PASSPHRASE&pbkeylen=16' }
)
$ffmpeg = (Get-Command $FfmpegPath -ErrorAction SilentlyContinue).Source
if (-not $ffmpeg) {
Write-Error "ffmpeg not found ('$FfmpegPath'). Install it or set `$FfmpegPath to ffmpeg.exe."
exit 1
}
# The RTSP socket-timeout option differs by ffmpeg version: -timeout (modern) or
# -stimeout (older). Detect which this build exposes; only needed for RTSP.
$TimeoutOption = $null
if ($ReadTimeoutMicros -gt 0 -and ($Cameras | Where-Object { $_.Type -ne 'usb' })) {
try {
$rtspHelp = (& $ffmpeg -hide_banner -h demuxer=rtsp 2>&1 | Out-String)
foreach ($opt in 'timeout', 'stimeout') {
if ($rtspHelp -match "(?m)^\s*-$opt\s") { $TimeoutOption = "-$opt"; break }
}
} catch { }
if (-not $TimeoutOption) {
Write-Warning 'No RTSP socket-timeout option found; running without stall detection (auto-restart still works).'
}
}
$logDir = if ($PSScriptRoot) { Join-Path $PSScriptRoot 'logs' } else { Join-Path (Get-Location) 'logs' }
if (-not (Test-Path $logDir)) { New-Item -ItemType Directory -Path $logDir | Out-Null }
# WebRTC carries only Opus/G711 and silently drops AAC/mp2, so 'opus' (transcode)
# is the safe default; 'copy' plays on the HLS fallback only; 'none' strips audio.
function Get-AudioArgs($Cam) {
$mode = if ($Cam.Audio) { $Cam.Audio } else { 'opus' }
switch ($mode) {
'copy' { @('-c:a', 'copy') }
'none' { @('-an') }
default { @('-c:a', 'libopus', '-b:a', '64k', '-ac', '1') }
}
}
# H.264 encode flags shared by USB capture and RTSP re-encode. yuv420p + H.264 is
# what WebRTC needs; -g sets a keyframe every ~2s so WebRTC/HLS segment cleanly.
function Get-EncodeArgs($Fps = 30, $Bitrate = '2M') {
@('-c:v', 'libx264', '-preset', 'veryfast', '-tune', 'zerolatency',
'-pix_fmt', 'yuv420p', '-g', "$([int]$Fps * 2)", '-b:v', $Bitrate)
}
function Start-Publisher {
param($Cam)
if ($Cam.Type -eq 'usb') {
# DirectShow capture. Wrap the device spec in literal quotes: Start-Process
# won't quote the space in "Webcam C110" itself, so ffmpeg would otherwise
# see only "video=Webcam" ("Could not find video device"). Webcams aren't
# H.264, so the video is encoded here.
$inputArgs = @('-f', 'dshow', '-rtbufsize', '100M')
if ($Cam.InputCodec) { $inputArgs += @('-vcodec', $Cam.InputCodec) }
if ($Cam.FrameSize) { $inputArgs += @('-video_size', $Cam.FrameSize) }
if ($Cam.FrameRate) { $inputArgs += @('-framerate', "$($Cam.FrameRate)") }
$spec = "video=$($Cam.Device)"
if ($Cam.Audio -ne 'none' -and $Cam.AudioDevice) { $spec += ":audio=$($Cam.AudioDevice)" }
$inputArgs += @('-i', "`"$spec`"")
$fps = if ($Cam.FrameRate) { [int]$Cam.FrameRate } else { 30 }
$bitrate = if ($Cam.VideoBitrate) { $Cam.VideoBitrate } else { '2M' }
$vArgs = Get-EncodeArgs $fps $bitrate
$aArgs = if ($Cam.AudioDevice) { Get-AudioArgs $Cam } else { @('-an') }
}
else {
$inputArgs = @()
if ($TimeoutOption) { $inputArgs += @($TimeoutOption, "$ReadTimeoutMicros") }
$inputArgs += @('-rtsp_transport', 'tcp', '-i', $Cam.Source)
# Forward H.264 untouched (no CPU/GPU cost) unless the source is H.265,
# which WebRTC can't decode — then transcode to H.264.
if ($Cam.Reencode) {
$bitrate = if ($Cam.VideoBitrate) { $Cam.VideoBitrate } else { '2M' }
$vArgs = Get-EncodeArgs 30 $bitrate
} else {
$vArgs = @('-c:v', 'copy')
}
$aArgs = Get-AudioArgs $Cam
}
$ffArgs = @('-hide_banner', '-loglevel', 'warning') + $inputArgs + $vArgs + $aArgs + @('-f', 'mpegts', $Cam.Srt)
$log = Join-Path $logDir ("{0}.log" -f $Cam.Name)
# -NoNewWindow avoids the SmartScreen block on a downloaded ffmpeg.exe;
# stderr is redirected to the per-camera log.
return Start-Process -FilePath $ffmpeg -ArgumentList $ffArgs `
-NoNewWindow -PassThru -RedirectStandardError $log
}
# Default a Name for any entry that omits one so log files don't collide.
$n = 0
foreach ($cam in $Cameras) { $n++; if (-not $cam.Name) { $cam.Name = "cam$n" } }
$publishers = @(foreach ($cam in $Cameras) {
[pscustomobject]@{ Name = $cam.Name; Cam = $cam; Process = (Start-Publisher -Cam $cam); Restarts = 0; NextStartAt = $null }
})
Write-Host ("Publishing {0} camera(s). Logs in {1}. Press Ctrl+C to stop." -f $publishers.Count, $logDir)
try {
while ($true) {
Start-Sleep -Seconds $PollSeconds
$now = Get-Date
foreach ($p in $publishers) {
if ($p.Process -and -not $p.Process.HasExited) { continue } # healthy
if ($null -eq $p.NextStartAt) {
$why = Get-Content (Join-Path $logDir ("{0}.log" -f $p.Name)) -Tail 1 -ErrorAction SilentlyContinue
$suffix = if ($why) { " - $($why.Trim())" } else { '' }
Write-Warning ("[{0}] {1} stopped{2}; restarting in {3}s" -f $now.ToString('HH:mm:ss'), $p.Name, $suffix, $RestartDelaySeconds)
$p.NextStartAt = $now.AddSeconds($RestartDelaySeconds)
}
elseif ($now -ge $p.NextStartAt) {
$p.Process = Start-Publisher -Cam $p.Cam; $p.Restarts++; $p.NextStartAt = $null
Write-Host ("[{0}] {1} restarted (restart #{2})" -f $now.ToString('HH:mm:ss'), $p.Name, $p.Restarts)
}
}
}
}
finally {
Write-Host 'Stopping all publishers...'
foreach ($p in $publishers) {
if ($p.Process -and -not $p.Process.HasExited) { Stop-Process -Id $p.Process.Id -Force -ErrorAction SilentlyContinue }
}
}

The socket-timeout flag makes ffmpeg exit if the feed stalls instead of hanging on a half-open connection — that exit is what lets the supervisor detect the failure and restart it. Its name differs by ffmpeg version (-timeout on modern builds, -stimeout on older ones), so the script detects which your build supports; set $ReadTimeoutMicros = 0 to disable it.

On Linux/macOS, wrap the publisher in a restart loop for the same behavior:

Terminal window
while true; do
# -timeout is the modern RTSP socket-timeout option; older ffmpeg uses -stimeout.
ffmpeg -hide_banner -loglevel warning -timeout 5000000 \
-rtsp_transport tcp -i "rtsp://USER:PASS@192.168.1.50:81/cam1" \
-c:v copy -c:a libopus -b:a 64k -ac 1 -f mpegts \
"srt://stream.skynetgo.org:8890?streamid=publish:UID:publisher:SECRET&passphrase=PASSPHRASE&pbkeylen=16"
echo "stream exited; restarting in 5s" >&2
sleep 5
done

For survival across host reboots, run the publisher as a service or scheduled task (Task Scheduler on Windows, a systemd unit on Linux) so it starts on boot; the loop above keeps it alive within a session.

Section titled “Blue Iris (recommended for multiple cameras)”

Blue Iris is a Windows NVR that can ingest many cameras (RTSP, ONVIF, vendor protocols) and re-stream each one as a clean, uniform H.264 RTSP feed. If you have more than a couple of cameras, running Blue Iris as the aggregator is the easiest setup:

  • One place to manage every camera, with recording, motion alerts, and a consistent RTSP URL per camera regardless of the camera’s own quirks.
  • You can normalize resolution/codec there, so the ffmpeg publisher just does -c:v copy against a predictable H.264 stream.
  • Point the ffmpeg publisher (§3) at Blue Iris’s RTSP re-stream URL instead of the camera directly — everything else is identical.

In this arrangement Blue Iris is the RTSP source aggregator and ffmpeg is the SRT bridge to Skynet. Make sure the Blue Iris re-stream you pull is the H.264 profile, and that audio is enabled on that camera in Blue Iris if you want sound (its default re-stream profile may be video-only).

Native camera streams (Blue Iris is optional)

Section titled “Native camera streams (Blue Iris is optional)”

Blue Iris is not required. If a camera exposes its own RTSP stream — almost all do — you can point the ffmpeg publisher (§3) straight at it:

rtsp://USER:PASS@<camera-ip>:<port>/<path>

Pulling natively is fully supported and removes a moving part. The requirements are the same as above, verified per camera instead of once at the aggregator:

  • The stream the publisher pulls must be H.264 video (use the camera’s H.264 profile/sub-stream, not H.265).
  • Audio, if you want it on WebRTC, gets transcoded to Opus by the publisher (-c:a libopus) — the camera can send AAC; ffmpeg converts it.
  • The camera must be reachable from the publisher on the LAN.

Use Blue Iris when you want central management/recording across many cameras; pull natively when you have a few cameras and just want them live.

Audio requires the most attention, because the streaming origin does not transcode: whatever codec you publish is what viewers must be able to play, and the two playback paths accept different audio codecs:

  • WebRTC (the primary in-browser player) carries Opus or G711 only. It silently drops AAC — and also drops mp2, which is what the MPEG-TS muxer picks by default if you forget to set -c:a.
  • HLS (the fallback) carries AAC fine.

Most IP cameras emit AAC audio. With AAC, video plays but the WebRTC viewer has no sound and reports no error. The options:

You want… Use Result
Audio on the WebRTC player -c:a libopus -b:a 64k -ac 1 Transcodes the camera’s audio to Opus. Works everywhere. Recommended.
Audio, HLS-only viewing -c:a copy Passes AAC through. Plays on HLS, not WebRTC.
No audio at all -an Strips audio entirely.

Audio transcoding is inexpensive relative to video, so -c:a libopus is a safe default even though the video stays -c:v copy.

Check what your source actually sends first:

Terminal window
ffprobe -rtsp_transport tcp "rtsp://USER:PASS@192.168.1.50:81/cam1"

If the dump shows no Audio: stream, the camera/feed isn’t sending audio at all — enable the camera’s microphone (and, in Blue Iris, that camera’s audio) before any ffmpeg flag can help. If it shows Audio: aac, transcode to Opus as above.

WebRTC playback requires H.264 video, and the origin does not transcode, so what you publish must be H.264 (SkyNode’s card applies the same rules with its Video setting):

  • RTSP cameras — publish the camera’s H.264 profile/sub-stream, forwarded with -c:v copy (the codec you pull is the codec viewers get). Don’t publish H.265/HEVC — browsers can’t decode it over WebRTC. If a camera only offers H.265, set Reencode = $true to transcode it to H.264, at some CPU cost.
  • USB webcams — the publisher encodes the webcam’s MJPEG/raw frames to H.264 for you (-c:v libx264 -pix_fmt yuv420p); see USB webcams.