demuxe 0.3.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +352 -0
- package/README.md +75 -0
- package/bin/demuxe.mjs +30 -0
- package/docs/API-MIGRATION.md +54 -0
- package/docs/BETA.md +98 -0
- package/docs/BRANDING-MIGRATION.md +77 -0
- package/docs/COMPATIBILITY-EXPANSION.md +181 -0
- package/docs/LICENSING.md +83 -0
- package/docs/OPTIMIZATION-COMPLETION.md +511 -0
- package/docs/OPTIMIZATION-FLAC.md +178 -0
- package/docs/OPTIMIZATION-INTEGRATION.md +221 -0
- package/docs/OPTIMIZATION-REVIEW-FIXES.md +78 -0
- package/docs/PLAYER-COMPONENT.md +247 -0
- package/docs/PUBLIC-API-VALIDATION.md +163 -0
- package/docs/PUBLIC-API.md +245 -0
- package/docs/RELEASE.md +181 -0
- package/docs/RUNTIME-ASSETS.md +127 -0
- package/engine-build.json +8781 -0
- package/examples/custom-controls.html +14 -0
- package/examples/player-element.html +5 -0
- package/fixtures/DejaVuSans.ttf +0 -0
- package/fixtures/FONT-LICENSE.txt +187 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +46 -0
- package/player.d.ts +1 -0
- package/player.js +1 -0
- package/release-manifest.json +541 -0
- package/sources.lock.json +96 -0
- package/third_party/notices/dav1d/COPYING +23 -0
- package/third_party/notices/emscripten/LICENSE +102 -0
- package/third_party/notices/emscripten/system/lib/compiler-rt/LICENSE.TXT +311 -0
- package/third_party/notices/emscripten/system/lib/libc/musl/COPYRIGHT +193 -0
- package/third_party/notices/emscripten/system/lib/libcxx/LICENSE.TXT +311 -0
- package/third_party/notices/emscripten/system/lib/libcxxabi/LICENSE.TXT +311 -0
- package/third_party/notices/emsdk/LICENSE +27 -0
- package/third_party/notices/ffmpeg/COPYING.GPLv2 +339 -0
- package/third_party/notices/ffmpeg/COPYING.GPLv3 +674 -0
- package/third_party/notices/ffmpeg/COPYING.LGPLv2.1 +502 -0
- package/third_party/notices/ffmpeg/LICENSE.md +129 -0
- package/third_party/notices/ffmpeg-adaptation/COPYING.LGPLv2.1 +502 -0
- package/third_party/notices/ffmpeg-adaptation/LICENSE.md +127 -0
- package/third_party/notices/freetype/LICENSE.TXT +46 -0
- package/third_party/notices/freetype/docs/FTL.TXT +169 -0
- package/third_party/notices/freetype/docs/GPLv2.TXT +340 -0
- package/third_party/notices/fribidi/COPYING +504 -0
- package/third_party/notices/harfbuzz/COPYING +42 -0
- package/third_party/notices/libass/COPYING +15 -0
- package/third_party/notices/libplacebo/LICENSE +458 -0
- package/third_party/notices/libxml2/Copyright +23 -0
- package/third_party/notices/libxml2/dict.c.notice +17 -0
- package/third_party/notices/libxml2/list.c.notice +16 -0
- package/third_party/notices/mpv/Copyright +78 -0
- package/third_party/notices/mpv/LICENSE.GPL +338 -0
- package/third_party/notices/mpv/LICENSE.LGPL +501 -0
- package/third_party/notices/vulkan-headers/LICENSE.txt +202 -0
- package/third_party/notices/zimg/COPYING +14 -0
- package/third_party/notices/zlib/LICENSE +22 -0
- package/third_party/notices.json +166 -0
- package/toolchain.lock.json +204 -0
- package/web/audio-worklet.js +45 -0
- package/web/cheap-mp4-probe.js +82 -0
- package/web/engine-adaptation/manifest.json +75 -0
- package/web/engine-adaptation/remux.mjs +2 -0
- package/web/engine-adaptation/remux.wasm +0 -0
- package/web/engine-ass/manifest.json +55 -0
- package/web/engine-ass/subtitles.mjs +2 -0
- package/web/engine-ass/subtitles.wasm +0 -0
- package/web/engine-hybrid/player.mjs +2 -0
- package/web/engine-hybrid/player.wasm +0 -0
- package/web/engine-remux/remux.mjs +2 -0
- package/web/engine-remux/remux.wasm +0 -0
- package/web/engine-software-full/player.mjs +2 -0
- package/web/engine-software-full/player.wasm +0 -0
- package/web/file-reader.js +34 -0
- package/web/filter-retained-engine-worker.js +292 -0
- package/web/generated/index.d.ts +6 -0
- package/web/generated/index.js +4 -0
- package/web/generated/internal/assets.d.ts +2 -0
- package/web/generated/internal/assets.js +7 -0
- package/web/generated/internal/backend.d.ts +27 -0
- package/web/generated/internal/backend.js +1 -0
- package/web/generated/internal/errors.d.ts +13 -0
- package/web/generated/internal/errors.js +54 -0
- package/web/generated/internal/native-ass.d.ts +38 -0
- package/web/generated/internal/native-ass.js +206 -0
- package/web/generated/internal/native-player.d.ts +95 -0
- package/web/generated/internal/native-player.js +502 -0
- package/web/generated/internal/playback-plans.d.ts +526 -0
- package/web/generated/internal/playback-plans.js +110 -0
- package/web/generated/internal/selection.d.ts +45 -0
- package/web/generated/internal/selection.js +45 -0
- package/web/generated/internal/state.d.ts +8 -0
- package/web/generated/internal/state.js +56 -0
- package/web/generated/internal/wasm-player.d.ts +127 -0
- package/web/generated/internal/wasm-player.js +372 -0
- package/web/generated/player/index.d.ts +198 -0
- package/web/generated/player/index.js +873 -0
- package/web/generated/player/interaction.d.ts +6 -0
- package/web/generated/player/interaction.js +14 -0
- package/web/generated/player/styles.d.ts +1 -0
- package/web/generated/player/styles.js +86 -0
- package/web/generated/types.d.ts +227 -0
- package/web/generated/types.js +2 -0
- package/web/generated/unified-player.d.ts +129 -0
- package/web/generated/unified-player.js +1074 -0
- package/web/io-worker.js +65 -0
- package/web/native-ass-worker.js +26 -0
- package/web/native-remux-player.js +301 -0
- package/web/native-remux-source-worker.js +25 -0
- package/web/native-remux-worker.js +46 -0
- package/web/range-reader.js +130 -0
- package/web/remux-packaging.js +11 -0
- package/web/resource-loader.js +173 -0
- package/web/retained-decoder-worker.js +200 -0
- package/web/retained-video.js +15 -0
- package/web/segmented-subtitles.js +37 -0
- package/web/software-full-engine-worker.js +234 -0
- package/web/source-probe.js +28 -0
- package/web/split-mp4.js +159 -0
- package/web/streaming-manifest.js +136 -0
- package/web/subtitle-overlay.js +26 -0
- package/web/video-codec-config.js +59 -0
- package/web/vod-manifest.js +54 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Stage 2: maintained progressive FLAC preparation
|
|
2
|
+
|
|
3
|
+
Historical checkpoint report. For subsequent local implementation and current coverage, see [completion status](OPTIMIZATION-COMPLETION.md).
|
|
4
|
+
|
|
5
|
+
For the subsequent correctness fixes and current unequal-tail limitation, see
|
|
6
|
+
[the review-fix report](OPTIMIZATION-REVIEW-FIXES.md).
|
|
7
|
+
|
|
8
|
+
This is an uncommitted integration checkpoint, not completion of the requested
|
|
9
|
+
optimization program. Starting commit remains
|
|
10
|
+
`f2491f62c777fa55225aed9b0b7ecf2e340accf7` on
|
|
11
|
+
`codex/optimization-integration`. No remote mutation or laboratory modification.
|
|
12
|
+
|
|
13
|
+
## Implementation and timestamp repair
|
|
14
|
+
|
|
15
|
+
The optional preparation profile compiles the maintained remuxer with audio-only
|
|
16
|
+
FFmpeg decoders and a FLAC encoder. It contains **no video decoder or encoder**.
|
|
17
|
+
It uses the saved modernization's FFmpeg **9.0.1**, locked patches and Emscripten
|
|
18
|
+
4.0.14. Its own generated glue accompanies its own Wasm. Existing packet-copy,
|
|
19
|
+
Hybrid and Software runtime artifacts remain unchanged; rebuilding all saved
|
|
20
|
+
streaming engines is still a separate qualification gate.
|
|
21
|
+
|
|
22
|
+
The historical scratch adapter's missing-DTS = PTS algorithm still reproduces
|
|
23
|
+
`33600 >= 32528` and is retained as evidence. The replacement reuses the maintained
|
|
24
|
+
remuxer's explicit H.264 SPS reorder bound and bounded Matroska PTS queue to derive
|
|
25
|
+
missing decode timestamps in packet decode order. Established timestamps elsewhere
|
|
26
|
+
are rescaled normally. Unestablished or discontinuous timestamps reject. No
|
|
27
|
+
arbitrary monotonic clamp, video re-encoding, packet dropping or B-frame blanket
|
|
28
|
+
ban was introduced. The existing codec packaging adapters derive video configuration
|
|
29
|
+
and MIME. Actual packet ends correct the final adapted presentation duration.
|
|
30
|
+
|
|
31
|
+
`native/adaptation/flac.h` decodes only the selected audio stream, buffers bounded
|
|
32
|
+
integer PCM and feeds a continuous FLAC encoder during sequential playback. Metadata
|
|
33
|
+
probing cannot invoke incidental audio decoders. The final partial frame and encoder
|
|
34
|
+
are drained; decoded and encoded sample counts must agree. Audio/video offsets share
|
|
35
|
+
the maintained source origin and positive mux preroll bias. Browser playback owns the
|
|
36
|
+
final A/V clock. Native FFmpeg used by tests is offline fixture/verification tooling,
|
|
37
|
+
never playback transcoding.
|
|
38
|
+
|
|
39
|
+
## Explicit admission and fidelity
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
const player = new Player(container, {
|
|
43
|
+
mode: 'native',
|
|
44
|
+
experimentalAudioAdaptation: 'flac',
|
|
45
|
+
experimentalBufferedNativeSeeks: true,
|
|
46
|
+
audioGain: 0.5, // optional, separately requested scalar effect
|
|
47
|
+
});
|
|
48
|
+
await player.open(fileOrQualifiedRangeSource);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Ordinary direct playback and supported audio packet copy are still attempted first.
|
|
52
|
+
FLAC preparation is lazy-loaded only after the copy path reports unsupported audio.
|
|
53
|
+
The existing controller carries remote source identity into that transition.
|
|
54
|
+
General automatic FLAC admission is **disabled**. Explicit Native rejection remains
|
|
55
|
+
visible to the application; it does not silently introduce Opus or another effect.
|
|
56
|
+
|
|
57
|
+
Tested adaptation inputs are PCM S16/S24, conventional mono/stereo, 44.1/48 kHz.
|
|
58
|
+
Admission requires established 16/24-bit integer precision, unchanged sample rate
|
|
59
|
+
and mono/stereo channel order. Unknown precision, floating-point, 32-bit precision,
|
|
60
|
+
multichannel layouts and midstream configuration changes reject. FLAC/DTS decoder
|
|
61
|
+
support is compiled but has no broad input qualification; DTS with unknown decoded
|
|
62
|
+
precision rejects. This stage makes no surround or lossy-input qualification claim.
|
|
63
|
+
If later qualified for already-lossy input, FLAC would avoid an additional lossy
|
|
64
|
+
generation; it would not restore the original recording.
|
|
65
|
+
|
|
66
|
+
The gain combination changes amplitude intentionally. Sample-exact conversion
|
|
67
|
+
checks concern decoded FLAC before browser output processing, not speakers or
|
|
68
|
+
physical A/V synchronization. `selectAudioTrack(null)` retains the existing Native
|
|
69
|
+
mute behavior; eliminating conversion for disabled audio is not qualified here.
|
|
70
|
+
|
|
71
|
+
## Lifecycle and resources
|
|
72
|
+
|
|
73
|
+
Preparation uses existing File/range/AVIO workers, cancellation mailboxes, source
|
|
74
|
+
identities, deadlines, append admission and worker retirement. Normal playback
|
|
75
|
+
converts ahead incrementally; paused playback stops conversion at the current
|
|
76
|
+
bounded target. Distant seeks restart near the target and retain pause intent.
|
|
77
|
+
Buffered seeks retain the worker/generation only with current MSE coverage and RAP
|
|
78
|
+
eligibility. Overlapping public operations remain serialized.
|
|
79
|
+
|
|
80
|
+
PCM FIFO is capped at 131072 samples and individual decoded frames at 65536.
|
|
81
|
+
Preparation Wasm starts at 64 MiB with a 128 MiB maximum; existing transport,
|
|
82
|
+
fragment and MSE caps remain in effect. Browser decoder allocations are opaque.
|
|
83
|
+
Diagnostics record copied video packets, decoded frames/samples, encoded
|
|
84
|
+
samples/packets, generated bytes, buffered ranges and cancellation snapshots.
|
|
85
|
+
These are not a complete aggregate resident-memory accounting system.
|
|
86
|
+
|
|
87
|
+
## Executed evidence
|
|
88
|
+
|
|
89
|
+
Raw logs, browser JSON, captured output MP4, fixture commands and hashes are under
|
|
90
|
+
`results/optimization-integration/stage2/`. Failed attempts are retained.
|
|
91
|
+
|
|
92
|
+
| Check | Result and limit |
|
|
93
|
+
|---|---|
|
|
94
|
+
| Eight B0/B2 × zero/nonzero start × duration-match fixtures plus original edge | Chrome and Firefox pass through final output; all copied video packet payloads and PTS offsets preserved; audio decode-back byte exact |
|
|
95
|
+
| Original edge video | Offline decoded frame hashes match; no missing final frames |
|
|
96
|
+
| Two-audio fixture | Chrome selects mono 44.1 kHz PCM16, preserves selection across gain reopen, sample-exact decode-back |
|
|
97
|
+
| Separate audio start offset | Firefox preserves 137 ms audio/video offset |
|
|
98
|
+
| Paused adaptation + gain | Chrome/Firefox: conversion counters stable while paused, bounded ahead, buffered worker reuse, distant/overlapping seeks preserve pause |
|
|
99
|
+
| Real authenticated ranges | Chrome/Firefox: authorization survives copy-to-adaptation transition |
|
|
100
|
+
| Outstanding response-body barrier | Chrome/Firefox: destroy aborts pending open and retires all workers promptly |
|
|
101
|
+
| Incorrect Content-Range | Chrome/Firefox reject |
|
|
102
|
+
| PCM32, float and surround | Chrome explicit precision/layout rejection; cleanup passes |
|
|
103
|
+
| Saved streaming overlay plus actual optimization delta | Assembly 12 compiles; 59 contracts pass |
|
|
104
|
+
| Root contracts with owned range server | 61 pass |
|
|
105
|
+
| Baseline output/signal checks | Chrome: direct, remux, gain, Hybrid, filtered Hybrid, Software pass |
|
|
106
|
+
| Installed clean consumer | Five Chrome routes pass, including optional FLAC assets copied by the public CLI |
|
|
107
|
+
|
|
108
|
+
The first range-server test command lacked its required server and failed with
|
|
109
|
+
ECONNREFUSED; the corrected invocation passes. An authenticated test initially
|
|
110
|
+
omitted `If-Range` from its test server's CORS allow-list; fixing the harness resolves
|
|
111
|
+
that failure. The first adapter rejected unspecified Matroska mono/stereo layouts;
|
|
112
|
+
explicit conventional-layout handling resolves that case. No failure is deleted.
|
|
113
|
+
|
|
114
|
+
**Assembly evidence correction:** stage 1 assemblies 02–07 silently skipped tracked
|
|
115
|
+
patches. Their passes establish only saved-overlay behavior. The new assembler
|
|
116
|
+
uses reviewed three-way merges, records each merged file hash, and fails on unknown
|
|
117
|
+
conflicts. Assembly 12 checks combined code. Saved HLS/DASH manifests, qualification
|
|
118
|
+
gates, lockfiles and patch collections remain unchanged. Live/ABR admission has not
|
|
119
|
+
been broadened, and no replacement streaming library was introduced.
|
|
120
|
+
|
|
121
|
+
## Reproduction and packaging
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
python3 experiments/optimization-integration/fixtures.py
|
|
125
|
+
python3 experiments/optimization-integration/prepare.py --output build/streaming-new
|
|
126
|
+
# Build from the assembled tree so its exact saved locks and patches are used:
|
|
127
|
+
python3 build/streaming-new/streaming/scripts/build-audio-adaptation.py \
|
|
128
|
+
--sdk /path/to/emsdk-4.0.14 --archive /path/to/verified-ffmpeg.tar.gz \
|
|
129
|
+
--output /absolute/path/to/new-adaptation-build
|
|
130
|
+
# Copy only the generated matching remux.mjs/remux.wasm to web/engine-adaptation.
|
|
131
|
+
npm run build
|
|
132
|
+
node tests/audio-adaptation.mjs
|
|
133
|
+
BROWSER=firefox node tests/audio-adaptation.mjs
|
|
134
|
+
node tests/audio-adaptation-lifecycle.mjs
|
|
135
|
+
node tests/audio-adaptation-cost.mjs
|
|
136
|
+
python3 scripts/package-beta.py --output build/package-new \
|
|
137
|
+
--adaptation-build /path/to/versioned-engine-directory
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The optional local package includes matched assets, runtime hashes and FFmpeg
|
|
141
|
+
notices. A companion contains preferred patched FFmpeg source, exact patches/locks,
|
|
142
|
+
configuration and immutable preparation source snapshots. Release packaging with
|
|
143
|
+
adaptation is explicitly rejected: full SDK/source-companion release qualification
|
|
144
|
+
is still open. No unrelated benchmark Wasm or LibAV dependency ships.
|
|
145
|
+
|
|
146
|
+
## Remaining gates
|
|
147
|
+
|
|
148
|
+
Native ASS and its paused-resize fix, ASS/adaptation/gain combinations, Opus delay
|
|
149
|
+
and drain, full fidelity-policy routing, complete source/worker fault matrix,
|
|
150
|
+
subtitle fullscreen/PiP/casting behavior, HLS/DASH adaptation and sustained browser
|
|
151
|
+
qualification remain incomplete. Safari/mobile are untested. General automatic
|
|
152
|
+
adaptation is disabled. First/steady fragment tuning, FLAC setting comparisons,
|
|
153
|
+
module reuse, Hybrid copy reductions and new Software YUV artifacts are deferred;
|
|
154
|
+
no performance improvement from these candidates is claimed. See the full candidate
|
|
155
|
+
inventory in [the integration report](OPTIMIZATION-INTEGRATION.md).
|
|
156
|
+
|
|
157
|
+
## Short cost screen
|
|
158
|
+
|
|
159
|
+
Two cold and two warm trials per plan passed on the same 30-second, 160×90
|
|
160
|
+
PCM24 fixture. Each measured interval includes open, at least 10 seconds playback,
|
|
161
|
+
and destroy. This extends the established CDP process-CPU and `ps` RSS method.
|
|
162
|
+
New processes contribute their lifetime CPU; disappearing processes invalidate a
|
|
163
|
+
trial. The first attempt failed its accounting/setup checks and is retained.
|
|
164
|
+
|
|
165
|
+
| Condition | Plan | Mean browser CPU seconds | Mean peak RSS MiB | Mean open ms | Mean progress ms |
|
|
166
|
+
|---|---|---:|---:|---:|---:|
|
|
167
|
+
| cold | native | 3.69 | 1005 | 382 | 652 |
|
|
168
|
+
| cold | hybrid | 5.55 | 1106 | 524 | 775 |
|
|
169
|
+
| warm | native | 3.36 | 1107 | 143 | 414 |
|
|
170
|
+
| warm | hybrid | 5.37 | 1179 | 243 | 501 |
|
|
171
|
+
|
|
172
|
+
Open is promise completion; progress is the first observed public position beyond
|
|
173
|
+
150 ms, not an independent first-photon measurement. Cold means fresh browser,
|
|
174
|
+
not flushed OS caches. RSS includes all observed browser processes and is not
|
|
175
|
+
exclusive memory. External OS media services are excluded. These small-fixture
|
|
176
|
+
results do not qualify universal cost rankings, sustained playback, seek CPU,
|
|
177
|
+
or other new plans. Automatic route ordering remains unchanged. Raw counters
|
|
178
|
+
and per-trial diagnostics are in `stage2/cost-1789507138369/result.json`.
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Optimization integration: local stage checkpoint
|
|
2
|
+
|
|
3
|
+
Historical checkpoint report. For subsequent local implementation and current coverage, see [completion status](OPTIMIZATION-COMPLETION.md).
|
|
4
|
+
|
|
5
|
+
For the subsequent correctness fixes and current unequal-tail limitation, see
|
|
6
|
+
[the review-fix report](OPTIMIZATION-REVIEW-FIXES.md).
|
|
7
|
+
|
|
8
|
+
This is **partial implementation, not completion of the optimization program**.
|
|
9
|
+
Do not promote adaptation, Native ASS, or the new experimental options to general
|
|
10
|
+
automatic admission. A separate maintained audio-preparation engine has been built. Release qualification,
|
|
11
|
+
physical A/V measurement, endurance and performance improvements are not claimed.
|
|
12
|
+
See [the stage 2 report](OPTIMIZATION-FLAC.md) for the current adaptation evidence.
|
|
13
|
+
|
|
14
|
+
## Starting point and isolation
|
|
15
|
+
|
|
16
|
+
Remote refs were fetched on 2026-09-15. `origin/main` remained
|
|
17
|
+
`51f0792fa6c5229a8695d908006a0a573bfc1c10`; the integration branch
|
|
18
|
+
`codex/optimization-integration` starts at saved streaming checkpoint
|
|
19
|
+
`f2491f62c777fa55225aed9b0b7ecf2e340accf7` in a dedicated worktree.
|
|
20
|
+
The original checkout and the adaptation laboratory were not modified.
|
|
21
|
+
An existing `origin/HEAD.lock` prevented the first generic fetch; fetching the two
|
|
22
|
+
explicit refs with remote HEAD following disabled succeeded without deleting it.
|
|
23
|
+
No commit, push, merge, tag, or publication was performed.
|
|
24
|
+
|
|
25
|
+
The original adaptation/risk-review laboratory was found at
|
|
26
|
+
`[local evidence path omitted from runtime package]`.
|
|
27
|
+
Selected original source, patches, failure results and the edge fixture are copied
|
|
28
|
+
under `results/optimization-integration/reference/`, with SHA-256 provenance.
|
|
29
|
+
These are historical test references, excluded from runtime packaging.
|
|
30
|
+
|
|
31
|
+
## Implemented stage
|
|
32
|
+
|
|
33
|
+
- Conservative opt-in buffered remux seeks use **current** media and SourceBuffer
|
|
34
|
+
ranges, a retained random-access point, and accepted source/generation identity.
|
|
35
|
+
They preserve the worker, MediaSource and SourceBuffer. The consumer target moves
|
|
36
|
+
backwards without rewinding the producer or incorrectly evicting the new playhead.
|
|
37
|
+
Native waits for a target video-frame callback, not merely `seeked`, on this path.
|
|
38
|
+
- MSE initialization removes its event listener and clears its deadline on success,
|
|
39
|
+
failure and cancellation. Source initialization accepts one completion only.
|
|
40
|
+
Failed-generation worker messages cannot negotiate a new buffer or append output.
|
|
41
|
+
Repeated remux destruction cannot revoke the same URL again.
|
|
42
|
+
- Native scalar attenuation uses one media-element source and one GainNode output.
|
|
43
|
+
Gain 1 allocates no AudioContext on a new session. Play resumes a suspended
|
|
44
|
+
context; retirement disconnects nodes and closes it. Ordinary volume/mute stay
|
|
45
|
+
on the media element. Remote Native already requires CORS-clean media.
|
|
46
|
+
- Hybrid can retain WebCodecs video with an explicitly admitted scalar mpv audio
|
|
47
|
+
filter. Constructor, dynamic setter, automatic selection and capabilities share
|
|
48
|
+
the feature policy. Unsupported chains go to Software in automatic mode or reject
|
|
49
|
+
in explicit Hybrid mode. They are never silently removed.
|
|
50
|
+
- A finite internal plan registry names the accepted direct/remux/gain/Hybrid/filter/
|
|
51
|
+
Software plans and records source prerequisites, resources, fidelity and fallback.
|
|
52
|
+
Diagnostics expose the actual plan. This is an initial registry; it does not yet
|
|
53
|
+
implement all the requested source/feature/fidelity policy decisions.
|
|
54
|
+
|
|
55
|
+
### Public API additions
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
const player = new Player(container, {
|
|
59
|
+
experimentalBufferedNativeSeeks: true, // default false
|
|
60
|
+
experimentalHybridAudioFilters: true, // default false
|
|
61
|
+
audioFilters: 'lavfi=[volume=0.5]',
|
|
62
|
+
});
|
|
63
|
+
// Separately requested scalar attenuation (0..1, default 1):
|
|
64
|
+
await player.setAudioGain(0.5);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`audioGain` is also a constructor option. It is experimental, not a claim of
|
|
68
|
+
sample-exact final output. Native uses Web Audio; mpv routes use the scalar audio
|
|
69
|
+
filter. `setAudioGain` uses the existing transactional replacement contract,
|
|
70
|
+
preserving position, rate, mute and playback intent. It currently reopens the
|
|
71
|
+
session; it is not an optimized live gain setter. Filters admitted on Hybrid are
|
|
72
|
+
only `volume=N` and `lavfi=[volume=N]`, with finite decimal N from 0 through 1.
|
|
73
|
+
`capabilities.features.audioGain` reports gain support; audio-filter availability
|
|
74
|
+
still requires checking this documented qualified subset. Amplification,
|
|
75
|
+
expressions, other filters and arbitrary chains are not newly admitted.
|
|
76
|
+
|
|
77
|
+
The three public modes and existing default selection behavior are preserved.
|
|
78
|
+
New buffered seeking and Hybrid filters remain explicitly experimental. No
|
|
79
|
+
background Hybrid-to-Native handoff or per-open engine benchmark was added.
|
|
80
|
+
|
|
81
|
+
## Timestamp blocker: historical reproduction and maintained replacement
|
|
82
|
+
|
|
83
|
+
`experiments/optimization-integration/fixtures.py` generates eight small fixtures:
|
|
84
|
+
B-frames 0/2 × start 0/2 seconds × matched/unequal audio duration. The unequal case
|
|
85
|
+
has an awkward final audio-frame length. Commands and SHA-256 hashes are saved in
|
|
86
|
+
`fixture-manifest.json`; packet/stream probes remain in `build/optimization-fixtures`.
|
|
87
|
+
The original 8.1-second risk fixture is retained verbatim in the reference folder.
|
|
88
|
+
|
|
89
|
+
`reproduce-timestamps.mjs` runs the **historical scratch worker**, read-only, using
|
|
90
|
+
the original laboratory LibAV binary only as a reproducer. No benchmark binary is
|
|
91
|
+
added to the product. All eight no-B-frame codec/case combinations convert; all
|
|
92
|
+
eight B-frame combinations fail. Both original edge-fixture runs reproduce:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
Application provided invalid, non monotonically increasing dts to muxer in stream 0: 33600 >= 32528
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The scratch worker reconstructs absent DTS from PTS. That is invalid for reordered
|
|
99
|
+
video. The failure exists independently of the streaming checkpoint. Neither
|
|
100
|
+
clamping DTS, dropping packets, video transcoding nor a blanket B-frame ban was
|
|
101
|
+
implemented. A maintained adaptation pipeline must preserve demux decode order and
|
|
102
|
+
rescale established timestamps, or explicitly reject unavailable timestamp
|
|
103
|
+
information. Stage 2 adds a maintained, opt-in FLAC adapter using the existing bounded
|
|
104
|
+
Matroska/H.264 decode-order reconstruction instead of the scratch algorithm.
|
|
105
|
+
All eight controlled fixtures and the original failure pass in Chrome and Firefox.
|
|
106
|
+
General automatic FLAC and all Opus admission remain disabled. The original scratch adapter also hard-codes AVC MIME, 90-second
|
|
107
|
+
duration, stereo/48 kHz and restricted PCM assumptions; those are not ported.
|
|
108
|
+
|
|
109
|
+
## Complete candidate inventory
|
|
110
|
+
|
|
111
|
+
| Candidate | Stage status and gate |
|
|
112
|
+
|---|---|
|
|
113
|
+
| Buffered Native seeks | Implemented, opt-in; Chrome/Firefox short output/refill checks |
|
|
114
|
+
| Hybrid scalar audio filters | Implemented, opt-in; dynamic reconfiguration and signal checks |
|
|
115
|
+
| Other Hybrid audio filters | Deferred; per-filter latency/continuity qualification required |
|
|
116
|
+
| Native Web Audio scalar gain | Implemented, explicit request; signal/mute/zero/restore checks |
|
|
117
|
+
| Native ASS/libass overlay | Deferred; original loader and paused-resize patch preserved, not integrated |
|
|
118
|
+
| Progressive FLAC adaptation | Implemented for explicit Native trials; maintained FFmpeg 9.0.1; integer mono/stereo qualification only |
|
|
119
|
+
| Explicitly permitted Opus adaptation | Blocked; no implicit lossy permission or fallback |
|
|
120
|
+
| Adaptation + ASS | Disabled, constituent plans unqualified |
|
|
121
|
+
| Adaptation + gain | Implemented, experimental; bounded playback/seek and selected-track tests |
|
|
122
|
+
| Adaptation + ASS + gain | Disabled, constituent plans unqualified |
|
|
123
|
+
| First versus steady fragment sizing | Deferred pending paired cost evidence; existing bounded fragment policy retained |
|
|
124
|
+
| FLAC encoder settings | Deferred; sample-exact adapter and end-to-end benchmark required |
|
|
125
|
+
| Compiled module/worker reuse | Deferred; no cross-source reuse or credential state introduced |
|
|
126
|
+
| Hybrid compressed-packet copies | Inspected; unchanged pending ownership/copy-cost measurement |
|
|
127
|
+
| Packet/configuration adapters | Preserved; codec/configuration tests pass; no replacement claimed |
|
|
128
|
+
| Software YUV/GPU | Existing experimental presenter preserved, RGB default; no new artifact built |
|
|
129
|
+
| Arbitrary Native/Hybrid GPU effects | Separately gated follow-up |
|
|
130
|
+
| Separate audio/video SourceBuffers | Separately gated follow-up |
|
|
131
|
+
| WebCodecs audio decoding | Separately gated follow-up |
|
|
132
|
+
| Authenticated unchanged-byte transport prototype | Not revived; no demonstrated win |
|
|
133
|
+
| Routine Hybrid-to-Native handoff | Not revived |
|
|
134
|
+
| Client video transcoding | Not introduced |
|
|
135
|
+
| Independently clocked custom audio with Native video | Not introduced |
|
|
136
|
+
|
|
137
|
+
## Fidelity, source identity and fallback
|
|
138
|
+
|
|
139
|
+
Original-track direct playback and packet-copy remux retain their preference.
|
|
140
|
+
Explicit Native FLAC trials add selected-audio lossless conversion only. No new
|
|
141
|
+
downmix, sample-rate change or lossy adaptation permission is introduced. The scalar effect is a separately requested transformation, not an
|
|
142
|
+
encoding fidelity claim. Existing browser/mpv output resampling remains governed
|
|
143
|
+
by the existing backend behavior. Final speaker output and physical A/V sync were
|
|
144
|
+
not measured.
|
|
145
|
+
|
|
146
|
+
Existing operation serialization, source-scoped track identities, immutable range
|
|
147
|
+
checks, resource limits, cancellation and fallback loop protection remain active.
|
|
148
|
+
The plan registry does not supersede mpv's streaming scheduler or clock. Existing
|
|
149
|
+
source/integrity errors retain their terminal handling. Broader error classification
|
|
150
|
+
and authorization-refresh policy unification remain outstanding.
|
|
151
|
+
|
|
152
|
+
## Streaming baseline preservation
|
|
153
|
+
|
|
154
|
+
The saved modernization remains staged rather than installed into the root runtime.
|
|
155
|
+
Root engines use mpv 0.40.0 / FFmpeg 7.1.1. The final saved overlay uses mpv 0.41.0 /
|
|
156
|
+
FFmpeg 9.0.1, pinned libass and its maintained browser/AVIO patches. Neither lock nor
|
|
157
|
+
patch collection was changed. TypeScript 5.9.3 and Playwright 1.58.2 remain pinned.
|
|
158
|
+
The saved candidate-26 release/live qualification blockers remain open.
|
|
159
|
+
|
|
160
|
+
`experiments/optimization-integration/prepare.py` checks the exact saved checkpoint,
|
|
161
|
+
runs its unmodified `prepare.py --timeline`, then merges the optimization delta.
|
|
162
|
+
**Correction to stage 1:** assemblies 02–07 silently skipped tracked-file patches
|
|
163
|
+
because `git apply` was invoked from the wrong directory. Their 59 test passes
|
|
164
|
+
covered the saved overlay, not combined implementation. The original logs remain
|
|
165
|
+
historical evidence. Assembly 08 exposed real patch conflicts. The assembler now
|
|
166
|
+
uses a three-way merge and only explicitly reviewed additive resolutions; unknown
|
|
167
|
+
conflicts stop with a saved artifact. Assembly 12 contains the actual delta,
|
|
168
|
+
compiles, and passes all 59 saved integration contracts. These are source/contract
|
|
169
|
+
checks, not rebuilt HLS/DASH browser qualification. The separate FFmpeg 9.0.1 FLAC
|
|
170
|
+
preparation engine uses its own matching glue and explicit remux ABI.
|
|
171
|
+
|
|
172
|
+
## Validation and evidence
|
|
173
|
+
|
|
174
|
+
Evidence lives under `results/optimization-integration/` and the existing harness
|
|
175
|
+
result directories referenced by its logs. Initial build passed. The initial unit
|
|
176
|
+
run had 25 passes plus a browser-harness setup failure from missing generated VP8/
|
|
177
|
+
VP9 fixtures; that run was not a playback regression. The first aggregate streaming
|
|
178
|
+
unit invocation omitted its required environment variables; its failures remain
|
|
179
|
+
saved, followed by the correctly configured run.
|
|
180
|
+
|
|
181
|
+
New contract tests fail on the missing buffered-seek implementation before the
|
|
182
|
+
change, then pass afterward. Cancellation tests establish an outstanding MSE open
|
|
183
|
+
before supersession/destroy and assert no late worker allocation. These are injected
|
|
184
|
+
contracts, not real network-fault coverage.
|
|
185
|
+
|
|
186
|
+
Short Chrome and Firefox checks cover Native direct/remux/gain, ordinary Hybrid,
|
|
187
|
+
filtered Hybrid and Software. Buffered seeks retain identities, present the target
|
|
188
|
+
frame while paused, and resume through refill. Scalar checks compare signal
|
|
189
|
+
amplitudes, mute, zero gain, unity restoration and closed retired contexts. All
|
|
190
|
+
cases assert worker/surface cleanup. Earlier harness mistakes (reading an absent
|
|
191
|
+
`state.paused`, and fetching a fixture from a server-disallowed path) remain saved.
|
|
192
|
+
No amplitude claim is inferred from the earlier visual-only runs.
|
|
193
|
+
|
|
194
|
+
Root playback uses six verified existing engine assets. `runtime-reuse.json`
|
|
195
|
+
records SHA-256 and correspondence to the 51f0792 release archive. Browser glue
|
|
196
|
+
matches exactly except the saved diagnostic product rename. No newer Wasm is paired
|
|
197
|
+
with older glue. The assembled streaming source is tested separately without
|
|
198
|
+
borrowing these engines.
|
|
199
|
+
|
|
200
|
+
Representative commands:
|
|
201
|
+
|
|
202
|
+
```sh
|
|
203
|
+
npm ci --ignore-scripts --no-audit --no-fund
|
|
204
|
+
npm run build
|
|
205
|
+
node --test tests/optimization-contracts.mjs tests/remux-buffering.mjs tests/native-selection.mjs
|
|
206
|
+
python3 experiments/optimization-integration/fixtures.py
|
|
207
|
+
node tests/optimization-playback.mjs
|
|
208
|
+
BROWSER=firefox node tests/optimization-playback.mjs
|
|
209
|
+
LAB_VENDOR=/path/to/preserved/lab/repo/web/adapt/vendor node experiments/optimization-integration/reproduce-timestamps.mjs
|
|
210
|
+
python3 experiments/optimization-integration/prepare.py --output build/optimization-streaming-new
|
|
211
|
+
INTEGRATION_ROOT=build/optimization-streaming-new/streaming RETAINED_WORKER=build/optimization-streaming-new/streaming/web/filter-retained-engine-worker.js node --test experiments/streaming-modernization/integration/*.test.mjs
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Stage 1 had **no paired CPU/memory benchmarks**. Stage 2 adds a bounded
|
|
215
|
+
FLAC-versus-Hybrid cold/warm screen; see [its exact scope](OPTIMIZATION-FLAC.md). Correctness checks and existing
|
|
216
|
+
historical percentages are not performance evidence. The requested cold/warm
|
|
217
|
+
open→10-second playback→destroy comparisons, full lifecycle/range-fault matrix,
|
|
218
|
+
broader adaptation codec/layout qualification, Native ASS/fullscreen/PiP,
|
|
219
|
+
and final rebuilt streaming/browser suites remain outstanding. Safari and mobile
|
|
220
|
+
are not qualified. This checkpoint delivers the implemented stages and preserves
|
|
221
|
+
the unresolved work; it does not satisfy all requested completion gates.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Review fixes: bounded work, track identity and frame-verified seeks
|
|
2
|
+
|
|
3
|
+
Historical checkpoint report. For subsequent local implementation and current coverage, see [completion status](OPTIMIZATION-COMPLETION.md).
|
|
4
|
+
|
|
5
|
+
All three findings from `results/optimization-review/REVIEW.md` are addressed.
|
|
6
|
+
Work remains local and uncommitted on the saved integration checkpoint. This does
|
|
7
|
+
not complete the wider optimization program or enable automatic FLAC admission.
|
|
8
|
+
|
|
9
|
+
## Changes
|
|
10
|
+
|
|
11
|
+
- **Bounded audio tails:** the preparation profile yields after roughly half a
|
|
12
|
+
second of decoded audio even if no further video packet arrives. A single
|
|
13
|
+
decoded frame remains subject to its existing sample cap. The controller limits
|
|
14
|
+
prepared source time separately from MSE buffered intersection. Pausing cannot
|
|
15
|
+
force conversion of an arbitrarily longer audio track.
|
|
16
|
+
- **Explicit unequal-tail limitation:** a single combined SourceBuffer may stop
|
|
17
|
+
exposing playable coverage when its shorter track ends. If playing cannot
|
|
18
|
+
progress within the five-second preparation cap, the adapter reports
|
|
19
|
+
`Adapted track timelines cannot progress within the preparation budget; use Hybrid`.
|
|
20
|
+
Explicit Native does not silently change modes. The regression verifies that
|
|
21
|
+
the application can then switch the same source to Hybrid. Long unmatched tails
|
|
22
|
+
are not newly qualified for Native. Existing short duration mismatches remain
|
|
23
|
+
covered by packet and sample comparisons. No valid packet is dropped or clamped.
|
|
24
|
+
- **Source-scoped audio identity:** both `remux` and `adapted-flac` use the same
|
|
25
|
+
stream-index identity. Public selections survive Native/Hybrid transitions,
|
|
26
|
+
gain replacement and automatic-selection activation. On return to Native, the
|
|
27
|
+
selected stream is passed to preparation before opening; the default track is
|
|
28
|
+
not temporarily adapted first.
|
|
29
|
+
- **Frame-verified seeks:** frame callbacks are registered before issuing the seek and
|
|
30
|
+
accepted only once the browser reports seeking complete at the requested media
|
|
31
|
+
time. Registration cannot wait for the queued DOM `seeking` event, which can
|
|
32
|
+
arrive after the target compositor callback. The callback's frame timestamp can precede the target for low-frame-rate
|
|
33
|
+
or variable-frame-rate content. A future frame cannot satisfy the seek, and a
|
|
34
|
+
retired presentation/generation cannot complete it. The ten-second deadline and
|
|
35
|
+
cancellation cleanup remain. No broad timestamp tolerance or guessed frame rate.
|
|
36
|
+
|
|
37
|
+
## Regression coverage
|
|
38
|
+
|
|
39
|
+
`tests/optimization-review-regressions.mjs` adds three real-browser cases:
|
|
40
|
+
|
|
41
|
+
1. One-second video plus 30-second PCM24 audio: paused work stays below seven
|
|
42
|
+
seconds, remains stable, and the unmatched-tail limitation settles explicitly
|
|
43
|
+
during playback. The source remains usable through Hybrid.
|
|
44
|
+
2. Public second-audio selection across Native → Hybrid → Native, gain replacement,
|
|
45
|
+
and automatic selection. The same public track ID persists, and Native's
|
|
46
|
+
preparation/cancellation counters contain only the selected 44.1 kHz stream.
|
|
47
|
+
3. Three cycles of buffered seeks at 2.5, 2.75, 4.5 and 2.25 seconds in a 1 fps video. Paused
|
|
48
|
+
playback preserves the worker and generation. Browser canvas pixels agree for
|
|
49
|
+
targets covered by the same frame and differ for a different frame. The test
|
|
50
|
+
waits for actual buffered eligibility after refill; Firefox's first fixed-delay
|
|
51
|
+
attempt exercised the safe regeneration path and was retained as harness evidence.
|
|
52
|
+
|
|
53
|
+
Chrome and Firefox pass all three cases. Eighteen targeted root contracts pass,
|
|
54
|
+
including new stale-generation and low-frame-rate seek contracts. Assembly 15
|
|
55
|
+
contains the actual combined streaming delta, compiles, and passes 59 saved
|
|
56
|
+
streaming contracts. Full rebuilt HLS/DASH browser qualification remains gated.
|
|
57
|
+
Additional fidelity, lifecycle and installed-consumer results are indexed in
|
|
58
|
+
`results/optimization-integration/stage3/summary.json`.
|
|
59
|
+
|
|
60
|
+
## Reproduction
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
python3 experiments/optimization-integration/fixtures.py
|
|
64
|
+
npm run build
|
|
65
|
+
node --test tests/optimization-contracts.mjs tests/remux-buffering.mjs tests/native-selection.mjs
|
|
66
|
+
node tests/optimization-review-regressions.mjs
|
|
67
|
+
BROWSER=firefox node tests/optimization-review-regressions.mjs
|
|
68
|
+
node tests/audio-adaptation.mjs
|
|
69
|
+
node tests/audio-adaptation-lifecycle.mjs
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The maintained FLAC engine was relinked with the same saved FFmpeg 9.0.1 libraries,
|
|
73
|
+
locked patches and Emscripten 4.0.14. It has matching new glue and Wasm in a fresh
|
|
74
|
+
versioned build directory. Original engine artifacts, failed reproducers, stage 2
|
|
75
|
+
results and the laboratory remain preserved. No new dependencies, codec upgrades,
|
|
76
|
+
streaming gates or public playback modes were introduced. Earlier cost screens
|
|
77
|
+
remain evidence for their original artifact hashes; they were not rerun for this
|
|
78
|
+
correctness fix and do not qualify the new artifact's performance.
|