Architecture Overview
Segra uses a layered architecture to interact with OBS:Core Components
OBSService - Backend/Recorder/OBSService.cs
OBSService - Backend/Recorder/OBSService.cs
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 Integration
ObsKit.NET Integration
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)
- Signal handling for events (hooked/unhooked, replay saved)
GPU Vendor Detection
GPU Vendor Detection
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:Check OBS Installation
Verifies that
obs.dll exists in the application directory. If missing, Segra downloads the appropriate OBS version from Segra’s CDN.Detect Available Encoders
Queries OBS for available video encoders and stores them in application state for the settings UI.
Recording Pipeline
Scene Composition
Segra creates a layered scene with multiple capture sources:Layer Order (bottom to top):
- Display Capture (fallback layer)
- Game Capture (primary layer when hooked)
- Audio sources (microphones, desktop audio, game audio)
Game Capture Hooking
Segra uses OBS’s game capture plugin to hook directly into games: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 featureGame + Discord
Records game audio and Discord voice chat separately
- 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
UsesRecordingOutput to record the entire gaming session to an MP4 file:
Replay Buffer
UsesReplayBuffer to maintain a rolling buffer in memory:
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:Display Capture Methods
Segra supports two display capture methods:| Method | Technology | Performance | Compatibility |
|---|---|---|---|
| DXGI | Desktop Duplication API | High | Windows 8+ |
| WGC | Windows Graphics Capture | Very High | Windows 10 1903+ |
| Auto | Selects best available | - | All versions |