@torrent-tv/proxy 2.9.5 → 2.9.6

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,8 @@
1
+ ## 2.9.6
2
+
3
+ - **Fix**: `probeInputDurationSeconds` now returns as soon as ffmpeg prints the container header (`Duration:`) instead of letting `-f null -` decode the whole stream until the 8 s timeout. Transcode-session creation was wasting ~8.6 s per session on this redundant decode (the duration was already available from the header, and `playback-plan` had probed it moments earlier). Cuts session-creation latency from ~9.7 s to ~1 s.
4
+ - **New**: `GET /api/transcode-sessions/:id/progress` now includes `segmentDurationSec`, so the browser can show progress toward the first segment (the only thing it waits for before playback) instead of a percentage of the whole-file transcode.
5
+
1
6
  ## 2.9.5
2
7
 
3
8
  - **Fix**: Segment files are now read with a 4 MB `highWaterMark` (`hls-session-manager.js` `getFileStream`) so the body is delivered in few, large chunks. On a busy ARM host the in-process WebTorrent hashing starves the Node event loop in bursts while the first segments are served; reading in fewer iterations cuts the time lost between chunks (the first segment previously transferred in ~79 × 43 KB reads spaced ~610 ms apart).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torrent-tv/proxy",
3
- "version": "2.9.5",
3
+ "version": "2.9.6",
4
4
  "description": "Torrent proxy client that exposes webseed-like HTTP stream endpoint.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "publishConfig": {
@@ -277,6 +277,17 @@ async function probeInputDurationSeconds(ffmpegBin, inputUrl) {
277
277
  }, 8_000);
278
278
  ffmpeg.stderr.on("data", (chunk) => {
279
279
  stderr += String(chunk);
280
+ // ffmpeg prints the container header ("Duration:") almost immediately,
281
+ // long before it decodes anything. Bail as soon as we have it instead of
282
+ // letting `-f null -` decode the whole stream until the 8 s timeout.
283
+ const duration = parseFfmpegDurationSeconds(stderr);
284
+ if (duration != null) {
285
+ clearTimeout(timeoutId);
286
+ if (!ffmpeg.killed) {
287
+ ffmpeg.kill("SIGTERM");
288
+ }
289
+ finish(duration);
290
+ }
280
291
  });
281
292
  ffmpeg.on("error", () => {
282
293
  clearTimeout(timeoutId);
@@ -983,6 +994,10 @@ export class HlsSessionManager {
983
994
  remainingSeconds: session.progress.remainingSeconds,
984
995
  warmupPercent,
985
996
  warmupRemainingSeconds,
997
+ // Segment length, so the browser can show progress toward the FIRST
998
+ // segment (the only thing it waits for before playback starts) instead
999
+ // of a percentage of the whole-file transcode.
1000
+ segmentDurationSec: this.segmentDurationSec,
986
1001
  speed: session.progress.speed,
987
1002
  updatedAt: session.progress.updatedAt,
988
1003
  error: session.state === "failed" ? session.lastError : ""