DEV Community

Cover image for How I Automated OBS Streaming with JavaScript (And Saved Our Office Hours of Setup Time)
Kurt De Austria
Kurt De Austria

Posted on • Edited on

2 1 1 1

How I Automated OBS Streaming with JavaScript (And Saved Our Office Hours of Setup Time)

📌 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.

👉 GitHub Repo


🚨 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_Instances\OBS1  
C:\OBS_Instances\OBS2
Enter fullscreen mode Exit fullscreen mode

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',
  }
});
Enter fullscreen mode Exit fullscreen mode

🚀 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 and Promise.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

Portfolio | GitHub

Sentry image

Make it make sense

Make sense of fixing your code with straight-forward application monitoring.

Start debugging →

Top comments (2)

Collapse
 
nevodavid profile image
Nevo David

man now thats a slick setup, cuts out so much wasted time. id be way less stressed if my own stuff reset like that after a crash.

Collapse
 
kurtchan profile image
Kurt De Austria

right?? imagine setting up multiple streams and all of a sudden it all crashed.

Tiger Data image

🐯 🚀 Timescale is now TigerData: Building the Modern PostgreSQL for the Analytical and Agentic Era

We’ve quietly evolved from a time-series database into the modern PostgreSQL for today’s and tomorrow’s computing, built for performance, scale, and the agentic future.

So we’re changing our name: from Timescale to TigerData. Not to change who we are, but to reflect who we’ve become. TigerData is bold, fast, and built to power the next era of software.

Read more

👋 Kindness is contagious

Dive into this thoughtful piece, beloved in the supportive DEV Community. Coders of every background are invited to share and elevate our collective know-how.

A sincere "thank you" can brighten someone's day—leave your appreciation below!

On DEV, sharing knowledge smooths our journey and tightens our community bonds. Enjoyed this? A quick thank you to the author is hugely appreciated.

Okay