Video Shaders
A modern web application for real-time video processing and shader effects, built with Svelte 5 and powered by WebCodecs API for hardware-accelerated video decoding.
š¬ Features
- Hardware-Accelerated Video Decoding: Uses WebCodecs API for efficient H.264 video processing
- Real-Time Shader Effects: WebGL/Three.js powered video rendering with custom shaders
- Interactive Controls: Tweakpane UI for real-time parameter adjustment
- Advanced MP4 Support: MP4Box.js integration for robust video file parsing
- Browser-Native Performance: Direct VideoFrame-to-WebGL texture uploads
šļø Architecture
- Frontend: Svelte 5 with runes
- Video Processing: WebCodecs API + MP4Box.js
- Rendering: Three.js + WebGL
- UI: Tweakpane for interactive controls
- Media Utils: Mediabunny library
š Quick Start
Prerequisites
- Node.js 18+
- Modern browser with WebCodecs support (Chrome 94+, Edge 94+)
Installation
# Clone the repository
git clone <repository-url>
cd svelte-video-shaders
# Install dependencies
pnpm install
# Start development server
pnpm run dev
Usage
- Upload Video: Click the upload button in the Tweakpane UI
- Select MP4 File: Choose an H.264 encoded MP4 video
- Apply Shaders: Use the controls to adjust shader parameters in real-time
- Enjoy: Watch your video with custom shader effects!
š ļø Development
Development Server
pnpm run dev
# Open in browser automatically
pnpm run dev -- --open
Building for Production
pnpm run build
Preview Production Build
pnpm run preview
š Project Structure
svelte-video-shaders/
āāā src/
ā āāā lib/
ā ā āāā ShaderPlayer.svelte # Main video rendering component
ā ā āāā VideoControls.svelte # Tweakpane UI controls
ā āāā routes/
ā ā āāā +page.svelte # Main application page
ā āāā app.html
āāā mediabunny/ # Video processing utilities
āāā static/ # Static assets
āāā DEVELOPMENT_PLAN.md # Detailed development notes
āāā package.json
š§ Technical Details
Video Processing Pipeline
- File Upload ā Tweakpane UI file dialog
- MP4 Parsing ā MP4Box.js extracts video track + AVC config
- WebCodecs Setup ā VideoDecoder configured with H.264 parameters
- Frame Decoding ā Hardware-accelerated decoding to VideoFrames
- WebGL Upload ā Direct VideoFrame-to-texture using
gl.texSubImage2D
- Shader Rendering ā Three.js renders with custom fragment shaders
Key Technologies
- WebCodecs API: Browser-native video decoding
- MP4Box.js: Robust MP4 file parsing and AVC configuration extraction
- Three.js: WebGL abstraction for shader rendering
- Tweakpane: Interactive parameter controls
- Svelte 5: Reactive UI with runes
Browser Compatibility
- Chrome 94+: Full WebCodecs support
- Edge 94+: Full WebCodecs support
- Firefox: Limited (WebCodecs behind flag)
- Safari: Not supported (WebCodecs not implemented)
š Documentation
š Debugging
For detailed debugging information, check:
- Browser Console: Look for
[Tracer]
prefixed logs
- WebCodecs Support: Ensure browser supports VideoDecoder
- File Format: Use H.264 encoded MP4 files
- Development Plan: Check
DEVELOPMENT_PLAN.md
for current issues
š¤ Contributing
Contributions are welcome! Please check the Development Plan for current tasks and known issues.
š License
MIT License - Feel free to use this project for your own video shader experiments!
Note: This project requires a modern browser with WebCodecs API support for hardware-accelerated video decoding.