hls.js

JavaScript HLS client that plays HTTP Live Streaming video in the browser via MSE

Library
npm
v1.7.3
16,957 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
94 /100 Excellent
Development Activity 96
Maintenance 96
Community 84
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
82 /100 Excellent
Architecture 90
Code Quality 88
Innovation 82
Learning Curve 68

hls.js is a JavaScript library that implements an HTTP Live Streaming (HLS) client entirely in the browser, with no plugins or native support required. It works by transmuxing MPEG-2 Transport Stream and fragmented MP4 segments into ISO BMFF fragments that are fed into the browser’s Media Source Extensions (MSE) API, driving playback through a standard HTML5 <video> element.

Maintained by the video-dev community and originally built at Dailymotion, hls.js powers adaptive bitrate streaming, live and VOD playlists, subtitles, alternate audio tracks, and DRM (FairPlay, PlayReady, Widevine) across Chrome, Firefox, Edge, and Safari. It’s the de facto standard for HLS playback outside of Safari’s native support, and is embedded inside major players like Video.js, Shaka Player integrations, and countless custom video products.

What You Get

  • A full HLS client: multivariant and media playlist parsing, VOD/live/event playlists, DVR support, and low-latency HLS (Part/Preload-Hint) handling
  • Adaptive bitrate switching with three quality-switch modes (instant, smooth, and bandwidth-conservative) plus an emergency switch-down under bandwidth drops
  • Transmuxing of MPEG-2 TS (H.264/H.265, AAC, MP3, AC-3) and passthrough of fmp4/CMAF segments into ISO BMFF fragments, performed off the main thread in a Web Worker
  • DRM support via Encrypted Media Extensions for FairPlay, PlayReady, and Widevine with fmp4 segments, plus AES-128 and SAMPLE-AES decryption
  • CEA-608/708 captions, WebVTT subtitles, alternate audio track rendition selection, and Content Steering for multi-CDN failover
  • A rich event system exposing every internal network and video event plus built-in playback session metrics for analytics

Common Use Cases

  • Playing live and VOD HLS streams in Chrome, Firefox, and Edge, where there is no native HLS support in the <video> element
  • Building custom video players or embedding HLS playback inside existing players (Video.js and others ship hls.js-based tech plugins)
  • Streaming DRM-protected content (FairPlay/PlayReady/Widevine) to web audiences without falling back to Flash or native app wrappers
  • Low-latency live streaming (sports, events, live commerce) using HLS Part/Preload-Hint and configurable live-sync tuning
  • Multi-CDN video delivery with automatic failover via redundant playlists or EXT-X-CONTENT-STEERING

Under The Hood

Architecture hls.js is built around a central Hls class (src/hls.ts) that wires together a set of single-responsibility controllers registered on a shared EventEmitter. PlaylistLoader and m3u8-parser.ts fetch and parse multivariant/media playlists into Level and Fragment models; LevelController, StreamController, AudioStreamController, and SubtitleStreamController (all extending BaseStreamController, src/controller/base-stream-controller.ts) drive segment scheduling and buffering per media type; AbrController picks the active quality level from bandwidth estimates; and BufferController/GapController manage the MediaSource SourceBuffer and stall recovery. Segment data flows through TransmuxerInterface into a Web Worker (transmuxer-worker.ts) running tsdemuxer.ts/mp4demuxer.ts (demux) and mp4-remuxer.ts/passthrough-remuxer.ts (remux) so CPU-heavy work never blocks the main thread, with FragmentTracker reconciling what’s actually been buffered. Errors surface through ErrorController for centralized fatal/non-fatal recovery. Tech Stack The library is authored in strict TypeScript (94% of the codebase) with a small JavaScript polyfill layer, built via Rollup into ESM/CJS/light bundles (rollup.config.js, build-config.js), type-checked with tsc and packaged with @microsoft/api-extractor for a single rolled-up .d.ts. Runtime dependencies are minimal and deliberately vendored-small: eventemitter3 for pub/sub, url-toolkit for URL resolution, and the @svta/cml-* packages for CMCD/ID3/utility helpers — there is no framework dependency, keeping the library embeddable anywhere a <video> element exists. Code Quality The tests/ directory contains 62+ unit/functional/e2e test files covering crypto, demuxers, loaders, remuxers, and controllers individually (tests/unit/controller, tests/unit/demuxer, etc.), run via Karma/Mocha with cross-browser matrices on Sauce Labs and BrowserStack in CI, plus a full ESLint + Prettier + tsc --noEmit gate wired into npm run sanity-check and a Husky pre-commit hook. Naming is consistent (*Controller, *Loader, *Track) and the strict TypeScript config forces explicit typing across the 137 source files, though the sheer surface area (26k+ LOC) and deep import graph in hls.ts mean the learning curve for contributors is nontrivial. API Design The public API centers on one Hls class with a small, well-documented surface: loadSource(), attachMedia(), event constants on Hls.Events, and a single HlsConfig object for the ~60 tunable parameters (buffer thresholds, ABR behavior, live-sync windows) documented exhaustively in docs/API.md. Getting started is genuinely three lines of code (new Hls(), attachMedia(), loadSource()), but the deep configurability that makes it production-ready for broadcasters also means newcomers face a large options surface before they need to touch most of it.

