@torrent-tv/proxy 2.16.0 → 2.17.0
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/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/server.js +6 -12
- package/services/hls-session-manager.js +50 -8
- package/services/hwaccel.js +1502 -1248
- package/test/encode-slope.test.js +46 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The slope that turns ffmpeg's progress reports into a preset's speed.
|
|
3
|
+
*
|
|
4
|
+
* Written against the faults a review found in it on 2026-08-15, each of which
|
|
5
|
+
* would have opened the quality ladder rather than closing it: a window of no
|
|
6
|
+
* width at all, and a position ffmpeg reports as the smallest signed 64-bit
|
|
7
|
+
* integer when it has none yet.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import assert from "node:assert/strict";
|
|
11
|
+
import test from "node:test";
|
|
12
|
+
|
|
13
|
+
import { slopeOf } from "../services/hwaccel.js";
|
|
14
|
+
|
|
15
|
+
const at = (wallSec, outSec) => ({ wallSec, outSec });
|
|
16
|
+
|
|
17
|
+
test("a steady run measures its own speed", () => {
|
|
18
|
+
assert.equal(slopeOf([at(1, 10), at(2, 14)]), 4);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("a window of no width is refused, however tempting the numbers", () => {
|
|
22
|
+
// Two reports a millisecond apart: 0.042 s of video over 0.001 s of clock is
|
|
23
|
+
// 42x, on a host that may be doing 3x.
|
|
24
|
+
assert.equal(slopeOf([at(1.0, 10), at(1.001, 10.042)], 0.2), null);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("a run that produced nothing between two reports says nothing", () => {
|
|
28
|
+
assert.equal(slopeOf([at(1, 10), at(3, 10)]), null);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("one report is not a measurement", () => {
|
|
32
|
+
assert.equal(slopeOf([at(1, 10)]), null);
|
|
33
|
+
assert.equal(slopeOf([]), null);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("an impossible speed is a fault, not a fast machine", () => {
|
|
37
|
+
// Nothing encodes 640x360 five thousand times realtime; a reading that says
|
|
38
|
+
// so is a measurement fault, and letting it through raises the bar every
|
|
39
|
+
// ladder decision is taken from.
|
|
40
|
+
assert.equal(slopeOf([at(1, 0), at(2, 5000)]), null);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("the narrowest allowed window is honoured", () => {
|
|
44
|
+
assert.equal(slopeOf([at(1.0, 10), at(1.3, 11)], 0.5), null);
|
|
45
|
+
assert.ok(slopeOf([at(1.0, 10), at(1.6, 12)], 0.5) > 0);
|
|
46
|
+
});
|