node-av 6.2.0-beta.2 → 6.2.0-beta.21
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/README.md +13 -8
- package/dist/api/audio-frame-buffer.d.ts +73 -1
- package/dist/api/audio-frame-buffer.js +127 -1
- package/dist/api/audio-frame-buffer.js.map +1 -1
- package/dist/api/bitstream-filter.d.ts +82 -4
- package/dist/api/bitstream-filter.js +197 -100
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +5 -0
- package/dist/api/decoder.js +13 -6
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/demuxer.d.ts +15 -1
- package/dist/api/demuxer.js +165 -54
- package/dist/api/demuxer.js.map +1 -1
- package/dist/api/encoder-pool.d.ts +43 -1
- package/dist/api/encoder-pool.js +121 -9
- package/dist/api/encoder-pool.js.map +1 -1
- package/dist/api/encoder.d.ts +19 -0
- package/dist/api/encoder.js +112 -45
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter.js +15 -6
- package/dist/api/filter.js.map +1 -1
- package/dist/api/fmp4-stream.d.ts +167 -3
- package/dist/api/fmp4-stream.js +423 -90
- package/dist/api/fmp4-stream.js.map +1 -1
- package/dist/api/hardware.d.ts +2 -0
- package/dist/api/hardware.js +25 -4
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/io-stream.d.ts +3 -2
- package/dist/api/io-stream.js +61 -5
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/muxer.d.ts +14 -0
- package/dist/api/muxer.js +131 -51
- package/dist/api/muxer.js.map +1 -1
- package/dist/api/pipeline.d.ts +24 -0
- package/dist/api/pipeline.js +76 -5
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/rtp-stream.d.ts +56 -6
- package/dist/api/rtp-stream.js +252 -80
- package/dist/api/rtp-stream.js.map +1 -1
- package/dist/api/scaler.d.ts +105 -17
- package/dist/api/scaler.js +326 -108
- package/dist/api/scaler.js.map +1 -1
- package/dist/api/utilities/async-queue.d.ts +3 -0
- package/dist/api/utilities/async-queue.js +8 -0
- package/dist/api/utilities/async-queue.js.map +1 -1
- package/dist/api/webrtc-stream.d.ts +2 -0
- package/dist/api/webrtc-stream.js +46 -12
- package/dist/api/webrtc-stream.js.map +1 -1
- package/dist/api/whisper.d.ts +2 -0
- package/dist/api/whisper.js +63 -23
- package/dist/api/whisper.js.map +1 -1
- package/dist/constants/constants.d.ts +1 -0
- package/dist/constants/constants.js +1 -0
- package/dist/constants/constants.js.map +1 -1
- package/dist/constants/filter-options.d.ts +2 -0
- package/dist/ffmpeg/install.js +115 -29
- package/dist/ffmpeg/install.js.map +1 -1
- package/dist/ffmpeg/utils.js +7 -4
- package/dist/ffmpeg/utils.js.map +1 -1
- package/dist/lib/binding.d.ts +1 -0
- package/dist/lib/binding.js +12 -16
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/codec-context.d.ts +0 -2
- package/dist/lib/codec-context.js +4 -22
- package/dist/lib/codec-context.js.map +1 -1
- package/dist/lib/filter-context.d.ts +0 -1
- package/dist/lib/filter-context.js +2 -11
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/format-context.d.ts +63 -7
- package/dist/lib/format-context.js +70 -21
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +11 -11
- package/dist/lib/frame.js +13 -20
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/hardware-frames-context.d.ts +0 -1
- package/dist/lib/hardware-frames-context.js +2 -8
- package/dist/lib/hardware-frames-context.js.map +1 -1
- package/dist/lib/io-context.d.ts +4 -2
- package/dist/lib/io-context.js +4 -2
- package/dist/lib/io-context.js.map +1 -1
- package/dist/lib/native-types.d.ts +4 -4
- package/dist/lib/option.d.ts +26 -0
- package/dist/lib/option.js +42 -18
- package/dist/lib/option.js.map +1 -1
- package/dist/lib/packet.d.ts +5 -0
- package/dist/lib/packet.js +5 -0
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/stream.d.ts +3 -4
- package/dist/lib/stream.js +17 -24
- package/dist/lib/stream.js.map +1 -1
- package/install/check.js +40 -79
- package/package.json +43 -32
- package/build_mac_local.sh +0 -69
package/dist/api/scaler.d.ts
CHANGED
|
@@ -81,6 +81,10 @@ export interface ScalerOptions {
|
|
|
81
81
|
* Software frames are scaled with swscale; hardware frames are cropped, scaled,
|
|
82
82
|
* and converted on the GPU with only the small result downloaded.
|
|
83
83
|
*
|
|
84
|
+
* Safe for concurrent use: calls that share a cached graph or pooled encoder are
|
|
85
|
+
* serialized on that resource, while distinct output configurations run fully in
|
|
86
|
+
* parallel, and cache eviction never disposes a resource that is still in flight.
|
|
87
|
+
*
|
|
84
88
|
* @example
|
|
85
89
|
* ```typescript
|
|
86
90
|
* import { Scaler } from 'node-av/api';
|
|
@@ -99,13 +103,14 @@ export interface ScalerOptions {
|
|
|
99
103
|
*/
|
|
100
104
|
export declare class Scaler implements Disposable {
|
|
101
105
|
private native;
|
|
106
|
+
private syncNative?;
|
|
107
|
+
private nativeLock;
|
|
102
108
|
private hardware?;
|
|
103
109
|
private flags;
|
|
104
110
|
private maxCacheSize;
|
|
105
111
|
private graphs;
|
|
106
112
|
private jpegPool?;
|
|
107
113
|
private pngPool?;
|
|
108
|
-
private downloadFrame?;
|
|
109
114
|
private disposed;
|
|
110
115
|
/**
|
|
111
116
|
* Create a new scaler.
|
|
@@ -259,12 +264,13 @@ export declare class Scaler implements Disposable {
|
|
|
259
264
|
/**
|
|
260
265
|
* Download a hardware frame to system memory (no hardware context available).
|
|
261
266
|
*
|
|
262
|
-
*
|
|
263
|
-
* selects a supported software
|
|
267
|
+
* Allocates a fresh target per call - concurrent downloads must not share a
|
|
268
|
+
* staging frame. The frame's own hwframe context selects a supported software
|
|
269
|
+
* format. The caller frees the returned frame.
|
|
264
270
|
*
|
|
265
271
|
* @param frame - Hardware source frame
|
|
266
272
|
*
|
|
267
|
-
* @returns Software frame
|
|
273
|
+
* @returns Software frame (caller frees)
|
|
268
274
|
*
|
|
269
275
|
* @throws {FFmpegError} If the transfer fails
|
|
270
276
|
*
|
|
@@ -276,7 +282,7 @@ export declare class Scaler implements Disposable {
|
|
|
276
282
|
*
|
|
277
283
|
* @param frame - Hardware source frame
|
|
278
284
|
*
|
|
279
|
-
* @returns Software frame
|
|
285
|
+
* @returns Software frame (caller frees)
|
|
280
286
|
*
|
|
281
287
|
* @throws {FFmpegError} If the transfer fails
|
|
282
288
|
*
|
|
@@ -284,13 +290,34 @@ export declare class Scaler implements Disposable {
|
|
|
284
290
|
*/
|
|
285
291
|
private downloadToSoftwareSync;
|
|
286
292
|
/**
|
|
287
|
-
*
|
|
293
|
+
* Run the pooled native software scaler, serialized per instance.
|
|
294
|
+
*
|
|
295
|
+
* The native scaler reuses staging frames and sws contexts per configuration;
|
|
296
|
+
* overlapping async calls would race on them in the worker threads.
|
|
297
|
+
*
|
|
298
|
+
* @param frame - Software source frame
|
|
299
|
+
*
|
|
300
|
+
* @param options - Crop, resize, and format options
|
|
301
|
+
*
|
|
302
|
+
* @returns Tightly packed pixel data
|
|
303
|
+
*
|
|
304
|
+
* @throws {FFmpegError} If scaling fails
|
|
305
|
+
*
|
|
306
|
+
* @internal
|
|
307
|
+
*/
|
|
308
|
+
private processNative;
|
|
309
|
+
/**
|
|
310
|
+
* The native scaler used by the sync path (lazily created).
|
|
311
|
+
*
|
|
312
|
+
* Sync calls block the event loop but can land while an async call's worker is
|
|
313
|
+
* scaling in the background; a separate native instance keeps them off the async
|
|
314
|
+
* scaler's pooled contexts, which are not safe to share across threads.
|
|
288
315
|
*
|
|
289
|
-
* @returns The
|
|
316
|
+
* @returns The sync-path native scaler
|
|
290
317
|
*
|
|
291
318
|
* @internal
|
|
292
319
|
*/
|
|
293
|
-
private
|
|
320
|
+
private getSyncNative;
|
|
294
321
|
/**
|
|
295
322
|
* Scale/crop/convert a frame through a cached filter graph and return the
|
|
296
323
|
* resulting frame (caller must free it).
|
|
@@ -318,6 +345,10 @@ export declare class Scaler implements Disposable {
|
|
|
318
345
|
/**
|
|
319
346
|
* Synchronous version of toFrame.
|
|
320
347
|
*
|
|
348
|
+
* Sync scales cannot interleave with each other (they block the event loop),
|
|
349
|
+
* but they can land between the awaits of an in-flight async scale; a busy
|
|
350
|
+
* cached graph is bypassed with a throwaway graph in that case.
|
|
351
|
+
*
|
|
321
352
|
* @param frame - Source frame (software, or hardware with a hardware context)
|
|
322
353
|
*
|
|
323
354
|
* @param crop - Crop region, or undefined for the full frame
|
|
@@ -332,9 +363,23 @@ export declare class Scaler implements Disposable {
|
|
|
332
363
|
*/
|
|
333
364
|
private toFrameSync;
|
|
334
365
|
/**
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
366
|
+
* Scale through a throwaway graph with the crop baked in, bypassing the cache.
|
|
367
|
+
*
|
|
368
|
+
* @param frame - Source frame
|
|
369
|
+
*
|
|
370
|
+
* @param acq - Resolved operation configuration
|
|
371
|
+
*
|
|
372
|
+
* @returns The scaled output frame (caller frees)
|
|
373
|
+
*
|
|
374
|
+
* @throws {Error} If the graph produces no frame
|
|
375
|
+
*
|
|
376
|
+
* @internal
|
|
377
|
+
*/
|
|
378
|
+
private scaleOneShotSync;
|
|
379
|
+
/**
|
|
380
|
+
* Resolve (and, on demand, build) the cached filter graph for a frame. Shared
|
|
381
|
+
* by the sync and async scaling paths; all of this work is synchronous, so a
|
|
382
|
+
* resolved entry cannot be evicted before the caller marks it in use.
|
|
338
383
|
*
|
|
339
384
|
* @param frame - Source frame (software, or hardware with a hardware context)
|
|
340
385
|
*
|
|
@@ -344,7 +389,7 @@ export declare class Scaler implements Disposable {
|
|
|
344
389
|
*
|
|
345
390
|
* @param format - Output pixel format
|
|
346
391
|
*
|
|
347
|
-
* @returns The cached graph entry
|
|
392
|
+
* @returns The cached graph entry and the resolved operation configuration
|
|
348
393
|
*
|
|
349
394
|
* @throws {Error} If the crop is out of bounds
|
|
350
395
|
*
|
|
@@ -352,16 +397,57 @@ export declare class Scaler implements Disposable {
|
|
|
352
397
|
*/
|
|
353
398
|
private resolveGraph;
|
|
354
399
|
/**
|
|
355
|
-
*
|
|
400
|
+
* Bring a cached graph in line with the current call. Must run under the entry
|
|
401
|
+
* lock (async path) or with no async call in flight (sync path).
|
|
402
|
+
*
|
|
403
|
+
* Rebuilds the graph when the source parameters changed: FilterAPI would
|
|
404
|
+
* otherwise reinitialize itself from the original graph description, silently
|
|
405
|
+
* resurrecting the crop baked in at build time instead of the current one. A
|
|
406
|
+
* graph that has not seen a frame yet is likewise rebuilt when the crop
|
|
407
|
+
* differs, because commands cannot be sent before initialization. Otherwise a
|
|
408
|
+
* changed crop is re-aimed with runtime commands - identical crops reuse the
|
|
409
|
+
* graph untouched (no config_input/config_output re-run).
|
|
356
410
|
*
|
|
357
|
-
*
|
|
358
|
-
* longer accept frames) so the next operation rebuilds it.
|
|
411
|
+
* @param acq - Resolved graph and operation configuration
|
|
359
412
|
*
|
|
360
|
-
* @param
|
|
413
|
+
* @param frame - Frame about to be processed
|
|
414
|
+
*
|
|
415
|
+
* @internal
|
|
416
|
+
*/
|
|
417
|
+
private prepareGraph;
|
|
418
|
+
/**
|
|
419
|
+
* Remove a graph from the cache and retire it.
|
|
420
|
+
*
|
|
421
|
+
* Identity-checked so a newer graph cached under the same key is left alone.
|
|
422
|
+
* Used after a flush (the graph is at EOF and can no longer accept frames) and
|
|
423
|
+
* after mid-stream failures, so the next operation rebuilds it.
|
|
424
|
+
*
|
|
425
|
+
* @param key - Cache key of the graph
|
|
426
|
+
*
|
|
427
|
+
* @param entry - The exact entry to evict
|
|
361
428
|
*
|
|
362
429
|
* @internal
|
|
363
430
|
*/
|
|
364
431
|
private evictGraph;
|
|
432
|
+
/**
|
|
433
|
+
* Take a graph out of service, disposing it now or on last release.
|
|
434
|
+
*
|
|
435
|
+
* An entry with in-flight scales is only marked; the final {@link releaseGraph}
|
|
436
|
+
* disposes the filter once nothing uses it anymore.
|
|
437
|
+
*
|
|
438
|
+
* @param entry - Entry removed from the cache
|
|
439
|
+
*
|
|
440
|
+
* @internal
|
|
441
|
+
*/
|
|
442
|
+
private retireEntry;
|
|
443
|
+
/**
|
|
444
|
+
* Drop an in-flight reference, disposing the graph if it was retired meanwhile.
|
|
445
|
+
*
|
|
446
|
+
* @param entry - Entry acquired by {@link toFrame}
|
|
447
|
+
*
|
|
448
|
+
* @internal
|
|
449
|
+
*/
|
|
450
|
+
private releaseGraph;
|
|
365
451
|
/**
|
|
366
452
|
* Tag a frame for MJPEG encoding: full color range and a per-frame quality.
|
|
367
453
|
*
|
|
@@ -397,7 +483,9 @@ export declare class Scaler implements Disposable {
|
|
|
397
483
|
* For software frames this is `crop,scale,format`. For hardware frames the crop
|
|
398
484
|
* filter sets crop metadata that the hardware scaler (scale_vt/scale_cuda/
|
|
399
485
|
* scale_vaapi) applies on the GPU; the result is kept in NV12, downloaded, and
|
|
400
|
-
* converted on the CPU.
|
|
486
|
+
* converted on the CPU. Scalers with a same-size/same-format passthrough mode
|
|
487
|
+
* (scale_vaapi/scale_cuda/vpp_qsv) get `passthrough=0`, since skipping the scaler
|
|
488
|
+
* would drop the crop metadata unapplied. When `commandable` the crop is a labeled instance
|
|
401
489
|
* (`crop@sc`) whose initial region is `crop` but which is re-aimed per frame via
|
|
402
490
|
* `sendCommand`. Otherwise (OpenCL) the crop is fixed in the graph.
|
|
403
491
|
*
|