Used by 9 apps in this directory

Rust
54%
Other

Cap

Team Chat · Video Conferencing

22,884

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
64
Dependency
Built with
Rust 54%
TypeScript 42%
Updated 4 days ago
TypeScript
61%
EPL-2.0

Huly Platform

Collaboration · Project Management · Team Chat

27,797

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
62
Dependency
Built with
TypeScript 61%
Svelte 34%
Updated 6 days ago
TypeScript
96%
AGPL 3.0

Midday

Invoicing Finance · Productivity

15,042

All-in-one AI-powered business operations platform for freelancers and solo entrepreneurs to manage invoicing, time tracking, banking, and financial intelligence.

View details
53
Repo Health
78
Technical
67
Dependency
Built with
TypeScript 96%
Updated 3 months ago
TypeScript
91%
AGPL 3.0

PeerTube

Social Media

15,340

A federated, ActivityPub-based video hosting platform built by Framasoft — self-hostable instances interconnect into a network with no vendor lock-in, P2P-assisted streaming, and no ads.

View details
96
Repo Health
75
Technical
70
Dependency
Built with
TypeScript 91%
Updated 1 weeks ago
PHP
69%
AGPL 3.0

Pixelfed

Social Media

7,105

A decentralized, self-hosted photo sharing platform built on ActivityPub for the open Fediverse.

View details
91
Repo Health
68
Technical
65
Dependency
Built with
PHP 69%
Vue 22%
Updated 5 days ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

39,975

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated 4 days ago
Python
64%
AGPL 3.0

Shadowbroker

Analytics · Monitoring · Security

11,261

Self-hosted OSINT dashboard that fuses 60+ live intelligence feeds — flight tracking, ship AIS, satellites, CCTV, seismic and radio networks — into one real-time map, with an agent-ready command channel for AI co-analysts.

View details
84
Repo Health
83
Technical
71
Dependency
Built with
Python 64%
TypeScript 32%
Updated 1 weeks ago
AGPL 3.0

VoiceStudio

Mcp · Music Audio · Voice AI

50,643

Open-source, fully local ElevenLabs alternative for voice cloning, voice design, video dubbing, dictation, transcription and audiobooks, with a local API and MCP server for agents.

View details
84
Repo Health
83
Technical
70
Dependency
TypeScript
51%
Other

World Monitor

Analytics · Monitoring

87,476

Real-time global intelligence dashboard that fuses AI-synthesized news, geopolitical risk scoring, and infrastructure tracking into one open-source situational awareness platform.

View details
87
Repo Health
89
Technical
68
Dependency
Built with
TypeScript 51%
JavaScript 47%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers