@torrent-tv/proxy 2.95.11 → 2.95.13
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/package.json
CHANGED
|
@@ -152,8 +152,12 @@ export function buildRunCommand({
|
|
|
152
152
|
}
|
|
153
153
|
} else {
|
|
154
154
|
args.push("-copyts");
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
// Audio's output seek removes demux preroll and subtracts that absolute
|
|
156
|
+
// seek from packet timestamps. Restore the published position explicitly;
|
|
157
|
+
// positive copied AAC timestamps alone are not retained by every movenc.
|
|
158
|
+
const offset = audioOnly ? startSeconds : -sourceStartTime;
|
|
159
|
+
if (offset !== 0) {
|
|
160
|
+
args.push("-output_ts_offset", ffmpegSeconds(offset));
|
|
157
161
|
}
|
|
158
162
|
}
|
|
159
163
|
const runEnd = Number.isInteger(endIndex) ? endIndex : -1;
|
|
@@ -175,6 +179,8 @@ export function buildRunCommand({
|
|
|
175
179
|
audioCodecArgs.push("-af", `atrim=start=${ffmpegSeconds(seekAt)}`);
|
|
176
180
|
}
|
|
177
181
|
if (audioOnly === true) {
|
|
182
|
+
// Input seeking locates bytes; copied audio also needs an output trim.
|
|
183
|
+
if (keyframeGrid) args.push("-ss", ffmpegSeconds(seekAt));
|
|
178
184
|
args.push("-vn", "-map", `0:a:${audioSourceTrackIndex}?`, ...audioCodecArgs);
|
|
179
185
|
} else if (servesAudioSeparately) {
|
|
180
186
|
args.push("-an", "-map", `0:v:${videoSourceTrackIndex}?`, ...videoCodecArgs);
|
|
@@ -58,17 +58,26 @@ import os from "node:os";
|
|
|
58
58
|
* Version 1 states the file lists of the cgroup alone as `active_file` and of
|
|
59
59
|
* it with its descendants as `total_active_file`; its usage includes the
|
|
60
60
|
* descendants, so the hierarchical figures are the ones that subtract from it.
|
|
61
|
+
*
|
|
62
|
+
* Version 2 has two limits. `memory.max` is where the kernel kills;
|
|
63
|
+
* `memory.high` is where it throttles the cgroup and pushes its memory out —
|
|
64
|
+
* on the Home Assistant kernel a 300 MB allocation took 2123 ms instead of
|
|
65
|
+
* 527 ms past a 128 MiB `memory.high`, with 186 MiB of it sent to swap
|
|
66
|
+
* (torrent-tv/meta#155). systemd's `MemoryHigh=` sets it without
|
|
67
|
+
* `MemoryMax=`, so it is a limit of its own, and a level's limit is the
|
|
68
|
+
* smaller of the two. Version 1's soft limit is not a counterpart: it only
|
|
69
|
+
* orders reclaim when the whole machine is short.
|
|
61
70
|
*/
|
|
62
71
|
const HIERARCHIES = {
|
|
63
72
|
1: {
|
|
64
73
|
mount: "/sys/fs/cgroup/memory",
|
|
65
|
-
|
|
74
|
+
limits: ["memory.limit_in_bytes"],
|
|
66
75
|
usage: "memory.usage_in_bytes",
|
|
67
76
|
reclaimable: ["total_active_file", "total_inactive_file"]
|
|
68
77
|
},
|
|
69
78
|
2: {
|
|
70
79
|
mount: "/sys/fs/cgroup",
|
|
71
|
-
|
|
80
|
+
limits: ["memory.max", "memory.high"],
|
|
72
81
|
usage: "memory.current",
|
|
73
82
|
reclaimable: ["active_file", "inactive_file", "slab_reclaimable"]
|
|
74
83
|
}
|
|
@@ -230,18 +239,24 @@ function levelsOf(mount, path) {
|
|
|
230
239
|
* @param {string} directory
|
|
231
240
|
* @param {number} hostTotal
|
|
232
241
|
* @returns {{ roomBytes: number, limitBytes: number } | null} Null where this
|
|
233
|
-
* level states no limit — `max
|
|
242
|
+
* level states no limit — `max` in every limit file, the version 1
|
|
243
|
+
* sentinel — or is not there.
|
|
234
244
|
*/
|
|
235
245
|
function roomAt(readFile, hierarchy, directory, hostTotal) {
|
|
236
|
-
let limitBytes;
|
|
237
246
|
let usageBytes;
|
|
238
247
|
try {
|
|
239
|
-
limitBytes = bytesOf(readFile(`${directory}/${hierarchy.limit}`));
|
|
240
248
|
usageBytes = bytesOf(readFile(`${directory}/${hierarchy.usage}`));
|
|
241
249
|
} catch {
|
|
242
250
|
return null; // silent-ok: no such level, or no memory controller on it.
|
|
243
251
|
}
|
|
244
|
-
|
|
252
|
+
const limitBytes = Math.min(...hierarchy.limits.map((name) => {
|
|
253
|
+
try {
|
|
254
|
+
return bytesOf(readFile(`${directory}/${name}`));
|
|
255
|
+
} catch {
|
|
256
|
+
return Number.NaN; // silent-ok: a limit file this kernel does not have states no limit.
|
|
257
|
+
}
|
|
258
|
+
}).filter(Number.isFinite));
|
|
259
|
+
if (limitBytes >= hostTotal || !Number.isFinite(usageBytes)) {
|
|
245
260
|
return null;
|
|
246
261
|
}
|
|
247
262
|
let reclaimableBytes = 0;
|