Skip to main content
Segra’s recording engine is built on top of Open Broadcaster Software (OBS) using ObsKit.NET, a modern C# wrapper that provides type-safe access to OBS’s powerful recording capabilities.

Architecture Overview

Segra uses a layered architecture to interact with OBS:

Core Components

The OBSService class is the central hub for all recording operations. It manages:
  • OBS context initialization and shutdown
  • Video encoder configuration (NVENC, AMF, QSV, x264)
  • Audio source management (microphones, desktop audio, game audio)
  • Scene composition with game capture and display capture
  • Recording outputs (sessions, replay buffer, hybrid mode)
ObsKit.NET provides a fluent, type-safe API for interacting with OBS. Segra uses it for:
  • Video/audio encoder creation
  • Source management (GameCapture, MonitorCapture, AudioInputCapture)
  • Output handling (RecordingOutput, ReplayBuffer)
  • .NET events for OBS callbacks (Hooked/Unhooked on GameCapture, Saved/Stopped on ReplayBuffer, Stopped on RecordingOutput) — replaces the older raw ConnectSignal(OutputSignal.*) handles
  • Global hotkey registration via Obs.RegisterHotkey(...) (see Hotkeys)
Segra tracks the minimum ObsKit.NET version it needs in Segra.csproj.
Segra automatically detects your GPU vendor (NVIDIA, AMD, Intel) to select the optimal hardware encoder:
  • NVIDIA: NVENC (H.264/HEVC)
  • AMD: AMF (H.264/HEVC)
  • Intel: QSV (H.264/HEVC)
  • Fallback: x264 (software encoding)

Initialization Process

When Segra starts, it initializes OBS through several stages:
1

Check OBS Installation

Verifies that obs.dll exists in the application directory. If missing, Segra downloads the appropriate OBS version from Segra’s CDN. Current builds bundle OBS 30.1.1, 31.1.2, 32.1.2, 32.2.1, and 32.2.2 with FFmpeg 9.0.1; the automatic default (when selectedOBSVersion is null) is the latest non-beta build.
2

Initialize OBS Context

Creates an OBS context with the fluent API:
3

Detect Available Encoders

Queries OBS for available video encoders and stores them in application state for the settings UI.
4

Start Game Detection

Begins monitoring Windows processes for game launches using WMI event watchers.

Recording Pipeline

Scene Composition

Segra creates a layered scene with multiple capture sources:
Layer Order (bottom to top):
  1. Display Capture (fallback layer)
  2. Game Capture (primary layer when hooked)
  3. Audio sources (microphones, desktop audio, game audio)

Game Capture Hooking

Segra uses OBS’s game capture plugin to hook directly into games:
Some applications are blacklisted by OBS and cannot be captured using game capture:
  • explorer.exe, chrome.exe, discord.exe, firefox.exe
  • Steam, Battle.net, Origin launchers
  • Windows system apps
Segra automatically falls back to display capture for these applications.

Audio Routing

Segra supports three audio output modes:

All Audio

Records all desktop audio sources (default behavior)

Game Only

Records only game audio using OBS’s capture_audio feature

Game + Discord

Records game audio and Discord voice chat separately
When game capture hooks successfully, Segra automatically:
  • Mutes desktop audio sources
  • Unmutes game audio and Discord sources (if enabled)
  • Switches back to desktop audio when the game unhooks

Encoder Configuration

Segra configures encoders based on user settings:

Recording Modes

Segra supports three recording modes, each using different OBS output types:

Session Recording

Uses RecordingOutput to record the entire gaming session to an MP4 file. Segra always attempts the Hybrid MP4 muxer (crash-resilient, chapter markers; OBS 30.2+) and transparently falls back to the plain ffmpeg muxer when the running OBS build doesn’t register mp4_output:

Replay Buffer

Uses ReplayBuffer to maintain a rolling buffer in memory:
Saves for network / slow storage back-stop on an internal timeout of up to 15 minutes so a stalled mux doesn’t leave the replay buffer permanently in a half-saved state.

Hybrid Mode

Runs both session recording and replay buffer simultaneously, allowing:
  • Full session recording with bookmarks
  • Instant replay saving during gameplay
  • Separate file organization

Separate Audio Tracks

Segra can record up to 6 audio tracks using OBS’s multi-track support:
1

Track 1 - Master Mix

All audio sources combined (always present)
2

Tracks 2-6 - Individual Sources

Up to 5 separate audio sources (microphones, game audio, Discord)
Separate audio tracks enable advanced editing workflows where you can independently control game audio, microphone, and Discord volumes in post-production.

Display Capture Methods

Segra supports three display capture methods (Auto is the default and picks the best of the two backends below for your hardware):

Resource Management

Segra follows strict resource disposal patterns to prevent memory leaks:
1

Stop Outputs

Gracefully stop recording/replay buffer with 30-second timeout
2

Dispose Scene

Remove and dispose all scene items and the scene itself
3

Dispose Sources

Release game capture, display capture, and audio sources
4

Clear Encoders

Encoders are automatically disposed by ObsKit.NET when outputs stop
Never dispose OBS resources while they are still in use. Always stop outputs before disposing sources and encoders.

Log Processing

OBS log messages are processed asynchronously using channels to prevent blocking:
This prevents OBS’s internal logging thread from being blocked by Serilog’s file I/O operations.

ObsKit.NET

Modern C# wrapper for OBS Studio

OBS Studio

Free and open source recording software

Performance

Optimize recording performance

Troubleshooting

Common issues and solutions