node-av 1.1.0 → 1.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.
- package/README.md +51 -38
- package/dist/api/bitstream-filter.d.ts +180 -123
- package/dist/api/bitstream-filter.js +180 -125
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +279 -132
- package/dist/api/decoder.js +285 -142
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/encoder.d.ts +246 -162
- package/dist/api/encoder.js +272 -208
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-presets.d.ts +690 -94
- package/dist/api/filter-presets.js +686 -102
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +249 -213
- package/dist/api/filter.js +252 -242
- package/dist/api/filter.js.map +1 -1
- package/dist/api/hardware.d.ts +224 -117
- package/dist/api/hardware.js +380 -214
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/index.d.ts +3 -3
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/io-stream.d.ts +65 -61
- package/dist/api/io-stream.js +43 -46
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/media-input.d.ts +242 -140
- package/dist/api/media-input.js +205 -103
- package/dist/api/media-input.js.map +1 -1
- package/dist/api/media-output.d.ts +206 -128
- package/dist/api/media-output.js +210 -128
- package/dist/api/media-output.js.map +1 -1
- package/dist/api/pipeline.d.ts +168 -38
- package/dist/api/pipeline.js +238 -14
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/types.d.ts +21 -187
- package/dist/api/utils.d.ts +1 -2
- package/dist/api/utils.js +9 -0
- package/dist/api/utils.js.map +1 -1
- package/dist/lib/audio-fifo.d.ts +127 -170
- package/dist/lib/audio-fifo.js +130 -173
- package/dist/lib/audio-fifo.js.map +1 -1
- package/dist/lib/binding.js +5 -0
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/bitstream-filter-context.d.ts +139 -184
- package/dist/lib/bitstream-filter-context.js +139 -188
- package/dist/lib/bitstream-filter-context.js.map +1 -1
- package/dist/lib/bitstream-filter.d.ts +68 -54
- package/dist/lib/bitstream-filter.js +68 -54
- package/dist/lib/bitstream-filter.js.map +1 -1
- package/dist/lib/codec-context.d.ts +316 -380
- package/dist/lib/codec-context.js +316 -381
- package/dist/lib/codec-context.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +160 -170
- package/dist/lib/codec-parameters.js +162 -172
- package/dist/lib/codec-parameters.js.map +1 -1
- package/dist/lib/codec-parser.d.ts +91 -104
- package/dist/lib/codec-parser.js +92 -103
- package/dist/lib/codec-parser.js.map +1 -1
- package/dist/lib/codec.d.ts +264 -281
- package/dist/lib/codec.js +268 -285
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/dictionary.d.ts +149 -203
- package/dist/lib/dictionary.js +158 -212
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/error.d.ts +96 -130
- package/dist/lib/error.js +98 -128
- package/dist/lib/error.js.map +1 -1
- package/dist/lib/filter-context.d.ts +284 -218
- package/dist/lib/filter-context.js +290 -227
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/filter-graph.d.ts +251 -292
- package/dist/lib/filter-graph.js +253 -294
- package/dist/lib/filter-graph.js.map +1 -1
- package/dist/lib/filter-inout.d.ts +87 -95
- package/dist/lib/filter-inout.js +87 -95
- package/dist/lib/filter-inout.js.map +1 -1
- package/dist/lib/filter.d.ts +93 -111
- package/dist/lib/filter.js +93 -111
- package/dist/lib/filter.js.map +1 -1
- package/dist/lib/format-context.d.ts +320 -428
- package/dist/lib/format-context.js +313 -385
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +262 -405
- package/dist/lib/frame.js +263 -408
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/hardware-device-context.d.ts +149 -203
- package/dist/lib/hardware-device-context.js +149 -203
- package/dist/lib/hardware-device-context.js.map +1 -1
- package/dist/lib/hardware-frames-context.d.ts +170 -180
- package/dist/lib/hardware-frames-context.js +171 -181
- package/dist/lib/hardware-frames-context.js.map +1 -1
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/input-format.d.ts +89 -117
- package/dist/lib/input-format.js +89 -117
- package/dist/lib/input-format.js.map +1 -1
- package/dist/lib/io-context.d.ts +209 -241
- package/dist/lib/io-context.js +220 -252
- package/dist/lib/io-context.js.map +1 -1
- package/dist/lib/log.d.ts +85 -119
- package/dist/lib/log.js +85 -122
- package/dist/lib/log.js.map +1 -1
- package/dist/lib/native-types.d.ts +117 -106
- package/dist/lib/native-types.js +0 -7
- package/dist/lib/native-types.js.map +1 -1
- package/dist/lib/option.d.ts +284 -241
- package/dist/lib/option.js +309 -249
- package/dist/lib/option.js.map +1 -1
- package/dist/lib/output-format.d.ts +77 -101
- package/dist/lib/output-format.js +77 -101
- package/dist/lib/output-format.js.map +1 -1
- package/dist/lib/packet.d.ts +172 -240
- package/dist/lib/packet.js +172 -241
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/rational.d.ts +0 -2
- package/dist/lib/rational.js +0 -2
- package/dist/lib/rational.js.map +1 -1
- package/dist/lib/software-resample-context.d.ts +241 -325
- package/dist/lib/software-resample-context.js +242 -326
- package/dist/lib/software-resample-context.js.map +1 -1
- package/dist/lib/software-scale-context.d.ts +129 -173
- package/dist/lib/software-scale-context.js +131 -175
- package/dist/lib/software-scale-context.js.map +1 -1
- package/dist/lib/stream.d.ts +87 -197
- package/dist/lib/stream.js +87 -197
- package/dist/lib/stream.js.map +1 -1
- package/dist/lib/utilities.d.ts +372 -181
- package/dist/lib/utilities.js +373 -182
- package/dist/lib/utilities.js.map +1 -1
- package/install/check.js +0 -1
- package/package.json +21 -12
- package/release_notes.md +43 -59
- package/CHANGELOG.md +0 -8
package/dist/lib/frame.d.ts
CHANGED
|
@@ -4,20 +4,21 @@ import type { AVChromaLocation, AVColorPrimaries, AVColorRange, AVColorSpace, AV
|
|
|
4
4
|
import type { NativeFrame, NativeWrapper } from './native-types.js';
|
|
5
5
|
import type { ChannelLayout } from './types.js';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Container for uncompressed audio/video data.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Stores decoded audio samples or video pixels. Each frame contains raw data
|
|
10
|
+
* for a single video frame or a set of audio samples. Includes format information,
|
|
11
|
+
* timing data, and metadata. Supports both software and hardware (GPU) frames.
|
|
12
|
+
* Essential for decoding, encoding, and filter operations.
|
|
12
13
|
*
|
|
13
14
|
* Direct mapping to FFmpeg's AVFrame.
|
|
14
15
|
*
|
|
15
16
|
* @example
|
|
16
17
|
* ```typescript
|
|
17
18
|
* import { Frame, FFmpegError } from 'node-av';
|
|
18
|
-
* import { AV_PIX_FMT_YUV420P
|
|
19
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
19
20
|
*
|
|
20
|
-
* // Create and allocate frame
|
|
21
|
+
* // Create and allocate frame
|
|
21
22
|
* const frame = new Frame();
|
|
22
23
|
* frame.alloc();
|
|
23
24
|
*
|
|
@@ -25,775 +26,635 @@ import type { ChannelLayout } from './types.js';
|
|
|
25
26
|
* frame.format = AV_PIX_FMT_YUV420P;
|
|
26
27
|
* frame.width = 1920;
|
|
27
28
|
* frame.height = 1080;
|
|
28
|
-
* const
|
|
29
|
-
* FFmpegError.throwIfError(
|
|
29
|
+
* const ret = frame.allocBuffer();
|
|
30
|
+
* FFmpegError.throwIfError(ret, 'allocBuffer');
|
|
30
31
|
*
|
|
31
|
-
* //
|
|
32
|
-
* const
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* const audioRet = audioFrame.getBuffer(); // Allocate buffers
|
|
39
|
-
* FFmpegError.throwIfError(audioRet, 'getBuffer');
|
|
40
|
-
*
|
|
41
|
-
* // Receive decoded data
|
|
42
|
-
* const ret = await codecContext.receiveFrame(frame);
|
|
43
|
-
* FFmpegError.throwIfError(ret, 'receiveFrame');
|
|
44
|
-
* console.log(`Frame PTS: ${frame.pts}`);
|
|
32
|
+
* // Receive decoded frame
|
|
33
|
+
* const ret2 = await codecContext.receiveFrame(frame);
|
|
34
|
+
* if (ret2 >= 0) {
|
|
35
|
+
* console.log(`Frame PTS: ${frame.pts}`);
|
|
36
|
+
* console.log(`Frame type: ${frame.pictType}`);
|
|
37
|
+
* console.log(`Keyframe: ${frame.keyFrame}`);
|
|
38
|
+
* }
|
|
45
39
|
*
|
|
46
40
|
* // Cleanup
|
|
47
|
-
* frame.unref();
|
|
48
|
-
* frame.free(); // Free frame completely
|
|
41
|
+
* frame.unref();
|
|
49
42
|
* ```
|
|
50
43
|
*
|
|
44
|
+
* @see [AVFrame](https://ffmpeg.org/doxygen/trunk/structAVFrame.html) - FFmpeg Doxygen
|
|
51
45
|
* @see {@link CodecContext} For encoding/decoding frames
|
|
52
46
|
* @see {@link FilterContext} For filtering frames
|
|
53
47
|
*/
|
|
54
48
|
export declare class Frame implements Disposable, NativeWrapper<NativeFrame> {
|
|
55
49
|
private native;
|
|
56
50
|
private _hwFramesCtx?;
|
|
57
|
-
/**
|
|
58
|
-
* Create a new frame.
|
|
59
|
-
*
|
|
60
|
-
* The frame is uninitialized - you must call alloc() before use.
|
|
61
|
-
* No FFmpeg resources are allocated until alloc() is called.
|
|
62
|
-
*
|
|
63
|
-
* Direct wrapper around AVFrame.
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* import { Frame } from 'node-av';
|
|
68
|
-
*
|
|
69
|
-
* const frame = new Frame();
|
|
70
|
-
* frame.alloc();
|
|
71
|
-
* // Frame is now ready for use
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
51
|
constructor();
|
|
75
52
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* For video: AVPixelFormat (-1 if unknown or unset).
|
|
79
|
-
* For audio: AVSampleFormat (-1 if unknown or unset).
|
|
80
|
-
*
|
|
81
|
-
* Direct mapping to AVFrame->format
|
|
53
|
+
* Pixel format for video frames or sample format for audio.
|
|
82
54
|
*
|
|
83
|
-
*
|
|
55
|
+
* Direct mapping to AVFrame->format.
|
|
84
56
|
*/
|
|
85
57
|
get format(): AVPixelFormat | AVSampleFormat;
|
|
86
58
|
set format(value: AVPixelFormat | AVSampleFormat);
|
|
87
59
|
/**
|
|
88
|
-
* Width of
|
|
60
|
+
* Width of video frame in pixels.
|
|
89
61
|
*
|
|
90
|
-
* Direct mapping to AVFrame->width
|
|
91
|
-
*
|
|
92
|
-
* For video: MUST be set before calling getBuffer() or allocBuffer().
|
|
93
|
-
* For audio: unused (0).
|
|
62
|
+
* Direct mapping to AVFrame->width.
|
|
94
63
|
*/
|
|
95
64
|
get width(): number;
|
|
96
65
|
set width(value: number);
|
|
97
66
|
/**
|
|
98
|
-
* Height of
|
|
99
|
-
*
|
|
100
|
-
* Direct mapping to AVFrame->height
|
|
67
|
+
* Height of video frame in pixels.
|
|
101
68
|
*
|
|
102
|
-
*
|
|
103
|
-
* For audio: unused (0).
|
|
69
|
+
* Direct mapping to AVFrame->height.
|
|
104
70
|
*/
|
|
105
71
|
get height(): number;
|
|
106
72
|
set height(value: number);
|
|
107
73
|
/**
|
|
108
|
-
* Number of audio samples
|
|
74
|
+
* Number of audio samples per channel.
|
|
109
75
|
*
|
|
110
|
-
* Direct mapping to AVFrame->nb_samples
|
|
111
|
-
*
|
|
112
|
-
* For audio: MUST be set before calling getBuffer() or allocBuffer().
|
|
113
|
-
* For video: unused (0).
|
|
76
|
+
* Direct mapping to AVFrame->nb_samples.
|
|
114
77
|
*/
|
|
115
78
|
get nbSamples(): number;
|
|
116
79
|
set nbSamples(value: number);
|
|
117
80
|
/**
|
|
118
|
-
* Presentation timestamp
|
|
119
|
-
*
|
|
120
|
-
* Time when frame should be shown to user.
|
|
81
|
+
* Presentation timestamp.
|
|
121
82
|
*
|
|
122
|
-
*
|
|
83
|
+
* Time when the frame should be presented.
|
|
84
|
+
* In time base units. AV_NOPTS_VALUE if unknown.
|
|
123
85
|
*
|
|
124
|
-
*
|
|
86
|
+
* Direct mapping to AVFrame->pts.
|
|
125
87
|
*/
|
|
126
88
|
get pts(): bigint;
|
|
127
89
|
set pts(value: bigint);
|
|
128
90
|
/**
|
|
129
|
-
* DTS
|
|
91
|
+
* DTS from the packet that produced this frame.
|
|
130
92
|
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
93
|
+
* Copy of packet DTS for reference.
|
|
94
|
+
* In time base units. AV_NOPTS_VALUE if unknown.
|
|
133
95
|
*
|
|
134
|
-
* Direct mapping to AVFrame->pkt_dts
|
|
96
|
+
* Direct mapping to AVFrame->pkt_dts.
|
|
135
97
|
*/
|
|
136
98
|
get pktDts(): bigint;
|
|
137
99
|
set pktDts(value: bigint);
|
|
138
100
|
/**
|
|
139
101
|
* Best effort timestamp.
|
|
140
102
|
*
|
|
141
|
-
*
|
|
103
|
+
* Frame timestamp estimated using various heuristics.
|
|
104
|
+
* In time base units.
|
|
142
105
|
*
|
|
143
|
-
*
|
|
144
|
-
* Uses pts if available, otherwise falls back to pkt_dts.
|
|
106
|
+
* Direct mapping to AVFrame->best_effort_timestamp.
|
|
145
107
|
*/
|
|
146
108
|
get bestEffortTimestamp(): bigint;
|
|
147
109
|
set bestEffortTimestamp(value: bigint);
|
|
148
110
|
/**
|
|
149
|
-
* Time base for
|
|
111
|
+
* Time base for timestamps.
|
|
150
112
|
*
|
|
151
|
-
*
|
|
113
|
+
* Defines the unit of the timestamps (seconds per tick).
|
|
152
114
|
*
|
|
153
|
-
*
|
|
154
|
-
* of which frame timestamps are represented.
|
|
115
|
+
* Direct mapping to AVFrame->time_base.
|
|
155
116
|
*/
|
|
156
117
|
get timeBase(): Rational;
|
|
157
118
|
set timeBase(value: Rational);
|
|
158
119
|
/**
|
|
159
120
|
* Whether this frame is a keyframe.
|
|
160
121
|
*
|
|
161
|
-
*
|
|
122
|
+
* 1 if keyframe, 0 otherwise.
|
|
162
123
|
*
|
|
163
|
-
*
|
|
164
|
-
* It is set to 1 for all frames in intra-only codecs.
|
|
165
|
-
* - encoding: Set by libavcodec.
|
|
166
|
-
* - decoding: Set by libavcodec.
|
|
124
|
+
* Direct mapping to AVFrame->key_frame.
|
|
167
125
|
*/
|
|
168
126
|
get keyFrame(): number;
|
|
169
127
|
set keyFrame(value: number);
|
|
170
128
|
/**
|
|
171
129
|
* Picture type of the frame.
|
|
172
130
|
*
|
|
173
|
-
*
|
|
131
|
+
* Type of frame (I, P, B, etc.).
|
|
174
132
|
*
|
|
175
|
-
*
|
|
176
|
-
* AV_PICTURE_TYPE_B for bi-directionally predicted frames, etc.
|
|
177
|
-
* - encoding: Set by libavcodec. for coded_picture (and set by user for input).
|
|
178
|
-
* - decoding: Set by libavcodec.
|
|
133
|
+
* Direct mapping to AVFrame->pict_type.
|
|
179
134
|
*/
|
|
180
135
|
get pictType(): AVPictureType;
|
|
181
136
|
set pictType(value: AVPictureType);
|
|
182
137
|
/**
|
|
183
|
-
* Sample aspect ratio
|
|
138
|
+
* Sample aspect ratio.
|
|
184
139
|
*
|
|
185
|
-
*
|
|
140
|
+
* Pixel width/height ratio. 0/1 if unknown.
|
|
186
141
|
*
|
|
187
|
-
*
|
|
188
|
-
* This is the aspect ratio of a single pixel (width/height).
|
|
189
|
-
* For anamorphic video, this differs from the display aspect ratio.
|
|
142
|
+
* Direct mapping to AVFrame->sample_aspect_ratio.
|
|
190
143
|
*/
|
|
191
144
|
get sampleAspectRatio(): Rational;
|
|
192
145
|
set sampleAspectRatio(value: Rational);
|
|
193
146
|
/**
|
|
194
|
-
*
|
|
147
|
+
* Audio sample rate.
|
|
195
148
|
*
|
|
196
|
-
*
|
|
149
|
+
* Number of samples per second.
|
|
197
150
|
*
|
|
198
|
-
*
|
|
199
|
-
* - encoding: MUST be set by user.
|
|
200
|
-
* - decoding: MAY be set by libavcodec.
|
|
151
|
+
* Direct mapping to AVFrame->sample_rate.
|
|
201
152
|
*/
|
|
202
153
|
get sampleRate(): number;
|
|
203
154
|
set sampleRate(value: number);
|
|
204
155
|
/**
|
|
205
|
-
*
|
|
156
|
+
* Audio channel layout.
|
|
206
157
|
*
|
|
207
|
-
*
|
|
158
|
+
* Describes the channel configuration.
|
|
208
159
|
*
|
|
209
|
-
*
|
|
210
|
-
* Must be set before calling getBuffer() for audio frames.
|
|
160
|
+
* Direct mapping to AVFrame->ch_layout.
|
|
211
161
|
*/
|
|
212
162
|
get channelLayout(): ChannelLayout;
|
|
213
163
|
set channelLayout(value: ChannelLayout);
|
|
214
164
|
/**
|
|
215
165
|
* Number of audio channels.
|
|
216
166
|
*
|
|
217
|
-
* Direct mapping to AVFrame->channels
|
|
218
|
-
*
|
|
219
167
|
* Derived from channel layout.
|
|
220
|
-
* @readonly
|
|
221
168
|
*/
|
|
222
169
|
get channels(): number;
|
|
223
170
|
/**
|
|
224
|
-
* Line
|
|
225
|
-
*
|
|
226
|
-
* Direct mapping to AVFrame->linesize
|
|
227
|
-
*
|
|
228
|
-
* For video, the size in bytes of each picture line.
|
|
229
|
-
* For audio, the size in bytes of each plane.
|
|
171
|
+
* Line sizes for each plane.
|
|
230
172
|
*
|
|
231
|
-
*
|
|
232
|
-
* plane must be the same size.
|
|
173
|
+
* Number of bytes per line for each data plane.
|
|
233
174
|
*
|
|
234
|
-
*
|
|
235
|
-
* this is 16 or 32 for modern desktop CPUs.
|
|
236
|
-
* @readonly
|
|
175
|
+
* Direct mapping to AVFrame->linesize.
|
|
237
176
|
*/
|
|
238
177
|
get linesize(): number[];
|
|
239
178
|
/**
|
|
240
|
-
*
|
|
179
|
+
* Color range.
|
|
241
180
|
*
|
|
242
|
-
*
|
|
181
|
+
* MPEG (limited) or JPEG (full) range.
|
|
243
182
|
*
|
|
244
|
-
*
|
|
245
|
-
* - encoding: Set by user
|
|
246
|
-
* - decoding: Set by libavcodec
|
|
183
|
+
* Direct mapping to AVFrame->color_range.
|
|
247
184
|
*/
|
|
248
185
|
get colorRange(): AVColorRange;
|
|
249
186
|
set colorRange(value: AVColorRange);
|
|
250
187
|
/**
|
|
251
|
-
*
|
|
188
|
+
* Color primaries.
|
|
252
189
|
*
|
|
253
|
-
*
|
|
190
|
+
* Chromaticity coordinates of the source primaries.
|
|
254
191
|
*
|
|
255
|
-
*
|
|
256
|
-
* - encoding: Set by user
|
|
257
|
-
* - decoding: Set by libavcodec
|
|
192
|
+
* Direct mapping to AVFrame->color_primaries.
|
|
258
193
|
*/
|
|
259
194
|
get colorPrimaries(): AVColorPrimaries;
|
|
260
195
|
set colorPrimaries(value: AVColorPrimaries);
|
|
261
196
|
/**
|
|
262
|
-
* Color
|
|
197
|
+
* Color transfer characteristic.
|
|
263
198
|
*
|
|
264
|
-
*
|
|
199
|
+
* Transfer function (gamma).
|
|
265
200
|
*
|
|
266
|
-
*
|
|
267
|
-
* - encoding: Set by user
|
|
268
|
-
* - decoding: Set by libavcodec
|
|
201
|
+
* Direct mapping to AVFrame->color_trc.
|
|
269
202
|
*/
|
|
270
203
|
get colorTrc(): AVColorTransferCharacteristic;
|
|
271
204
|
set colorTrc(value: AVColorTransferCharacteristic);
|
|
272
205
|
/**
|
|
273
|
-
* YUV
|
|
206
|
+
* YUV color space.
|
|
274
207
|
*
|
|
275
|
-
*
|
|
208
|
+
* Color space type for YUV content.
|
|
276
209
|
*
|
|
277
|
-
*
|
|
278
|
-
* - encoding: Set by user
|
|
279
|
-
* - decoding: Set by libavcodec
|
|
210
|
+
* Direct mapping to AVFrame->colorspace.
|
|
280
211
|
*/
|
|
281
212
|
get colorSpace(): AVColorSpace;
|
|
282
213
|
set colorSpace(value: AVColorSpace);
|
|
283
214
|
/**
|
|
284
|
-
*
|
|
215
|
+
* Chroma sample location.
|
|
285
216
|
*
|
|
286
|
-
*
|
|
217
|
+
* Position of chroma samples.
|
|
287
218
|
*
|
|
288
|
-
*
|
|
289
|
-
* - encoding: Set by user
|
|
290
|
-
* - decoding: Set by libavcodec
|
|
219
|
+
* Direct mapping to AVFrame->chroma_location.
|
|
291
220
|
*/
|
|
292
221
|
get chromaLocation(): AVChromaLocation;
|
|
293
222
|
set chromaLocation(value: AVChromaLocation);
|
|
294
223
|
/**
|
|
295
|
-
*
|
|
224
|
+
* Raw frame data planes.
|
|
296
225
|
*
|
|
297
|
-
*
|
|
226
|
+
* Array of buffers containing the frame data.
|
|
227
|
+
* One buffer per plane (e.g., Y, U, V for YUV420P).
|
|
298
228
|
*
|
|
299
|
-
*
|
|
300
|
-
* For packed audio, this is a single pointer to all audio data.
|
|
301
|
-
* For planar audio, each channel has a separate data pointer.
|
|
302
|
-
*
|
|
303
|
-
* AVFrame.data pointers must point to the first element of an AVFrame.buf array.
|
|
304
|
-
* @readonly
|
|
229
|
+
* Direct mapping to AVFrame->data.
|
|
305
230
|
*/
|
|
306
231
|
get data(): Buffer[] | null;
|
|
307
232
|
/**
|
|
308
|
-
*
|
|
233
|
+
* Extended data planes.
|
|
309
234
|
*
|
|
310
|
-
*
|
|
235
|
+
* For audio with >8 channels or planar audio.
|
|
236
|
+
* Points to data planes beyond the first 8.
|
|
311
237
|
*
|
|
312
|
-
*
|
|
313
|
-
* to access channels beyond the first 8. Otherwise, data[] should be used.
|
|
314
|
-
* @readonly
|
|
238
|
+
* Direct mapping to AVFrame->extended_data.
|
|
315
239
|
*/
|
|
316
240
|
get extendedData(): Buffer[] | null;
|
|
317
241
|
/**
|
|
318
|
-
* Check if
|
|
319
|
-
*
|
|
320
|
-
* Direct mapping to av_frame_is_writable()
|
|
242
|
+
* Check if frame data is writable.
|
|
321
243
|
*
|
|
322
|
-
*
|
|
323
|
-
* only one reference to each buffer. Use makeWritable() to ensure writability.
|
|
324
|
-
* @readonly
|
|
244
|
+
* True if the frame data can be modified.
|
|
325
245
|
*/
|
|
326
246
|
get isWritable(): boolean;
|
|
327
247
|
/**
|
|
328
248
|
* Hardware frames context.
|
|
329
249
|
*
|
|
330
|
-
*
|
|
250
|
+
* Reference to hardware frames context for GPU frames.
|
|
251
|
+
* Null for software frames.
|
|
331
252
|
*
|
|
332
|
-
*
|
|
333
|
-
* AVHWFramesContext describing the frame.
|
|
253
|
+
* Direct mapping to AVFrame->hw_frames_ctx.
|
|
334
254
|
*/
|
|
335
255
|
get hwFramesCtx(): HardwareFramesContext | null;
|
|
336
256
|
set hwFramesCtx(value: HardwareFramesContext | null);
|
|
337
257
|
/**
|
|
338
|
-
* Allocate
|
|
258
|
+
* Allocate a new frame.
|
|
339
259
|
*
|
|
340
|
-
* Allocates the
|
|
341
|
-
*
|
|
260
|
+
* Allocates the frame structure. Must be called before using the frame
|
|
261
|
+
* unless it was created by another function (e.g., clone()).
|
|
342
262
|
*
|
|
343
|
-
* Direct mapping to av_frame_alloc()
|
|
263
|
+
* Direct mapping to av_frame_alloc().
|
|
344
264
|
*
|
|
345
|
-
* @throws {Error}
|
|
265
|
+
* @throws {Error} If allocation fails (ENOMEM)
|
|
346
266
|
*
|
|
347
267
|
* @example
|
|
348
268
|
* ```typescript
|
|
349
|
-
* import { Frame } from 'node-av';
|
|
350
|
-
*
|
|
351
269
|
* const frame = new Frame();
|
|
352
270
|
* frame.alloc();
|
|
353
|
-
* // Frame structure is now
|
|
354
|
-
* // Still need to allocate data buffers with getBuffer()
|
|
271
|
+
* // Frame structure is now ready
|
|
355
272
|
* ```
|
|
356
273
|
*
|
|
357
|
-
* @see {@link
|
|
358
|
-
* @see {@link free} To
|
|
274
|
+
* @see {@link allocBuffer} To allocate data buffers
|
|
275
|
+
* @see {@link free} To deallocate the frame
|
|
359
276
|
*/
|
|
360
277
|
alloc(): void;
|
|
361
278
|
/**
|
|
362
|
-
* Free the frame
|
|
363
|
-
*
|
|
364
|
-
* Frees the frame structure and all associated data buffers.
|
|
365
|
-
* If the frame is reference counted, it will be unreferenced first.
|
|
279
|
+
* Free the frame.
|
|
366
280
|
*
|
|
367
|
-
*
|
|
281
|
+
* Deallocates the frame and its data. The frame becomes invalid after this.
|
|
368
282
|
*
|
|
369
|
-
*
|
|
370
|
-
* Calling this multiple times is safe, because we check the freed state
|
|
283
|
+
* Direct mapping to av_frame_free().
|
|
371
284
|
*
|
|
372
285
|
* @example
|
|
373
286
|
* ```typescript
|
|
374
|
-
* import { Frame } from 'node-av';
|
|
375
|
-
*
|
|
376
287
|
* frame.free();
|
|
377
|
-
* //
|
|
288
|
+
* // Frame is now invalid
|
|
378
289
|
* ```
|
|
379
290
|
*
|
|
380
|
-
* @see {@link unref} To
|
|
291
|
+
* @see {@link unref} To only free data, keeping structure
|
|
381
292
|
*/
|
|
382
293
|
free(): void;
|
|
383
294
|
/**
|
|
384
|
-
*
|
|
295
|
+
* Create a reference to another frame.
|
|
385
296
|
*
|
|
386
|
-
*
|
|
387
|
-
* Both frames will share the same data
|
|
388
|
-
* This function does not copy side data.
|
|
297
|
+
* Sets up this frame as a reference to the source frame's data.
|
|
298
|
+
* Both frames will share the same data buffers.
|
|
389
299
|
*
|
|
390
|
-
* Direct mapping to av_frame_ref()
|
|
300
|
+
* Direct mapping to av_frame_ref().
|
|
391
301
|
*
|
|
392
302
|
* @param src - Source frame to reference
|
|
393
|
-
*
|
|
394
303
|
* @returns 0 on success, negative AVERROR on error:
|
|
395
|
-
* -
|
|
396
|
-
* -
|
|
397
|
-
* - AVERROR(EINVAL): Invalid parameters (null frame)
|
|
398
|
-
* - <0: Other errors
|
|
304
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
305
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
399
306
|
*
|
|
400
307
|
* @example
|
|
401
308
|
* ```typescript
|
|
402
|
-
* import {
|
|
309
|
+
* import { FFmpegError } from 'node-av';
|
|
403
310
|
*
|
|
404
|
-
* const
|
|
405
|
-
*
|
|
406
|
-
*
|
|
311
|
+
* const frame2 = new Frame();
|
|
312
|
+
* frame2.alloc();
|
|
313
|
+
* const ret = frame2.ref(frame1);
|
|
314
|
+
* FFmpegError.throwIfError(ret, 'ref');
|
|
315
|
+
* // frame2 now references frame1's data
|
|
407
316
|
* ```
|
|
408
317
|
*
|
|
409
|
-
* @see {@link unref} To remove
|
|
410
|
-
* @see {@link clone} To create
|
|
318
|
+
* @see {@link unref} To remove reference
|
|
319
|
+
* @see {@link clone} To create independent copy
|
|
411
320
|
*/
|
|
412
321
|
ref(src: Frame): number;
|
|
413
322
|
/**
|
|
414
|
-
* Unreference
|
|
323
|
+
* Unreference the frame.
|
|
415
324
|
*
|
|
416
|
-
*
|
|
417
|
-
* The frame
|
|
325
|
+
* Frees the frame data if this was the last reference.
|
|
326
|
+
* The frame structure remains allocated and can be reused.
|
|
418
327
|
*
|
|
419
|
-
* Direct mapping to av_frame_unref()
|
|
328
|
+
* Direct mapping to av_frame_unref().
|
|
420
329
|
*
|
|
421
330
|
* @example
|
|
422
331
|
* ```typescript
|
|
423
|
-
* import { Frame } from 'node-av';
|
|
424
|
-
*
|
|
425
332
|
* frame.unref();
|
|
426
|
-
* // Frame is
|
|
427
|
-
* // Can be reused for next decode/encode
|
|
333
|
+
* // Frame data is freed, structure can be reused
|
|
428
334
|
* ```
|
|
429
335
|
*
|
|
430
|
-
* @see {@link
|
|
336
|
+
* @see {@link ref} To create reference
|
|
337
|
+
* @see {@link free} To free everything
|
|
431
338
|
*/
|
|
432
339
|
unref(): void;
|
|
433
340
|
/**
|
|
434
|
-
*
|
|
341
|
+
* Clone the frame.
|
|
435
342
|
*
|
|
436
|
-
* Creates
|
|
437
|
-
*
|
|
343
|
+
* Creates an independent copy of the frame with its own data buffers.
|
|
344
|
+
* The new frame has the same content but can be modified independently.
|
|
438
345
|
*
|
|
439
|
-
* Direct mapping to av_frame_clone()
|
|
346
|
+
* Direct mapping to av_frame_clone().
|
|
440
347
|
*
|
|
441
|
-
* @returns New frame
|
|
442
|
-
* - Frame object: Success (new frame references this frame's data)
|
|
443
|
-
* - null: Memory allocation failure (ENOMEM)
|
|
348
|
+
* @returns New frame instance, or null on allocation failure
|
|
444
349
|
*
|
|
445
350
|
* @example
|
|
446
351
|
* ```typescript
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
* throw new Error('Failed to clone frame: Out of memory');
|
|
352
|
+
* const copy = frame.clone();
|
|
353
|
+
* if (copy) {
|
|
354
|
+
* // Modify copy without affecting original
|
|
355
|
+
* copy.pts = frame.pts + 1000n;
|
|
452
356
|
* }
|
|
453
|
-
* // clonedFrame references the same data as frame
|
|
454
|
-
* // Both frames must be freed independently
|
|
455
357
|
* ```
|
|
456
358
|
*
|
|
457
|
-
* @see {@link ref} To reference
|
|
359
|
+
* @see {@link ref} To create reference instead of copy
|
|
360
|
+
* @see {@link copy} To copy into existing frame
|
|
458
361
|
*/
|
|
459
362
|
clone(): Frame | null;
|
|
460
363
|
/**
|
|
461
|
-
*
|
|
364
|
+
* Get required buffer size for the frame.
|
|
462
365
|
*
|
|
463
|
-
*
|
|
464
|
-
*
|
|
366
|
+
* Calculates the required buffer size based on frame parameters.
|
|
367
|
+
* Must set format, width/height (video) or format, nb_samples, channel_layout (audio) first.
|
|
465
368
|
*
|
|
466
|
-
* Direct mapping to av_frame_get_buffer()
|
|
369
|
+
* Direct mapping to av_frame_get_buffer().
|
|
467
370
|
*
|
|
468
|
-
* @param align -
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
* - 0: Success (buffers allocated)
|
|
472
|
-
* - AVERROR(EINVAL): Invalid frame parameters (format/size not set)
|
|
473
|
-
* - AVERROR(ENOMEM): Memory allocation failure
|
|
474
|
-
* - <0: Other errors
|
|
371
|
+
* @param align - Buffer size alignment (0 for default)
|
|
372
|
+
* @returns Required buffer size in bytes, or negative AVERROR:
|
|
373
|
+
* - AVERROR_EINVAL: Invalid frame parameters
|
|
475
374
|
*
|
|
476
375
|
* @example
|
|
477
376
|
* ```typescript
|
|
478
|
-
* import {
|
|
377
|
+
* import { FFmpegError } from 'node-av';
|
|
479
378
|
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
* frame.height = 1080;
|
|
484
|
-
* const ret = frame.getBuffer(0);
|
|
485
|
-
* FFmpegError.throwIfError(ret, 'getBuffer');
|
|
486
|
-
* // Frame data buffers are now allocated
|
|
379
|
+
* const size = frame.getBuffer();
|
|
380
|
+
* FFmpegError.throwIfError(size, 'getBuffer');
|
|
381
|
+
* console.log(`Buffer size: ${size} bytes`);
|
|
487
382
|
* ```
|
|
488
383
|
*
|
|
489
|
-
* @see {@link allocBuffer}
|
|
490
|
-
* @see {@link makeWritable} Ensure buffer is writable
|
|
491
|
-
*
|
|
492
|
-
* Required fields before calling:
|
|
493
|
-
* - format (pixel format for video, sample format for audio)
|
|
494
|
-
* - width and height for video
|
|
495
|
-
* - nb_samples and channel_layout for audio
|
|
384
|
+
* @see {@link allocBuffer} To allocate the buffer
|
|
496
385
|
*/
|
|
497
386
|
getBuffer(align?: number): number;
|
|
498
387
|
/**
|
|
499
|
-
* Allocate
|
|
388
|
+
* Allocate data buffers for the frame.
|
|
500
389
|
*
|
|
501
|
-
*
|
|
390
|
+
* Allocates buffers based on frame format and dimensions.
|
|
502
391
|
* Frame parameters must be set before calling.
|
|
503
392
|
*
|
|
504
|
-
* Direct mapping to av_frame_get_buffer()
|
|
393
|
+
* Direct mapping to av_frame_get_buffer().
|
|
505
394
|
*
|
|
506
395
|
* @returns 0 on success, negative AVERROR on error:
|
|
507
|
-
* -
|
|
508
|
-
* -
|
|
509
|
-
* - AVERROR(ENOMEM): Memory allocation failure
|
|
510
|
-
* - <0: Other errors
|
|
396
|
+
* - AVERROR_EINVAL: Invalid frame parameters
|
|
397
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
511
398
|
*
|
|
512
399
|
* @example
|
|
513
400
|
* ```typescript
|
|
514
|
-
* import {
|
|
401
|
+
* import { FFmpegError } from 'node-av';
|
|
402
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
515
403
|
*
|
|
404
|
+
* frame.format = AV_PIX_FMT_YUV420P;
|
|
405
|
+
* frame.width = 1920;
|
|
406
|
+
* frame.height = 1080;
|
|
516
407
|
* const ret = frame.allocBuffer();
|
|
517
408
|
* FFmpegError.throwIfError(ret, 'allocBuffer');
|
|
518
|
-
* // Frame data buffers are now allocated
|
|
519
409
|
* ```
|
|
520
410
|
*
|
|
521
|
-
* @see {@link getBuffer}
|
|
411
|
+
* @see {@link getBuffer} To get required size
|
|
522
412
|
*/
|
|
523
413
|
allocBuffer(): number;
|
|
524
414
|
/**
|
|
525
|
-
* Ensure
|
|
415
|
+
* Ensure frame data is writable.
|
|
526
416
|
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
417
|
+
* Creates a private copy of the data if it's shared with other frames.
|
|
418
|
+
* Call before modifying frame data to avoid affecting other references.
|
|
529
419
|
*
|
|
530
|
-
* Direct mapping to av_frame_make_writable()
|
|
420
|
+
* Direct mapping to av_frame_make_writable().
|
|
531
421
|
*
|
|
532
422
|
* @returns 0 on success, negative AVERROR on error:
|
|
533
|
-
* -
|
|
534
|
-
* -
|
|
535
|
-
* - AVERROR(EINVAL): Invalid parameters
|
|
536
|
-
* - <0: Other errors
|
|
423
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
424
|
+
* - AVERROR_EINVAL: Invalid frame
|
|
537
425
|
*
|
|
538
426
|
* @example
|
|
539
427
|
* ```typescript
|
|
540
|
-
* import {
|
|
428
|
+
* import { FFmpegError } from 'node-av';
|
|
541
429
|
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
* // Frame data can now be modified safely
|
|
430
|
+
* // Ensure we can safely modify data
|
|
431
|
+
* const ret = frame.makeWritable();
|
|
432
|
+
* FFmpegError.throwIfError(ret, 'makeWritable');
|
|
433
|
+
* // Now safe to modify frame.data
|
|
547
434
|
* ```
|
|
548
|
-
*
|
|
549
|
-
* @see {@link isWritable} Check if writable
|
|
550
435
|
*/
|
|
551
436
|
makeWritable(): number;
|
|
552
437
|
/**
|
|
553
|
-
* Copy
|
|
438
|
+
* Copy frame properties without copying data.
|
|
554
439
|
*
|
|
555
|
-
* Copies
|
|
556
|
-
*
|
|
440
|
+
* Copies metadata, timestamps, format info, etc. but not the actual data.
|
|
441
|
+
* Useful for preparing output frames with same properties.
|
|
557
442
|
*
|
|
558
|
-
* Direct mapping to av_frame_copy_props()
|
|
443
|
+
* Direct mapping to av_frame_copy_props().
|
|
559
444
|
*
|
|
560
445
|
* @param src - Source frame to copy properties from
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
* - >=0: Success (properties copied)
|
|
564
|
-
* - AVERROR(ENOMEM): Memory allocation failure
|
|
565
|
-
* - <0: Other errors
|
|
446
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
447
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
566
448
|
*
|
|
567
449
|
* @example
|
|
568
450
|
* ```typescript
|
|
569
|
-
* import {
|
|
451
|
+
* import { FFmpegError } from 'node-av';
|
|
570
452
|
*
|
|
571
453
|
* const ret = dstFrame.copyProps(srcFrame);
|
|
572
454
|
* FFmpegError.throwIfError(ret, 'copyProps');
|
|
573
|
-
* // dstFrame now has same properties as srcFrame
|
|
455
|
+
* // dstFrame now has same properties as srcFrame
|
|
574
456
|
* ```
|
|
575
457
|
*
|
|
576
|
-
* @see {@link copy} To copy
|
|
458
|
+
* @see {@link copy} To copy both properties and data
|
|
577
459
|
*/
|
|
578
460
|
copyProps(src: Frame): number;
|
|
579
461
|
/**
|
|
580
|
-
* Copy
|
|
581
|
-
*
|
|
582
|
-
* Copies the actual data buffers from source to destination.
|
|
583
|
-
* Destination must be pre-allocated with same parameters.
|
|
462
|
+
* Copy frame data and properties.
|
|
584
463
|
*
|
|
585
|
-
*
|
|
464
|
+
* Copies both data and metadata from source frame.
|
|
465
|
+
* Destination must have allocated buffers of correct size.
|
|
586
466
|
*
|
|
587
|
-
*
|
|
467
|
+
* Direct mapping to av_frame_copy().
|
|
588
468
|
*
|
|
589
|
-
* @
|
|
590
|
-
*
|
|
591
|
-
* -
|
|
592
|
-
* - <0: Other errors
|
|
469
|
+
* @param src - Source frame to copy from
|
|
470
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
471
|
+
* - AVERROR_EINVAL: Incompatible frames
|
|
593
472
|
*
|
|
594
473
|
* @example
|
|
595
474
|
* ```typescript
|
|
596
|
-
* import {
|
|
475
|
+
* import { FFmpegError } from 'node-av';
|
|
597
476
|
*
|
|
598
|
-
* //
|
|
477
|
+
* // Allocate destination with same format
|
|
599
478
|
* dstFrame.format = srcFrame.format;
|
|
600
479
|
* dstFrame.width = srcFrame.width;
|
|
601
480
|
* dstFrame.height = srcFrame.height;
|
|
602
|
-
*
|
|
603
|
-
* FFmpegError.throwIfError(allocRet, 'allocBuffer');
|
|
481
|
+
* dstFrame.allocBuffer();
|
|
604
482
|
*
|
|
605
483
|
* const ret = dstFrame.copy(srcFrame);
|
|
606
484
|
* FFmpegError.throwIfError(ret, 'copy');
|
|
607
|
-
* // Data has been copied to dstFrame
|
|
608
485
|
* ```
|
|
609
486
|
*
|
|
610
|
-
* @see {@link copyProps} To copy
|
|
487
|
+
* @see {@link copyProps} To copy only properties
|
|
488
|
+
* @see {@link clone} To create new frame with copy
|
|
611
489
|
*/
|
|
612
490
|
copy(src: Frame): number;
|
|
613
491
|
/**
|
|
614
|
-
* Fill frame data from
|
|
615
|
-
*
|
|
616
|
-
* Copies raw frame data from a Buffer into this frame's data planes.
|
|
617
|
-
* The frame must be allocated with the correct format, width/height (for video),
|
|
618
|
-
* or nb_samples (for audio) before calling this method.
|
|
492
|
+
* Fill frame data from buffer.
|
|
619
493
|
*
|
|
620
|
-
*
|
|
621
|
-
*
|
|
494
|
+
* Copies data from buffer into frame data planes.
|
|
495
|
+
* Frame must have allocated buffers.
|
|
622
496
|
*
|
|
623
|
-
* @param buffer -
|
|
624
|
-
* @returns 0 on success, negative AVERROR on
|
|
497
|
+
* @param buffer - Source buffer with frame data
|
|
498
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
499
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
625
500
|
*
|
|
626
501
|
* @example
|
|
627
502
|
* ```typescript
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
* frame.height = 1080;
|
|
634
|
-
* frame.allocBuffer();
|
|
635
|
-
* frame.fromBuffer(rawYuvBuffer);
|
|
636
|
-
*
|
|
637
|
-
* // Audio frame from raw PCM data
|
|
638
|
-
* const audioFrame = new Frame();
|
|
639
|
-
* audioFrame.alloc();
|
|
640
|
-
* audioFrame.format = AV_SAMPLE_FMT_FLTP;
|
|
641
|
-
* audioFrame.nbSamples = 1024;
|
|
642
|
-
* audioFrame.channelLayout = { order: 0, nb_channels: 2, u: { mask: 3n } };
|
|
643
|
-
* audioFrame.allocBuffer();
|
|
644
|
-
* audioFrame.fromBuffer(rawPcmBuffer);
|
|
503
|
+
* import { FFmpegError } from 'node-av';
|
|
504
|
+
*
|
|
505
|
+
* const buffer = Buffer.from(rawVideoData);
|
|
506
|
+
* const ret = frame.fromBuffer(buffer);
|
|
507
|
+
* FFmpegError.throwIfError(ret, 'fromBuffer');
|
|
645
508
|
* ```
|
|
646
509
|
*/
|
|
647
510
|
fromBuffer(buffer: Buffer): number;
|
|
648
511
|
/**
|
|
649
|
-
* Transfer data
|
|
512
|
+
* Transfer data between hardware and software frames.
|
|
650
513
|
*
|
|
651
|
-
*
|
|
652
|
-
*
|
|
514
|
+
* Copies frame data between GPU and system memory.
|
|
515
|
+
* Direction depends on source and destination frame types.
|
|
653
516
|
*
|
|
654
|
-
* Direct mapping to av_hwframe_transfer_data()
|
|
517
|
+
* Direct mapping to av_hwframe_transfer_data().
|
|
655
518
|
*
|
|
656
|
-
* @param dst - Destination frame
|
|
657
|
-
* @param flags - Transfer flags (
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
* -
|
|
661
|
-
* - AVERROR(ENOSYS): Operation not supported
|
|
662
|
-
* - AVERROR(EINVAL): Invalid parameters
|
|
663
|
-
* - AVERROR(ENOMEM): Memory allocation failure
|
|
664
|
-
* - <0: Other hardware-specific errors
|
|
519
|
+
* @param dst - Destination frame (software or hardware)
|
|
520
|
+
* @param flags - Transfer flags (0 for default)
|
|
521
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
522
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
523
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
665
524
|
*
|
|
666
525
|
* @example
|
|
667
526
|
* ```typescript
|
|
668
|
-
* import {
|
|
527
|
+
* import { FFmpegError } from 'node-av';
|
|
669
528
|
*
|
|
670
|
-
* //
|
|
529
|
+
* // Download from GPU to CPU
|
|
671
530
|
* const swFrame = new Frame();
|
|
672
531
|
* swFrame.alloc();
|
|
673
|
-
* const ret = await hwFrame.hwframeTransferData(swFrame
|
|
532
|
+
* const ret = await hwFrame.hwframeTransferData(swFrame);
|
|
674
533
|
* FFmpegError.throwIfError(ret, 'hwframeTransferData');
|
|
675
|
-
* // Data is now in CPU memory
|
|
676
534
|
* ```
|
|
677
535
|
*
|
|
678
|
-
* @see {@link isHwFrame}
|
|
536
|
+
* @see {@link isHwFrame} To check if frame is hardware
|
|
537
|
+
* @see {@link isSwFrame} To check if frame is software
|
|
679
538
|
*/
|
|
680
539
|
hwframeTransferData(dst: Frame, flags?: number): Promise<number>;
|
|
681
540
|
/**
|
|
682
541
|
* Check if this is a hardware frame.
|
|
683
542
|
*
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
* Direct check of AVFrame->hw_frames_ctx
|
|
543
|
+
* Returns true if frame data is in GPU memory.
|
|
687
544
|
*
|
|
688
|
-
* @returns True if
|
|
545
|
+
* @returns True if hardware frame, false otherwise
|
|
689
546
|
*
|
|
690
547
|
* @example
|
|
691
548
|
* ```typescript
|
|
692
|
-
* import { Frame } from 'node-av';
|
|
693
|
-
*
|
|
694
549
|
* if (frame.isHwFrame()) {
|
|
695
550
|
* console.log('Frame is in GPU memory');
|
|
696
|
-
* } else {
|
|
697
|
-
* console.log('Frame is in CPU memory');
|
|
698
551
|
* }
|
|
699
552
|
* ```
|
|
700
553
|
*
|
|
701
|
-
* @see {@link
|
|
554
|
+
* @see {@link isSwFrame} To check for software frame
|
|
555
|
+
* @see {@link hwframeTransferData} To transfer between GPU/CPU
|
|
702
556
|
*/
|
|
703
557
|
isHwFrame(): boolean;
|
|
704
558
|
/**
|
|
705
559
|
* Check if this is a software frame.
|
|
706
560
|
*
|
|
707
|
-
*
|
|
708
|
-
* but has actual data pointers.
|
|
709
|
-
*
|
|
710
|
-
* Direct check of AVFrame->data[0] && !AVFrame->hw_frames_ctx
|
|
561
|
+
* Returns true if frame data is in system memory.
|
|
711
562
|
*
|
|
712
|
-
* @returns True if
|
|
563
|
+
* @returns True if software frame, false otherwise
|
|
713
564
|
*
|
|
714
565
|
* @example
|
|
715
566
|
* ```typescript
|
|
716
|
-
* import { Frame } from 'node-av';
|
|
717
|
-
*
|
|
718
567
|
* if (frame.isSwFrame()) {
|
|
719
|
-
* console.log('Frame is in
|
|
720
|
-
* // Safe to access frame.data
|
|
568
|
+
* console.log('Frame is in system memory');
|
|
721
569
|
* }
|
|
722
570
|
* ```
|
|
723
571
|
*
|
|
724
|
-
* @see {@link isHwFrame} To check for hardware
|
|
572
|
+
* @see {@link isHwFrame} To check for hardware frame
|
|
573
|
+
* @see {@link hwframeTransferData} To transfer between GPU/CPU
|
|
725
574
|
*/
|
|
726
575
|
isSwFrame(): boolean;
|
|
727
576
|
/**
|
|
728
|
-
* Get side data
|
|
577
|
+
* Get frame side data.
|
|
578
|
+
*
|
|
579
|
+
* Retrieves additional data associated with the frame
|
|
580
|
+
* (e.g., motion vectors, film grain, HDR metadata).
|
|
729
581
|
*
|
|
730
|
-
* Direct mapping to av_frame_get_side_data()
|
|
582
|
+
* Direct mapping to av_frame_get_side_data().
|
|
731
583
|
*
|
|
732
|
-
* @param type -
|
|
733
|
-
* @returns
|
|
584
|
+
* @param type - Type of side data to retrieve
|
|
585
|
+
* @returns Side data buffer, or null if not present
|
|
734
586
|
*
|
|
735
587
|
* @example
|
|
736
588
|
* ```typescript
|
|
737
|
-
* import {
|
|
738
|
-
* import { AV_FRAME_DATA_A53_CC } from 'node-av/constants';
|
|
589
|
+
* import { AV_FRAME_DATA_MOTION_VECTORS } from 'node-av/constants';
|
|
739
590
|
*
|
|
740
|
-
*
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
* console.log('Found closed caption data:', ccData.length, 'bytes');
|
|
591
|
+
* const motionVectors = frame.getSideData(AV_FRAME_DATA_MOTION_VECTORS);
|
|
592
|
+
* if (motionVectors) {
|
|
593
|
+
* console.log(`Motion data size: ${motionVectors.length} bytes`);
|
|
744
594
|
* }
|
|
745
595
|
* ```
|
|
596
|
+
*
|
|
597
|
+
* @see {@link newSideData} To add side data
|
|
598
|
+
* @see {@link removeSideData} To remove side data
|
|
746
599
|
*/
|
|
747
600
|
getSideData(type: AVFrameSideDataType): Buffer | null;
|
|
748
601
|
/**
|
|
749
|
-
* Allocate new side data
|
|
602
|
+
* Allocate new side data.
|
|
750
603
|
*
|
|
751
|
-
* Allocates
|
|
752
|
-
* Returns
|
|
753
|
-
*
|
|
604
|
+
* Allocates side data buffer attached to the frame.
|
|
605
|
+
* Returns buffer that can be written to directly.
|
|
606
|
+
*
|
|
607
|
+
* Direct mapping to av_frame_new_side_data().
|
|
608
|
+
*
|
|
609
|
+
* @param type - Type of side data
|
|
610
|
+
* @param size - Size in bytes to allocate
|
|
611
|
+
* @returns Allocated buffer for writing
|
|
754
612
|
*
|
|
755
|
-
* @param type - The type of side data to allocate
|
|
756
|
-
* @param size - Size of the side data buffer to allocate
|
|
757
|
-
* @returns Buffer referencing the allocated side data
|
|
758
613
|
* @throws {Error} If allocation fails
|
|
759
614
|
*
|
|
760
615
|
* @example
|
|
761
616
|
* ```typescript
|
|
762
|
-
* import { Frame } from 'node-av';
|
|
763
617
|
* import { AV_FRAME_DATA_MASTERING_DISPLAY_METADATA } from 'node-av/constants';
|
|
764
618
|
*
|
|
765
|
-
* // Allocate HDR metadata
|
|
766
|
-
* const
|
|
619
|
+
* // Allocate and write HDR metadata
|
|
620
|
+
* const hdrData = frame.newSideData(
|
|
767
621
|
* AV_FRAME_DATA_MASTERING_DISPLAY_METADATA,
|
|
768
|
-
*
|
|
622
|
+
* 40
|
|
769
623
|
* );
|
|
770
|
-
* // Write
|
|
624
|
+
* // Write metadata to buffer...
|
|
771
625
|
* ```
|
|
626
|
+
*
|
|
627
|
+
* @see {@link getSideData} To retrieve side data
|
|
628
|
+
* @see {@link removeSideData} To remove side data
|
|
772
629
|
*/
|
|
773
630
|
newSideData(type: AVFrameSideDataType, size: number): Buffer;
|
|
774
631
|
/**
|
|
775
|
-
* Remove side data from
|
|
632
|
+
* Remove side data from frame.
|
|
633
|
+
*
|
|
634
|
+
* Removes specific type of side data.
|
|
776
635
|
*
|
|
777
|
-
*
|
|
778
|
-
* Direct mapping to av_frame_remove_side_data()
|
|
636
|
+
* Direct mapping to av_frame_remove_side_data().
|
|
779
637
|
*
|
|
780
|
-
* @param type -
|
|
638
|
+
* @param type - Type of side data to remove
|
|
781
639
|
*
|
|
782
640
|
* @example
|
|
783
641
|
* ```typescript
|
|
784
|
-
* import { Frame } from 'node-av';
|
|
785
642
|
* import { AV_FRAME_DATA_MOTION_VECTORS } from 'node-av/constants';
|
|
786
643
|
*
|
|
787
|
-
* // Remove motion vectors data
|
|
788
644
|
* frame.removeSideData(AV_FRAME_DATA_MOTION_VECTORS);
|
|
645
|
+
* // Motion vectors removed
|
|
789
646
|
* ```
|
|
647
|
+
*
|
|
648
|
+
* @see {@link getSideData} To retrieve side data
|
|
649
|
+
* @see {@link newSideData} To add side data
|
|
790
650
|
*/
|
|
791
651
|
removeSideData(type: AVFrameSideDataType): void;
|
|
792
652
|
/**
|
|
793
|
-
* Get the native
|
|
653
|
+
* Get the underlying native Frame object.
|
|
654
|
+
*
|
|
655
|
+
* @returns The native Frame binding object
|
|
794
656
|
*
|
|
795
|
-
* @internal
|
|
796
|
-
* @returns The underlying native frame object
|
|
657
|
+
* @internal
|
|
797
658
|
*/
|
|
798
659
|
getNative(): NativeFrame;
|
|
799
660
|
/**
|
|
@@ -804,16 +665,12 @@ export declare class Frame implements Disposable, NativeWrapper<NativeFrame> {
|
|
|
804
665
|
*
|
|
805
666
|
* @example
|
|
806
667
|
* ```typescript
|
|
807
|
-
* import { Frame } from 'node-av';
|
|
808
|
-
*
|
|
809
668
|
* {
|
|
810
669
|
* using frame = new Frame();
|
|
811
670
|
* frame.alloc();
|
|
812
|
-
* //
|
|
671
|
+
* // Use frame...
|
|
813
672
|
* } // Automatically freed when leaving scope
|
|
814
673
|
* ```
|
|
815
|
-
*
|
|
816
|
-
* @see {@link free} For manual cleanup
|
|
817
674
|
*/
|
|
818
675
|
[Symbol.dispose](): void;
|
|
819
676
|
}
|