RealView.js is a high-performance, browser-native video decoder optimized for real-time streaming. Powered by the WebCodecs API and hardware acceleration, it delivers ultra-low latency and smooth playbackโno plugins required.
- ๐ฌ Real-time Video Decoding: Hardware-accelerated decoding using WebCodecs API
- โก MPEG-TS Demuxing: Complete MPEG Transport Stream parsing and demuxing
- ๐ Multi-stream Support: Handle multiple video streams simultaneously
- ๐ฑ Browser Native: Pure JavaScript implementation, no additional plugins required
- ๐ฏ Canvas Rendering: Direct canvas output with optional WebGL acceleration
- ๐ Real-time Statistics: Provides FPS, latency, and frame count metrics
npm install realview.js
import { Player } from 'realview.js';
const canvas = document.getElementById('videoCanvas') as HTMLCanvasElement;
const player = new Player('ws://localhost:8081/stream', canvas, {
width: 1280,
height: 720
});
player.play();
- Decode and display 1-64 video streams simultaneously
- Dynamic layout adjustment
- Real-time decoding statistics
- Fullscreen support
npx nx serve vanilla-js-video-wall
- 13 sample video sources for testing
- WebSocket streaming with H.264 encoding
- Real-time video delivery
npx nx serve multi-ws-streamer
- React component wrapper for the video decoder
- State management integration
- Event handling examples
npx nx serve react-demo
- Simple video decoding example
- Basic controls and statistics
- Performance monitoring
npx nx serve vanilla-js-demo
- Basic WebSocket video streaming
- FFmpeg integration for H.264 encoding
- Low-latency configuration
npx nx serve ws-streamer
new Player(url: string, canvas: HTMLCanvasElement, options?: PlayerOptions)
interface PlayerOptions {
enableWebGL?: boolean; // Enable WebGL rendering (default: false)
width?: number; // Canvas width (default: 1280)
height?: number; // Canvas height (default: 720)
}
play()
: Start video decoding and playbackpause()
: Pause decoding and renderingstop()
: Stop decoding and cleanupdestroy()
: Destroy player instancegetStats()
: Get decoding statisticsresize(width, height)
: Resize canvasfullscreen()
: Enter fullscreen modeexitFullscreen()
: Exit fullscreen mode
onPlaying
: Fired when decoding startsonPaused
: Fired when pausedonError
: Fired when decoding error occursonStopped
: Fired when stopped
interface PlayerStats {
fps: number; // Current decoding frame rate
latency: number; // Decoding latency (ms)
bytesReceived: number; // Bytes received from stream
frameCount: number; // Total frames decoded
}
- Chrome: 94+ (Full VideoDecoder support)
- Firefox: 113+ (Full VideoDecoder support)
- Safari: 16.4+ (Full VideoDecoder support)
- Edge: 94+ (Full VideoDecoder support)
Note: VideoDecoder API is required for video decoding functionality. Older browsers will not work.
- Decoding Latency: < 10ms typical
- Frame Rate: Supports up to 60fps and beyond
- CPU: Hardware-accelerated decoding when available
- Concurrency: Multiple player instances supported
- Node.js 18+
- npm or yarn
- FFmpeg (for demo streaming servers)
# Install dependencies
npm install
# Build core library
nx build core
# Run tests
nx test core
# Start demo servers
nx serve vanilla-js-video-wall
nx serve multi-ws-streamer
import { Player } from 'realview.js';
const canvas = document.getElementById('videoCanvas') as HTMLCanvasElement;
const player = new Player('ws://localhost:8081/video', canvas);
player.addEventListener('onPlaying', () => {
console.log('Video decoding started');
});
player.addEventListener('onError', (error) => {
console.error('Decoding error:', error);
});
player.play();
import { Player } from 'realview.js';
class VideoWall {
private players: Player[] = [];
constructor(container: HTMLElement, streamCount: number) {
for (let i = 0; i < streamCount; i++) {
const canvas = document.createElement('canvas');
const player = new Player(`ws://localhost:8081/stream-${i}`, canvas);
this.players.push(player);
container.appendChild(canvas);
}
}
startAll() {
this.players.forEach(player => player.play());
}
stopAll() {
this.players.forEach(player => player.stop());
}
}
Contributions are welcome! Please ensure:
- Follow existing code style
- Add appropriate tests
- Update relevant documentation
- Check third-party component credits
MIT License - see LICENSE
This project includes components from:
See ACKNOWLEDGMENTS.md for full details
RealView.js - High-performance video decoding for the browser ๐