node-av 6.2.0-beta.9 → 7.0.0-beta.1

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 (116) 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 +67 -5
  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 +54 -33
  43. package/dist/api/rtp-stream.js +232 -153
  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/bsf-options.d.ts +32 -8
  61. package/dist/constants/constants.d.ts +36 -114
  62. package/dist/constants/constants.js +32 -95
  63. package/dist/constants/constants.js.map +1 -1
  64. package/dist/constants/decoders.d.ts +74 -74
  65. package/dist/constants/decoders.js +79 -77
  66. package/dist/constants/decoders.js.map +1 -1
  67. package/dist/constants/encoders.d.ts +20 -21
  68. package/dist/constants/encoders.js +25 -24
  69. package/dist/constants/encoders.js.map +1 -1
  70. package/dist/constants/filter-options.d.ts +1378 -194
  71. package/dist/constants/format-options.d.ts +1342 -83
  72. package/dist/constants/formats.d.ts +2 -2
  73. package/dist/constants/options.d.ts +2261 -125
  74. package/dist/ffmpeg/utils.js +7 -4
  75. package/dist/ffmpeg/utils.js.map +1 -1
  76. package/dist/ffmpeg/version.d.ts +1 -1
  77. package/dist/ffmpeg/version.js +1 -1
  78. package/dist/ffmpeg/version.js.map +1 -1
  79. package/dist/lib/binding.d.ts +10 -1
  80. package/dist/lib/binding.js +25 -16
  81. package/dist/lib/binding.js.map +1 -1
  82. package/dist/lib/bitstream-filter-context.d.ts +2 -0
  83. package/dist/lib/bitstream-filter-context.js +2 -0
  84. package/dist/lib/bitstream-filter-context.js.map +1 -1
  85. package/dist/lib/filter-context.d.ts +3 -0
  86. package/dist/lib/filter-context.js +3 -0
  87. package/dist/lib/filter-context.js.map +1 -1
  88. package/dist/lib/filter-graph-segment.d.ts +3 -2
  89. package/dist/lib/filter-graph-segment.js +3 -2
  90. package/dist/lib/filter-graph-segment.js.map +1 -1
  91. package/dist/lib/filter-graph.d.ts +4 -4
  92. package/dist/lib/filter-graph.js +4 -4
  93. package/dist/lib/filter-inout.d.ts +4 -0
  94. package/dist/lib/filter-inout.js +4 -0
  95. package/dist/lib/filter-inout.js.map +1 -1
  96. package/dist/lib/format-context.d.ts +27 -3
  97. package/dist/lib/format-context.js +30 -6
  98. package/dist/lib/format-context.js.map +1 -1
  99. package/dist/lib/frame.d.ts +6 -2
  100. package/dist/lib/frame.js +11 -3
  101. package/dist/lib/frame.js.map +1 -1
  102. package/dist/lib/io-context.d.ts +4 -2
  103. package/dist/lib/io-context.js +4 -2
  104. package/dist/lib/io-context.js.map +1 -1
  105. package/dist/lib/native-types.d.ts +7 -3
  106. package/dist/lib/output-format.d.ts +42 -0
  107. package/dist/lib/output-format.js +46 -0
  108. package/dist/lib/output-format.js.map +1 -1
  109. package/dist/lib/stream.d.ts +5 -0
  110. package/dist/lib/stream.js +5 -0
  111. package/dist/lib/stream.js.map +1 -1
  112. package/dist/lib/utilities.d.ts +26 -0
  113. package/dist/lib/utilities.js +28 -0
  114. package/dist/lib/utilities.js.map +1 -1
  115. package/install/check.js +14 -16
  116. package/package.json +28 -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;
@@ -68,6 +72,9 @@ export interface RTPStreamOptions {
68
72
  width?: number;
69
73
  height?: number;
70
74
  bitrate?: number;
75
+ dumpExtra?: boolean;
76
+ /** Transcode even when the source codec is one of `supportedVideoCodecs`. */
77
+ transcode?: boolean;
71
78
  encoderOptions?: EncoderOptions['options'];
72
79
  };
