node-av 5.2.4-beta.1 → 6.0.0-beta.10
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 +15 -1
- package/dist/api/bitstream-filter.d.ts +110 -87
- package/dist/api/bitstream-filter.js +162 -102
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +87 -8
- package/dist/api/decoder.js +179 -4
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/demuxer.d.ts +30 -24
- package/dist/api/demuxer.js +4 -5
- package/dist/api/demuxer.js.map +1 -1
- package/dist/api/device.js.map +1 -1
- package/dist/api/encoder-pool.d.ts +220 -0
- package/dist/api/encoder-pool.js +285 -0
- package/dist/api/encoder-pool.js.map +1 -0
- package/dist/api/encoder.d.ts +133 -7
- package/dist/api/encoder.js +392 -68
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-complex.d.ts +2 -1
- package/dist/api/filter-complex.js +11 -7
- package/dist/api/filter-complex.js.map +1 -1
- package/dist/api/filter-presets.d.ts +130 -654
- package/dist/api/filter-presets.js +180 -858
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.js +13 -8
- package/dist/api/filter.js.map +1 -1
- package/dist/api/fmp4-stream.js +1 -1
- package/dist/api/fmp4-stream.js.map +1 -1
- package/dist/api/index.d.ts +6 -6
- package/dist/api/index.js +8 -8
- package/dist/api/index.js.map +1 -1
- package/dist/api/muxer.d.ts +43 -15
- package/dist/api/muxer.js +79 -27
- package/dist/api/muxer.js.map +1 -1
- package/dist/api/pipeline.d.ts +50 -0
- package/dist/api/pipeline.js +138 -22
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/probe.d.ts +128 -0
- package/dist/api/probe.js +227 -0
- package/dist/api/probe.js.map +1 -0
- package/dist/api/rtp-stream.js +1 -1
- package/dist/api/rtp-stream.js.map +1 -1
- package/dist/api/scaler.d.ts +431 -0
- package/dist/api/scaler.js +620 -0
- package/dist/api/scaler.js.map +1 -0
- package/dist/api/utilities/async-queue.d.ts +27 -1
- package/dist/api/utilities/async-queue.js +38 -1
- package/dist/api/utilities/async-queue.js.map +1 -1
- package/dist/api/utilities/electron-shared-texture.d.ts +41 -1
- package/dist/api/utilities/electron-shared-texture.js +41 -4
- package/dist/api/utilities/electron-shared-texture.js.map +1 -1
- package/dist/api/utilities/index.d.ts +1 -1
- package/dist/api/utilities/index.js.map +1 -1
- package/dist/api/webrtc-stream.d.ts +0 -1
- package/dist/api/webrtc-stream.js +0 -1
- package/dist/api/webrtc-stream.js.map +1 -1
- package/dist/constants/bsf-options.d.ts +333 -0
- package/dist/constants/bsf-options.js +7 -0
- package/dist/constants/bsf-options.js.map +1 -0
- package/dist/constants/constants.d.ts +109 -0
- package/dist/constants/constants.js +110 -0
- package/dist/constants/constants.js.map +1 -1
- package/dist/constants/decoders.d.ts +636 -618
- package/dist/constants/decoders.js +1 -3
- package/dist/constants/decoders.js.map +1 -1
- package/dist/constants/encoders.d.ts +300 -282
- package/dist/constants/encoders.js +0 -2
- package/dist/constants/encoders.js.map +1 -1
- package/dist/constants/filter-options.d.ts +10915 -0
- package/dist/constants/filter-options.js +7 -0
- package/dist/constants/filter-options.js.map +1 -0
- package/dist/constants/format-options.d.ts +3056 -0
- package/dist/constants/format-options.js +7 -0
- package/dist/constants/format-options.js.map +1 -0
- package/dist/constants/formats.d.ts +18 -0
- package/dist/constants/formats.js +7 -0
- package/dist/constants/formats.js.map +1 -0
- package/dist/constants/index.d.ts +5 -0
- package/dist/constants/options.d.ts +4073 -0
- package/dist/constants/options.js +7 -0
- package/dist/constants/options.js.map +1 -0
- package/dist/lib/binding.d.ts +4 -1
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/codec.d.ts +36 -5
- package/dist/lib/codec.js +37 -4
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/dictionary.d.ts +1 -1
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/error.d.ts +69 -0
- package/dist/lib/error.js +92 -0
- package/dist/lib/error.js.map +1 -1
- package/dist/lib/frame.d.ts +46 -3
- package/dist/lib/frame.js +50 -3
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/native-types.d.ts +68 -0
- package/dist/lib/packet.d.ts +17 -3
- package/dist/lib/packet.js +19 -3
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/utilities.d.ts +21 -0
- package/dist/lib/utilities.js +23 -0
- package/dist/lib/utilities.js.map +1 -1
- package/dist/webrtc/index.d.ts +3 -0
- package/dist/webrtc/index.js +7 -0
- package/dist/webrtc/index.js.map +1 -0
- package/package.json +33 -22
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { Frame } from '../lib/frame.js';
|
|
2
|
+
import type { SwsFlags } from '../constants/index.js';
|
|
3
|
+
import type { HardwareContext } from './hardware.js';
|
|
4
|
+
/**
|
|
5
|
+
* Output pixel format for scaled images.
|
|
6
|
+
*/
|
|
7
|
+
export type ScaledImageFormat = 'rgb' | 'rgba' | 'gray' | 'nv12' | 'yuv420p';
|
|
8
|
+
/**
|
|
9
|
+
* Crop region in source pixel coordinates.
|
|
10
|
+
*/
|
|
11
|
+
export interface ScalerCrop {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Target dimensions for scaling.
|
|
19
|
+
*/
|
|
20
|
+
export interface ScalerResize {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Options for a single scale/crop/convert operation.
|
|
26
|
+
*/
|
|
27
|
+
export interface ScaleOptions {
|
|
28
|
+
/** Optional crop applied before scaling (source pixel coordinates). */
|
|
29
|
+
crop?: ScalerCrop;
|
|
30
|
+
/** Optional target dimensions. Omit to keep the (cropped) source size. */
|
|
31
|
+
resize?: ScalerResize;
|
|
32
|
+
/** Optional output pixel format. Omit to keep the source format. */
|
|
33
|
+
format?: ScaledImageFormat;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Options for encoding a frame to JPEG.
|
|
37
|
+
*/
|
|
38
|
+
export interface JpegOptions {
|
|
39
|
+
/** Optional crop applied before scaling (source pixel coordinates). */
|
|
40
|
+
crop?: ScalerCrop;
|
|
41
|
+
/** Optional target dimensions. Omit to keep the (cropped) source size. */
|
|
42
|
+
resize?: ScalerResize;
|
|
43
|
+
/** JPEG quality from 1 (smallest, lowest quality) to 100 (best). Default 90. */
|
|
44
|
+
quality?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Options for encoding a frame to PNG.
|
|
48
|
+
*/
|
|
49
|
+
export interface PngOptions {
|
|
50
|
+
/** Optional crop applied before scaling (source pixel coordinates). */
|
|
51
|
+
crop?: ScalerCrop;
|
|
52
|
+
/** Optional target dimensions. Omit to keep the (cropped) source size. */
|
|
53
|
+
resize?: ScalerResize;
|
|
54
|
+
/** Output color format. Default `'rgb'`. */
|
|
55
|
+
format?: 'rgb' | 'rgba' | 'gray';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Options for creating a {@link Scaler}.
|
|
59
|
+
*/
|
|
60
|
+
export interface ScalerOptions {
|
|
61
|
+
/**
|
|
62
|
+
* Hardware context. Required to process hardware frames - crop/scale/convert
|
|
63
|
+
* then run on the GPU and only the small result is downloaded.
|
|
64
|
+
*/
|
|
65
|
+
hardware?: HardwareContext | null;
|
|
66
|
+
/** swscale algorithm flags (SWS_*) for the software path. Defaults to `SWS_BILINEAR`. */
|
|
67
|
+
flags?: SwsFlags;
|
|
68
|
+
/**
|
|
69
|
+
* Maximum number of cached hardware filter graphs (one per distinct output
|
|
70
|
+
* configuration). Least-recently-used graphs are evicted beyond this. Default 16.
|
|
71
|
+
*/
|
|
72
|
+
maxCacheSize?: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* High-level image scaler, cropper, and pixel-format converter.
|
|
76
|
+
*
|
|
77
|
+
* Scales, crops, and converts decoded frames to raw pixel buffers or encoded
|
|
78
|
+
* JPEG/PNG images. Built for the detection/thumbnail/snapshot workload: one
|
|
79
|
+
* instance pools its swscale contexts, GPU filter graphs, and encoders, so
|
|
80
|
+
* reusing it for every frame and every crop avoids per-frame allocation.
|
|
81
|
+
* Software frames are scaled with swscale; hardware frames are cropped, scaled,
|
|
82
|
+
* and converted on the GPU with only the small result downloaded.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* import { Scaler } from 'node-av/api';
|
|
87
|
+
*
|
|
88
|
+
* using scaler = new Scaler({ hardware });
|
|
89
|
+
*
|
|
90
|
+
* // Scale + convert to RGB (on the GPU for hardware frames)
|
|
91
|
+
* const rgb = await scaler.toBuffer(frame, { resize: { width: 640, height: 360 }, format: 'rgb' });
|
|
92
|
+
*
|
|
93
|
+
* // Crop a detected region and encode a snapshot
|
|
94
|
+
* const jpeg = await scaler.toJpeg(frame, { crop: { x, y, width: w, height: h }, quality: 85 });
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @see {@link EncoderPool} For pooled image encoders
|
|
98
|
+
* @see {@link FilterAPI} For streaming filtergraphs
|
|
99
|
+
*/
|
|
100
|
+
export declare class Scaler implements Disposable {
|
|
101
|
+
private native;
|
|
102
|
+
private hardware?;
|
|
103
|
+
private flags;
|
|
104
|
+
private maxCacheSize;
|
|
105
|
+
private graphs;
|
|
106
|
+
private jpegPool?;
|
|
107
|
+
private pngPool?;
|
|
108
|
+
private downloadFrame?;
|
|
109
|
+
private disposed;
|
|
110
|
+
/**
|
|
111
|
+
* Create a new scaler.
|
|
112
|
+
*
|
|
113
|
+
* @param options - Scaler options
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* using scaler = new Scaler({ hardware: HardwareContext.auto() });
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
constructor(options?: ScalerOptions);
|
|
121
|
+
/**
|
|
122
|
+
* Scale, crop, and/or convert a frame and return the raw pixel data.
|
|
123
|
+
*
|
|
124
|
+
* The returned buffer is tightly packed (no row padding). For planar formats
|
|
125
|
+
* (`nv12`, `yuv420p`) planes are concatenated.
|
|
126
|
+
*
|
|
127
|
+
* @param frame - Source frame (software or hardware; hardware frames are processed on the GPU and downloaded)
|
|
128
|
+
*
|
|
129
|
+
* @param options - Crop, resize, and format options
|
|
130
|
+
*
|
|
131
|
+
* @returns Tightly packed pixel data
|
|
132
|
+
*
|
|
133
|
+
* @throws {FFmpegError} If scaling fails
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* const gray = await scaler.toBuffer(frame, { resize: { width: 320, height: 180 }, format: 'gray' });
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* @see {@link toBufferSync} For synchronous version
|
|
141
|
+
*/
|
|
142
|
+
toBuffer(frame: Frame, options?: ScaleOptions): Promise<Buffer>;
|
|
143
|
+
/**
|
|
144
|
+
* Scale, crop, and/or convert a frame and return the raw pixel data.
|
|
145
|
+
* Synchronous version of toBuffer.
|
|
146
|
+
*
|
|
147
|
+
* @param frame - Source frame (software or hardware; hardware frames are processed on the GPU and downloaded)
|
|
148
|
+
*
|
|
149
|
+
* @param options - Crop, resize, and format options
|
|
150
|
+
*
|
|
151
|
+
* @returns Tightly packed pixel data
|
|
152
|
+
*
|
|
153
|
+
* @throws {FFmpegError} If scaling fails
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const gray = scaler.toBufferSync(frame, { resize: { width: 320, height: 180 }, format: 'gray' });
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @see {@link toBuffer} For async version
|
|
161
|
+
*/
|
|
162
|
+
toBufferSync(frame: Frame, options?: ScaleOptions): Buffer;
|
|
163
|
+
/**
|
|
164
|
+
* Scale/crop a frame and encode it to a JPEG image.
|
|
165
|
+
*
|
|
166
|
+
* The encoder is pooled per output size and reused across calls - no encoder is
|
|
167
|
+
* rebuilt per snapshot. Hardware frames are scaled on the GPU and downloaded;
|
|
168
|
+
* software frames are scaled with swscale.
|
|
169
|
+
*
|
|
170
|
+
* @param frame - Source frame (software or hardware)
|
|
171
|
+
*
|
|
172
|
+
* @param options - Crop, resize, and quality options
|
|
173
|
+
*
|
|
174
|
+
* @returns Encoded JPEG bytes
|
|
175
|
+
*
|
|
176
|
+
* @throws {FFmpegError} If scaling or encoding fails
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const jpeg = await scaler.toJpeg(frame, { resize: { width: 1280, height: 720 }, quality: 85 });
|
|
181
|
+
* await writeFile('snapshot.jpg', jpeg);
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* @see {@link toJpegSync} For synchronous version
|
|
185
|
+
*/
|
|
186
|
+
toJpeg(frame: Frame, options?: JpegOptions): Promise<Buffer>;
|
|
187
|
+
/**
|
|
188
|
+
* Scale/crop a frame and encode it to a JPEG image.
|
|
189
|
+
* Synchronous version of toJpeg.
|
|
190
|
+
*
|
|
191
|
+
* @param frame - Source frame (software or hardware)
|
|
192
|
+
*
|
|
193
|
+
* @param options - Crop, resize, and quality options
|
|
194
|
+
*
|
|
195
|
+
* @returns Encoded JPEG bytes
|
|
196
|
+
*
|
|
197
|
+
* @throws {FFmpegError} If scaling or encoding fails
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* const jpeg = scaler.toJpegSync(frame, { resize: { width: 1280, height: 720 }, quality: 85 });
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @see {@link toJpeg} For async version
|
|
205
|
+
*/
|
|
206
|
+
toJpegSync(frame: Frame, options?: JpegOptions): Buffer;
|
|
207
|
+
/**
|
|
208
|
+
* Scale/crop a frame and encode it to a PNG image.
|
|
209
|
+
*
|
|
210
|
+
* The encoder is pooled per output size/format and reused across calls. Hardware
|
|
211
|
+
* frames are scaled on the GPU and downloaded; software frames use swscale.
|
|
212
|
+
*
|
|
213
|
+
* @param frame - Source frame (software or hardware)
|
|
214
|
+
*
|
|
215
|
+
* @param options - Crop, resize, and color-format options
|
|
216
|
+
*
|
|
217
|
+
* @returns Encoded PNG bytes
|
|
218
|
+
*
|
|
219
|
+
* @throws {FFmpegError} If scaling or encoding fails
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* const png = await scaler.toPng(frame, { crop: { x, y, width: w, height: h } });
|
|
224
|
+
* await writeFile('region.png', png);
|
|
225
|
+
* ```
|
|
226
|
+
*
|
|
227
|
+
* @see {@link toPngSync} For synchronous version
|
|
228
|
+
*/
|
|
229
|
+
toPng(frame: Frame, options?: PngOptions): Promise<Buffer>;
|
|
230
|
+
/**
|
|
231
|
+
* Scale/crop a frame and encode it to a PNG image.
|
|
232
|
+
* Synchronous version of toPng.
|
|
233
|
+
*
|
|
234
|
+
* @param frame - Source frame (software or hardware)
|
|
235
|
+
*
|
|
236
|
+
* @param options - Crop, resize, and color-format options
|
|
237
|
+
*
|
|
238
|
+
* @returns Encoded PNG bytes
|
|
239
|
+
*
|
|
240
|
+
* @throws {FFmpegError} If scaling or encoding fails
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* const png = scaler.toPngSync(frame, { crop: { x, y, width: w, height: h } });
|
|
245
|
+
* ```
|
|
246
|
+
*
|
|
247
|
+
* @see {@link toPng} For async version
|
|
248
|
+
*/
|
|
249
|
+
toPngSync(frame: Frame, options?: PngOptions): Buffer;
|
|
250
|
+
/**
|
|
251
|
+
* Release all pooled scaling contexts, graphs, and frames.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```typescript
|
|
255
|
+
* scaler.close();
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
close(): void;
|
|
259
|
+
/**
|
|
260
|
+
* Download a hardware frame to system memory (no hardware context available).
|
|
261
|
+
*
|
|
262
|
+
* Reuses a single target frame across calls. The frame's own hwframe context
|
|
263
|
+
* selects a supported software format.
|
|
264
|
+
*
|
|
265
|
+
* @param frame - Hardware source frame
|
|
266
|
+
*
|
|
267
|
+
* @returns Software frame
|
|
268
|
+
*
|
|
269
|
+
* @throws {FFmpegError} If the transfer fails
|
|
270
|
+
*
|
|
271
|
+
* @internal
|
|
272
|
+
*/
|
|
273
|
+
private downloadToSoftware;
|
|
274
|
+
/**
|
|
275
|
+
* Synchronous version of downloadToSoftware.
|
|
276
|
+
*
|
|
277
|
+
* @param frame - Hardware source frame
|
|
278
|
+
*
|
|
279
|
+
* @returns Software frame
|
|
280
|
+
*
|
|
281
|
+
* @throws {FFmpegError} If the transfer fails
|
|
282
|
+
*
|
|
283
|
+
* @internal
|
|
284
|
+
*/
|
|
285
|
+
private downloadToSoftwareSync;
|
|
286
|
+
/**
|
|
287
|
+
* Lazily allocate and reset the reused download target frame.
|
|
288
|
+
*
|
|
289
|
+
* @returns The cleared download frame
|
|
290
|
+
*
|
|
291
|
+
* @internal
|
|
292
|
+
*/
|
|
293
|
+
private prepareDownloadTarget;
|
|
294
|
+
/**
|
|
295
|
+
* Scale/crop/convert a frame through a cached filter graph and return the
|
|
296
|
+
* resulting frame (caller must free it).
|
|
297
|
+
*
|
|
298
|
+
* Software frames are scaled with swscale filters; hardware frames are
|
|
299
|
+
* cropped/scaled/converted on the GPU and downloaded. The crop region is
|
|
300
|
+
* reconfigured per frame via a runtime command on a graph shared per output
|
|
301
|
+
* size (except OpenCL, where the crop is baked in).
|
|
302
|
+
*
|
|
303
|
+
* @param frame - Source frame (software, or hardware with a hardware context)
|
|
304
|
+
*
|
|
305
|
+
* @param crop - Crop region, or undefined for the full frame
|
|
306
|
+
*
|
|
307
|
+
* @param resize - Target dimensions, or undefined to keep the cropped size
|
|
308
|
+
*
|
|
309
|
+
* @param format - Output pixel format
|
|
310
|
+
*
|
|
311
|
+
* @returns The scaled output frame (caller frees)
|
|
312
|
+
*
|
|
313
|
+
* @throws {Error} If the crop is out of bounds or the graph produces no frame
|
|
314
|
+
*
|
|
315
|
+
* @internal
|
|
316
|
+
*/
|
|
317
|
+
private toFrame;
|
|
318
|
+
/**
|
|
319
|
+
* Synchronous version of toFrame.
|
|
320
|
+
*
|
|
321
|
+
* @param frame - Source frame (software, or hardware with a hardware context)
|
|
322
|
+
*
|
|
323
|
+
* @param crop - Crop region, or undefined for the full frame
|
|
324
|
+
*
|
|
325
|
+
* @param resize - Target dimensions, or undefined to keep the cropped size
|
|
326
|
+
*
|
|
327
|
+
* @param format - Output pixel format
|
|
328
|
+
*
|
|
329
|
+
* @returns The scaled output frame (caller frees)
|
|
330
|
+
*
|
|
331
|
+
* @internal
|
|
332
|
+
*/
|
|
333
|
+
private toFrameSync;
|
|
334
|
+
/**
|
|
335
|
+
* Resolve (and, on demand, build) the cached filter graph for a frame, applying
|
|
336
|
+
* the crop reconfiguration. Shared by the sync and async scaling paths; all of
|
|
337
|
+
* this work (parse, config, sendCommand) is synchronous.
|
|
338
|
+
*
|
|
339
|
+
* @param frame - Source frame (software, or hardware with a hardware context)
|
|
340
|
+
*
|
|
341
|
+
* @param crop - Crop region, or undefined for the full frame
|
|
342
|
+
*
|
|
343
|
+
* @param resize - Target dimensions, or undefined to keep the cropped size
|
|
344
|
+
*
|
|
345
|
+
* @param format - Output pixel format
|
|
346
|
+
*
|
|
347
|
+
* @returns The cached graph entry, ready to process the frame
|
|
348
|
+
*
|
|
349
|
+
* @throws {Error} If the crop is out of bounds
|
|
350
|
+
*
|
|
351
|
+
* @internal
|
|
352
|
+
*/
|
|
353
|
+
private resolveGraph;
|
|
354
|
+
/**
|
|
355
|
+
* Tag a frame for MJPEG encoding: full color range and a per-frame quality.
|
|
356
|
+
*
|
|
357
|
+
* MJPEG quality is carried on the frame (the encoder pool sets the QSCALE flag),
|
|
358
|
+
* so one pooled encoder serves every quality for a given output size.
|
|
359
|
+
*
|
|
360
|
+
* @param frame - Frame about to be JPEG-encoded
|
|
361
|
+
*
|
|
362
|
+
* @param quality - Quality from 1 (worst) to 100 (best)
|
|
363
|
+
*
|
|
364
|
+
* @internal
|
|
365
|
+
*/
|
|
366
|
+
private prepareJpegFrame;
|
|
367
|
+
/**
|
|
368
|
+
* The lazily created MJPEG encoder pool (QSCALE flag set for per-frame quality).
|
|
369
|
+
*
|
|
370
|
+
* @returns The JPEG encoder pool
|
|
371
|
+
*
|
|
372
|
+
* @internal
|
|
373
|
+
*/
|
|
374
|
+
private getJpegPool;
|
|
375
|
+
/**
|
|
376
|
+
* The lazily created PNG encoder pool.
|
|
377
|
+
*
|
|
378
|
+
* @returns The PNG encoder pool
|
|
379
|
+
*
|
|
380
|
+
* @internal
|
|
381
|
+
*/
|
|
382
|
+
private getPngPool;
|
|
383
|
+
/**
|
|
384
|
+
* Build a crop+scale+convert graph.
|
|
385
|
+
*
|
|
386
|
+
* For software frames this is `crop,scale,format`. For hardware frames the crop
|
|
387
|
+
* filter sets crop metadata that the hardware scaler (scale_vt/scale_cuda/
|
|
388
|
+
* scale_vaapi) applies on the GPU; the result is kept in NV12, downloaded, and
|
|
389
|
+
* converted on the CPU. When `commandable` the crop is a labeled instance
|
|
390
|
+
* (`crop@sc`) whose initial region is `crop` but which is re-aimed per frame via
|
|
391
|
+
* `sendCommand`. Otherwise (OpenCL) the crop is fixed in the graph.
|
|
392
|
+
*
|
|
393
|
+
* @param isHw - Whether the input is a hardware frame
|
|
394
|
+
*
|
|
395
|
+
* @param outW - Output width
|
|
396
|
+
*
|
|
397
|
+
* @param outH - Output height
|
|
398
|
+
*
|
|
399
|
+
* @param format - Output pixel format
|
|
400
|
+
*
|
|
401
|
+
* @param crop - Initial crop region
|
|
402
|
+
*
|
|
403
|
+
* @param commandable - Whether the crop can be reconfigured at runtime
|
|
404
|
+
*
|
|
405
|
+
* @returns Filtergraph description
|
|
406
|
+
*
|
|
407
|
+
* @internal
|
|
408
|
+
*/
|
|
409
|
+
private buildGraph;
|
|
410
|
+
/**
|
|
411
|
+
* Insert a graph, evicting the least-recently-used entry if over capacity.
|
|
412
|
+
*
|
|
413
|
+
* @param key - Operation-configuration key
|
|
414
|
+
*
|
|
415
|
+
* @param entry - Graph entry to cache
|
|
416
|
+
*
|
|
417
|
+
* @internal
|
|
418
|
+
*/
|
|
419
|
+
private cacheSet;
|
|
420
|
+
/**
|
|
421
|
+
* Dispose of the scaler (for `using` statements).
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* ```typescript
|
|
425
|
+
* using scaler = new Scaler();
|
|
426
|
+
* // ... use scaler ...
|
|
427
|
+
* // automatically disposed at end of scope
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
430
|
+
[Symbol.dispose](): void;
|
|
431
|
+
}
|