@torrent-tv/proxy 2.101.16 → 2.101.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/package.json
CHANGED
|
@@ -409,7 +409,8 @@ export class EncodeRuns {
|
|
|
409
409
|
* @param {string | null} [following] - The working name of the file the muxer closed after it.
|
|
410
410
|
* @returns {object | null | false}
|
|
411
411
|
*/
|
|
412
|
-
#wholeClosedPiece(session, name, index, admitted = false, bytes = null, run = null, timing = null, following = null,
|
|
412
|
+
#wholeClosedPiece(session, name, index, admitted = false, bytes = null, run = null, timing = null, following = null,
|
|
413
|
+
{ tentative = false, audioOnPublishedGrid = false } = {}) {
|
|
413
414
|
|
|
414
415
|
const format = session.segmentFormat;
|
|
415
416
|
if (!format?.readMediaRanges || !Number.isInteger(index) || index < 0) {
|
|
@@ -422,6 +423,9 @@ export class EncodeRuns {
|
|
|
422
423
|
const cut = cutOf(session.timeline, index);
|
|
423
424
|
const grid = session.timeline.published ?? session.timeline.boundaries;
|
|
424
425
|
const interval = admitted ? { from: grid?.[index], to: grid?.[index + 1],
|
|
426
|
+
// Copied sound is cut on the published grid, so the run's raw muxer
|
|
427
|
+
// clock shift must not be applied to its AAC interval.
|
|
428
|
+
...(audioOnPublishedGrid ? { shiftByKind: { soun: 0 } } : {}),
|
|
425
429
|
...(index === session.timeline.segmentCount - 1 ? { endsWithSource: true, sourceEnds: Object.fromEntries(
|
|
426
430
|
(admitted.tracks ?? []).filter(input => Number.isFinite(input.sourceEndSeconds))
|
|
427
431
|
.map(input => [input.track.type === "video" ? "vide" : "soun", input.sourceEndSeconds])) } : {}),
|
|
@@ -1163,12 +1167,15 @@ export class EncodeRuns {
|
|
|
1163
1167
|
const address = session.outputKey ?? "";
|
|
1164
1168
|
// Read before anything rewrites it: when the encoder finished it.
|
|
1165
1169
|
const writtenAt = this.#host.segmentFiles.writtenAtOf?.(address, name) ?? null;
|
|
1166
|
-
const fmp4 = admittedInput && session.segmentFormat.id === "fmp4"
|
|
1170
|
+
const fmp4 = admittedInput && session.segmentFormat.id === "fmp4";
|
|
1171
|
+
const pictureFmp4 = fmp4 && session.spec.carries !== "audio-only";
|
|
1167
1172
|
// The first piece of a run that read the picture from its keyframe:
|
|
1168
1173
|
// its leading pictures are the ones the run before made, or none.
|
|
1169
|
-
const firstOfRun =
|
|
1174
|
+
const firstOfRun = pictureFmp4 && this.#copiesOriginalPicture(session, admittedInput) &&
|
|
1170
1175
|
index === run.from && index > 0 && !fromKeyframeBefore;
|
|
1171
|
-
const soundInPiece =
|
|
1176
|
+
const soundInPiece = pictureFmp4 && session.spec.audio && !this.#host.servesAudioSeparately(session);
|
|
1177
|
+
const audioOnPublishedGrid = fmp4 && session.spec.audio && !session.spec.transcodesAudio &&
|
|
1178
|
+
(session.spec.carries === "audio-only" || !this.#host.servesAudioSeparately(session));
|
|
1172
1179
|
if (firstOfRun || soundInPiece) {
|
|
1173
1180
|
try {
|
|
1174
1181
|
const grid = session.timeline.published ?? session.timeline.boundaries;
|
|
@@ -1181,7 +1188,8 @@ export class EncodeRuns {
|
|
|
1181
1188
|
throw error;
|
|
1182
1189
|
}
|
|
1183
1190
|
}
|
|
1184
|
-
const mediaRanges = this.#wholeClosedPiece(session, name, index, admittedInput, bytes, run, timing, following,
|
|
1191
|
+
const mediaRanges = this.#wholeClosedPiece(session, name, index, admittedInput, bytes, run, timing, following,
|
|
1192
|
+
{ tentative, audioOnPublishedGrid });
|
|
1185
1193
|
// Tried on its own line and not proved whole: it waits for the next file.
|
|
1186
1194
|
if (mediaRanges === false && tentative) return null;
|
|
1187
1195
|
if (mediaRanges === false) throw Object.assign(new Error(`Closed piece #${index} has incomplete media.`),
|
|
@@ -192,15 +192,16 @@ export function judgeNeighbors(left, right) {
|
|
|
192
192
|
* soundtrack's at 1419.904 s against a final cut of 1419.993 s, and both last
|
|
193
193
|
* pieces were refused, so no viewer could reach the end of the episode.
|
|
194
194
|
*/
|
|
195
|
-
function intervalFailure(coverage, { from, to, requiredKinds, sourceEnds = {}, shift = 0, endsWithSource = false, nextLeadingSeconds = 0 }) {
|
|
195
|
+
function intervalFailure(coverage, { from, to, requiredKinds, sourceEnds = {}, shift = 0, shiftByKind = {}, endsWithSource = false, nextLeadingSeconds = 0 }) {
|
|
196
196
|
if (!Number.isFinite(from) || !Number.isFinite(to) || !(to > from) || !requiredKinds?.length) return "segment-interval-is-not-declared";
|
|
197
197
|
for (const kind of requiredKinds) {
|
|
198
198
|
const track = coverage?.tracks?.find(track => track.kind === kind);
|
|
199
199
|
if (!track?.ranges?.length || !(track.timescale > 0n)) return `segment-missing-${kind}`;
|
|
200
|
-
const
|
|
201
|
-
const
|
|
200
|
+
const trackShift = Number.isFinite(shiftByKind[kind]) ? shiftByKind[kind] : shift;
|
|
201
|
+
const start = BigInt(Math.round((from + trackShift) * Number(track.timescale)));
|
|
202
|
+
const cutAt = to + trackShift - (kind === "vide" && !endsWithSource ? nextLeadingSeconds : 0);
|
|
202
203
|
const through = Number.isFinite(sourceEnds[kind]) ? Math.min(cutAt, sourceEnds[kind]) : cutAt;
|
|
203
|
-
if (!(through > from +
|
|
204
|
+
if (!(through > from + trackShift)) return `segment-interval-is-empty-${kind}`;
|
|
204
205
|
const end = BigInt(Math.round(through * Number(track.timescale)));
|
|
205
206
|
const first = track.ranges[0];
|
|
206
207
|
const frame = track.productionFrame ?? first.frame;
|