@torrent-tv/proxy 2.101.16 → 2.101.17

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torrent-tv/proxy",
3
- "version": "2.101.16",
3
+ "version": "2.101.17",
4
4
  "description": "Torrent proxy client that exposes webseed-like HTTP stream endpoint.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
@@ -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, { tentative = false } = {}) {
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
+ // Embedded copied sound was selected by presentationSegment on the
427
+ // published grid, so its raw muxer cut shift no longer applies.
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])) } : {}),
@@ -1181,7 +1185,8 @@ export class EncodeRuns {
1181
1185
  throw error;
1182
1186
  }
1183
1187
  }
1184
- const mediaRanges = this.#wholeClosedPiece(session, name, index, admittedInput, bytes, run, timing, following, { tentative });
1188
+ const mediaRanges = this.#wholeClosedPiece(session, name, index, admittedInput, bytes, run, timing, following,
1189
+ { tentative, audioOnPublishedGrid: soundInPiece });
1185
1190
  // Tried on its own line and not proved whole: it waits for the next file.
1186
1191
  if (mediaRanges === false && tentative) return null;
1187
1192
  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 start = BigInt(Math.round((from + shift) * Number(track.timescale)));
201
- const cutAt = to + shift - (kind === "vide" && !endsWithSource ? nextLeadingSeconds : 0);
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 + shift)) return `segment-interval-is-empty-${kind}`;
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;