HLS.js: HTTP Live Streaming client for browsers
JavaScript HLS client with MPEG-TS to MP4 transmuxing.
Learn more about hls.js
HLS.js is a JavaScript library that implements an HTTP Live Streaming client for web browsers. It works by transmuxing MPEG-2 Transport Stream and AAC/MP3 audio into ISO BMFF (MP4) fragments, with transmuxing performed asynchronously using Web Workers when available. The library is written in ECMAScript6 and TypeScript, then transpiled to ES5 using Babel and the TypeScript compiler. It supports both VOD and live playlists with features including adaptive bitrate streaming, multiple audio tracks, CEA-608/708 captions, WebVTT subtitles, and DRM via Encrypted Media Extensions.
Asynchronous transmuxing
Uses Web Workers to perform MPEG-2 TS to MP4 fragment conversion off the main thread, reducing blocking operations during playback.
Multiple container support
Handles MPEG-2 TS, fragmented MP4, AAC, and MPEG Audio containers with support for H.264, H.265, AAC, MP3, AC-3, and ID3 metadata streams.
Granular quality control
Provides three distinct adaptive bitrate switching modes (instant, smooth, and bandwidth-conservative) with level capping based on resolution, dropped frames, and HDCP support.
import Hls from 'hls.js';
const video = document.getElementById('video');
const videoSrc = 'https://example.com/playlist.m3u8';
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(videoSrc);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function() {
console.log('Manifest loaded, found ' + hls.levels.length + ' quality levels');
video.play();
});
hls.on(Hls.Events.ERROR, function(event, data) {
console.error('HLS error:', data);
});
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = videoSrc;
video.addEventListener('loadedmetadata', function() {
video.play();
});
}Bug fixes for PlayReady endianness, FairPlay key patching, and interstitial asset handling.
- –Fixed PlayReady endianness conversion device discrepancy
- –Fixed FairPlay Streaming key ID patching (`"keyId is null"` error)
- –Fixed reloading interstitial asset-list when seeking between assets in append-in-place mode
- –Fixed Interstitials fallback to primary on live start with empty asset-list
- –Fixed switching back to main audio-only after end-of-stream buffered
Fixes interstitial preroll and legacy platform compatibility issues.
- –Fixed exception calling `setMediaKeys` with Interstitial preroll
- –Fixed exception on legacy platforms where `media.play()` does not return a `Promise` with Interstitials
Alpha release marking LTS branch creation and merging of v1.7.0 development changes.
- –Marks creation of branch patch/v1.6x for LTS maintenance and merging of changes slated for 1.7.0 into development
Top in Frontend
Related Repositories
Discover similar tools and frameworks used by developers
Lucide
Framework-agnostic SVG icons with native component packages.
AdminLTE
Production-ready Bootstrap 5 template with SCSS build tooling.
Bootstrap
Sass-based component library with responsive grid system.
Remix
Full-stack web framework built on web standards with modular routing, middleware, and session packages.
Dash
Build reactive web apps with Python callbacks.