Skip to content

feat: Hardware Acceleration (v1.16.0)#36

Merged
superninja-app[bot] merged 1 commit intomainfrom
feature/hardware-acceleration
Mar 8, 2026
Merged

feat: Hardware Acceleration (v1.16.0)#36
superninja-app[bot] merged 1 commit intomainfrom
feature/hardware-acceleration

Conversation

@superninja-app
Copy link
Copy Markdown
Contributor

@superninja-app superninja-app bot commented Mar 8, 2026

Summary

Adds comprehensive hardware acceleration features with GPU management, hardware encoding/decoding support, and performance benchmarking.

Features Added

GPU Management

  • Multi-GPU support with detection and management
  • Vendor support: NVIDIA (NVENC/NVDEC), AMD (AMF), Intel (QuickSync), Apple (VideoToolbox)
  • Auto GPU selection based on performance
  • Real-time GPU statistics (utilization, temperature, memory, power)

Hardware Encoder Support

  • NVIDIA NVENC: H.264, HEVC, AV1
  • AMD AMF: H.264, HEVC
  • Intel QuickSync: H.264, HEVC, AV1
  • Apple VideoToolbox: H.264, HEVC
  • Software fallback: x264, x265, SVT-AV1

Encoder Settings

  • Presets: P1-P7 (NVENC), Speed/Balanced/Quality (AMF)
  • Rate control: CBR, VBR, CQP, Lookahead modes
  • Multi-pass encoding: Quarter and full resolution
  • B-frames support with configurable count
  • Keyframe interval configuration

Hardware Decoder

  • NVIDIA NVDEC, AMD, Intel QuickSync, Apple VideoToolbox
  • Low latency mode for real-time streaming
  • Configurable maximum decoder instances

GPU Benchmark

  • Test encoding performance with custom settings
  • Resolution options: 720p, 1080p, 1440p, 4K
  • Frame rate options: 30, 60, 120 fps
  • Metrics: FPS, latency, GPU usage, power, quality score

Files Added

  • src/types/hardwareAcceleration.ts - Type definitions
  • src/services/HardwareAccelerationService.ts - Service layer
  • src/hooks/useHardwareAcceleration.ts - React hook
  • src/components/HardwareAccelerationPanel.tsx - UI component
  • src/components/HardwareAccelerationPanel.css - Styling

Testing

  • Build passes successfully
  • TypeScript compilation clean

- Add HardwareAccelerationPanel component with GPU management
- Add HardwareAccelerationService for GPU detection and monitoring
- Add useHardwareAcceleration hook for state management
- Support NVIDIA, AMD, Intel, Apple hardware encoders/decoders
- Add GPU benchmarking functionality
- Add real-time GPU statistics monitoring
- Support encoder presets, rate control, multi-pass encoding
@superninja-app superninja-app bot merged commit fd76255 into main Mar 8, 2026
5 checks passed
@superninja-app superninja-app bot deleted the feature/hardware-acceleration branch March 8, 2026 15:43
return null;
}

const sessionId = `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;

Check failure

Code scanning / CodeQL

Insecure randomness High

This uses a cryptographically insecure random number generated at
Math.random()
in a security context.

Copilot Autofix

AI about 1 month ago

In general, to fix insecure randomness in Node.js, replace uses of Math.random() in security-sensitive contexts with a cryptographically secure PRNG, such as crypto.randomBytes, and encode the result as a string (hex/base64/url-safe) as needed. Avoid homegrown number conversions that introduce bias.

For this specific code, the best fix with minimal functional change is to keep the existing session-<timestamp>-<randomSuffix> format but generate the random suffix using Node’s crypto module instead of Math.random(). We can generate, say, 6–8 random bytes with crypto.randomBytes, encode them as a base-36 or hex string, and truncate to 9 characters to preserve approximate length and appearance. This will produce an unpredictable session ID while keeping the structure and usage of sessionId unchanged.

Concretely, in src/services/HardwareAccelerationService.ts:

  • Add an import for Node’s crypto module at the top of the file (without altering existing imports).
  • Replace the Math.random().toString(36).substr(2, 9) expression on line 357 with a call that derives a base-36 string from crypto.randomBytes. For example:
    • const randomSuffix = parseInt(crypto.randomBytes(6).toString('hex'), 16).toString(36).slice(0, 9);
    • And then: const sessionId = `session-${Date.now()}-${randomSuffix}`;
  • All other logic for session creation, storage, and return remains unchanged.
Suggested changeset 1
src/services/HardwareAccelerationService.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/services/HardwareAccelerationService.ts b/src/services/HardwareAccelerationService.ts
--- a/src/services/HardwareAccelerationService.ts
+++ b/src/services/HardwareAccelerationService.ts
@@ -23,6 +23,7 @@
   DEFAULT_HARDWARE_ACCELERATION_CONFIG,
   DEFAULT_HARDWARE_ENCODER_SETTINGS
 } from '../types/hardwareAcceleration';
+import * as crypto from 'crypto';
 
 // ============================================================================
 // EVENT EMITTER
@@ -354,7 +355,8 @@
       return null;
     }
 
-    const sessionId = `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
+    const randomSuffix = parseInt(crypto.randomBytes(6).toString('hex'), 16).toString(36).slice(0, 9);
+    const sessionId = `session-${Date.now()}-${randomSuffix}`;
     
     const session: EncodingSession = {
       id: sessionId,
EOF
@@ -23,6 +23,7 @@
DEFAULT_HARDWARE_ACCELERATION_CONFIG,
DEFAULT_HARDWARE_ENCODER_SETTINGS
} from '../types/hardwareAcceleration';
import * as crypto from 'crypto';

// ============================================================================
// EVENT EMITTER
@@ -354,7 +355,8 @@
return null;
}

const sessionId = `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
const randomSuffix = parseInt(crypto.randomBytes(6).toString('hex'), 16).toString(36).slice(0, 9);
const sessionId = `session-${Date.now()}-${randomSuffix}`;

const session: EncodingSession = {
id: sessionId,
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant