Skip to content

About

๐ŸŽž๏ธ Ultra-Fast GPU Hardware-Accelerated Video Player & Decoding Engine for Java via Windows Media Foundation & DirectX.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

FastVideoPlayer 0.1.0 โ€” Ultra-Fast Hardware-Accelerated Video Player Engine for Java

Status License: MIT Java Platform JitPack


โšก 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.


Quick Start

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();
            }
        }
    }
}

Table of Contents


Why FastVideoPlayer?

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)

Key Features

  • โšก 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 ByteBuffer containers 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 FastCore native library auto-extraction and clean lifecycle management via AutoCloseable.

Real-World Use Cases

  • ๐ŸŽฌ 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.

Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    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       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Performance Benchmarks

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)

API Quick Reference

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.


Technical Demos & Benchmarks

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.

Installation

Option 1: Maven (Recommended via JitPack)

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>

Option 2: Gradle (via JitPack)

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.andrestubbe:FastVideoPlayer:0.1.0'
    implementation 'com.github.andrestubbe:FastCore:0.1.0'
}

Option 3: Direct Download (Pre-built JAR)

Download the latest pre-compiled standalone JAR directly from GitHub Releases:

  1. ๐Ÿ“ฆ FastVideoPlayer-0.1.0.jar (The Core Video Engine)
  2. โš™๏ธ FastCore-0.1.0.jar (Native Platform Loader)

Documentation

  • 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 Support

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

License

MIT License โ€” See LICENSE file for details.


Related Projects

  • 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. ๐Ÿš€๐Ÿ“‹

About

๐ŸŽž๏ธ Ultra-Fast GPU Hardware-Accelerated Video Player & Decoding Engine for Java via Windows Media Foundation & DirectX.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages