
On this page 14 sections
Search for “how to protect HLS video” and you will find two answers that sound almost identical: encrypt it with AES-128 and use DRM. Both involve AES encryption. Both produce an HLS stream that cannot be played by simply downloading the segments. But they protect against very different things, and choosing the wrong one is one of the most common mistakes in video platforms.
This guide explains exactly how HLS AES-128 encryption works, how DRM differs, what each one stops, and how to choose.
How AES-128 HLS encryption works
The HLS specification includes a simple encryption option. Each media segment is encrypted with AES-128 in CBC mode, and the media playlist tells the player where to get the key:
#EXT-X-KEY:METHOD=AES-128,URI="https://keys.example.com/video42.key",IV=0x1f2e3d4c5b6a79880123456789abcdef
#EXTINF:6.0,
segment0.ts
When a player loads this playlist, it:
- Reads the
#EXT-X-KEYtag. - Fetches the 16-byte key from the
URI. - Downloads each segment and decrypts it with that key and the IV.
- Plays the decrypted media.
Everything happens in the player’s own code or the browser’s native HLS stack. The key arrives as an ordinary HTTP response. In a web player such as hls.js, it is a JavaScript ArrayBuffer that any developer tool can see.
You can spot this in any playlist with our M3U8 analyzer: it reports METHOD=AES-128 and a key format of “identity”, meaning no DRM.
How DRM works differently
DRM systems such as Widevine, FairPlay and PlayReady also use AES encryption on the media, but the key’s journey is completely different:
- The player sees that content is DRM-protected and asks the device’s Content Decryption Module (CDM) for a licence request.
- The CDM creates a signed request tied to that device.
- The licence server checks the viewer’s rights and sends back a licence in which the key is encrypted for that specific CDM.
- The CDM decrypts the video internally. The key never appears in the page’s JavaScript or in readable memory. On hardware-backed devices, even the decoded frames stay protected.
That single difference, where the key lives, changes everything. If you want the full DRM flow, read what is Widevine DRM and Encrypted Media Extensions explained.
Side-by-side comparison
| AES-128 HLS | DRM (Widevine / FairPlay / PlayReady) | |
|---|---|---|
| Media encryption | AES-128 CBC, whole segments | AES-128 CTR or CBC (CENC), per sample |
| Key delivery | Plain HTTP(S) response | Licence encrypted for one device’s CDM |
| Key visible to JavaScript | Yes | No |
| Stops direct file downloads | Yes | Yes |
| Stops download tools and extensions | No | Yes, for most tools |
| Blocks screen recording | No | Often (protected video shows black) |
| Device-level quality rules | No | Yes (L1 vs L3, HDCP) |
| Offline licences with expiry | No | Yes |
| Studio-approved | No | Yes |
| Cost | Nearly free | DRM vendor fees |
| Setup complexity | Low | Medium |
What AES-128 actually protects against
AES-128 is not useless. It solves some real problems:
- Hotlinking and CDN scraping. Someone who finds your segment URLs cannot play them without the key.
- Casual downloading. Right-click “save video” does not work, and there is no MP4 link to share.
- Storage leaks. If your storage bucket is exposed, the segments are encrypted at rest.
- Access control, when combined with tokens. If the key URL requires a valid session cookie or signed token, only logged-in users get the key.
What AES-128 does not protect against
The weakness is simple: anyone who can play the video has the key.
- Popular browser extensions and command-line tools can read an HLS playlist, fetch the key using the viewer’s own session, download the segments and decrypt them into a single MP4 in minutes.
- A paying user can share the downloaded file freely afterwards.
- Screen recording works normally.
- You cannot enforce different rules for different devices.
In other words, AES-128 stops people who are not logged in. It does not stop a logged-in user who wants a copy.
Making AES-128 harder to abuse
If DRM is not an option yet, you can raise the bar:
- Short-lived, signed key URLs. Generate the key URI per session with an expiring signature, and bind it to the user’s session or IP range.
- Key rotation. Use different keys for different parts of a video, so that one intercepted key does not unlock everything.
- Check the referrer and origin on the key endpoint, and rate-limit requests.
- Visible watermarking with the user’s email or ID overlaid on the player, so recordings are traceable. See forensic watermarking explained for stronger options.
- Limit concurrent sessions per account.
None of these turn AES-128 into DRM, but together they discourage casual sharing.
SAMPLE-AES: the in-between option
HLS also defines METHOD=SAMPLE-AES, which encrypts individual audio and video samples rather than entire segments. It is the mode FairPlay uses. On its own, with a plain key (KEYFORMAT="identity"), SAMPLE-AES is no more secure than AES-128, because the key is still delivered in the clear. Its value comes when it is paired with a DRM key format such as com.apple.streamingkeydelivery for FairPlay.
The modern equivalent across all DRMs is cbcs Common Encryption in CMAF segments, signalled with METHOD=SAMPLE-AES in HLS and a ContentProtection element in DASH.
Cost and complexity
AES-128 costs almost nothing. Encoders like FFmpeg and most packagers support it out of the box, and a key server can be a single endpoint in your existing backend that checks the session and returns 16 bytes.
DRM means working with a multi-DRM provider, integrating a DRM-capable player, packaging in CENC and handling licence tokens. Vendors typically charge per licence or per month. For small platforms this can start in the tens of dollars a month; for large audiences it is a meaningful line item. Many all-in-one video platforms include DRM in higher plans.
Which should you use?
Choose AES-128 when:
- The content is internal, free or low-value, and you mainly want to stop hotlinking and casual downloads.
- You need something working today with no vendor.
- Your audience uses old devices that do not support DRM.
Choose DRM when:
- Licensing deals require it (films, series, sports, music).
- You sell premium content and a single leaked copy costs you real money, such as paid courses, fitness programmes, exam preparation or pay-per-view events.
- You need rentals, offline downloads with expiry, or different quality for different devices.
- You want screen capture blocked on most devices.
For many course creators the best answer is DRM plus watermarking, with AES-128 kept only as a fallback for unsupported devices. Our guide on how to protect videos from being downloaded walks through the full set of options by budget.
How to check what a stream is using
Paste any HLS playlist into the M3U8 analyzer and read the encryption line:
METHOD=AES-128, key format identity: plain AES, not DRM.METHOD=SAMPLE-AES, key formatcom.apple.streamingkeydelivery: FairPlay DRM.METHOD=SAMPLE-AES-CTRorSAMPLE-AESwith a Widevine system ID: Widevine over HLS.
A realistic migration path from AES-128 to DRM
Many platforms start with AES-128 and move to DRM once revenue justifies it. The move is smoother if you plan for it from day one.
Stage 1: AES-128 with signed keys. Encode your ladder, package HLS with METHOD=AES-128, and serve the key from an endpoint that checks the viewer’s session. Add a visible watermark. This is cheap and blocks most casual sharing.
Stage 2: switch packaging to CMAF. Even before adding DRM, move from MPEG-TS segments to fragmented MP4 (CMAF). This is the format all three DRMs expect, and it lets you serve HLS and DASH from one set of files. Your player needs to support fMP4, which hls.js, Shaka Player, Video.js and native Safari all do.
Stage 3: add multi-DRM for new uploads. Sign up with a DRM vendor, encrypt new content with cbcs, and switch your player to a DRM-capable configuration. Keep the AES-128 versions of older titles running while you re-package them in the background.
Stage 4: re-package the back catalogue. Most packagers can take your existing mezzanine files and produce DRM-protected CMAF without re-encoding. Once finished, retire the AES-128 key endpoint.
Stage 5: tune policies. Use device security levels to decide who gets HD and 4K, set licence durations, and decide whether to allow offline downloads.
Planning this way means you never have to rebuild your player or storage layout, only add layers.
Frequently confused terms
- HTTPS encrypts the connection, not the file. Anyone who can load the video over HTTPS can save it.
- Signed URLs control who can fetch a file, for a limited time. They do not encrypt it.
- AES-128 HLS encrypts segments, but the key is available to the player.
- DRM encrypts segments and protects the key inside the device.
Each layer solves a different problem. Strong setups use all four.
A quick way to test your own setup
Before you decide, find out what a determined user could actually do with your current stream. Log in as a normal customer, open the browser’s developer tools and look at the network tab while a lesson plays. If you can see a request that returns 16 bytes from a .key URL, and the segments are plain .ts or .m4s files, a download tool can almost certainly rebuild the video.
Then try the same thing on a DRM-protected service you subscribe to. You will see licence requests going to a licence server, but the responses are opaque blobs, and the segments are useless without the device’s CDM. Paste each playlist into the M3U8 analyzer and the difference is spelled out in the encryption line.
That ten-minute test usually settles the argument inside a team faster than any comparison table. For the full list of options, including watermarking and session limits, see how to protect videos from being downloaded.
Summary
AES-128 HLS encryption locks segments with a key the player downloads openly, so it keeps out strangers but not paying users who want a copy. DRM locks the key itself inside a trusted component on each device, enabling real download protection, device rules and expiring offline playback. Use AES-128 for low-risk content and as a fallback, and DRM when your video is the product.
Frequently asked questions
Can AES-128 encrypted HLS be downloaded?
Yes, by anyone who can play it. The key is delivered to the browser in the clear, so common download tools fetch the key along with the segments and decrypt them. Token protection on the key URL slows this down but does not stop it.
Is AES-128 HLS the same as SAMPLE-AES?
No. AES-128 encrypts whole segments. SAMPLE-AES encrypts individual media samples and is the method FairPlay uses. SAMPLE-AES with a plain identity key is still not DRM.
Is AES-128 good enough for online courses?
It stops casual right-click downloads and hides direct MP4 links. Determined users with browser extensions can still save lessons. If leaks cost you real revenue, use DRM plus watermarking.


