Perfect quality for every network
Single API call enables multi-bitrate encoding
import { WaveClient } from '@wave/sdk';
import { DesignTokens, getContainer, getSection } from '@/lib/design-tokens';
const wave = new WaveClient({
apiKey: process.env.WAVE_API_KEY
});
// Create ABR-enabled stream
const stream = await wave.streams.create({
title: 'Adaptive Stream',
protocol: 'webrtc',
abr: {
enabled: true,
// WAVE encodes 6 quality levels automatically
ladder: 'default', // 'default' | 'dense' | 'sparse'
profiles: [
{ name: '4K', width: 3840, height: 2160, bitrate: 8000, fps: 60 },
{ name: '1080p', width: 1920, height: 1080, bitrate: 4500, fps: 30 },
{ name: '720p', width: 1280, height: 720, bitrate: 2500, fps: 30 },
{ name: '480p', width: 854, height: 480, bitrate: 1200, fps: 30 },
{ name: '360p', width: 640, height: 360, bitrate: 700, fps: 30 },
{ name: '240p', width: 426, height: 240, bitrate: 400, fps: 30 }
],
// Adaptation settings
adaptation: {
strategy: 'bandwidth-based', // 'bandwidth' | 'buffer' | 'hybrid'
switchUpThreshold: 1.5, // Switch up when bandwidth 1.5x higher
switchDownThreshold: 0.8, // Switch down when bandwidth 0.8x lower
minSwitchInterval: 5000 // Min 5s between switches
}
}
});
console.log('Master playlist:', stream.hls_url);
console.log('Profiles:', stream.abr.profiles.length);Choose the right quality ladder for your use case
Balanced ladder for most use cases. Good coverage from 240p to 4K.
4K (8000kbps) • 1080p (4500kbps) • 720p (2500kbps) • 480p (1200kbps) • 360p (700kbps) • 240p (400kbps)More quality steps for smoother adaptation. Higher encoding cost.
Includes intermediate steps like 900p, 540p, 432pFewer profiles for faster encoding and lower costs.
1080p (4500kbps) • 720p (2500kbps) • 480p (1200kbps) • 240p (400kbps)Track quality switches and viewer experience
// Get ABR analytics
const analytics = await wave.analytics.get(streamId, {
metrics: ['quality_switches', 'rebuffer_rate', 'startup_time']
});
console.log('Quality distribution:');
analytics.quality_distribution.forEach(q => {
console.log(` ${q.profile}: ${q.percentage}% of viewers`);
});
// Output:
// 1080p: 45% of viewers
// 720p: 30% of viewers
// 480p: 20% of viewers
// 360p: 5% of viewers
console.log(`Avg quality switches: ${analytics.avg_switches}/viewer`);
console.log(`Rebuffer rate: ${analytics.rebuffer_rate}%`);
console.log(`Startup time: ${analytics.startup_time}ms`);