feat(core): add HDR Vivid hybrids and a MonaLisa command builder

This commit is contained in:
CodeName393
2026-12-01 15:29:03 -06:00
committed by GitHub
parent 71b8b63037
commit 90ab0ca4cb
27 changed files with 756 additions and 119 deletions
+2 -2
View File
@@ -156,7 +156,7 @@ class TrackRequest:
```
!!! note "`generate_dv` and a hand-made HYBRID"
A service that fetches the HYBRID variants itself (HDR10 and DV) must also fetch
A service that fetches the HYBRID variants itself (HDR10 or HDR Vivid, and DV) must also fetch
HDR10P when `track_request.generate_dv` is set and the title has no DV track.
unshackle prefers an HEVC HDR10+ track as the base, and measures an HDR10 base from the decoded video.
`get_tracks_for_variants` does this for you.
@@ -528,7 +528,7 @@ Each exposes `from_url(url, session=...)` (or `from_text(text, url)`) and then
Some services deliver a **separate manifest per codec/range**. The base class
provides `get_tracks_for_variants(title, fetch_fn)` to fan out over every
codec×range in the `TrackRequest`, including `HYBRID` (fetch HDR10 + DV and
codec×range in the `TrackRequest`, including `HYBRID` (fetch HDR10, or HDR Vivid when there is no HDR10, + DV and
merge) and `--best-available` skip-on-error handling:
```python
+1 -1
View File
@@ -340,7 +340,7 @@ When you give both `season` and `episode`, the server combines them into a `"{se
"bitrate": 8000, "bitrate_bps": 8000000, "width": 3840, "height": 2160,
"resolution": "2160p", "fps": "24", "range": "HDR10",
"range_display": "HDR", "scan_type": null, "closed_captions": [],
"dv_compatible_bitstream": false, "hdr10plus": false, "hdr10_base": false, "stereo": false, "language": "en",
"dv_compatible_bitstream": false, "hdr10plus": false, "hdr10_base": false, "hlg_base": false, "stereo": false, "language": "en",
"is_original_lang": true,
"name": null, "track_name": "English", "needs_repack": false, "edition": [], "note": null, "data": null,
"drm": [], "descriptor": "DASH"
+5 -5
View File
@@ -302,8 +302,8 @@ closed-caption descriptors. The relevant enums:
- **`Video.Codec`**: `AVC` (H.264), `HEVC` (H.265), `VC1`, `VP8`, `VP9`, `AV1`, `LCEVC`.
- **`Video.Range`**: `SDR`, `HLG`, `HDR10`, `HDR10P` (HDR10+), `VIVID` (HDR Vivid), `DV` (Dolby
Vision), and `HYBRID`. `HYBRID` is special: it tells the pipeline to select both an HDR10(+) base and
a DV track and merge the DV RPU onto the HDR10 track with `dovi_tool` (see
Vision), and `HYBRID`. `HYBRID` is special: it tells the pipeline to select both an HDR10(+) or PQ HDR Vivid base and
a DV track and merge the DV RPU onto the base track with `dovi_tool` (see
[Dolby Vision hybrid](#dolby-vision-and-hybrid)).
!!! note "Bitrate units"
@@ -429,7 +429,7 @@ service to talk to the platform's license server. unshackle recognizes seven DRM
| `PlayReady` | PlayReady | CDM challenge (WRM header) → license server → content keys (`.prd` device) |
| `ClearKeyCENC` | W3C `org.w3.clearkey` or W3C common PSSH over CENC | JSON KID request → JWK set; no CDM |
| `ClearKey` | HLS AES-128 | content key fetched directly from a URI; no CDM, no challenge |
| `MonaLisa` | Proprietary WASM DRM | keys extracted locally; no license server |
| `MonaLisa` | Proprietary WASM DRM | keys extracted locally; no license server. `command_builder` sets the command of the decryption backend, and `segment_decrypt=False` runs it once on the merged file |
| `BlowfishStripe` | Blowfish CBC stripe cipher | the service gives the per-track key; no CDM, no license server |
| `ClearKeyCTR` | AES-128-CTR over a whole file | the service gives the IV and licenses the content key at the licence step; no CDM, no license server |
@@ -533,9 +533,9 @@ HLS and DASH streams that carry a valid DV RPU but advertise plain HEVC, with DV
supplemental codecs (`dv_compatible_bitstream`). `--list` shows such a track as `HDR10+DV` or `HDR10P+DV`.
A service sets `hdr10_base` on a DV track that has an HDR10 base layer (DV profile 8.1), and `--list` shows it as `DV+HDR10`.
The HLS and DASH parsers set `stereo` on a stereoscopic 3D (MV-HEVC) track: an HLS `REQ-VIDEO-LAYOUT` that names `CH-STEREO`, or a DV profile 20 codec. `--list` shows it as `3D`.
**Hybrid** processing (`Video.Range.HYBRID`) selects an HDR10(+) base and a DV donor,
**Hybrid** processing (`Video.Range.HYBRID`) selects an HDR10(+) or PQ HDR Vivid base and a DV donor,
extracts the RPU with `dovi_tool`, and injects it onto the base layer, to make a single
track that carries both HDR10 metadata and the DV RPU. Both are automatic once the
track that carries both the base metadata and the DV RPU. Both are automatic once the
pipeline selects the right tracks. A service only needs to give accurate ranges.
The fixup replaces the track file with a raw HEVC file. A raw HEVC file has no duration and
+1 -1
View File
@@ -89,7 +89,7 @@ unshackle dl [OPTIONS] SERVICE [SERVICE ARGS...]
| `-rab`, `--real-audio-bitrate` | off | Same for audio (slower). |
!!! note "`HYBRID` range"
`-r HYBRID` fetches both HDR10/HDR10+ and Dolby Vision and merges them with `dovi_tool`. It requires the `dovi_tool` binary on your `PATH`.
`-r HYBRID` fetches both an HDR10/HDR10+/HDR Vivid base and Dolby Vision and merges them with `dovi_tool`. It requires the `dovi_tool` binary on your `PATH`.
### Language & subtitles
+13 -11
View File
@@ -105,7 +105,7 @@ By default a missing requested resolution is an error. Two flags change that:
A `quality` in the config counts as a requested resolution. When `--best-available` finds none of the
requested resolutions, `--worst` also picks from the lowest resolution. In hybrid mode, that is the
lowest resolution that has an HDR10 or HDR10+ base.
lowest resolution that has an HDR10, HDR10+ or HDR Vivid base.
```shell title="Never fail on a missing resolution"
unshackle dl -q 2160 --best-available EXAMPLE 0ABC123
@@ -152,7 +152,7 @@ unshackle dl -v hevc,avc EXAMPLE 81234567
| `HDR10P` | HDR10+ (`-r HDR10+` also works) |
| `VIVID` | HDR Vivid (`-r "HDR Vivid"` also works) |
| `DV` | Dolby Vision |
| `HYBRID` | Fetch both an HDR10/HDR10+ base and a DV track, then merge them |
| `HYBRID` | Fetch both an HDR10/HDR10+/HDR Vivid base and a DV track, then merge them |
```shell title="Grab HDR10 and Dolby Vision in one run"
unshackle dl -q 2160 -r HDR10,DV EXAMPLE '...'
@@ -179,18 +179,20 @@ MP4, see [3D output](output-and-naming.md#3d-output).
!!! warning "HYBRID requires dovi_tool"
`-r HYBRID` makes a single hybrid track by injecting the Dolby Vision RPU
metadata onto an HDR10/HDR10+ base layer with **dovi_tool**.
metadata onto an HDR10/HDR10+/HDR Vivid base layer with **dovi_tool**.
It requires the `dovi_tool` binary, resolved from unshackle's `binaries/` folder,
the `binaries` folder of your user data directory, or your `PATH`. A hybrid needs a DV track plus an HDR10 or
HDR10+ base. With no DV track, the title fails, unless you add `--generate-dv` (see below).
When HDR10+ is present, unshackle prefers it over HDR10 as the base layer. The base must be
HEVC; a title whose HDR10/HDR10+ tracks are all in another codec fails before it downloads.
the `binaries` folder of your user data directory, or your `PATH`. A hybrid needs a DV track plus an HDR10,
HDR10+ or HDR Vivid base. With no DV track, the title fails, unless you add `--generate-dv` (see below).
unshackle prefers HDR10+ as the base layer, then HDR10. It uses an HDR Vivid track only when the title has
no HEVC HDR10 or HDR10+ track, and only a track with a PQ base. The base and the DV track must have the
same frame rate, and the DV track must not be profile 8.4 (HLG). The base must be
HEVC; a title whose HDR10/HDR10+/HDR Vivid tracks are all in another codec fails before it downloads.
If the hybrid step fails for one resolution, unshackle logs an error, skips that resolution
and goes on with the other resolutions of the title. When no hybrid file at all was made,
the title fails.
A track that is `DV+HDR10P`, `HDR10+DV` or `HDR10P+DV` in `--list` already carries Dolby Vision and an HDR10
or HDR10+ base, so it is already a hybrid. At a resolution that has one, `-r HYBRID` selects it
A track that is `DV+HDR10P`, `HDR10+DV`, `HDR10P+DV` or `VIVID+DV` in `--list` already carries Dolby Vision and
an HDR10, HDR10+ or PQ HDR Vivid base, so it is already a hybrid. At a resolution that has one, `-r HYBRID` selects it
and muxes it as it is, with no base track and no dovi_tool step. A track that carries HDR10+
comes first, then the highest bitrate (the lowest with `--worst`). The other resolutions get a
hybrid that unshackle makes.
@@ -201,13 +203,13 @@ MP4, see [3D output](output-and-naming.md#3d-output).
#### Dolby Vision without a DV track
When a title has no DV track, `-r HYBRID --generate-dv` makes a Dolby Vision Profile 8.1 track
for its HDR10 or HDR10+ base. When a title has a DV track, unshackle uses that track and ignores
for its HDR10, HDR10+ or HDR Vivid base. When a title has a DV track, unshackle uses that track and ignores
the flag. When it has none, the flag also makes unshackle ask the service for its HDR10+ tracks.
| Base | Source of the Dolby Vision brightness values |
| --- | --- |
| HDR10+, with `hdr10plus_tool` installed | The HDR10+ metadata |
| HDR10, or HDR10+ without `hdr10plus_tool`, or an HDR10+ label with no metadata in the track | The decoded video |
| HDR10, HDR Vivid, or HDR10+ without `hdr10plus_tool`, or an HDR10+ label with no metadata in the track | The decoded video |
A track that the service labels HDR10 but that carries HDR10+ metadata counts as HDR10+
(see [`hdr10plus_probe`](../reference/configuration/download.md#hdr10plus_probe)).
+1 -1
View File
@@ -50,7 +50,7 @@ license-server handshake. The rest are special cases.
| **PlayReady** (Microsoft) | `.prd` | CDM challenge (WRM header) → license server → CDM parses → keys | shaka-packager / mp4decrypt |
| **ClearKey (CENC)**, W3C EME `org.w3.clearkey` or the W3C common PSSH | none | JSON `{"kids":[...],"type":"temporary"}` → license server returns a JWK Set. No CDM. | shaka-packager / mp4decrypt |
| **ClearKey (HLS)**, AES-128 `EXT-X-KEY` | none | Key fetched directly from a URI or `data:` URL. No CDM, no challenge. | in-process AES-CBC |
| **MonaLisa** (proprietary, WASM) | `.mld` | Ticket from the service API; keys extracted locally via WASM. No license server. | ML-Worker binary + AES-ECB, per segment |
| **MonaLisa** (proprietary, WASM) | `.mld` | Ticket from the service API; keys extracted locally via WASM. No license server. | External tool that the service names, per segment or on the whole track |
| **Blowfish stripe** | none | The service gives the per-track key. No CDM, no license server. | in-process Blowfish-CBC on every third 2048-byte chunk |
| **ClearKey (CTR)**, AES-128-CTR | none | The service gives the per-track key and IV. No CDM, no license server. | in-process AES-CTR over the whole file |
+1 -1
View File
@@ -108,7 +108,7 @@ Every variable below is valid in both output and folder templates. unshackle tak
| `quality` | Standard resolution with scan suffix | `1080p`, `2160p`, `576i` |
| `resolution` | Standard resolution number only | `1080` |
| `video` | Video codec | `H.264`, `H.265` |
| `hdr` | Dynamic-range label | `HDR`, `HDR10P`, `DV`, `DV.HDR`, `DV.HDR10P`, `HDRVivid`, `HLG` |
| `hdr` | Dynamic-range label | `HDR`, `HDR10P`, `DV`, `DV.HDR`, `DV.HDR10P`, `DV.HDRVivid`, `HDRVivid`, `HLG` |
| `hfr` | High frame rate marker (frame rate > 30) | `HFR` |
| `3d` | Stereoscopic 3D marker (MV-HEVC video) | `3D` |
| `edition` | Edition label from the track, if any | `Directors Cut` |
+1 -1
View File
@@ -46,7 +46,7 @@ When the decode fails, unshackle:
The download stops with an error instead of writing noise when no ciphertext is left to retry with, or when every vault and the CDM are used up. Without a local SQLite vault nothing remembers a flag, so the same vault serves the same pair again and the download stops there.
Per-segment decryption gives up the retry. With `decrypt_segments` on, and always with MonaLisa, the plaintext replaces each segment as it arrives, so no ciphertext is left. A failed decode then flags the pair and stops the download. The next run skips the flagged pair.
Per-segment decryption gives up the retry. With `decrypt_segments` on, and always with a MonaLisa tool that decrypts segments, the plaintext replaces each segment as it arrives, so no ciphertext is left. A failed decode then flags the pair and stops the download. The next run skips the flagged pair.
unshackle copies a content key from one vault to the others only after this check passes, so a content key that fails the check does not spread. Without FFmpeg, a content key from a vault is not copied at all. To see or clear the flags, open the SQLite file and read or delete rows in `bad_keys`.
+2 -1
View File
@@ -451,7 +451,8 @@ probes the two highest and the two lowest bitrates first:
The probe also finds HDR Vivid in HEVC HDR10 and HLG tracks. A track becomes `VIVID`, so
`-r VIVID` selects it, when its first frame carries CUVA HDR Vivid metadata, or when its MPEG-TS
program map table (PMT) has the `cuvv` registration. An HLG track never becomes `HDR10P`. An audio
program map table (PMT) has the `cuvv` registration. An HLG track never becomes `HDR10P`,
and an HDR Vivid track with an HLG base never makes a hybrid. An audio
track with no codec gets its codec from the PMT of an MPEG-TS first segment: the `AVSA`
registration or `stream_type` `0xD5` gives `Audio Vivid`. The probe has no HDR10+ result for an
MPEG-TS track.
+3 -3
View File
@@ -170,11 +170,11 @@ Put the more specific rules first, because unshackle stops at the first match.
!!! warning "Match `hdr` on the exact value"
Matching is exact, and `hdr` is a composite label for Dolby Vision titles: a DV title with
an HDR10 base layer gives `DV.HDR`, and with an HDR10+ base layer `DV.HDR10P`. Plain `DV`
does **not** match those. Name every variant you want, as the example above does. Note
an HDR10 base layer gives `DV.HDR`, with an HDR10+ base layer `DV.HDR10P`, and with an HDR Vivid base
layer `DV.HDRVivid`. Plain `DV` does **not** match those. Name every variant you want, as the example above does. Note
also that HDR10 gives `HDR`, not `HDR10`, and so does a PQ video track with no HDR10
metadata. The full set of values is `HDR`, `HDR10P`, `DV`, `DV.HDR`, `DV.HDR10P`,
`HDRVivid`, and `HLG`, as listed in the
`DV.HDRVivid`, `HDRVivid`, and `HLG`, as listed in the
[variable table](../../guide/output-and-naming.md#template-variables).
### Operators