73
80
  /**
@@ -144,6 +151,7 @@ export declare class RTPStream {
144
151
  private videoDecoder?;
145
152
  private videoFilter?;
146
153
  private videoEncoder?;
154
+ private videoBitstreamFilter?;
147
155
  private audioDecoder?;
148
156
  private audioFilter?;
149
157
  private audioEncoder?;
@@ -152,11 +160,11 @@ export declare class RTPStream {
152
160
  private signal?;
153
161
  private supportedVideoCodecs;
154
162
  private supportedAudioCodecs;
155
- private videoKeyframeRequested;
156
163
  private abortHandler?;
157
164
  private stopRequested;
158
165
  private stopPromise?;
159
166
  private startAbort?;
167
+ private stopSignal;
160
168
  /**
161
169
  * @param input - Media input URL or pre-opened Demuxer
162
170
  *
@@ -211,6 +219,10 @@ export declare class RTPStream {
211
219
  /**
212
220
  * Check if the stream is active.
213
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
+ *
214
226
  * @returns True if the stream is active, false otherwise
215
227
  */
216
228
  get isStreamActive(): boolean;
@@ -238,9 +250,9 @@ export declare class RTPStream {
238
250
  *
239
251
  * Used to answer receiver feedback (e.g. a WebRTC PLI) so a receiver that
240
252
  * missed the stream start or lost packets can resync without waiting for the
241
- * next scheduled GOP keyframe. Currently effective for frame-source inputs
242
- * ({@link MediaFrameSource}); for demuxer inputs the encoder's regular GOP
243
- * 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.
244
256
  *
245
257
  * @example
246
258
  * ```typescript
@@ -250,20 +262,6 @@ export declare class RTPStream {
250
262
  * ```
251
263
  */
252
264
  requestVideoKeyframe(): void;
253
- /**
254
- * Pass video frames through, forcing a keyframe when one was requested.
255
- *
256
- * Sets `pictType = I` on the next frame after {@link requestVideoKeyframe};
257
- * combined with the encoder's `forced-idr` option this produces an IDR the
258
- * receiver can resync on.
259
- *
260
- * @param src - The user-provided video frame source
261
- *
262
- * @yields {Frame | null} The unchanged frames (with pictType forced when requested)
263
- *
264
- * @internal
265
- */
266
- private wrapVideoSource;
267
265
  /**
268
266
  * Start streaming media to RTP packets.
269
267
  *
@@ -311,32 +309,38 @@ export declare class RTPStream {
311
309
  */
312
310
  private throwIfStopRequested;
313
311
  /**
314
- * Cap the video bitrate on the encoder context.
312
+ * Wire the pipeline completion to the onClose/error callbacks.
315
313
  *
316
- * Applies a VBV rate cap (maxrate + a 1s buffer) WITHOUT setting a target
317
- * bitrate, so the encoder keeps its default constant-quality mode but can
318
- * never exceed the negotiated ceiling. Setting the bitrate as an ABR target
319
- * instead would push a normally-lighter stream UP to fill it, overshooting
320
- * on bursts.
314
+ * On success invokes `onClose()`; on error stops the stream and invokes
315
+ * `onClose(error)`. Either way `onClose` runs exactly once and the detached
316
+ * chain never rejects. Runs in the background (not awaited).
321
317
  *
322
- * @param ctx - Encoder codec context
318
+ * @param completion - The pipeline completion promise
323
319
  *
324
- * @param bitrate - Maximum bitrate in bits per second, or undefined
320
+ * @internal
321
+ */
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
325
330
  *
326
331
  * @internal
327
332
  */
328
- private applyBitrate;
333
+ private emitClose;
329
334
  /**
330
- * Wire the pipeline completion to the onClose/error callbacks.
335
+ * Whether a pipeline rejection was caused by an intentional shutdown.
331
336
  *
332
- * On success invokes `onClose()`; on error stops the stream and invokes
333
- * `onClose(error)`. Runs in the background (not awaited).
337
+ * @param error - The pipeline rejection reason
334
338
  *
335
- * @param completion - The pipeline completion promise
339
+ * @returns True when stop() is in flight or the owner's signal aborted
336
340
  *
337
341
  * @internal
338
342
  */
339
- private attachCompletion;
343
+ private isDeliberateStop;
340
344
  /**
341
345
  * Set up encoders and RTP outputs for a pre-composited frame source and start
342
346
  * encoding. No demuxer or decoder is involved - the provided frames are encoded
@@ -384,7 +388,8 @@ export declare class RTPStream {
384
388
  *
385
389
  * Stops the pipeline, closes output, and releases all FFmpeg resources.
386
390
  * Safe to call multiple times. After stopping, you can call start() again
387
- * to restart the stream.
391
+ * to restart the stream. Resolves even if the pipeline had failed; that
392
+ * error is reported through `onClose(error)`.
388
393
  *
389
394
  * @example
390
395
  * ```typescript
@@ -414,6 +419,22 @@ export declare class RTPStream {
414
419
  * @internal
415
420
  */
416
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;
417
438
  /**
418
439
  * Check if the given video codec is supported.
419
440
  *