@torrent-tv/proxy 2.89.16 → 2.89.18
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/README.md +14 -3
- package/package.json +10 -2
- package/routes/api/client-logs/post.js +9 -2
- package/server.js +0 -11
- package/.claude/commands/opsx/apply.md +0 -155
- package/.claude/commands/opsx/archive.md +0 -160
- package/.claude/commands/opsx/explore.md +0 -174
- package/.claude/commands/opsx/propose.md +0 -109
- package/.claude/commands/opsx/sync.md +0 -143
- package/.claude/skills/openspec-apply-change/SKILL.md +0 -159
- package/.claude/skills/openspec-archive-change/SKILL.md +0 -117
- package/.claude/skills/openspec-explore/SKILL.md +0 -289
- package/.claude/skills/openspec-propose/SKILL.md +0 -113
- package/.claude/skills/openspec-sync-specs/SKILL.md +0 -147
- package/.dockerignore +0 -5
- package/AGENTS.md +0 -363
- package/CHANGELOG.md +0 -2373
- package/Dockerfile +0 -30
- package/biome.json +0 -412
- package/corpus.tmp.json +0 -1
- package/docs/browser-proxy-contract.md +0 -155
- package/docs/container-architecture.md +0 -273
- package/docs/download-architecture.md +0 -261
- package/docs/encode-architecture.md +0 -765
- package/docs/encode-run-state.md +0 -96
- package/docs/logs.md +0 -138
- package/docs/playback-start-forecast.md +0 -113
- package/docs/socks5-egress-research.md +0 -114
- package/docs/storage-architecture.md +0 -273
- package/knip.json +0 -14
- package/main2.cpuprofile +0 -1
- package/openspec/changes/adaptive-bitrate/.openspec.yaml +0 -0
- package/openspec/changes/adaptive-bitrate/design.md +0 -92
- package/openspec/changes/adaptive-bitrate/proposal.md +0 -56
- package/openspec/changes/adaptive-bitrate/specs/adaptive-bitrate/spec.md +0 -51
- package/openspec/changes/adaptive-bitrate/tasks.md +0 -40
- package/openspec/changes/binary-distribution/.openspec.yaml +0 -2
- package/openspec/changes/binary-distribution/proposal.md +0 -53
- package/openspec/changes/chunked-request-bodies/design.md +0 -81
- package/openspec/changes/chunked-request-bodies/proposal.md +0 -53
- package/openspec/changes/chunked-request-bodies/specs/chunked-request-bodies/spec.md +0 -30
- package/openspec/changes/chunked-request-bodies/tasks.md +0 -40
- package/openspec/changes/cold-start/design.md +0 -98
- package/openspec/changes/cold-start/proposal.md +0 -62
- package/openspec/changes/cold-start/specs/cold-start/spec.md +0 -47
- package/openspec/changes/cold-start/tasks.md +0 -48
- package/openspec/changes/disk-cap/.openspec.yaml +0 -2
- package/openspec/changes/disk-cap/proposal.md +0 -37
- package/openspec/changes/disk-cap/specs/disk-cap/spec.md +0 -25
- package/openspec/changes/disk-cap/tasks.md +0 -19
- package/openspec/changes/proxy-observability/.openspec.yaml +0 -2
- package/openspec/changes/proxy-observability/design.md +0 -38
- package/openspec/changes/proxy-observability/proposal.md +0 -49
- package/openspec/changes/proxy-observability/specs/observability/spec.md +0 -33
- package/openspec/changes/proxy-observability/tasks.md +0 -21
- package/openspec/changes/seek-debounce/.openspec.yaml +0 -0
- package/openspec/changes/seek-debounce/design.md +0 -118
- package/openspec/changes/seek-debounce/proposal.md +0 -59
- package/openspec/changes/seek-debounce/specs/seek-debounce/spec.md +0 -41
- package/openspec/changes/seek-debounce/tasks.md +0 -33
- package/openspec/changes/subtitle-language/.openspec.yaml +0 -2
- package/openspec/changes/subtitle-language/proposal.md +0 -50
- package/openspec/changes/subtitle-language/specs/subtitle-language/spec.md +0 -34
- package/openspec/changes/subtitle-language/tasks.md +0 -26
- package/openspec/changes/track-selection/.openspec.yaml +0 -2
- package/openspec/changes/track-selection/design.md +0 -47
- package/openspec/changes/track-selection/proposal.md +0 -45
- package/openspec/changes/track-selection/specs/track-selection/spec.md +0 -41
- package/openspec/changes/track-selection/tasks.md +0 -20
- package/openspec/changes/transcode-quality/.openspec.yaml +0 -2
- package/openspec/changes/transcode-quality/proposal.md +0 -51
- package/openspec/changes/transcode-quality/specs/transcode-quality/spec.md +0 -139
- package/openspec/changes/transcode-quality/tasks.md +0 -63
- package/openspec/config.yaml +0 -38
- package/public/.well-known/appspecific/com.chrome.devtools.json +0 -1
- package/research/delivery-wedge-stand-ladder-2026-09-13.md +0 -329
- package/research/double-spawn-2026-09-10.md +0 -171
- package/research/handover-2026-09-13.md +0 -209
- package/research/handover-reader-claims-removal-2026-09-12.md +0 -166
- package/research/piece-withdrawn-but-still-claimed-2026-09-12.md +0 -175
- package/research/preset-benchmark-size-scaling-2026-08-22.md +0 -55
- package/research/priority-map-is-the-truth-2026-09-12.md +0 -225
- package/research/valgrind-replica-2026-08-27/logs.tar.gz +0 -0
- package/scripts/build-audio-samples.mjs +0 -31
- package/scripts/render-run-graph.js +0 -173
- package/test/asset-paths.test.js +0 -28
- package/test/audio-buffer-continuity.test.js +0 -77
- package/test/audio-calibration.test.js +0 -23
- package/test/audio-inventory.test.js +0 -212
- package/test/audio-track-bitrate.test.js +0 -40
- package/test/audio-warm-recorded.test.js +0 -63
- package/test/auto-quality-step.test.js +0 -762
- package/test/available-share.test.js +0 -76
- package/test/background-fill.test.js +0 -190
- package/test/client-log-file.test.js +0 -126
- package/test/coalesce.test.js +0 -39
- package/test/completed-files.test.js +0 -115
- package/test/concurrent-cost.test.js +0 -148
- package/test/container-media-info.test.js +0 -228
- package/test/contention.test.js +0 -76
- package/test/core-dumps.test.js +0 -57
- package/test/coverage-follows-the-disk.test.js +0 -233
- package/test/coverage-map.test.js +0 -195
- package/test/cue-push-carries-what-the-walk-found.test.js +0 -58
- package/test/cut-times-timeline.test.js +0 -65
- package/test/cuts-follow-published-grid.test.js +0 -109
- package/test/data-channel-frame.test.js +0 -63
- package/test/data-channel-viewer-lifecycle.test.js +0 -193
- package/test/dead-torrent-handle.test.js +0 -52
- package/test/declared-rates.test.js +0 -116
- package/test/declared-tracks.test.js +0 -43
- package/test/decode-cost-fit.test.js +0 -202
- package/test/decode-cost.test.js +0 -475
- package/test/delivery-probe-field.test.js +0 -173
- package/test/delivery-probe.test.js +0 -382
- package/test/demand-register.test.js +0 -206
- package/test/dht-bootstrap.test.js +0 -72
- package/test/drain-threat.test.js +0 -65
- package/test/duplicate-add.test.js +0 -48
- package/test/encode-admission.test.js +0 -170
- package/test/encode-cost.test.js +0 -275
- package/test/encode-exit.test.js +0 -111
- package/test/encode-orchestrator.test.js +0 -426
- package/test/encode-plan-viewers.test.js +0 -725
- package/test/encode-plan.test.js +0 -545
- package/test/encode-run-state.test.js +0 -314
- package/test/encode-run.test.js +0 -248
- package/test/encode-slope.test.js +0 -46
- package/test/encoded-output.test.js +0 -39
- package/test/encoder-kinds.test.js +0 -122
- package/test/encoder-readings.test.js +0 -68
- package/test/episode-naming.test.js +0 -131
- package/test/every-claimant-is-told-its-share.test.js +0 -152
- package/test/failed-encoder-still-serves-what-exists.test.js +0 -354
- package/test/failed-start-breaker.test.js +0 -202
- package/test/fastest-wires.test.js +0 -143
- package/test/ffmpeg-stream-counts.test.js +0 -101
- package/test/file-edges.test.js +0 -191
- package/test/files-in-use.test.js +0 -34
- package/test/fixtures/audio-frame-boundary.json +0 -1
- package/test/fixtures/refused-audio-20261002.json +0 -10
- package/test/fmp4-presentation-clock.test.js +0 -148
- package/test/fmp4-self-contained.test.js +0 -80
- package/test/fmp4-timestamps.test.js +0 -140
- package/test/fmp4-track-completeness.test.js +0 -41
- package/test/format-keyed-outputs.test.js +0 -78
- package/test/health-metrics.test.js +0 -36
- package/test/held-read-ownership.test.js +0 -77
- package/test/held-request-width.test.js +0 -157
- package/test/helpers/encode-run.js +0 -248
- package/test/helpers/held-file.js +0 -77
- package/test/helpers/manager.js +0 -62
- package/test/helpers/matroska-file.js +0 -296
- package/test/helpers/output-spec.js +0 -63
- package/test/host-load.test.js +0 -68
- package/test/index-accuracy-is-about-the-file.test.js +0 -128
- package/test/init-compat.test.js +0 -219
- package/test/input-lost-quiets-the-plan.test.js +0 -261
- package/test/input-unavailable.test.js +0 -48
- package/test/installation-id.test.js +0 -39
- package/test/keeping-period.test.js +0 -83
- package/test/keyframe-index-accuracy.test.js +0 -188
- package/test/keyframe-table-budget.test.js +0 -123
- package/test/keyframes-belong-to-the-file.test.js +0 -249
- package/test/learned-median.test.js +0 -37
- package/test/letting-go-asks-who-is-watching.test.js +0 -191
- package/test/limit-row-by-area.test.js +0 -60
- package/test/link-budget.test.js +0 -111
- package/test/link-probe.test.js +0 -56
- package/test/local-encoding-data.test.js +0 -273
- package/test/logger-repeats.test.js +0 -134
- package/test/look-ahead-coverage.test.js +0 -56
- package/test/manager-surface.test.js +0 -291
- package/test/matroska-blocks.test.js +0 -0
- package/test/matroska-cluster-discovery.test.js +0 -323
- package/test/matroska-cues-track.test.js +0 -192
- package/test/media-time.test.js +0 -62
- package/test/memory-budget.test.js +0 -390
- package/test/move-cost.test.js +0 -216
- package/test/mp4-composition-times.test.js +0 -0
- package/test/mp4-subtitles.test.js +0 -173
- package/test/one-authority.test.js +0 -285
- package/test/one-budget.test.js +0 -149
- package/test/one-output-one-session.test.js +0 -273
- package/test/one-resource-divided.test.js +0 -185
- package/test/one-serving-output-per-height.test.js +0 -458
- package/test/orchestrator-wired.test.js +0 -207
- package/test/output-catalog.test.js +0 -39
- package/test/output-shape.test.js +0 -21
- package/test/output-spec.test.js +0 -251
- package/test/output-speed.test.js +0 -92
- package/test/outputs-being-prepared.test.js +0 -40
- package/test/packet-witness-ring.test.js +0 -236
- package/test/packet-witness.test.js +0 -148
- package/test/piece-completeness.test.js +0 -78
- package/test/piece-disk-store.test.js +0 -401
- package/test/piece-from-whole-file.test.js +0 -129
- package/test/piece-lru.test.js +0 -319
- package/test/piece-reader.test.js +0 -162
- package/test/piece-selection-offset.test.js +0 -85
- package/test/piece-store-eviction.test.js +0 -595
- package/test/piece-store-never-refuses.test.js +0 -153
- package/test/piece-store-reservations.test.js +0 -403
- package/test/piece-store-slow-disk.test.js +0 -159
- package/test/piece-tail.test.js +0 -97
- package/test/plan-host-timings.test.js +0 -68
- package/test/plan-is-steady.test.js +0 -225
- package/test/playback-readiness.test.js +0 -518
- package/test/playback-start-regressions.test.js +0 -101
- package/test/priority-map-download.test.js +0 -174
- package/test/priority-map-emptied.test.js +0 -204
- package/test/priority-map-per-output.test.js +0 -215
- package/test/priority-map.test.js +0 -163
- package/test/probe-wedge-certainty.test.js +0 -60
- package/test/produced-copy-choice.test.js +0 -213
- package/test/published-timeline.test.js +0 -83
- package/test/quality-offer.test.js +0 -160
- package/test/quality-variants.test.js +0 -1274
- package/test/rate-control-in-the-output.test.js +0 -181
- package/test/read-survives-withdrawal.test.js +0 -164
- package/test/read-window.test.js +0 -365
- package/test/reads-not-yet-arrived.test.js +0 -218
- package/test/resume-warm.test.js +0 -39
- package/test/run-graph-drift.test.js +0 -37
- package/test/run-inputs.test.js +0 -80
- package/test/run-intervals.test.js +0 -100
- package/test/run-position-follows-published-grid.test.js +0 -89
- package/test/run-progress.test.js +0 -64
- package/test/same-height-switch.test.js +0 -663
- package/test/seek-frees-the-viewers-requests.test.js +0 -217
- package/test/seek-landing.test.js +0 -109
- package/test/seek-target-not-superseded.test.js +0 -195
- package/test/segment-closed-on-both-branches.test.js +0 -114
- package/test/segment-cut-times.test.js +0 -63
- package/test/segment-demand.test.js +0 -80
- package/test/segment-hold-supersede.test.js +0 -91
- package/test/segment-judged-by-its-own-header.test.js +0 -222
- package/test/segment-serve-wiring.test.js +0 -481
- package/test/segment-store-eviction.test.js +0 -247
- package/test/segment-store.test.js +0 -352
- package/test/segment-true-start.test.js +0 -86
- package/test/segments-are-shared.test.js +0 -176
- package/test/send-chunk-bytes.test.js +0 -86
- package/test/serving-existing-output.test.js +0 -111
- package/test/serving-output.test.js +0 -102
- package/test/shared-piece-store.test.js +0 -310
- package/test/sidecar-naming.test.js +0 -142
- package/test/soundtrack-rate-bound.test.js +0 -289
- package/test/source-file.test.js +0 -133
- package/test/source-files-route.test.js +0 -113
- package/test/source-registry.test.js +0 -18
- package/test/split-a-stretch.test.js +0 -139
- package/test/stale-request-after-seek.test.js +0 -158
- package/test/startup-readings.test.js +0 -124
- package/test/stream-route.test.js +0 -237
- package/test/subtitle-cue-framing.test.js +0 -200
- package/test/subtitle-cue-source.test.js +0 -102
- package/test/subtitle-cue-walk.test.js +0 -385
- package/test/subtitle-cursor.test.js +0 -63
- package/test/subtitle-defaults.test.js +0 -118
- package/test/subtitle-language.test.js +0 -252
- package/test/subtitle-metadata.test.js +0 -15
- package/test/subtitle-plan-waits.test.js +0 -125
- package/test/subtitle-track-numbering.test.js +0 -391
- package/test/supply-margin.test.js +0 -190
- package/test/swarm-follows-readers.test.js +0 -174
- package/test/swarm-reach.test.js +0 -130
- package/test/swarm-selection.test.js +0 -220
- package/test/tail-duplication.test.js +0 -167
- package/test/the-channel-has-both-ends.test.js +0 -91
- package/test/the-torrent-thread-serves-bytes.test.js +0 -107
- package/test/thread-pool.test.js +0 -53
- package/test/timeline.test.js +0 -84
- package/test/torrent-contents.test.js +0 -235
- package/test/torrent-cost.test.js +0 -71
- package/test/torrent-files.test.js +0 -221
- package/test/torrent-naming.test.js +0 -255
- package/test/tracks-begin-together.test.js +0 -209
- package/test/tunnel-renewal.test.js +0 -167
- package/test/two-viewers-one-picture.test.js +0 -508
- package/test/upload-hurry.test.js +0 -186
- package/test/usrsctp-state.test.js +0 -131
- package/test/video-facts.test.js +0 -102
- package/test/viewer-assignments.test.js +0 -143
- package/test/viewer-outputs.test.js +0 -285
- package/test/viewer-presence.test.js +0 -116
- package/test/viewer-requests-admission.test.js +0 -92
- package/test/viewer-starts-on-map.test.js +0 -27
- package/test/viewer-states.test.js +0 -192
- package/test/viewer-subtitle-subscription.test.js +0 -96
- package/test/viewer.test.js +0 -139
- package/test/viewing-generations.test.js +0 -390
- package/test/visible-rung.test.js +0 -37
- package/test/wait-ledger.test.js +0 -100
- package/test/webrtc-shim.test.js +0 -149
- package/test/wedge-certainty.test.js +0 -131
- package/test/whole-file-held-read.test.js +0 -30
- package/test/withdraw-piece-claim.test.js +0 -212
- package/test/worker-channel.test.js +0 -158
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file What the plan believes exists is what the disk holds — with a real
|
|
3
|
-
* store, a real directory, and no ffmpeg.
|
|
4
|
-
*
|
|
5
|
-
* The failure these are written against, field 2026-09-07, twice in one evening
|
|
6
|
-
* on `Star.Trek.Strange.New.Worlds.S04E03`:
|
|
7
|
-
*
|
|
8
|
-
* > `encode: … ready=482 zones=[p100:#0..#0 …] runs=[#0..#0@0.0x] waiting=nobody`
|
|
9
|
-
* > `encode-run stopped #0..#0 …, reached #-1 (0 segment(s)) after 2778ms,`
|
|
10
|
-
* > `signal SIGTERM: the film is no worse off without it`
|
|
11
|
-
* > `encode: … ready=482 … runs=[] waiting=nobody`
|
|
12
|
-
*
|
|
13
|
-
* The map claimed every one of the film's 482 segments while the directory held
|
|
14
|
-
* nothing a header could be lifted out of, so every arrangement scored perfect,
|
|
15
|
-
* the only encoder was taken away as unnecessary and none was placed again. The
|
|
16
|
-
* viewer's browser asked for the init segment, was never answered, and gave up.
|
|
17
|
-
*
|
|
18
|
-
* Readiness had been accumulating for the life of the process: the map was told
|
|
19
|
-
* what existed and never told what had stopped existing — the word for that
|
|
20
|
-
* existed and was called from no line of the product. So these check the one
|
|
21
|
-
* property that makes the whole class of failure impossible: what the map says
|
|
22
|
-
* is ready is what the store can prove right now, and nothing older.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import test from "node:test";
|
|
26
|
-
import assert from "node:assert/strict";
|
|
27
|
-
import { EventEmitter } from "node:events";
|
|
28
|
-
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
29
|
-
import os from "node:os";
|
|
30
|
-
import path from "node:path";
|
|
31
|
-
import { EncodeRun } from "../services/encode/EncodeRun.js";
|
|
32
|
-
import { SegmentStore } from "../services/storage/segment-store/SegmentStore.js";
|
|
33
|
-
import { SoftwareEncoder } from "../services/encode/SoftwareEncoder.js";
|
|
34
|
-
import { EncodeOrchestrator } from "../services/encode/EncodeOrchestrator.js";
|
|
35
|
-
import { fmp4Format } from "../services/encode/segment-formats/fmp4.js";
|
|
36
|
-
|
|
37
|
-
const PICTURE = "torrent:abc:fmt=fmp4:grid=kf@0:video-only:v=0/copy";
|
|
38
|
-
const SEGMENTS = 482;
|
|
39
|
-
|
|
40
|
-
class FakeProcess extends EventEmitter {
|
|
41
|
-
constructor() {
|
|
42
|
-
super();
|
|
43
|
-
this.pid = 1;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
kill(signal) {
|
|
47
|
-
this.emit("exit", null, signal);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* A store on a real directory, and an orchestrator that owns it.
|
|
53
|
-
*
|
|
54
|
-
* @returns {{ made: EncodeOrchestrator, store: SegmentStore, dir: string,
|
|
55
|
-
* root: string, lines: string[] }}
|
|
56
|
-
*/
|
|
57
|
-
function orchestratorWithAStore() {
|
|
58
|
-
const root = mkdtempSync(path.join(os.tmpdir(), "coverage-disk-"));
|
|
59
|
-
const lines = [];
|
|
60
|
-
const logger = { info: (line) => lines.push(line), warn: (line) => lines.push(line) };
|
|
61
|
-
const store = new SegmentStore({ root, logger });
|
|
62
|
-
store.useFormat(PICTURE, fmp4Format);
|
|
63
|
-
const dir = store.directoryFor(PICTURE);
|
|
64
|
-
/** @type {EncodeOrchestrator} */
|
|
65
|
-
let made;
|
|
66
|
-
made = new EncodeOrchestrator({
|
|
67
|
-
maxRunsFor: () => 1,
|
|
68
|
-
segmentSeconds: 6,
|
|
69
|
-
killCostSec: 0,
|
|
70
|
-
firstByteWaitSec: 0.12,
|
|
71
|
-
refetchSecPerFilmSecond: () => 0.25,
|
|
72
|
-
startingSpeedFor: () => 2,
|
|
73
|
-
segmentCoverage: {
|
|
74
|
-
provenNumbers: (address) => store.provenNumbers(address),
|
|
75
|
-
announce: (address, index) => store.announce(address, index),
|
|
76
|
-
filesHeld: (address) => store.filesHeld(address),
|
|
77
|
-
clearUpAfter: (address, startedAt) => store.clearUpAfter(address, startedAt)
|
|
78
|
-
},
|
|
79
|
-
now: () => 1000,
|
|
80
|
-
logger,
|
|
81
|
-
makeRun: ({ address, from, to }) => new EncodeRun({
|
|
82
|
-
address,
|
|
83
|
-
encoder: new SoftwareEncoder(),
|
|
84
|
-
from,
|
|
85
|
-
to,
|
|
86
|
-
buildArgs: () => ["-i", "in", "out"],
|
|
87
|
-
spawn: () => new FakeProcess(),
|
|
88
|
-
logger,
|
|
89
|
-
now: () => 1000,
|
|
90
|
-
onEnded: (ended) => made.noteEnded(ended)
|
|
91
|
-
})
|
|
92
|
-
});
|
|
93
|
-
made.setSegmentCount(PICTURE, SEGMENTS);
|
|
94
|
-
return { made, store, dir, root, lines };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** A viewer stopped at the beginning, which is what a fresh session states. */
|
|
98
|
-
function aViewerAtTheStart(made) {
|
|
99
|
-
made.notePriorityMap(PICTURE, [
|
|
100
|
-
{ from: 0, to: 0, priority: 100, withinSeconds: 0 },
|
|
101
|
-
{ from: 1, to: SEGMENTS - 1, priority: 91, withinSeconds: 6 }
|
|
102
|
-
]);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Every segment of the film, written and reported closed — what the store looked
|
|
107
|
-
* like while the film was being watched.
|
|
108
|
-
*/
|
|
109
|
-
function theWholeFilmIsOnDisk(store, dir) {
|
|
110
|
-
for (let index = 0; index < SEGMENTS; index += 1) {
|
|
111
|
-
// Under the served name, which is the whole of what says a piece is closed:
|
|
112
|
-
// it takes that name only when its writer has said so. There used to be a
|
|
113
|
-
// statement kept beside the disk as well, told by whoever noticed a piece
|
|
114
|
-
// being produced — a second owner of one fact, and the fault this file's own
|
|
115
|
-
// subject is.
|
|
116
|
-
writeFileSync(path.join(dir, fmp4Format.segmentFileName(index)), Buffer.alloc(16));
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
test("a film that is entirely made needs no encoder", (t) => {
|
|
121
|
-
const { made, store, dir, root } = orchestratorWithAStore();
|
|
122
|
-
t.after(() => {
|
|
123
|
-
// THE STORE LETS ITS DIRECTORIES GO, and only then is the root removed. It
|
|
124
|
-
// holds a watch on each of them — that is how a piece closed by a muxer
|
|
125
|
-
// with no channel of its own becomes an event — and a directory with an
|
|
126
|
-
// open watch on it cannot be removed on Windows: `rmSync` retries until it
|
|
127
|
-
// gives up, and the check reads as a hang.
|
|
128
|
-
store.dropAll("the check is over");
|
|
129
|
-
rmSync(root, { recursive: true, force: true });
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
theWholeFilmIsOnDisk(store, dir);
|
|
133
|
-
aViewerAtTheStart(made);
|
|
134
|
-
made.reconcile();
|
|
135
|
-
|
|
136
|
-
// The other half of the property, and the reason the failure looked
|
|
137
|
-
// reasonable: when the film really is all there, taking the encoder away IS
|
|
138
|
-
// right, and the viewer is served from the disk.
|
|
139
|
-
assert.equal(made.runsOn(PICTURE).length, 0, "nothing left to make");
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
test("segments the store has lost stop being ready, and an encoder is placed again", (t) => {
|
|
143
|
-
const { made, store, dir, root } = orchestratorWithAStore();
|
|
144
|
-
t.after(() => {
|
|
145
|
-
// THE STORE LETS ITS DIRECTORIES GO, and only then is the root removed. It
|
|
146
|
-
// holds a watch on each of them — that is how a piece closed by a muxer
|
|
147
|
-
// with no channel of its own becomes an event — and a directory with an
|
|
148
|
-
// open watch on it cannot be removed on Windows: `rmSync` retries until it
|
|
149
|
-
// gives up, and the check reads as a hang.
|
|
150
|
-
store.dropAll("the check is over");
|
|
151
|
-
rmSync(root, { recursive: true, force: true });
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
theWholeFilmIsOnDisk(store, dir);
|
|
155
|
-
aViewerAtTheStart(made);
|
|
156
|
-
made.reconcile();
|
|
157
|
-
assert.equal(made.runsOn(PICTURE).length, 0);
|
|
158
|
-
|
|
159
|
-
// THE FIELD FAILURE. The output's directory goes — dropped for room, or by the
|
|
160
|
-
// idle rule, or because a killed process left it and the sweep cleared it. The
|
|
161
|
-
// map used to keep all 482 numbers and the plan went on believing the film was
|
|
162
|
-
// made, for the life of the process.
|
|
163
|
-
store.drop(PICTURE, "the test is taking its files away");
|
|
164
|
-
store.useFormat(PICTURE, fmp4Format);
|
|
165
|
-
store.directoryFor(PICTURE);
|
|
166
|
-
|
|
167
|
-
made.reconcile();
|
|
168
|
-
const runs = made.runsOn(PICTURE);
|
|
169
|
-
assert.equal(runs.length, 1, "the film is unmade again, so somebody makes it");
|
|
170
|
-
assert.equal(runs[0].from, 0, "beginning where the viewer is stopped");
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
test("a piece discarded with the run that had it open is not ready either", (t) => {
|
|
174
|
-
const { made, store, dir, root } = orchestratorWithAStore();
|
|
175
|
-
t.after(() => {
|
|
176
|
-
// THE STORE LETS ITS DIRECTORIES GO, and only then is the root removed. It
|
|
177
|
-
// holds a watch on each of them — that is how a piece closed by a muxer
|
|
178
|
-
// with no channel of its own becomes an event — and a directory with an
|
|
179
|
-
// open watch on it cannot be removed on Windows: `rmSync` retries until it
|
|
180
|
-
// gives up, and the check reads as a hang.
|
|
181
|
-
store.dropAll("the check is over");
|
|
182
|
-
rmSync(root, { recursive: true, force: true });
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
theWholeFilmIsOnDisk(store, dir);
|
|
186
|
-
aViewerAtTheStart(made);
|
|
187
|
-
made.reconcile();
|
|
188
|
-
assert.equal(made.runsOn(PICTURE).length, 0);
|
|
189
|
-
|
|
190
|
-
// A run stopped the instant after opening #0 leaves a file of no bytes under a
|
|
191
|
-
// name that reads as a segment; the store throws it away. Field 2026-09-07,
|
|
192
|
-
// 20:13:13 and 20:13:57 — printed twice while the map went on saying 482.
|
|
193
|
-
// Whoever removes a piece tells the store, as the serving path does after
|
|
194
|
-
// taking out a piece short of a track: the store's memory of a directory ends
|
|
195
|
-
// on an event, not on the directory's modification time, which moves in
|
|
196
|
-
// steps of several milliseconds and can stay where it was.
|
|
197
|
-
rmSync(path.join(dir, fmp4Format.segmentFileName(0)), { force: true });
|
|
198
|
-
store.forget(PICTURE);
|
|
199
|
-
|
|
200
|
-
made.reconcile();
|
|
201
|
-
assert.equal(made.runsOn(PICTURE).length, 1, "one number missing is one encoder");
|
|
202
|
-
assert.equal(made.runsOn(PICTURE)[0].from, 0);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
test("nobody making what somebody waits for is said out loud", (t) => {
|
|
206
|
-
const { made, store, root, lines } = orchestratorWithAStore();
|
|
207
|
-
t.after(() => {
|
|
208
|
-
// THE STORE LETS ITS DIRECTORIES GO, and only then is the root removed. It
|
|
209
|
-
// holds a watch on each of them — that is how a piece closed by a muxer
|
|
210
|
-
// with no channel of its own becomes an event — and a directory with an
|
|
211
|
-
// open watch on it cannot be removed on Windows: `rmSync` retries until it
|
|
212
|
-
// gives up, and the check reads as a hang.
|
|
213
|
-
store.dropAll("the check is over");
|
|
214
|
-
rmSync(root, { recursive: true, force: true });
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
// A HOST THAT CANNOT BUILD AN ENCODER. Whatever the reason — and there are
|
|
218
|
-
// several — the state it leaves is the one that cost two sessions on
|
|
219
|
-
// 2026-09-07: somebody is waiting, nothing is being made, and every line
|
|
220
|
-
// above reads as a healthy proxy. It ran for 41 seconds in the field with no
|
|
221
|
-
// word about it on either side, and ended at the browser's own timeout with a
|
|
222
|
-
// message naming no cause.
|
|
223
|
-
made.makeRun = () => null;
|
|
224
|
-
aViewerAtTheStart(made);
|
|
225
|
-
made.reconcile();
|
|
226
|
-
|
|
227
|
-
assert.equal(made.runsOn(PICTURE).length, 0);
|
|
228
|
-
const said = lines.find((line) => line.includes("NO ENCODER IS MAKING IT"));
|
|
229
|
-
assert.ok(said, "the state has a line of its own");
|
|
230
|
-
assert.ok(said.includes("#0"), "which number is wanted");
|
|
231
|
-
assert.ok(said.includes(PICTURE), "of which output, whole — not cut to sixty characters");
|
|
232
|
-
assert.ok(/files=\d+/.test(said), "and what the disk holds, beside what is proven");
|
|
233
|
-
});
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file The three states of a segment number, and the two questions that decide
|
|
3
|
-
* where an encoder goes.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import test from "node:test";
|
|
7
|
-
import assert from "node:assert/strict";
|
|
8
|
-
import { CoverageMap } from "../services/encode/CoverageMap.js";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A stand-in for a run.
|
|
12
|
-
*
|
|
13
|
-
* The map files a claim under the run ITSELF: a run has no name, and needs
|
|
14
|
-
* none — what identifies it is that it is itself, and what identifies it in a
|
|
15
|
-
* line is the stretch it was given, which no other live run of one output can
|
|
16
|
-
* hold.
|
|
17
|
-
*
|
|
18
|
-
* @returns {object}
|
|
19
|
-
*/
|
|
20
|
-
function aRun() {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
test("a number nobody has made and nobody is making is free", () => {
|
|
25
|
-
const map = new CoverageMap({ segmentCount: 10 });
|
|
26
|
-
assert.equal(map.stateOf(3), "free");
|
|
27
|
-
assert.equal(map.firstGapFrom(0), 0);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test("a closed file is ready whoever made it", () => {
|
|
31
|
-
const map = new CoverageMap({ segmentCount: 10 });
|
|
32
|
-
map.markReady(0);
|
|
33
|
-
map.markReady(1);
|
|
34
|
-
assert.equal(map.stateOf(1), "ready");
|
|
35
|
-
assert.equal(map.firstGapFrom(0), 2);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test("a run claims a stretch, and the gap search skips it", () => {
|
|
39
|
-
// The claim is an interval and not a head, which is the whole reason two runs
|
|
40
|
-
// can work on one output: the second is sent past what the first will reach.
|
|
41
|
-
const map = new CoverageMap({ segmentCount: 100 });
|
|
42
|
-
const runA = aRun();
|
|
43
|
-
map.claim(runA, 0, 40);
|
|
44
|
-
assert.equal(map.stateOf(20), "making");
|
|
45
|
-
assert.equal(map.makerOf(20), runA);
|
|
46
|
-
assert.equal(map.firstGapFrom(0), 41);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("a run that ends gives back what it did not finish, and keeps what it did", () => {
|
|
50
|
-
const map = new CoverageMap({ segmentCount: 100 });
|
|
51
|
-
const runA = aRun();
|
|
52
|
-
map.claim(runA, 0, 40);
|
|
53
|
-
map.markReady(0);
|
|
54
|
-
map.markReady(1);
|
|
55
|
-
map.release(runA);
|
|
56
|
-
assert.equal(map.stateOf(0), "ready", "a closed file survives its maker");
|
|
57
|
-
assert.equal(map.stateOf(2), "free", "the rest of the stretch is free again");
|
|
58
|
-
assert.equal(map.firstGapFrom(0), 2);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test("a run with no end claims everything ahead of it", () => {
|
|
62
|
-
// Which is what every run was before ends existed, and is why a second run
|
|
63
|
-
// could never be placed.
|
|
64
|
-
const map = new CoverageMap({ segmentCount: 100 });
|
|
65
|
-
const runA = aRun();
|
|
66
|
-
map.claim(runA, 10, Number.POSITIVE_INFINITY);
|
|
67
|
-
assert.equal(map.firstGapFrom(10), null);
|
|
68
|
-
assert.equal(map.firstGapFrom(0), 0, "behind it is still free");
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test("claiming again replaces the earlier claim rather than adding to it", () => {
|
|
72
|
-
// A run moved forward past ready material states its new stretch; if the two
|
|
73
|
-
// accumulated, the ground it has left would stay unavailable for ever.
|
|
74
|
-
const map = new CoverageMap({ segmentCount: 100 });
|
|
75
|
-
const runA = aRun();
|
|
76
|
-
map.claim(runA, 0, 20);
|
|
77
|
-
map.claim(runA, 50, 70);
|
|
78
|
-
assert.equal(map.stateOf(10), "free");
|
|
79
|
-
assert.equal(map.stateOf(60), "making");
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test("the covered stretch ahead is measured, which is what prices a move", () => {
|
|
83
|
-
const map = new CoverageMap({ segmentCount: 100 });
|
|
84
|
-
const runA = aRun();
|
|
85
|
-
const runB = aRun();
|
|
86
|
-
for (let index = 10; index <= 24; index += 1) {
|
|
87
|
-
map.markReady(index);
|
|
88
|
-
}
|
|
89
|
-
map.claim(runB, 25, 30);
|
|
90
|
-
// Ready 10..24 then another run's 25..30, so fifteen plus six.
|
|
91
|
-
assert.equal(map.coveredRunFrom(10, runA), 21);
|
|
92
|
-
assert.equal(map.firstGapFrom(10), 31);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test("a run's own claim is not counted as somebody else's coverage", () => {
|
|
96
|
-
// Otherwise a run would read its own stretch as a reason to move off it.
|
|
97
|
-
const map = new CoverageMap({ segmentCount: 100 });
|
|
98
|
-
const runA = aRun();
|
|
99
|
-
map.claim(runA, 10, 30);
|
|
100
|
-
assert.equal(map.coveredRunFrom(10, runA), 0);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test("nothing free ahead answers null rather than a number past the end", () => {
|
|
104
|
-
const map = new CoverageMap({ segmentCount: 5 });
|
|
105
|
-
map.setReady([0, 1, 2, 3, 4]);
|
|
106
|
-
assert.equal(map.firstGapFrom(0), null);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test("a file that has gone stops being ready", () => {
|
|
110
|
-
// THE CHECK THE FIELD FAILURE OF 2026-09-07 NEEDED. Readiness used to
|
|
111
|
-
// accumulate: a number told once stayed ready for the life of the process
|
|
112
|
-
// however its file ended, so the map claimed a whole film that was not there,
|
|
113
|
-
// the plan scored every arrangement as perfect and took the only encoder away.
|
|
114
|
-
const map = new CoverageMap({ segmentCount: 10 });
|
|
115
|
-
map.setReady([3, 4]);
|
|
116
|
-
assert.equal(map.stateOf(4), "ready");
|
|
117
|
-
map.setReady([3]);
|
|
118
|
-
assert.equal(map.stateOf(4), "free", "the picture is replaced, not added to");
|
|
119
|
-
assert.equal(map.stateOf(3), "ready", "and what is still there stays");
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
test("the whole picture is replaced, so nothing survives that the disk has lost", () => {
|
|
123
|
-
const map = new CoverageMap({ segmentCount: 500 });
|
|
124
|
-
for (let index = 0; index < 500; index += 1) {
|
|
125
|
-
map.markReady(index);
|
|
126
|
-
}
|
|
127
|
-
assert.equal(map.stats().ready, 500);
|
|
128
|
-
map.setReady([]);
|
|
129
|
-
assert.equal(map.stats().ready, 0, "an empty directory is an empty map");
|
|
130
|
-
assert.equal(map.firstGapFrom(0), 0, "and the first gap is the beginning again");
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
test("a run's own claim does not hide the gap it is trying to move into", () => {
|
|
134
|
-
// Found by the plan's own checks: a run that had claimed the rest of the film
|
|
135
|
-
// — which is what every run did before ends existed — could find no gap
|
|
136
|
-
// anywhere, so it was stopped instead of moved.
|
|
137
|
-
const map = new CoverageMap({ segmentCount: 100 });
|
|
138
|
-
const runA = aRun();
|
|
139
|
-
map.claim(runA, 0, 99);
|
|
140
|
-
map.setReady([10, 11, 12]);
|
|
141
|
-
assert.equal(map.firstGapFrom(10, 90), null, "to anybody else its ground is taken");
|
|
142
|
-
assert.equal(map.firstGapFrom(10, 90, runA), 13, "to itself the ground beyond is a gap");
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test("the free stretch ahead is measured, which is what gives a run its end", () => {
|
|
146
|
-
// A run handed the whole rest of the film would drive through the stretch
|
|
147
|
-
// another run is making. Handed the free stretch, it stops where the covered
|
|
148
|
-
// material begins.
|
|
149
|
-
const map = new CoverageMap({ segmentCount: 100 });
|
|
150
|
-
const runB = aRun();
|
|
151
|
-
map.claim(runB, 30, 60);
|
|
152
|
-
assert.equal(map.freeRunFrom(10), 20, "free from 10 up to 29");
|
|
153
|
-
map.markReady(15);
|
|
154
|
-
assert.equal(map.freeRunFrom(10), 5, "a ready segment ends the free stretch too");
|
|
155
|
-
assert.equal(map.freeRunFrom(15), 0, "a number that is not free has no free stretch");
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
test("a run's own claim does not end its own free stretch", () => {
|
|
159
|
-
const map = new CoverageMap({ segmentCount: 100 });
|
|
160
|
-
const runA = aRun();
|
|
161
|
-
map.claim(runA, 10, 40);
|
|
162
|
-
assert.equal(map.freeRunFrom(10, runA), 90, "its own ground is still its to fill");
|
|
163
|
-
assert.equal(map.freeRunFrom(10), 0, "to anybody else it is taken");
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
test("with the length unknown, a gap search needs its own bound", () => {
|
|
167
|
-
const map = new CoverageMap();
|
|
168
|
-
assert.equal(map.firstGapFrom(0), null, "no length and no bound answers nothing");
|
|
169
|
-
assert.equal(map.firstGapFrom(0, 3), 0);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
test("with the length unknown, the free stretch is answered without walking to it", () => {
|
|
173
|
-
// What this pins: on the addon host, 2026-09-05, a map with no length walked
|
|
174
|
-
// one number at a time to MAX_SAFE_INTEGER, scanning every claim at each step.
|
|
175
|
-
// The main thread spun at 100% from the look-ahead timer and the proxy stopped
|
|
176
|
-
// answering anything, its own log included. The length was missing because the
|
|
177
|
-
// field naming it had moved to the timeline and three readers were left on the
|
|
178
|
-
// old name — but this walk must not be able to do that even when it is.
|
|
179
|
-
//
|
|
180
|
-
// This check cannot FAIL against the old code — a synchronous walk cannot be
|
|
181
|
-
// interrupted by the runner, so it would hang the whole run instead, which is
|
|
182
|
-
// worse than no check. What it pins is the contract that replaced the walk:
|
|
183
|
-
// the answer comes from what the map holds.
|
|
184
|
-
const map = new CoverageMap();
|
|
185
|
-
|
|
186
|
-
assert.equal(map.freeRunFrom(0), Number.POSITIVE_INFINITY, "nothing is covered, so nothing bounds it");
|
|
187
|
-
|
|
188
|
-
const run = aRun();
|
|
189
|
-
map.claim(run, 500, 900);
|
|
190
|
-
assert.equal(map.freeRunFrom(0), 500, "and a claim ahead is where the free stretch ends");
|
|
191
|
-
assert.equal(map.freeRunFrom(0, run), Number.POSITIVE_INFINITY, "its own claim does not bound it");
|
|
192
|
-
|
|
193
|
-
map.markReady(200);
|
|
194
|
-
assert.equal(map.freeRunFrom(0), 200, "so is a segment somebody has already made");
|
|
195
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file What the subtitle walk found reaches the viewer whole.
|
|
3
|
-
*
|
|
4
|
-
* It did not. The walk has produced `detectedLanguage` on every push since
|
|
5
|
-
* 2.69.0 — the language read from the CUES rather than from a container that
|
|
6
|
-
* often states none — and the whole of the "label moves when the answer
|
|
7
|
-
* arrives" behaviour rests on it. It never arrived: the fact was copied by hand
|
|
8
|
-
* twice on its way out, and each copy listed the fields it knew about. The
|
|
9
|
-
* worker posted `trackIndex, cues, language, cursor`; the main thread's client
|
|
10
|
-
* rebuilt the same four from the message. `detectedLanguage` was in neither
|
|
11
|
-
* list, so the browser was told nothing and the label it shows for an untagged
|
|
12
|
-
* track has never moved.
|
|
13
|
-
*
|
|
14
|
-
* It is not a typo to fix in two places — it is the shape. A fact copied field
|
|
15
|
-
* by field loses whatever the copier did not know about, and says nothing when
|
|
16
|
-
* it does. The walk's own result travels now, so a field added to it arrives
|
|
17
|
-
* without anybody being told to forward it.
|
|
18
|
-
*
|
|
19
|
-
* (Both copies are gone anyway: the walk runs on the thread that pushes.)
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import test from "node:test";
|
|
23
|
-
import assert from "node:assert/strict";
|
|
24
|
-
import { readFileSync } from "node:fs";
|
|
25
|
-
import path from "node:path";
|
|
26
|
-
import { fileURLToPath } from "node:url";
|
|
27
|
-
|
|
28
|
-
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @param {string} relative
|
|
32
|
-
* @returns {string}
|
|
33
|
-
*/
|
|
34
|
-
function source(relative) {
|
|
35
|
-
return readFileSync(path.join(ROOT, relative), "utf8");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
test("the walk states the language it read from the cues", () => {
|
|
39
|
-
// The producer. Without this the rest of the check is about nothing.
|
|
40
|
-
assert.match(source("services/media/SubtitleCues.js"), /detectedLanguage: detectLanguage\(/);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test("the consumer asks for it", () => {
|
|
44
|
-
// The other end has always destructured it, which is what made the loss
|
|
45
|
-
// silent: a field nobody forwards is `undefined` and reads as "not detected".
|
|
46
|
-
assert.match(
|
|
47
|
-
source("services/transport/data-channel-handler.js"),
|
|
48
|
-
/function publishSubtitleCues\(\{[^}]*detectedLanguage[^}]*\}\)/
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test("the push forwards the whole of what the walk found, rather than a list of fields", () => {
|
|
53
|
-
// The one line that closes it. A list of names here is how the fact was lost
|
|
54
|
-
// twice, and a list cannot say that it is incomplete.
|
|
55
|
-
const wiring = source("server.js");
|
|
56
|
-
|
|
57
|
-
assert.match(wiring, /onSubtitleCues\?\.\(\{ sourceKey, fileIndex, \.\.\.entry \}\)/);
|
|
58
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file The cut list must be stated on the timeline the muxer decides against.
|
|
3
|
-
*
|
|
4
|
-
* Measured 2026-08-17 on a Matroska whose first timestamp is 2.002 s. Asked to
|
|
5
|
-
* cut at 808.808 s on the 0-based grid, the copied picture cut at 806.806 s —
|
|
6
|
-
* exactly the container's start time early, and itself a keyframe the file's
|
|
7
|
-
* own table names, which is why every "disagreement" landed on a real keyframe
|
|
8
|
-
* and the table looked like it was lying. The soundtrack, re-encoded and on the
|
|
9
|
-
* other branch, cut where it was asked. The two then wrote different values
|
|
10
|
-
* into the shared boundary table and corrected each other back and forth
|
|
11
|
-
* (#202: 808.808 → 806.806 → 808.750), so the playlist and the media drifted
|
|
12
|
-
* apart by a whole segment.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import assert from "node:assert/strict";
|
|
16
|
-
import { Timeline } from "../services/encode/output/Timeline.js";
|
|
17
|
-
import test from "node:test";
|
|
18
|
-
|
|
19
|
-
import { onKeyframeGridFor } from "../services/encode/run-command.js";
|
|
20
|
-
|
|
21
|
-
test("a copied picture works on the source's timeline", () => {
|
|
22
|
-
assert.equal(
|
|
23
|
-
onKeyframeGridFor({ transcodeVideo: false }),
|
|
24
|
-
true,
|
|
25
|
-
"video copied means the source's own timestamps are kept"
|
|
26
|
-
);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test("a re-encoded picture works on the 0-based timeline", () => {
|
|
30
|
-
assert.equal(onKeyframeGridFor({ transcodeVideo: true }), false);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test("a soundtrack follows the grid it was cut on, not its own encoding", () => {
|
|
34
|
-
// A rendition is re-encoded by definition, so asking `transcodeVideo` about
|
|
35
|
-
// it answers nothing. What decides its timeline is the grid it shares with
|
|
36
|
-
// the picture it plays with.
|
|
37
|
-
assert.equal(onKeyframeGridFor({ audioOnly: true, timeline: new Timeline({ boundaries: [], cutGrid: "keyframe" }) }), true);
|
|
38
|
-
assert.equal(onKeyframeGridFor({ audioOnly: true, timeline: new Timeline({ boundaries: [], cutGrid: "uniform" }) }), false);
|
|
39
|
-
assert.equal(
|
|
40
|
-
onKeyframeGridFor({ audioOnly: true, transcodeVideo: true, timeline: new Timeline({ boundaries: [], cutGrid: "keyframe" }) }),
|
|
41
|
-
true,
|
|
42
|
-
"its own encoding must not decide this — that disagreement is the defect"
|
|
43
|
-
);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test("one predicate answers for every caller", () => {
|
|
47
|
-
// The two callers used to answer this separately, in two expressions that
|
|
48
|
-
// could drift apart. A session put through both must get one answer.
|
|
49
|
-
for (const session of [
|
|
50
|
-
{ transcodeVideo: false },
|
|
51
|
-
{ transcodeVideo: true },
|
|
52
|
-
{ audioOnly: true, timeline: new Timeline({ boundaries: [], cutGrid: "keyframe" }) },
|
|
53
|
-
{ audioOnly: true, timeline: new Timeline({ boundaries: [], cutGrid: "uniform" }) },
|
|
54
|
-
{}
|
|
55
|
-
]) {
|
|
56
|
-
assert.equal(onKeyframeGridFor(session), onKeyframeGridFor({ ...session }));
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("a session that says nothing is treated as copying", () => {
|
|
61
|
-
// The default matters: an absent `transcodeVideo` means the picture is
|
|
62
|
-
// copied, which is the branch that needs the shift.
|
|
63
|
-
assert.equal(onKeyframeGridFor({}), true);
|
|
64
|
-
assert.equal(onKeyframeGridFor(null), true);
|
|
65
|
-
});
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file A run cuts where the player was told the cuts are.
|
|
3
|
-
*
|
|
4
|
-
* There are two boundary tables. The live one is corrected as produced segments
|
|
5
|
-
* reveal where the file's cuts truly are; the published one is the snapshot the
|
|
6
|
-
* playlist text was written from, and a player places every fragment by that
|
|
7
|
-
* text and nothing else. The cut list handed to ffmpeg used to come from the
|
|
8
|
-
* live table, so every correction moved the run away from the timeline the
|
|
9
|
-
* player is reading.
|
|
10
|
-
*
|
|
11
|
-
* Field 2026-08-20, `Minions.and.Monsters.1080p.mkv`: the picture's segments
|
|
12
|
-
* arrived a uniform 2.002 s before the times its playlist named — 119 of 125 of
|
|
13
|
-
* them — against the 0.5 s hls.js bridges. A fragment that does not land is
|
|
14
|
-
* fetched again, and on 2026-08-17 two of them were fetched 1908 times each.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import assert from "node:assert/strict";
|
|
18
|
-
import { computeCutGrid } from "../services/encode/output/cut-grid.js";
|
|
19
|
-
import { Timeline } from "../services/encode/output/Timeline.js";
|
|
20
|
-
import test from "node:test";
|
|
21
|
-
|
|
22
|
-
import { wireOutputs } from "../services/server/wire-outputs.js";
|
|
23
|
-
import { segmentCutTimesFrom } from "../services/encode/run-command.js";
|
|
24
|
-
|
|
25
|
-
/** What the playlist in the player's hands says. */
|
|
26
|
-
const PUBLISHED = [0, 4.004, 8.008, 12.012, 16.016, 20.02];
|
|
27
|
-
/** The same grid after produced segments moved two of its cuts. */
|
|
28
|
-
const CORRECTED = [0, 4.004, 6.006, 12.012, 14.014, 20.02];
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* A session that has published one grid and since corrected another.
|
|
32
|
-
*
|
|
33
|
-
* @returns {{ manager: object, session: object }}
|
|
34
|
-
*/
|
|
35
|
-
function sessionWithDriftedGrid() {
|
|
36
|
-
const manager = wireOutputs({
|
|
37
|
-
enabled: true,
|
|
38
|
-
ffmpegBin: "ffmpeg",
|
|
39
|
-
localBindHost: "127.0.0.1",
|
|
40
|
-
localPort: 9090
|
|
41
|
-
});
|
|
42
|
-
const session = {
|
|
43
|
-
id: "picture",
|
|
44
|
-
timeline: new Timeline({ boundaries: [...CORRECTED], published: [...PUBLISHED], cutGrid: "uniform" })
|
|
45
|
-
};
|
|
46
|
-
return { manager, session };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
test("the cut list is the one the playlist was written from", () => {
|
|
50
|
-
const { manager, session } = sessionWithDriftedGrid();
|
|
51
|
-
const grid = manager.outputTimes.publishedGridFor(session);
|
|
52
|
-
assert.deepEqual(grid, PUBLISHED);
|
|
53
|
-
// Interior cuts of a run starting at #1, rebased on the run's own start
|
|
54
|
-
// (4.004 s), and stopping before the last entry, which is the file's end.
|
|
55
|
-
assert.deepEqual(
|
|
56
|
-
segmentCutTimesFrom(grid, 1).map((time) => Number(time.toFixed(3))),
|
|
57
|
-
[4.004, 8.008, 12.012]
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test("a corrected grid does not move the cuts of a session already being read", () => {
|
|
62
|
-
const { manager, session } = sessionWithDriftedGrid();
|
|
63
|
-
const fromCorrected = segmentCutTimesFrom(session.timeline.boundaries, 1);
|
|
64
|
-
const fromPublished = segmentCutTimesFrom(manager.outputTimes.publishedGridFor(session), 1);
|
|
65
|
-
assert.notDeepEqual(fromCorrected, fromPublished);
|
|
66
|
-
// The gap the field measured: the corrected table would have cut #2 two
|
|
67
|
-
// seconds early, which is four times what a player bridges.
|
|
68
|
-
assert.equal(Number((fromPublished[0] - fromCorrected[0]).toFixed(3)), 2.002);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test("a session that published no grid falls back to the live one", () => {
|
|
72
|
-
const { manager } = sessionWithDriftedGrid();
|
|
73
|
-
const session = { id: "no-playlist", timeline: new Timeline({ boundaries: [...CORRECTED], published: [], cutGrid: "uniform" }) };
|
|
74
|
-
assert.deepEqual(manager.outputTimes.publishedGridFor(session), CORRECTED);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test("no segment is left shorter than a segment at the end of the film", () => {
|
|
78
|
-
// The field case of 2026-09-11, to the millisecond: a 54-minute film whose
|
|
79
|
-
// last keyframe sits 160 ms before the end. Taking it as a cut leaves a
|
|
80
|
-
// segment of 0.16 s — one the sound has no data in at all, which is how one
|
|
81
|
-
// output came to have 542 segments and the other 541.
|
|
82
|
-
const total = 3246.12;
|
|
83
|
-
const keyframes = [];
|
|
84
|
-
for (let at = 0; at < total - 1; at += 2) {
|
|
85
|
-
keyframes.push(Number(at.toFixed(3)));
|
|
86
|
-
}
|
|
87
|
-
keyframes.push(3245.96);
|
|
88
|
-
|
|
89
|
-
const grid = computeCutGrid({
|
|
90
|
-
useKeyframeGrid: true,
|
|
91
|
-
durationSeconds: total,
|
|
92
|
-
segDur: 6,
|
|
93
|
-
keyframeTimes: keyframes,
|
|
94
|
-
startTime: 0
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const last = grid.boundaries[grid.boundaries.length - 1];
|
|
98
|
-
const before = grid.boundaries[grid.boundaries.length - 2];
|
|
99
|
-
assert.equal(last, total, "the film still ends where it ends");
|
|
100
|
-
assert.ok(
|
|
101
|
-
last - before >= 6,
|
|
102
|
-
`the last segment is ${(last - before).toFixed(3)}s, shorter than the 6s every other cut is held to`
|
|
103
|
-
);
|
|
104
|
-
// And the rule is the one every cut obeys, so no segment anywhere is short.
|
|
105
|
-
for (let index = 1; index < grid.boundaries.length; index += 1) {
|
|
106
|
-
const span = grid.boundaries[index] - grid.boundaries[index - 1];
|
|
107
|
-
assert.ok(span >= 6 - 0.05, `segment ${index - 1} lasts ${span.toFixed(3)}s`);
|
|
108
|
-
}
|
|
109
|
-
});
|