node-av 6.2.0-beta.8 → 6.2.0

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.
Files changed (103) hide show
  1. package/README.md +7 -19
  2. package/dist/api/audio-frame-buffer.d.ts +378 -19
  3. package/dist/api/audio-frame-buffer.js +715 -101
  4. package/dist/api/audio-frame-buffer.js.map +1 -1
  5. package/dist/api/data/test_av1.ivf +0 -0
  6. package/dist/api/data/test_hevc.h265 +0 -0
  7. package/dist/api/data/test_vp9.ivf +0 -0
  8. package/dist/api/decoder.d.ts +117 -2
  9. package/dist/api/decoder.js +290 -23
  10. package/dist/api/decoder.js.map +1 -1
  11. package/dist/api/demuxer.d.ts +19 -3
  12. package/dist/api/demuxer.js +95 -29
  13. package/dist/api/demuxer.js.map +1 -1
  14. package/dist/api/encoder-pool.js +9 -1
  15. package/dist/api/encoder-pool.js.map +1 -1
  16. package/dist/api/encoder.d.ts +100 -6
  17. package/dist/api/encoder.js +249 -108
  18. package/dist/api/encoder.js.map +1 -1
  19. package/dist/api/filter-presets.d.ts +25 -1
  20. package/dist/api/filter-presets.js +63 -3
  21. package/dist/api/filter-presets.js.map +1 -1
  22. package/dist/api/filter.d.ts +62 -3
  23. package/dist/api/filter.js +118 -36
  24. package/dist/api/filter.js.map +1 -1
  25. package/dist/api/fmp4-stream.d.ts +179 -15
  26. package/dist/api/fmp4-stream.js +341 -120
  27. package/dist/api/fmp4-stream.js.map +1 -1
  28. package/dist/api/hardware.d.ts +2 -0
  29. package/dist/api/hardware.js +33 -10
  30. package/dist/api/hardware.js.map +1 -1
  31. package/dist/api/index.d.ts +2 -2
  32. package/dist/api/index.js.map +1 -1
  33. package/dist/api/io-stream.d.ts +3 -2
  34. package/dist/api/io-stream.js +23 -7
  35. package/dist/api/io-stream.js.map +1 -1
  36. package/dist/api/muxer.d.ts +276 -7
  37. package/dist/api/muxer.js +649 -116
  38. package/dist/api/muxer.js.map +1 -1
  39. package/dist/api/pipeline.d.ts +22 -0
  40. package/dist/api/pipeline.js +53 -0
  41. package/dist/api/pipeline.js.map +1 -1
  42. package/dist/api/rtp-stream.d.ts +58 -20
  43. package/dist/api/rtp-stream.js +237 -129
  44. package/dist/api/rtp-stream.js.map +1 -1
  45. package/dist/api/scaler.d.ts +39 -6
  46. package/dist/api/scaler.js +72 -18
  47. package/dist/api/scaler.js.map +1 -1
  48. package/dist/api/utilities/live-decoding.d.ts +15 -0
  49. package/dist/api/utilities/live-decoding.js +32 -0
  50. package/dist/api/utilities/live-decoding.js.map +1 -0
  51. package/dist/api/utilities/packet-age-watchdog.d.ts +198 -0
  52. package/dist/api/utilities/packet-age-watchdog.js +594 -0
  53. package/dist/api/utilities/packet-age-watchdog.js.map +1 -0
  54. package/dist/api/utilities/scale-size.d.ts +51 -0
  55. package/dist/api/utilities/scale-size.js +55 -0
  56. package/dist/api/utilities/scale-size.js.map +1 -0
  57. package/dist/api/utilities/video-transcode.d.ts +218 -0
  58. package/dist/api/utilities/video-transcode.js +624 -0
  59. package/dist/api/utilities/video-transcode.js.map +1 -0
  60. package/dist/constants/constants.d.ts +1 -0
  61. package/dist/constants/constants.js +1 -0
  62. package/dist/constants/constants.js.map +1 -1
  63. package/dist/constants/filter-options.d.ts +2 -0
  64. package/dist/ffmpeg/utils.js +7 -4
  65. package/dist/ffmpeg/utils.js.map +1 -1
  66. package/dist/lib/binding.d.ts +10 -1
  67. package/dist/lib/binding.js +25 -16
  68. package/dist/lib/binding.js.map +1 -1
  69. package/dist/lib/bitstream-filter-context.d.ts +2 -0
  70. package/dist/lib/bitstream-filter-context.js +2 -0
  71. package/dist/lib/bitstream-filter-context.js.map +1 -1
  72. package/dist/lib/filter-context.d.ts +3 -0
  73. package/dist/lib/filter-context.js +3 -0
  74. package/dist/lib/filter-context.js.map +1 -1
  75. package/dist/lib/filter-graph-segment.d.ts +3 -2
  76. package/dist/lib/filter-graph-segment.js +3 -2
  77. package/dist/lib/filter-graph-segment.js.map +1 -1
  78. package/dist/lib/filter-graph.d.ts +4 -4
  79. package/dist/lib/filter-graph.js +4 -4
  80. package/dist/lib/filter-inout.d.ts +4 -0
  81. package/dist/lib/filter-inout.js +4 -0
  82. package/dist/lib/filter-inout.js.map +1 -1
  83. package/dist/lib/format-context.d.ts +27 -3
  84. package/dist/lib/format-context.js +30 -6
  85. package/dist/lib/format-context.js.map +1 -1
  86. package/dist/lib/frame.d.ts +6 -2
  87. package/dist/lib/frame.js +11 -3
  88. package/dist/lib/frame.js.map +1 -1
  89. package/dist/lib/io-context.d.ts +4 -2
  90. package/dist/lib/io-context.js +4 -2
  91. package/dist/lib/io-context.js.map +1 -1
  92. package/dist/lib/native-types.d.ts +7 -3
  93. package/dist/lib/output-format.d.ts +42 -0
  94. package/dist/lib/output-format.js +46 -0
  95. package/dist/lib/output-format.js.map +1 -1
  96. package/dist/lib/stream.d.ts +5 -0
  97. package/dist/lib/stream.js +5 -0
  98. package/dist/lib/stream.js.map +1 -1
  99. package/dist/lib/utilities.d.ts +26 -0
  100. package/dist/lib/utilities.js +28 -0
  101. package/dist/lib/utilities.js.map +1 -1
  102. package/install/check.js +14 -16
  103. package/package.json +27 -44
