📌 TL;DR
I built a tool that automatically launches two OBS instances, connects to different RTSP streams, applies AI-based filters, and starts streaming to different RTMP servers — all with one click using Node.js + OBS WebSocket API.
🚨 The Problem We Had
At our workplace, we operate multiple mini PCs in a remote location — each with 2 camera feed — and we needed to livestream them 24/7 to different platforms. The steps were tedious:
- Manually open two OBS windows
- Set up each RTSP stream
- Apply AI detection filters (via obs-detect plugin)
- Configure different RTMP destinations
- Hit “Start Streaming” on both
Each time the PC was rebooted, all configurations had to be re-applied manually. Why initiate a reboot? To prevent thermal buildup and memory leaks—continuous 24/7 operation can lead to system degradation and reduced performance over time.
As you can imagine, this wasted time, was error-prone, and not scalable.
💡 My Eureka Moment: OBS + JavaScript
After some research, I discovered that OBS has a WebSocket API — and there’s an official JavaScript library called obs-websocket-js
. That opened up a world of automation.
From there, I built a Node.js script that could:
✅ Launch multiple OBS portable instances
✅ Detect if a media source exists, or create one
✅ Auto-apply AI filters from the obs-detect plugin
✅ Configure each stream’s RTMP server and key
✅ Start streaming — no clicks required
🔧 How It Works (In Simple Terms)
I created two folders:
C:OBS_InstancesOBS1
C:OBS_InstancesOBS2
Each folder holds a portable OBS installation. Basically, a copy of the original OBS directory and pasted on both instances. A Python script launches both and Node.js connects to them via WebSocket.
Using obs.call()
, I set up:
- Media Source: RTSP input from the camera
- Filters: Object detection + pixelation
- Output: RTMP settings
- Streaming: Triggered automatically
All configurations are driven by a .env
file so you don’t touch the code to change URLs, ports, or stream keys.
✨ The Result
Now, with a single double-click (autorun.exe
), both OBS instances:
- Launch silently
- Auto-connect to their respective RTSP feeds
- Apply detection filters
- Stream to different RTMP destinations
If either OBS crashes or the PC restarts, we just click again — no more 10-minute manual setup every time.
📦 Project Structure
-
obs.js
– Node script that configures OBS via WebSocket -
autorun.py
– Optional Python launcher to wrap both processes -
.env
– Environment variables (RTSP, ports, RTMP keys) -
autorun.exe
– Compiled version of the launcher
➡️ Full source code: GitHub Repo
📹 About obs-detect
Plugin
Each mini PC has obs-detect
installed — an AI plugin that identifies people in video streams and blurs them out using either pixelation or Gaussian blur.
In the automation script, I added a function to apply these filters automatically:
await obs.call('CreateSourceFilter', {
sourceName: 'CameraSource',
filterName: 'Detect',
filterKind: 'ai-detect',
filterSettings: {
ObjectCategory: 'Person',
MaskingOptions: true,
MaskingType: 'Pixelate',
BlurPixelSize: 20,
Dilation: 10,
AdvancedSettings: true,
ContinousTracking: true,
Model: 'Medium',
}
});
🚀 Try It Yourself
If you’re running multi-stream surveillance or broadcasting cameras remotely — automating OBS with JavaScript is a game changer.
Whether you’re in security, content creation, or a hybrid office setup, this approach saves time and guarantees consistency.
🧠 What I Learned
- OBS is more scriptable than most people realize.
- Combining Python (for process control) and Node.js (for logic) worked well.
- Using
.env
andPromise.all()
made the solution clean and scalable. - Writing tools to remove repetitive tasks = huge ROI for small teams.
Thanks for reading!
Feel free to fork the repo, suggest improvements, or reach out if you’re solving something similar. Happy streaming! 🎥
—
Kurt Chan