1. What is CENC decryption?
CENC (Common Encryption, ISO/IEC 23001-7) is the standard that lets a single fMP4 (fragmented MP4) file be protected by multiple DRM systems simultaneously — Widevine, PlayReady, FairPlay, ClearKey. The encryption is applied at the sample level inside mdat boxes. CENC decryption means:
- Parse the ISO BMFF box hierarchy (
ftyp/moov/moof/mdat/traf/senc). - Read the
tencbox (insideschi) for default IV size,isProtectedflag and default KID. - Read the
sencbox for per-sample IVs and optional subsample ranges (BytesOfClearData / BytesOfEncryptedData). - For each sample, run AES-128-CTR with the content key and the per-sample IV over the encrypted byte ranges.
- Emit clear samples.
2. cenc vs cbcs — the two Common Encryption schemes
| Attribute | cenc | cbcs |
|---|---|---|
| Cipher mode | AES-128-CTR | AES-128-CBC |
| Pattern encryption | No (full or subsample) | Yes (1:9, 5:5, 10:0) |
| IV size | 8 or 16 bytes | 16 bytes |
| Used by | Widevine, PlayReady, ClearKey | FairPlay (mandatory), Widevine, PlayReady |
| Constant IV (per-sample) | Typically no | Typically yes |
A correct CENC decryption tool must handle whichever scheme the tenc box declares. Panels that hard-code cenc break the moment a stream switches to cbcs.
3. The ISO BMFF boxes that matter
The boxes a CENC decryption tool has to parse correctly:
tenc— insideschi/sinf. Declaresdefault_isProtected,default_Per_Sample_IV_Size,default_KID. The authority on IV layout, except when it lies (see SENC IV edge case).pssh— inmoov. Carries DRM-specific init data for Widevine / PlayReady / FairPlay. Source of KIDs for license flows.senc— intraf. Per-sample IV + subsample ranges for the fragment.saiz/saio— sample auxiliary info size / offsets. Alternative location for SENC data in some encoders.tfhd/trun— sample counts and sizes, needed to slicemdatinto samples.
4. mp4decrypt and the Bento4 toolkit
The reference CENC decrypt CLI is mp4decrypt from the Bento4 toolkit:
mp4decrypt --key abcd1234deadbeef:0123456789abcdef0123456789abcdef \ init.mp4 init.dec.mp4 mp4decrypt --key abcd1234deadbeef:0123456789abcdef0123456789abcdef \ seg001.m4s seg001.dec.m4s
This is the right tool for a one-shot decrypt of a single VOD asset. For live DRM streaming where you might need to decrypt thousands of segments per channel per hour, shelling out to mp4decrypt has three issues:
- Subprocess overhead —
fork + execper segment dominates the CPU profile. - Disk round-trips — you have to write the encrypted segment to disk, run mp4decrypt, read the decrypted output, then feed it into FFmpeg.
- No structured error surface — when a sample fails to decrypt, you get an exit code, not a diagnostic.
Streamora's internal CENC engine avoids all three by operating on in-memory fMP4 boxes and streaming decrypted samples straight into the TS muxer.
5. The SENC IV size edge case — how audio corruption sneaks in
tenc box is not always truthful.
Several major DRM providers declare an 8-byte default IV size in tenc but transmit 16-byte IVs inside the actual senc box. If your CENC decryptor trusts tenc, every sample will decrypt to noise. On video tracks the resulting artifacts are obvious. On audio tracks — which typically have no subsamples to sanity-check — the output sounds like pure static.
A correct engine auto-detects IV size:
- For video tracks: compare
sencsize against the implied size fromsaiz/truncounts; if it matches 16-byte IVs better than 8-byte, pick 16. - For audio tracks (no subsamples): fall back to a heuristic that prefers 16-byte IVs when the
sencsize is divisible cleanly by sample count × 16. - On decrypt failure (frame-boundary corruption): flip IV size and retry once before failing hard.
Streamora v1.3.52 shipped with this auto-detection across audio and video tracks. The updates page includes the full changelog.
6. Streamora's internal CENC engine
The Go implementation inside Streamora's internal/remux package does the following in-process:
- ISO BMFF box walker — streaming parser that does not buffer the entire segment.
- AES-128-CTR + AES-128-CBC primitives — Go's
crypto/aes+crypto/cipherwith hardware AES-NI when available. - Per-track IV size auto-detection (cenc + cbcs).
- Subsample-aware sample slicing — clear / encrypted byte ranges respected.
- KID-keyed cache — rotation-aware, auto re-fetch on decrypt failure.
- Direct handoff to the TS muxer — H.264/H.265 Annex-B conversion, AAC/AC-3/E-AC-3 wrapping, PMT/PAT emission.
- HLS writer — rolling window, configurable segment duration, EXT-X-TARGETDURATION auto-tuned.
Skip the mp4decrypt shell-out loop
Install Streamora and run CENC decryption in-process with SENC IV auto-detection, rotation-aware keys and live HLS output.
Download Streamora — Latest Release DASH to HLS Guide
Signed binary • install.sh • changelog • free trial
7. Tool comparison matrix
| Capability | mp4decrypt | Shaka Packager | Streamora internal |
|---|---|---|---|
| CENC (AES-128-CTR) | ✓ | ✓ | ✓ |
| CBCS (AES-128-CBC pattern) | ✓ | ✓ | ✓ |
| In-process (no subprocess) | ✗ | ✗ | ✓ |
| SENC IV size auto-detect | ✗ | Partial | ✓ |
| Direct TS mux output | ✗ | ✗ | ✓ |
| Live rolling HLS origin | ✗ | ✗ | ✓ |
| Rotation-aware key cache | ✗ | ✗ | ✓ |
| AES-NI acceleration | ✓ | ✓ | ✓ |
8. CENC decryption FAQ
Is CENC encryption breakable?
CENC itself (AES-128-CTR) is not breakable in any practical sense. What can be extracted is the content key, via an L3 Widevine CDM in environments where the provider allows it. The cipher is strong; the entire DRM ecosystem exists to protect the key delivery, not the cipher.
What is SENC and why does it matter?
SENC (Sample Encryption) is the ISO BMFF box that carries per-sample IVs and subsample encryption ranges. Without correctly parsing SENC, you cannot decrypt a single sample. The SENC IV size edge case (8 vs 16 bytes) is the single most common reason custom CENC decryptors produce noisy audio.
Can Streamora decrypt CBCS (FairPlay) as well as CENC?
Yes. The internal engine handles both the cenc (AES-128-CTR) and cbcs (AES-128-CBC with pattern) schemes.
Do I need to install Bento4 to run Streamora?
The installer includes mp4decrypt for the ffmpeg_remux fallback pipeline, but the default internal_remux mode is fully self-contained — no Bento4 dependency at runtime.
How fast is the internal CENC engine?
On a typical 8-core VPS with AES-NI, Streamora decrypts and remuxes a 6 Mbps 1080p CENC-protected fMP4 DASH feed to MPEG-TS HLS at ~1.5–2% of one core. That is 50–70x cheaper than the shell-out pipeline of mp4decrypt + ffmpeg.
Replace mp4decrypt shell-outs with a real CENC engine
One bash command installs Streamora with its internal fMP4 CENC engine, SENC IV auto-detection and live HLS origin. Free trial license included.
Download Streamora — Latest Release Widevine Key Dumper Guide
Signed binary • install.sh • changelog • free trial license