@@ -25,6 +25,10 @@ export interface RTPStreamOptions {
25
25
  /**
26
26
  * Callback invoked when the stream is closed or encounters an error.
27
27
  *
28
+ * Called once per started session. On an error the stream has already been
29
+ * stopped and its resources (including the input connection) released.
30
+ * Exceptions thrown by the callback are logged and do not propagate.
31
+ *
28
32
  * @param error - Optional error if stream closed due to an error
29
33
  */
30
34
  onClose?: (error?: Error) => void;
@@ -67,6 +71,10 @@ export interface RTPStreamOptions {
67
71
  fps?: number;
68
72
  width?: number;
69
73
  height?: number;
74
+ bitrate?: number;
75
+ dumpExtra?: boolean;
76
+ /** Transcode even when the source codec is one of `supportedVideoCodecs`. */
77
+ transcode?: boolean;
70
78
  encoderOptions?: EncoderOptions['options'];
71
79
  };
72
80
  /**
@@ -143,6 +151,7 @@ export declare class RTPStream {
143
151
  private videoDecoder?;
144
152
  private videoFilter?;
145
153
  private videoEncoder?;
154
+ private videoBitstreamFilter?;
146
155
  private audioDecoder?;
147
156
  private audioFilter?;
148
157
  private audioEncoder?;
@@ -151,11 +160,11 @@ export declare class RTPStream {
151
160
  private signal?;
152
161
  private supportedVideoCodecs;
153
162
  private supportedAudioCodecs;
154
- private videoKeyframeRequested;
155
163
  private abortHandler?;
156
164
  private stopRequested;
157
165
  private stopPromise?;
158
166
  private startAbort?;
167
+ private stopSignal;
159
168
  /**
160
169
  * @param input - Media input URL or pre-opened Demuxer
161
170
  *
@@ -210,6 +219,10 @@ export declare class RTPStream {
210
219
  /**
211
220
  * Check if the stream is active.
212
221
  *
222
+ * Stays true while a requested stop is still unwinding: the pipeline reports
223
+ * itself stopped as soon as stop() is called, but its packets keep flowing
224
+ * and its native resources stay open until completion settles.
225
+ *
213
226
  * @returns True if the stream is active, false otherwise
214
227
  */
215
228
  get isStreamActive(): boolean;
@@ -237,9 +250,9 @@ export declare class RTPStream {
237
250
  *
238
251
  * Used to answer receiver feedback (e.g. a WebRTC PLI) so a receiver that
239
252
  * missed the stream start or lost packets can resync without waiting for the
240
- * next scheduled GOP keyframe. Currently effective for frame-source inputs
241
- * ({@link MediaFrameSource}); for demuxer inputs the encoder's regular GOP
242
- * cadence applies.
253
+ * next scheduled GOP keyframe. Effective whenever the video is encoded, from
254
+ * frame sources and from a transcoded URL or {@link Demuxer} input; a stream
255
+ * passed through keeps the source's keyframes.
243
256
  *
244
257
  * @example
245
258
  * ```typescript
@@ -249,20 +262,6 @@ export declare class RTPStream {
249
262
  * ```
250
263
  */
251
264
  requestVideoKeyframe(): void;
252
- /**
253
- * Pass video frames through, forcing a keyframe when one was requested.
254
- *
255
- * Sets `pictType = I` on the next frame after {@link requestVideoKeyframe};
256
- * combined with the encoder's `forced-idr` option this produces an IDR the
257
- * receiver can resync on.
258
- *
259
- * @param src - The user-provided video frame source
260
- *
261
- * @yields {Frame | null} The unchanged frames (with pictType forced when requested)
262
- *
263
- * @internal
264
- */
265
- private wrapVideoSource;
266
265
  /**
267
266
  * Start streaming media to RTP packets.
268
267
  *
@@ -313,13 +312,35 @@ export declare class RTPStream {
313
312
  * Wire the pipeline completion to the onClose/error callbacks.
314
313
  *
315
314
  * On success invokes `onClose()`; on error stops the stream and invokes
316
- * `onClose(error)`. Runs in the background (not awaited).
315
+ * `onClose(error)`. Either way `onClose` runs exactly once and the detached
316
+ * chain never rejects. Runs in the background (not awaited).
317
317
  *
318
318
  * @param completion - The pipeline completion promise
319
319
  *
320
320
  * @internal
321
321
  */
322
322
  private attachCompletion;
323
+ /**
324
+ * Invoke the owner's onClose callback.
325
+ *
326
+ * The completion chain runs detached, so an exception from the callback
327
+ * could only surface as an unhandled rejection - it is logged instead.
328
+ *
329
+ * @param error - Pipeline error, or undefined for a clean end
330
+ *
331
+ * @internal
332
+ */
333
+ private emitClose;
334
+ /**
335
+ * Whether a pipeline rejection was caused by an intentional shutdown.
336
+ *
337
+ * @param error - The pipeline rejection reason
338
+ *
339
+ * @returns True when stop() is in flight or the owner's signal aborted
340
+ *
341
+ * @internal
342
+ */
343
+ private isDeliberateStop;
323
344
  /**
324
345
  * Set up encoders and RTP outputs for a pre-composited frame source and start
325
346
  * encoding. No demuxer or decoder is involved - the provided frames are encoded
@@ -367,7 +388,8 @@ export declare class RTPStream {
367
388
  *
368
389
  * Stops the pipeline, closes output, and releases all FFmpeg resources.
369
390
  * Safe to call multiple times. After stopping, you can call start() again
370
- * to restart the stream.
391
+ * to restart the stream. Resolves even if the pipeline had failed; that
392
+ * error is reported through `onClose(error)`.
371
393
  *
372
394
  * @example
373
395
  * ```typescript
@@ -397,6 +419,22 @@ export declare class RTPStream {
397
419
  * @internal
398
420
  */
399
421
  private isAudioCodecSupported;
422
+ /**
423
+ * Find the encoder for a target video codec, on the device when it works there.
424
+ *
425
+ * @param target - Codec ID, or the name of a specific encoder to use as it is
426
+ *
427
+ * @param size - The output size, when known before the first frame
428
+ *
429
+ * @param size.width - Width
430
+ *
431
+ * @param size.height - Height
432
+ *
433
+ * @returns The encoder, or null if none exists
434
+ *
435
+ * @internal
436
+ */
437
+ private findVideoEncoder;
400
438
  /**
401
439
  * Check if the given video codec is supported.
402
440
  *