node-av 0.0.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.
- package/CHANGELOG.md +8 -0
- package/LICENSE.md +22 -0
- package/README.md +377 -0
- package/binding.gyp +78 -0
- package/dist/api/bitstream-filter.d.ts +246 -0
- package/dist/api/bitstream-filter.js +369 -0
- package/dist/api/bitstream-filter.js.map +1 -0
- package/dist/api/decoder.d.ts +257 -0
- package/dist/api/decoder.js +424 -0
- package/dist/api/decoder.js.map +1 -0
- package/dist/api/encoder.d.ts +298 -0
- package/dist/api/encoder.js +574 -0
- package/dist/api/encoder.js.map +1 -0
- package/dist/api/filter.d.ts +457 -0
- package/dist/api/filter.js +876 -0
- package/dist/api/filter.js.map +1 -0
- package/dist/api/hardware.d.ts +318 -0
- package/dist/api/hardware.js +558 -0
- package/dist/api/hardware.js.map +1 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/api/index.js +20 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/io-stream.d.ts +109 -0
- package/dist/api/io-stream.js +124 -0
- package/dist/api/io-stream.js.map +1 -0
- package/dist/api/media-input.d.ts +295 -0
- package/dist/api/media-input.js +456 -0
- package/dist/api/media-input.js.map +1 -0
- package/dist/api/media-output.d.ts +274 -0
- package/dist/api/media-output.js +486 -0
- package/dist/api/media-output.js.map +1 -0
- package/dist/api/pipeline.d.ts +117 -0
- package/dist/api/pipeline.js +836 -0
- package/dist/api/pipeline.js.map +1 -0
- package/dist/api/types.d.ts +440 -0
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -0
- package/dist/api/utilities/audio-sample.d.ts +115 -0
- package/dist/api/utilities/audio-sample.js +110 -0
- package/dist/api/utilities/audio-sample.js.map +1 -0
- package/dist/api/utilities/channel-layout.d.ts +83 -0
- package/dist/api/utilities/channel-layout.js +87 -0
- package/dist/api/utilities/channel-layout.js.map +1 -0
- package/dist/api/utilities/image.d.ts +177 -0
- package/dist/api/utilities/image.js +183 -0
- package/dist/api/utilities/image.js.map +1 -0
- package/dist/api/utilities/index.d.ts +8 -0
- package/dist/api/utilities/index.js +17 -0
- package/dist/api/utilities/index.js.map +1 -0
- package/dist/api/utilities/media-type.d.ts +56 -0
- package/dist/api/utilities/media-type.js +60 -0
- package/dist/api/utilities/media-type.js.map +1 -0
- package/dist/api/utilities/pixel-format.d.ts +94 -0
- package/dist/api/utilities/pixel-format.js +102 -0
- package/dist/api/utilities/pixel-format.js.map +1 -0
- package/dist/api/utilities/sample-format.d.ts +132 -0
- package/dist/api/utilities/sample-format.js +144 -0
- package/dist/api/utilities/sample-format.js.map +1 -0
- package/dist/api/utilities/streaming.d.ts +104 -0
- package/dist/api/utilities/streaming.js +137 -0
- package/dist/api/utilities/streaming.js.map +1 -0
- package/dist/api/utilities/timestamp.d.ts +187 -0
- package/dist/api/utilities/timestamp.js +200 -0
- package/dist/api/utilities/timestamp.js.map +1 -0
- package/dist/api/utils.d.ts +61 -0
- package/dist/api/utils.js +330 -0
- package/dist/api/utils.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/audio-fifo.d.ts +339 -0
- package/dist/lib/audio-fifo.js +365 -0
- package/dist/lib/audio-fifo.js.map +1 -0
- package/dist/lib/binding.d.ts +192 -0
- package/dist/lib/binding.js +70 -0
- package/dist/lib/binding.js.map +1 -0
- package/dist/lib/bitstream-filter-context.d.ts +345 -0
- package/dist/lib/bitstream-filter-context.js +407 -0
- package/dist/lib/bitstream-filter-context.js.map +1 -0
- package/dist/lib/bitstream-filter.d.ts +124 -0
- package/dist/lib/bitstream-filter.js +138 -0
- package/dist/lib/bitstream-filter.js.map +1 -0
- package/dist/lib/channel-layouts.d.ts +51 -0
- package/dist/lib/channel-layouts.js +55 -0
- package/dist/lib/channel-layouts.js.map +1 -0
- package/dist/lib/codec-context.d.ts +763 -0
- package/dist/lib/codec-context.js +974 -0
- package/dist/lib/codec-context.js.map +1 -0
- package/dist/lib/codec-parameters.d.ts +362 -0
- package/dist/lib/codec-parameters.js +460 -0
- package/dist/lib/codec-parameters.js.map +1 -0
- package/dist/lib/codec-parser.d.ts +185 -0
- package/dist/lib/codec-parser.js +193 -0
- package/dist/lib/codec-parser.js.map +1 -0
- package/dist/lib/codec.d.ts +432 -0
- package/dist/lib/codec.js +492 -0
- package/dist/lib/codec.js.map +1 -0
- package/dist/lib/constants.d.ts +2037 -0
- package/dist/lib/constants.js +1659 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/dictionary.d.ts +371 -0
- package/dist/lib/dictionary.js +406 -0
- package/dist/lib/dictionary.js.map +1 -0
- package/dist/lib/error.d.ts +216 -0
- package/dist/lib/error.js +254 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/filter-context.d.ts +445 -0
- package/dist/lib/filter-context.js +505 -0
- package/dist/lib/filter-context.js.map +1 -0
- package/dist/lib/filter-graph.d.ts +556 -0
- package/dist/lib/filter-graph.js +608 -0
- package/dist/lib/filter-graph.js.map +1 -0
- package/dist/lib/filter-inout.d.ts +205 -0
- package/dist/lib/filter-inout.js +264 -0
- package/dist/lib/filter-inout.js.map +1 -0
- package/dist/lib/filter.d.ts +231 -0
- package/dist/lib/filter.js +260 -0
- package/dist/lib/filter.js.map +1 -0
- package/dist/lib/format-context.d.ts +798 -0
- package/dist/lib/format-context.js +845 -0
- package/dist/lib/format-context.js.map +1 -0
- package/dist/lib/frame.d.ts +784 -0
- package/dist/lib/frame.js +933 -0
- package/dist/lib/frame.js.map +1 -0
- package/dist/lib/hardware-device-context.d.ts +407 -0
- package/dist/lib/hardware-device-context.js +429 -0
- package/dist/lib/hardware-device-context.js.map +1 -0
- package/dist/lib/hardware-frames-context.d.ts +374 -0
- package/dist/lib/hardware-frames-context.js +430 -0
- package/dist/lib/hardware-frames-context.js.map +1 -0
- package/dist/lib/index.d.ts +31 -0
- package/dist/lib/index.js +54 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/input-format.d.ts +216 -0
- package/dist/lib/input-format.js +246 -0
- package/dist/lib/input-format.js.map +1 -0
- package/dist/lib/io-context.d.ts +495 -0
- package/dist/lib/io-context.js +550 -0
- package/dist/lib/io-context.js.map +1 -0
- package/dist/lib/log.d.ts +201 -0
- package/dist/lib/log.js +219 -0
- package/dist/lib/log.js.map +1 -0
- package/dist/lib/native-types.d.ts +719 -0
- package/dist/lib/native-types.js +2 -0
- package/dist/lib/native-types.js.map +1 -0
- package/dist/lib/option.d.ts +589 -0
- package/dist/lib/option.js +853 -0
- package/dist/lib/option.js.map +1 -0
- package/dist/lib/output-format.d.ts +179 -0
- package/dist/lib/output-format.js +205 -0
- package/dist/lib/output-format.js.map +1 -0
- package/dist/lib/packet.d.ts +487 -0
- package/dist/lib/packet.js +558 -0
- package/dist/lib/packet.js.map +1 -0
- package/dist/lib/rational.d.ts +210 -0
- package/dist/lib/rational.js +233 -0
- package/dist/lib/rational.js.map +1 -0
- package/dist/lib/software-resample-context.d.ts +572 -0
- package/dist/lib/software-resample-context.js +610 -0
- package/dist/lib/software-resample-context.js.map +1 -0
- package/dist/lib/software-scale-context.d.ts +290 -0
- package/dist/lib/software-scale-context.js +308 -0
- package/dist/lib/software-scale-context.js.map +1 -0
- package/dist/lib/stream.d.ts +322 -0
- package/dist/lib/stream.js +408 -0
- package/dist/lib/stream.js.map +1 -0
- package/dist/lib/types.d.ts +59 -0
- package/dist/lib/types.js +8 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utilities.d.ts +346 -0
- package/dist/lib/utilities.js +424 -0
- package/dist/lib/utilities.js.map +1 -0
- package/install/check.js +113 -0
- package/install/ffmpeg.js +163 -0
- package/package.json +107 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { HardwareDeviceContext } from './hardware-device-context.js';
|
|
2
|
+
import type { AVHWFrameTransferDirection, AVPixelFormat } from './constants.js';
|
|
3
|
+
import type { Frame } from './frame.js';
|
|
4
|
+
import type { NativeHardwareFramesContext, NativeWrapper } from './native-types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Hardware frames context for GPU memory management.
|
|
7
|
+
*
|
|
8
|
+
* Manages pools of hardware frames for efficient GPU memory allocation.
|
|
9
|
+
* Handles format conversions and data transfers between CPU and GPU memory.
|
|
10
|
+
* Required for hardware-accelerated video processing pipelines.
|
|
11
|
+
*
|
|
12
|
+
* Direct mapping to FFmpeg's AVHWFramesContext.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { HardwareDeviceContext, HardwareFramesContext, Frame, FFmpegError } from 'node-av';
|
|
17
|
+
* import { AV_HWDEVICE_TYPE_CUDA, AV_PIX_FMT_CUDA, AV_PIX_FMT_NV12 } from 'node-av/constants';
|
|
18
|
+
*
|
|
19
|
+
* // Create hardware frames context
|
|
20
|
+
* const device = new HardwareDeviceContext();
|
|
21
|
+
* const deviceRet = device.create(AV_HWDEVICE_TYPE_CUDA, null, null);
|
|
22
|
+
* FFmpegError.throwIfError(deviceRet, 'create device');
|
|
23
|
+
*
|
|
24
|
+
* const frames = new HardwareFramesContext();
|
|
25
|
+
* frames.alloc(device);
|
|
26
|
+
*
|
|
27
|
+
* // Configure frame parameters
|
|
28
|
+
* frames.format = AV_PIX_FMT_CUDA; // Hardware format
|
|
29
|
+
* frames.swFormat = AV_PIX_FMT_NV12; // Software format
|
|
30
|
+
* frames.width = 1920;
|
|
31
|
+
* frames.height = 1080;
|
|
32
|
+
* frames.initialPoolSize = 10;
|
|
33
|
+
*
|
|
34
|
+
* // Initialize the context
|
|
35
|
+
* const ret = frames.init();
|
|
36
|
+
* FFmpegError.throwIfError(ret, 'init frames');
|
|
37
|
+
*
|
|
38
|
+
* // Allocate hardware frame
|
|
39
|
+
* const hwFrame = new Frame();
|
|
40
|
+
* hwFrame.alloc();
|
|
41
|
+
* const ret2 = frames.getBuffer(hwFrame, 0);
|
|
42
|
+
* FFmpegError.throwIfError(ret2, 'getBuffer');
|
|
43
|
+
*
|
|
44
|
+
* // Transfer between hardware and software
|
|
45
|
+
* const swFrame = new Frame();
|
|
46
|
+
* swFrame.alloc();
|
|
47
|
+
* swFrame.width = 1920;
|
|
48
|
+
* swFrame.height = 1080;
|
|
49
|
+
* swFrame.format = AV_PIX_FMT_NV12;
|
|
50
|
+
* const swRet = swFrame.getBuffer();
|
|
51
|
+
* FFmpegError.throwIfError(swRet, 'getBuffer sw');
|
|
52
|
+
*
|
|
53
|
+
* // Download from hardware
|
|
54
|
+
* const dlRet = await frames.transferData(swFrame, hwFrame, 0);
|
|
55
|
+
* FFmpegError.throwIfError(dlRet, 'download');
|
|
56
|
+
*
|
|
57
|
+
* // Upload to hardware
|
|
58
|
+
* const ulRet = await frames.transferData(hwFrame, swFrame, 0);
|
|
59
|
+
* FFmpegError.throwIfError(ulRet, 'upload');
|
|
60
|
+
*
|
|
61
|
+
* // Cleanup
|
|
62
|
+
* hwFrame.free();
|
|
63
|
+
* swFrame.free();
|
|
64
|
+
* frames.free();
|
|
65
|
+
* device.free();
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @see {@link HardwareDeviceContext} For device management
|
|
69
|
+
* @see {@link Frame} For frame allocation
|
|
70
|
+
*/
|
|
71
|
+
export declare class HardwareFramesContext implements Disposable, NativeWrapper<NativeHardwareFramesContext> {
|
|
72
|
+
private native;
|
|
73
|
+
private _deviceRef?;
|
|
74
|
+
/**
|
|
75
|
+
* Create a new hardware frames context.
|
|
76
|
+
*
|
|
77
|
+
* The context is uninitialized - you must call alloc() before use.
|
|
78
|
+
* No FFmpeg resources are allocated until initialization.
|
|
79
|
+
*
|
|
80
|
+
* Direct wrapper around AVHWFramesContext.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* import { HardwareFramesContext, FFmpegError } from 'node-av';
|
|
85
|
+
*
|
|
86
|
+
* const frames = new HardwareFramesContext();
|
|
87
|
+
* frames.alloc(device);
|
|
88
|
+
* // Configure parameters
|
|
89
|
+
* const ret = frames.init();
|
|
90
|
+
* FFmpegError.throwIfError(ret, 'init');
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
constructor();
|
|
94
|
+
/**
|
|
95
|
+
* Hardware pixel format.
|
|
96
|
+
*
|
|
97
|
+
* The pixel format identifying the underlying HW surface type.
|
|
98
|
+
*
|
|
99
|
+
* Direct mapping to AVHWFramesContext->format
|
|
100
|
+
*/
|
|
101
|
+
get format(): AVPixelFormat;
|
|
102
|
+
set format(value: AVPixelFormat);
|
|
103
|
+
/**
|
|
104
|
+
* Software pixel format.
|
|
105
|
+
*
|
|
106
|
+
* The pixel format identifying the actual data layout of the hardware frames.
|
|
107
|
+
*
|
|
108
|
+
* Direct mapping to AVHWFramesContext->sw_format
|
|
109
|
+
*/
|
|
110
|
+
get swFormat(): AVPixelFormat;
|
|
111
|
+
set swFormat(value: AVPixelFormat);
|
|
112
|
+
/**
|
|
113
|
+
* Frame width.
|
|
114
|
+
*
|
|
115
|
+
* The allocated dimensions of the frames in this pool.
|
|
116
|
+
*
|
|
117
|
+
* Direct mapping to AVHWFramesContext->width
|
|
118
|
+
*/
|
|
119
|
+
get width(): number;
|
|
120
|
+
set width(value: number);
|
|
121
|
+
/**
|
|
122
|
+
* Frame height.
|
|
123
|
+
*
|
|
124
|
+
* The allocated dimensions of the frames in this pool.
|
|
125
|
+
*
|
|
126
|
+
* Direct mapping to AVHWFramesContext->height
|
|
127
|
+
*/
|
|
128
|
+
get height(): number;
|
|
129
|
+
set height(value: number);
|
|
130
|
+
/**
|
|
131
|
+
* Initial pool size.
|
|
132
|
+
*
|
|
133
|
+
* Initial size of the frame pool. If a device type does not support
|
|
134
|
+
* dynamically resizing the pool, then this is also the maximum pool size.
|
|
135
|
+
*/
|
|
136
|
+
get initialPoolSize(): number;
|
|
137
|
+
set initialPoolSize(value: number);
|
|
138
|
+
/**
|
|
139
|
+
* Associated device context.
|
|
140
|
+
*
|
|
141
|
+
* Direct mapping to AVHWFramesContext->device_ref
|
|
142
|
+
*
|
|
143
|
+
* @readonly
|
|
144
|
+
*/
|
|
145
|
+
get deviceRef(): HardwareDeviceContext | null;
|
|
146
|
+
/**
|
|
147
|
+
* Allocate an AVHWFramesContext tied to a given device context.
|
|
148
|
+
*
|
|
149
|
+
* Direct mapping to av_hwframe_ctx_alloc()
|
|
150
|
+
*
|
|
151
|
+
* @param device - Hardware device context
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const frames = new HardwareFramesContext();
|
|
156
|
+
* frames.alloc(device);
|
|
157
|
+
* // Set parameters before init()
|
|
158
|
+
* frames.format = AV_PIX_FMT_CUDA;
|
|
159
|
+
* frames.swFormat = AV_PIX_FMT_NV12;
|
|
160
|
+
* frames.width = 1920;
|
|
161
|
+
* frames.height = 1080;
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @throws {Error} If allocation fails
|
|
165
|
+
*/
|
|
166
|
+
alloc(device: HardwareDeviceContext): void;
|
|
167
|
+
/**
|
|
168
|
+
* Finalize the context before use.
|
|
169
|
+
*
|
|
170
|
+
* Direct mapping to av_hwframe_ctx_init()
|
|
171
|
+
*
|
|
172
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
173
|
+
* - 0: Success
|
|
174
|
+
* - AVERROR(EINVAL): Invalid parameters
|
|
175
|
+
* - AVERROR(ENOMEM): Memory allocation failure
|
|
176
|
+
* - <0: Device-specific errors
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const ret = frames.init();
|
|
181
|
+
* if (ret < 0) {
|
|
182
|
+
* throw new FFmpegError(ret);
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
init(): number;
|
|
187
|
+
/**
|
|
188
|
+
* Free the frames context.
|
|
189
|
+
*
|
|
190
|
+
* Unreferences the AVBufferRef.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* frames.free();
|
|
195
|
+
* // frames is now invalid and should not be used
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
free(): void;
|
|
199
|
+
/**
|
|
200
|
+
* Allocate a new frame attached to the given AVHWFramesContext.
|
|
201
|
+
*
|
|
202
|
+
* Direct mapping to av_hwframe_get_buffer()
|
|
203
|
+
*
|
|
204
|
+
* @param frame - Frame to allocate (must be allocated but empty)
|
|
205
|
+
* @param flags - Currently unused, should be set to 0
|
|
206
|
+
*
|
|
207
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
208
|
+
* - 0: Success
|
|
209
|
+
* - AVERROR(EINVAL): Invalid parameters
|
|
210
|
+
* - AVERROR(ENOMEM): Memory allocation failure
|
|
211
|
+
* - <0: Device-specific errors
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* const frame = new Frame();
|
|
216
|
+
* frame.alloc();
|
|
217
|
+
* const ret = frames.getBuffer(frame, 0);
|
|
218
|
+
* if (ret < 0) {
|
|
219
|
+
* throw new FFmpegError(ret);
|
|
220
|
+
* }
|
|
221
|
+
* // frame now contains a hardware frame
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
getBuffer(frame: Frame, flags?: number): number;
|
|
225
|
+
/**
|
|
226
|
+
* Copy data to or from a hardware surface.
|
|
227
|
+
*
|
|
228
|
+
* Direct mapping to av_hwframe_transfer_data()
|
|
229
|
+
*
|
|
230
|
+
* @param dst - Destination frame
|
|
231
|
+
* @param src - Source frame
|
|
232
|
+
* @param flags - Currently unused, should be set to 0
|
|
233
|
+
*
|
|
234
|
+
* @returns Promise resolving to 0 on success, negative AVERROR on error:
|
|
235
|
+
* - 0: Success
|
|
236
|
+
* - AVERROR(ENOSYS): Transfer not supported
|
|
237
|
+
* - AVERROR(EINVAL): Invalid parameters
|
|
238
|
+
* - <0: Other errors
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* // Download from hardware to software
|
|
243
|
+
* const ret = await frames.transferData(swFrame, hwFrame, 0);
|
|
244
|
+
* if (ret < 0) {
|
|
245
|
+
* throw new FFmpegError(ret);
|
|
246
|
+
* }
|
|
247
|
+
*
|
|
248
|
+
* // Upload from software to hardware
|
|
249
|
+
* const ret2 = await frames.transferData(hwFrame, swFrame, 0);
|
|
250
|
+
* if (ret2 < 0) {
|
|
251
|
+
* throw new FFmpegError(ret2);
|
|
252
|
+
* }
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
transferData(dst: Frame, src: Frame, flags?: number): Promise<number>;
|
|
256
|
+
/**
|
|
257
|
+
* Get a list of possible source/target formats.
|
|
258
|
+
*
|
|
259
|
+
* Direct mapping to av_hwframe_transfer_get_formats()
|
|
260
|
+
*
|
|
261
|
+
* @param direction - Transfer direction (AV_HWFRAME_TRANSFER_DIRECTION_*)
|
|
262
|
+
*
|
|
263
|
+
* @returns Array of pixel formats or error code:
|
|
264
|
+
* - Array: List of supported formats
|
|
265
|
+
* - <0: AVERROR on failure
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```typescript
|
|
269
|
+
* // Get formats for downloading from hardware
|
|
270
|
+
* const formats = frames.transferGetFormats(AV_HWFRAME_TRANSFER_DIRECTION_FROM);
|
|
271
|
+
* if (Array.isArray(formats)) {
|
|
272
|
+
* console.log('Supported download formats:', formats);
|
|
273
|
+
* }
|
|
274
|
+
*
|
|
275
|
+
* // Get formats for uploading to hardware
|
|
276
|
+
* const formats2 = frames.transferGetFormats(AV_HWFRAME_TRANSFER_DIRECTION_TO);
|
|
277
|
+
* if (Array.isArray(formats2)) {
|
|
278
|
+
* console.log('Supported upload formats:', formats2);
|
|
279
|
+
* }
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
transferGetFormats(direction: AVHWFrameTransferDirection): AVPixelFormat[] | number;
|
|
283
|
+
/**
|
|
284
|
+
* Map a hardware frame.
|
|
285
|
+
*
|
|
286
|
+
* Direct mapping to av_hwframe_map()
|
|
287
|
+
*
|
|
288
|
+
* This has a number of different possible effects, depending on the format
|
|
289
|
+
* and origin of the src and dst frames. On input, src should be a usable
|
|
290
|
+
* frame with valid hardware/software format and allocated data.
|
|
291
|
+
*
|
|
292
|
+
* @param dst - Destination frame
|
|
293
|
+
* @param src - Source frame to map
|
|
294
|
+
* @param flags - Combination of AV_HWFRAME_MAP_* flags
|
|
295
|
+
*
|
|
296
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
297
|
+
* - 0: Success
|
|
298
|
+
* - AVERROR(ENOSYS): Mapping not supported
|
|
299
|
+
* - AVERROR(EINVAL): Invalid parameters
|
|
300
|
+
* - <0: Other errors
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```typescript
|
|
304
|
+
* const mappedFrame = new Frame();
|
|
305
|
+
* mappedFrame.alloc();
|
|
306
|
+
* const ret = frames.map(mappedFrame, hwFrame, AV_HWFRAME_MAP_READ);
|
|
307
|
+
* if (ret < 0) {
|
|
308
|
+
* throw new FFmpegError(ret);
|
|
309
|
+
* }
|
|
310
|
+
* // mappedFrame now provides CPU access to hwFrame
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
map(dst: Frame, src: Frame, flags?: number): number;
|
|
314
|
+
/**
|
|
315
|
+
* Create a new frame context derived from an existing one.
|
|
316
|
+
*
|
|
317
|
+
* Direct mapping to av_hwframe_ctx_create_derived()
|
|
318
|
+
*
|
|
319
|
+
* @param format - Pixel format for the derived context
|
|
320
|
+
* @param derivedDevice - Device context for the derived frames
|
|
321
|
+
* @param source - Source frames context
|
|
322
|
+
* @param flags - Currently unused, should be 0
|
|
323
|
+
*
|
|
324
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
325
|
+
* - 0: Success
|
|
326
|
+
* - AVERROR(ENOSYS): Derivation not supported
|
|
327
|
+
* - AVERROR(EINVAL): Invalid parameters
|
|
328
|
+
* - <0: Other errors
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```typescript
|
|
332
|
+
* const derived = new HardwareFramesContext();
|
|
333
|
+
* const ret = derived.createDerived(
|
|
334
|
+
* AV_PIX_FMT_NV12,
|
|
335
|
+
* derivedDevice,
|
|
336
|
+
* sourceFrames,
|
|
337
|
+
* 0
|
|
338
|
+
* );
|
|
339
|
+
* if (ret < 0) {
|
|
340
|
+
* throw new FFmpegError(ret);
|
|
341
|
+
* }
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
createDerived(format: AVPixelFormat, derivedDevice: HardwareDeviceContext, source: HardwareFramesContext, flags?: number): number;
|
|
345
|
+
/**
|
|
346
|
+
* Get the native FFmpeg AVHWFramesContext pointer.
|
|
347
|
+
*
|
|
348
|
+
* @internal For use by other wrapper classes
|
|
349
|
+
* @returns The underlying native hardware frames context object
|
|
350
|
+
*/
|
|
351
|
+
getNative(): NativeHardwareFramesContext;
|
|
352
|
+
/**
|
|
353
|
+
* Dispose of the hardware frames context.
|
|
354
|
+
*
|
|
355
|
+
* Implements the Disposable interface for automatic cleanup.
|
|
356
|
+
* Equivalent to calling free().
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* import { HardwareFramesContext, FFmpegError } from 'node-av';
|
|
361
|
+
*
|
|
362
|
+
* {
|
|
363
|
+
* using frames = new HardwareFramesContext();
|
|
364
|
+
* frames.alloc(device);
|
|
365
|
+
* const ret = frames.init();
|
|
366
|
+
* FFmpegError.throwIfError(ret, 'init');
|
|
367
|
+
* // ... use frames
|
|
368
|
+
* } // Automatically freed when leaving scope
|
|
369
|
+
* ```
|
|
370
|
+
*
|
|
371
|
+
* @see {@link free} For manual cleanup
|
|
372
|
+
*/
|
|
373
|
+
[Symbol.dispose](): void;
|
|
374
|
+
}
|