@torrent-tv/proxy 2.9.117 → 2.9.119

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 CHANGED
@@ -1,3 +1,11 @@
1
+ ## 2.9.119
2
+
3
+ - **Fix**: The progress report says the height the viewer is actually watching, not only the one an encoder is producing. It was zero whenever the video was copied — which is most sessions — so the quality menu read a bare "Auto" in exactly the case it was built to explain. Copying reports the source height, re-encoding reports the rung the proxy has settled on.
4
+
5
+ ## 2.9.118
6
+
7
+ - **New**: Suspending the encoder says what the decision was taken on — where the viewer is, how far the unbroken run of segments reaches from there, and how many segment files the session directory holds. Suspending stops the only thing that reads the input, so a wrong reading here stops the download as well: measured 2026-08-06, the log announced "135s ahead of the viewer" while three segments totalling 31 s lay on disk, and neither figure could be checked against the other because the line carried no evidence. The directory keeps the segments of every run a session has had, so which of them were counted is the whole question.
8
+
1
9
  ## 2.9.117
2
10
 
3
11
  - **Fix**: A seek backwards no longer kills playback. How far the encoder is ahead of the viewer was measured as the highest segment number lying in the session's directory, which equals the look-ahead only while a viewer moves forward through one run. Measured 2026-08-06: a seek forward left segments 662-665 on disk, the viewer seeked BACK to 646, and the limiter compared 6950 s of output against a viewer at 6700 s, called it "250s ahead" and suspended the new run **136 ms after it started**, before it had produced anything. With the encoder stopped nothing read the input, so no pieces were requested — `0 selection(s)` with 33 peers connected — and segment 646 was never made; the viewer sat on a spinner for four minutes while a stopped ffmpeg was held back for being too far ahead. The measure is now the unbroken run of segments starting where the viewer is, and a viewer whose own segment is missing is not "zero ahead" but waiting, which resumes the encoder instead of pausing it. Covered by tests, including the field case.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torrent-tv/proxy",
3
- "version": "2.9.117",
3
+ "version": "2.9.119",
4
4
  "description": "Torrent proxy client that exposes webseed-like HTTP stream endpoint.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "publishConfig": {
@@ -1909,7 +1909,8 @@ export class HlsSessionManager {
1909
1909
  // — `0 selection(s)` with 33 peers connected — and segment 646 was never
1910
1910
  // made. Segments beyond a hole are not look-ahead: the viewer cannot reach
1911
1911
  // them without the hole being filled first.
1912
- const aheadSeconds = this.#contiguousAheadSeconds(session, viewerSegment);
1912
+ const reading = this.#contiguousAheadSeconds(session, viewerSegment);
1913
+ const aheadSeconds = reading === null ? null : reading.seconds;
1913
1914
  if (aheadSeconds === null) {
1914
1915
  // The segment the viewer needs does not exist. Whatever else is on disk,
1915
1916
  // this encoder has work to do right now.
@@ -1942,7 +1943,19 @@ export class HlsSessionManager {
1942
1943
  }
1943
1944
 
1944
1945
  if (!session.encoderPaused && aheadSeconds > LOOKAHEAD_PAUSE_SECONDS) {
1945
- this.#pauseEncoder(session, `${Math.round(aheadSeconds)}s ahead of the viewer`);
1946
+ // The decision names what it was taken on. Suspending the encoder stops
1947
+ // the only thing that reads the input, so a wrong reading here stops the
1948
+ // download too — measured 2026-08-06: the log said "135s ahead" while
1949
+ // three segments totalling 31 s lay on disk, and neither figure could be
1950
+ // checked against the other because the line carried no evidence. The
1951
+ // directory holds segments from every run this session has had, so which
1952
+ // ones were counted is the whole question.
1953
+ this.#pauseEncoder(
1954
+ session,
1955
+ `${Math.round(aheadSeconds)}s ahead of the viewer ` +
1956
+ `(viewer at #${viewerSegment}, unbroken through #${reading.lastCovered}, ` +
1957
+ `${reading.total} segment file(s) present)`
1958
+ );
1946
1959
  } else if (session.encoderPaused && aheadSeconds <= LOOKAHEAD_RESUME_SECONDS) {
1947
1960
  this.#resumeEncoder(session, `${Math.round(aheadSeconds)}s ahead of the viewer`);
1948
1961
  }
@@ -1957,7 +1970,7 @@ export class HlsSessionManager {
1957
1970
  *
1958
1971
  * @param {HlsSession} session
1959
1972
  * @param {number} viewerSegment
1960
- * @returns {number | null}
1973
+ * @returns {{ seconds: number, lastCovered: number, total: number } | null}
1961
1974
  */
1962
1975
  #contiguousAheadSeconds(session, viewerSegment) {
1963
1976
  let present;
@@ -1984,7 +1997,7 @@ export class HlsSessionManager {
1984
1997
  if (!Number.isFinite(from) || !Number.isFinite(to)) {
1985
1998
  return null;
1986
1999
  }
1987
- return Math.max(0, to - from);
2000
+ return { seconds: Math.max(0, to - from), lastCovered, total: present.size };
1988
2001
  }
1989
2002
 
1990
2003
  /**
@@ -3481,13 +3494,16 @@ export class HlsSessionManager {
3481
3494
  segmentDurationSec: this.segmentDurationSec,
3482
3495
  speed: session.progress.speed,
3483
3496
  outputMbps,
3484
- // The height being produced RIGHT NOW. On automatic quality the proxy
3485
- // steps down a rung when the host cannot keep up or the viewer's link
3486
- // cannot carry the stream, and the menu said only "Auto" so the one
3487
- // question it raises, what am I actually watching, had no answer
3488
- // anywhere. Zero when the video is copied, because then nothing is being
3489
- // chosen: the source's own height is what plays.
3490
- currentHeight: session.transcodeVideo ? (session.encodeHeight ?? 0) : 0,
3497
+ // The height the viewer is WATCHING right now, which is what the menu
3498
+ // has to say next to "Auto". When the video is re-encoded that is the
3499
+ // rung the proxy has settled on it steps down when the host cannot keep
3500
+ // up or the link cannot carry the stream. When the video is COPIED it is
3501
+ // the source's own height, and reporting zero there was simply wrong:
3502
+ // most sessions copy the video, so the menu read a bare "Auto" almost
3503
+ // always, which is exactly the question it was supposed to answer.
3504
+ currentHeight: session.transcodeVideo
3505
+ ? (session.encodeHeight ?? session.sourceHeight ?? 0)
3506
+ : (session.sourceHeight ?? 0),
3491
3507
  updatedAt: session.progress.updatedAt,
3492
3508
  error: session.state === "failed" ? session.lastError : ""
3493
3509
  };