AutoCut.AI now includes client-side video compression using FFmpeg WebAssembly, allowing users to compress videos directly in their browser before upload. This provides several benefits:
- Privacy: Videos never leave the user's device during compression
- Faster Uploads: Smaller file sizes mean quicker uploads
- Cost Efficiency: Reduced server bandwidth and processing costs
- Better UX: Automatic compression suggestions for large files
- FFmpeg.wasm: WebAssembly version of FFmpeg running in browser
- Streaming Compression: Process large videos without memory issues
- Quality Presets: Optimized settings for different use cases
- Progress Tracking: Real-time compression progress updates
// Main compression engine
const processor = new ClientVideoProcessor();
await processor.initialize();
const compressed = await processor.compressVideo(file, {
quality: 'medium',
maxSizeMB: 25,
onProgress: (progress) => console.log(`${progress}%`)
});- Interactive compression UI
- Quality settings (low/medium/high)
- Real-time progress display
- Compression statistics
- Skip option for users
- Automatic compression detection (files > 25MB)
- Seamless integration with existing upload flow
- Compression recommendations
- File preview with controls
- High: CRF 18, 1920p, 2Mbps - Best quality, larger size
- Medium: CRF 23, 1080p, 1Mbps - Balanced quality/size
- Low: CRF 28, 720p, 500kbps - Smallest size, acceptable quality
- Automatic quality adjustment based on target file size
- Progressive compression if initial attempt is still too large
- Preserves aspect ratios and important video metadata
- Non-blocking initialization (loads FFmpeg in background)
- Real-time progress updates with percentage
- Compression statistics (original vs compressed size)
- One-click skip option for users who prefer original files
- All processing happens locally in browser
- No video data sent to servers during compression
- Original files never uploaded unless user chooses to skip
- Upload Detection: When user selects video > 25MB
- Compression Offer: Show compression interface with settings
- Processing: User can watch real-time compression progress
- Results: Show compression stats and file size reduction
- Upload: Proceed with compressed file or skip to use original
interface CompressionOptions {
quality: 'low' | 'medium' | 'high';
maxSizeMB: number; // Target max file size
onProgress?: (progress: number) => void;
}| Quality | CRF | Resolution | Bitrate | Use Case |
|---|---|---|---|---|
| High | 18 | 1920p | 2Mbps | Professional content, important details |
| Medium | 23 | 1080p | 1Mbps | General use, good balance |
| Low | 28 | 720p | 500kbps | Quick uploads, acceptable quality |
- ✅ Chrome 57+
- ✅ Firefox 52+
- ✅ Safari 15+
- ✅ Edge 79+
- WebAssembly support
- SharedArrayBuffer (for better performance)
- Modern JavaScript features (async/await, modules)
- FFmpeg.wasm uses significant memory for video processing
- Automatic cleanup after compression
- Streams large files to prevent memory overflow
- ~1-3x realtime for most videos (3min video = 1-9min compression)
- Depends on:
- Video resolution and duration
- Device CPU performance
- Selected quality settings
- Browser optimizations
Typical compression results:
- High Quality: 30-50% size reduction
- Medium Quality: 50-70% size reduction
- Low Quality: 70-85% size reduction
- If FFmpeg fails to load: Show skip option
- If compression fails: Fall back to original file
- Memory errors: Suggest lower quality settings
- Network errors: Retry initialization
// Clear error states with actionable messages
{
ffmpegLoadError: "Video compression unavailable. Continue without compression?",
compressionError: "Compression failed. Upload original file instead?",
memoryError: "File too large for compression. Try a shorter video or upload original."
}The compressed videos work seamlessly with the existing analysis pipeline:
- Frame Extraction: FFmpeg server-side processes compressed video normally
- Audio Extraction: Compressed audio maintains quality for transcription
- AI Analysis: Gemini processes frames from compressed video effectively
- Timestamp Accuracy: Compression preserves timing for precise cut recommendations
- Faster uploads (2-5x speed improvement for large files)
- Privacy protection (local processing)
- Cost awareness (smaller files = lower processing costs)
- Better experience (progress feedback, control over quality)
- Reduced bandwidth costs (smaller uploads)
- Faster server processing (smaller files to process)
- Better scalability (less server resources per user)
- Improved reliability (smaller files = fewer network issues)
- Batch compression for multiple videos
- Custom compression profiles for different content types
- Thumbnail extraction during compression
- Video analysis preview (duration, resolution, bitrate)
- Advanced settings for power users (custom CRF, filters, etc.)
- Worker threads for background compression
- Streaming uploads while compressing
- Progressive compression (start with low quality, enhance gradually)
- Smart presets based on content analysis
{
"@ffmpeg/ffmpeg": "^0.12.6",
"@ffmpeg/core": "^0.12.6",
"@ffmpeg/util": "^0.12.1"
}- FFmpeg WASM files are ~30MB total
- Consider CDN hosting for core files
- Lazy loading prevents blocking app startup
- SharedArrayBuffer requires proper headers in production
This client-side compression feature significantly enhances AutoCut.AI's user experience while maintaining privacy and reducing server costs.