โก Ultra-fast native GPU hardware-accelerated video decoding and playback engine for Java via Windows Media Foundation & DirectX.
FastVideoPlayer delivers low-overhead, kernel-direct video decoding and frame presentation for the FastJava ecosystem. Powered by Windows Media Foundation (WMF) via IMFSourceReader and hardware DXVA2 acceleration, it decodes MP4, H.264, WMV, and HEVC video streams directly into off-heap direct ByteBuffer instances with a sub-30 MB RAM footprint and zero per-frame Garbage Collection allocations.
import fastvideoplayer.FastVideoPlayer;
import java.io.File;
import java.nio.ByteBuffer;
public class QuickStart {
public static void main(String[] args) {
File videoFile = new File("sample.mp4");
// 1. Open video stream via hardware-accelerated Media Foundation reader
try (FastVideoPlayer player = FastVideoPlayer.open(videoFile)) {
System.out.printf("Video: %dx%d @ %.2f FPS (%.2fs)%n",
player.getWidth(), player.getHeight(),
player.getFrameRate(), player.getDurationSeconds());
// 2. Pre-allocate direct off-heap buffer for 32-bit RGBA frames
int frameBytes = player.getWidth() * player.getHeight() * 4;
ByteBuffer frameBuffer = ByteBuffer.allocateDirect(frameBytes);
// 3. Start playback
player.play();
// 4. Ingest uncompressed video frames into Direct2D / DirectX textures
while (player.readFrame(frameBuffer)) {
// Pass direct buffer pointer directly to GPU texture without memory copy...
frameBuffer.clear();
}
}
}
}- Quick Start
- Why FastVideoPlayer?
- Key Features
- Real-World Use Cases
- Architecture Overview
- Performance Benchmarks
- API Quick Reference
- Technical Demos & Benchmarks
- Installation
- Documentation
- Platform Support
- License
- Related Projects
Traditional video playback libraries in Java burden applications with massive runtime footprints, complex external installations, or severe GC pauses:
- Heavyweight LibVLC / VLCJ: Requires bundling 100+ MB of external VLC binaries, creates fragile native window-parenting hierarchies, and introduces inter-process frame copy latencies.
- JavaFX Media Stacks: Depends on extensive modular JavaFX runtimes and bundled GStreamer packages that inflate idle memory.
- Bulky FFmpeg JNI Wrappers: Requires bundling entire suites of multi-format FFmpeg decoders, bloating jar artifacts.
FastVideoPlayer replaces all three with a kernel-direct, OS-native pipeline:
| Feature | VLCJ / LibVLC | JavaFX Media | FastVideoPlayer |
|---|---|---|---|
| Underlying Engine | External VLC installation | GStreamer wrapper | Windows Media Foundation (WMF / DXVA2) |
| External Binaries | > 120 MB (VLC binaries) | Heavyweight JavaFX | Lightweight native DLL (~100 KB) |
| RAM Footprint | 150 MB โ 300 MB | 100 MB โ 250 MB | < 30 MB (Ultra-Lightweight) |
| GPU Acceleration | Complex manual setup | Limited | Native DXVA2 / Direct3D 11 Hardware Decoding |
| Per-Frame GC Churn | High (byte conversions) | Moderate | Zero GC (Direct Off-Heap Buffers) |
| Codec Requirement | Bundled / System VLC | Platform GStreamer | Zero (Native OS Codecs: H.264, MP4, WMV, HEVC) |
- โก GPU Hardware-Accelerated Decoding: Utilizes DXVA2 and D3D11 hardware transforms inside Windows Media Foundation for fluid 60+ FPS playback.
- ๐ชถ Sub-30 MB RAM Footprint: Minimal memory footprint without bloated third-party media runtimes or intermediate video pipelines.
- ๐จ Direct GPU Texture Streaming: Decodes frames directly into uncompressed 32-bit RGB/RGBA direct
ByteBuffercontainers ready for Direct2D, DirectX 11, FastVulkan, and FastGraphics. - โฑ๏ธ Sub-Millisecond Seek & Scrubbing: Instantaneous timestamp-accurate seeking using native 100-nanosecond Media Foundation presentation times.
- ๐ก๏ธ Zero Runtime GC Pressure: Reads video frames into pre-allocated direct memory buffers, completely eliminating Garbage Collection pauses during playback.
- ๐ฆ Seamless FastJava Interop: Packaged with
FastCorenative library auto-extraction and clean lifecycle management viaAutoCloseable.
- ๐ฌ UI Video Backgrounds & Cinematic Cuts: High-performance animated banners, video splash screens, and video widgets in FastGUI or native desktop apps.
- ๐ฎ Game Cutscenes & Texture Playback: Feed decoded video frames straight into Vulkan or DirectX render targets without CPU stalling.
- ๐บ Media Players & Video Preview: Ultra-lightweight desktop video playback tools and instant thumbnail/frame scrubbing.
- ๐ Computer Vision & Video Analysis: Stream video frames at maximum hardware decoding speed directly into native tensor and image pipelines.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Media File (.mp4, .wmv) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Windows Media Foundation (WMF) โ
โ โข Hardware Decoding (DXVA2 / D3D11) โ
โ โข Direct Color Conversion (RGB32 / RGBA) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Direct JNI Memory Copy
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Direct ByteBuffer โ
โ โข Off-Heap Frame Destination โ
โ โข Zero JVM Garbage Collection (0 KB Churn) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Zero-Copy Texture Ingestion
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GPU Presentation Pipeline โ
โ Direct2D โข DirectX 11 โข FastVulkan โข FastGUI โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Measured on Windows 11 (x64), Intel Core i5-1135G7, JDK 21.0.12.1 using OpenJDK JMH:
| Benchmark / Operation | Throughput (ops/ms) | Ops per Second | Latency | Memory Churn |
|---|---|---|---|---|
directBufferFrameAccess (1080p Frame Window) |
~447,761 ops/ms | > 447 Million | < 3 ns | 0 bytes |
| Hardware Video Decode (1080p60) | Native 60+ FPS | Fluid Real-Time | Hardware Bound | 0 bytes (Off-heap) |
| Method | Return Type | Description | Path |
|---|---|---|---|
FastVideoPlayer.open(file) |
FastVideoPlayer |
Opens a video stream from a File handle. | Reference |
FastVideoPlayer.open(path) |
FastVideoPlayer |
Opens a video stream from an absolute/relative path. | Reference |
play() |
void |
Starts or resumes video playback. | Reference |
pause() |
void |
Pauses video playback. | Reference |
seek(timestampSeconds) |
void |
Seeks immediately to timestamp in seconds. | Reference |
readFrame(directBuffer) |
boolean |
Decodes next 32-bit RGBA frame into direct buffer. | Reference |
getWidth() / getHeight() |
int |
Returns native video dimensions in pixels. | Reference |
getDurationSeconds() |
double |
Returns total stream duration in seconds. | Reference |
getFrameRate() |
double |
Returns native video frame rate (FPS). | Reference |
getCurrentPosition() |
double |
Returns current playback position in seconds. | Reference |
close() |
void |
Stops playback and destroys native decoder resources. | Reference |
For complete method signatures and details, refer to docs/REFERENCE.md.
| Case | Java Example | Launcher | Description |
|---|---|---|---|
| Showcase Demo | Demo.java | run-demo.bat |
End-to-end video stream initialization, telemetry inspection, and sequential frame decoding. |
| JMH Microbenchmark Suite | Benchmark.java | run-benchmark.bat |
High-throughput direct buffer frame access and off-heap memory throughput measurements. |
Add JitPack to your <repositories> and include the dependency in your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- FastVideoPlayer Engine -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastVideoPlayer</artifactId>
<version>0.1.0</version>
</dependency>
<!-- FastCore Platform Infrastructure -->
<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:FastVideoPlayer:0.1.0'
implementation 'com.github.andrestubbe:FastCore:0.1.0'
}Download the latest pre-compiled standalone JAR directly from GitHub Releases:
- ๐ฆ FastVideoPlayer-0.1.0.jar (The Core Video Engine)
- โ๏ธ FastCore-0.1.0.jar (Native Platform Loader)
- REFERENCE.md: Exhaustive API method descriptions and native buffer memory contracts.
- PHILOSOPHY.md: Design principles: zero-allocation, WMF hardware acceleration, and sub-30MB footprint.
- COMPILE.md: Compilation guide for MSVC native DLL and Maven packaging.
- ROADMAP.md: Planned milestones, audio synchronization, and Linux/macOS backends.
- CHANGELOG.md: Release history and version updates.
| Platform | Architecture | Status | Subsystem / Hardware Decoder |
|---|---|---|---|
| Windows 10 / 11 | x64 |
โ Fully Supported | Windows Media Foundation (IMFSourceReader / DXVA2) |
| Linux | x64 / ARM64 |
๐ง Planned | Native VA-API / DRM backend in development |
| macOS | Apple Silicon / x64 |
๐ง Planned | Native AVFoundation / VideoToolbox backend in development |
MIT License โ See LICENSE file for details.
- FastVideoStream โ Low-overhead hardware-accelerated desktop video streaming and RTMP ingestion
- FastAudioPlayer โ Ultra low-latency WASAPI and DirectSound native audio playback engine
- FastAudioProcess โ Zero-allocation audio DSP, resamplers, and timeline mixing
- FastScreen โ DXGI desktop duplication and ultra-fast hardware frame capture
- FastWindow โ Ultra-fast Win32 native window engine and HWND surface manager
- FastCore โ Native library loader, FFM gateway, and platform abstraction layer
Part of the FastJava Ecosystem โ Making the JVM faster. Small package. Maximum speed. Zero bloat. ๐๐