@revizly/node-av 5.2.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/BUILD_LINUX.md +61 -0
  2. package/LICENSE.md +22 -0
  3. package/README.md +662 -0
  4. package/build_mac_local.sh +69 -0
  5. package/dist/api/audio-frame-buffer.d.ts +205 -0
  6. package/dist/api/audio-frame-buffer.js +287 -0
  7. package/dist/api/audio-frame-buffer.js.map +1 -0
  8. package/dist/api/bitstream-filter.d.ts +820 -0
  9. package/dist/api/bitstream-filter.js +1242 -0
  10. package/dist/api/bitstream-filter.js.map +1 -0
  11. package/dist/api/constants.d.ts +44 -0
  12. package/dist/api/constants.js +45 -0
  13. package/dist/api/constants.js.map +1 -0
  14. package/dist/api/data/test_av1.ivf +0 -0
  15. package/dist/api/data/test_h264.h264 +0 -0
  16. package/dist/api/data/test_hevc.h265 +0 -0
  17. package/dist/api/data/test_mjpeg.mjpeg +0 -0
  18. package/dist/api/data/test_vp8.ivf +0 -0
  19. package/dist/api/data/test_vp9.ivf +0 -0
  20. package/dist/api/decoder.d.ts +1088 -0
  21. package/dist/api/decoder.js +1775 -0
  22. package/dist/api/decoder.js.map +1 -0
  23. package/dist/api/demuxer.d.ts +1219 -0
  24. package/dist/api/demuxer.js +2081 -0
  25. package/dist/api/demuxer.js.map +1 -0
  26. package/dist/api/device.d.ts +586 -0
  27. package/dist/api/device.js +961 -0
  28. package/dist/api/device.js.map +1 -0
  29. package/dist/api/encoder.d.ts +1132 -0
  30. package/dist/api/encoder.js +1988 -0
  31. package/dist/api/encoder.js.map +1 -0
  32. package/dist/api/filter-complex.d.ts +821 -0
  33. package/dist/api/filter-complex.js +1604 -0
  34. package/dist/api/filter-complex.js.map +1 -0
  35. package/dist/api/filter-presets.d.ts +1286 -0
  36. package/dist/api/filter-presets.js +2152 -0
  37. package/dist/api/filter-presets.js.map +1 -0
  38. package/dist/api/filter.d.ts +1234 -0
  39. package/dist/api/filter.js +1976 -0
  40. package/dist/api/filter.js.map +1 -0
  41. package/dist/api/fmp4-stream.d.ts +426 -0
  42. package/dist/api/fmp4-stream.js +739 -0
  43. package/dist/api/fmp4-stream.js.map +1 -0
  44. package/dist/api/hardware.d.ts +651 -0
  45. package/dist/api/hardware.js +1260 -0
  46. package/dist/api/hardware.js.map +1 -0
  47. package/dist/api/index.d.ts +17 -0
  48. package/dist/api/index.js +32 -0
  49. package/dist/api/index.js.map +1 -0
  50. package/dist/api/io-stream.d.ts +307 -0
  51. package/dist/api/io-stream.js +282 -0
  52. package/dist/api/io-stream.js.map +1 -0
  53. package/dist/api/muxer.d.ts +957 -0
  54. package/dist/api/muxer.js +2002 -0
  55. package/dist/api/muxer.js.map +1 -0
  56. package/dist/api/pipeline.d.ts +607 -0
  57. package/dist/api/pipeline.js +1145 -0
  58. package/dist/api/pipeline.js.map +1 -0
  59. package/dist/api/utilities/async-queue.d.ts +120 -0
  60. package/dist/api/utilities/async-queue.js +211 -0
  61. package/dist/api/utilities/async-queue.js.map +1 -0
  62. package/dist/api/utilities/audio-sample.d.ts +117 -0
  63. package/dist/api/utilities/audio-sample.js +112 -0
  64. package/dist/api/utilities/audio-sample.js.map +1 -0
  65. package/dist/api/utilities/channel-layout.d.ts +76 -0
  66. package/dist/api/utilities/channel-layout.js +80 -0
  67. package/dist/api/utilities/channel-layout.js.map +1 -0
  68. package/dist/api/utilities/electron-shared-texture.d.ts +328 -0
  69. package/dist/api/utilities/electron-shared-texture.js +503 -0
  70. package/dist/api/utilities/electron-shared-texture.js.map +1 -0
  71. package/dist/api/utilities/image.d.ts +207 -0
  72. package/dist/api/utilities/image.js +213 -0
  73. package/dist/api/utilities/image.js.map +1 -0
  74. package/dist/api/utilities/index.d.ts +12 -0
  75. package/dist/api/utilities/index.js +25 -0
  76. package/dist/api/utilities/index.js.map +1 -0
  77. package/dist/api/utilities/media-type.d.ts +49 -0
  78. package/dist/api/utilities/media-type.js +53 -0
  79. package/dist/api/utilities/media-type.js.map +1 -0
  80. package/dist/api/utilities/pixel-format.d.ts +89 -0
  81. package/dist/api/utilities/pixel-format.js +97 -0
  82. package/dist/api/utilities/pixel-format.js.map +1 -0
  83. package/dist/api/utilities/sample-format.d.ts +129 -0
  84. package/dist/api/utilities/sample-format.js +141 -0
  85. package/dist/api/utilities/sample-format.js.map +1 -0
  86. package/dist/api/utilities/scheduler.d.ts +138 -0
  87. package/dist/api/utilities/scheduler.js +98 -0
  88. package/dist/api/utilities/scheduler.js.map +1 -0
  89. package/dist/api/utilities/streaming.d.ts +186 -0
  90. package/dist/api/utilities/streaming.js +309 -0
  91. package/dist/api/utilities/streaming.js.map +1 -0
  92. package/dist/api/utilities/timestamp.d.ts +193 -0
  93. package/dist/api/utilities/timestamp.js +206 -0
  94. package/dist/api/utilities/timestamp.js.map +1 -0
  95. package/dist/api/utilities/whisper-model.d.ts +310 -0
  96. package/dist/api/utilities/whisper-model.js +528 -0
  97. package/dist/api/utilities/whisper-model.js.map +1 -0
  98. package/dist/api/utils.d.ts +19 -0
  99. package/dist/api/utils.js +39 -0
  100. package/dist/api/utils.js.map +1 -0
  101. package/dist/api/whisper.d.ts +324 -0
  102. package/dist/api/whisper.js +362 -0
  103. package/dist/api/whisper.js.map +1 -0
  104. package/dist/constants/channel-layouts.d.ts +53 -0
  105. package/dist/constants/channel-layouts.js +57 -0
  106. package/dist/constants/channel-layouts.js.map +1 -0
  107. package/dist/constants/constants.d.ts +2325 -0
  108. package/dist/constants/constants.js +1887 -0
  109. package/dist/constants/constants.js.map +1 -0
  110. package/dist/constants/decoders.d.ts +633 -0
  111. package/dist/constants/decoders.js +641 -0
  112. package/dist/constants/decoders.js.map +1 -0
  113. package/dist/constants/encoders.d.ts +295 -0
  114. package/dist/constants/encoders.js +308 -0
  115. package/dist/constants/encoders.js.map +1 -0
  116. package/dist/constants/hardware.d.ts +26 -0
  117. package/dist/constants/hardware.js +27 -0
  118. package/dist/constants/hardware.js.map +1 -0
  119. package/dist/constants/index.d.ts +5 -0
  120. package/dist/constants/index.js +6 -0
  121. package/dist/constants/index.js.map +1 -0
  122. package/dist/ffmpeg/index.d.ts +99 -0
  123. package/dist/ffmpeg/index.js +115 -0
  124. package/dist/ffmpeg/index.js.map +1 -0
  125. package/dist/ffmpeg/utils.d.ts +31 -0
  126. package/dist/ffmpeg/utils.js +68 -0
  127. package/dist/ffmpeg/utils.js.map +1 -0
  128. package/dist/ffmpeg/version.d.ts +6 -0
  129. package/dist/ffmpeg/version.js +7 -0
  130. package/dist/ffmpeg/version.js.map +1 -0
  131. package/dist/index.d.ts +4 -0
  132. package/dist/index.js +9 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/lib/audio-fifo.d.ts +399 -0
  135. package/dist/lib/audio-fifo.js +431 -0
  136. package/dist/lib/audio-fifo.js.map +1 -0
  137. package/dist/lib/binding.d.ts +228 -0
  138. package/dist/lib/binding.js +60 -0
  139. package/dist/lib/binding.js.map +1 -0
  140. package/dist/lib/bitstream-filter-context.d.ts +379 -0
  141. package/dist/lib/bitstream-filter-context.js +441 -0
  142. package/dist/lib/bitstream-filter-context.js.map +1 -0
  143. package/dist/lib/bitstream-filter.d.ts +140 -0
  144. package/dist/lib/bitstream-filter.js +154 -0
  145. package/dist/lib/bitstream-filter.js.map +1 -0
  146. package/dist/lib/codec-context.d.ts +1071 -0
  147. package/dist/lib/codec-context.js +1354 -0
  148. package/dist/lib/codec-context.js.map +1 -0
  149. package/dist/lib/codec-parameters.d.ts +616 -0
  150. package/dist/lib/codec-parameters.js +761 -0
  151. package/dist/lib/codec-parameters.js.map +1 -0
  152. package/dist/lib/codec-parser.d.ts +201 -0
  153. package/dist/lib/codec-parser.js +213 -0
  154. package/dist/lib/codec-parser.js.map +1 -0
  155. package/dist/lib/codec.d.ts +586 -0
  156. package/dist/lib/codec.js +713 -0
  157. package/dist/lib/codec.js.map +1 -0
  158. package/dist/lib/device.d.ts +291 -0
  159. package/dist/lib/device.js +324 -0
  160. package/dist/lib/device.js.map +1 -0
  161. package/dist/lib/dictionary.d.ts +333 -0
  162. package/dist/lib/dictionary.js +372 -0
  163. package/dist/lib/dictionary.js.map +1 -0
  164. package/dist/lib/error.d.ts +242 -0
  165. package/dist/lib/error.js +303 -0
  166. package/dist/lib/error.js.map +1 -0
  167. package/dist/lib/fifo.d.ts +416 -0
  168. package/dist/lib/fifo.js +453 -0
  169. package/dist/lib/fifo.js.map +1 -0
  170. package/dist/lib/filter-context.d.ts +712 -0
  171. package/dist/lib/filter-context.js +789 -0
  172. package/dist/lib/filter-context.js.map +1 -0
  173. package/dist/lib/filter-graph-segment.d.ts +160 -0
  174. package/dist/lib/filter-graph-segment.js +171 -0
  175. package/dist/lib/filter-graph-segment.js.map +1 -0
  176. package/dist/lib/filter-graph.d.ts +641 -0
  177. package/dist/lib/filter-graph.js +704 -0
  178. package/dist/lib/filter-graph.js.map +1 -0
  179. package/dist/lib/filter-inout.d.ts +198 -0
  180. package/dist/lib/filter-inout.js +257 -0
  181. package/dist/lib/filter-inout.js.map +1 -0
  182. package/dist/lib/filter.d.ts +243 -0
  183. package/dist/lib/filter.js +272 -0
  184. package/dist/lib/filter.js.map +1 -0
  185. package/dist/lib/format-context.d.ts +1254 -0
  186. package/dist/lib/format-context.js +1379 -0
  187. package/dist/lib/format-context.js.map +1 -0
  188. package/dist/lib/frame-utils.d.ts +116 -0
  189. package/dist/lib/frame-utils.js +98 -0
  190. package/dist/lib/frame-utils.js.map +1 -0
  191. package/dist/lib/frame.d.ts +1222 -0
  192. package/dist/lib/frame.js +1435 -0
  193. package/dist/lib/frame.js.map +1 -0
  194. package/dist/lib/hardware-device-context.d.ts +362 -0
  195. package/dist/lib/hardware-device-context.js +383 -0
  196. package/dist/lib/hardware-device-context.js.map +1 -0
  197. package/dist/lib/hardware-frames-context.d.ts +419 -0
  198. package/dist/lib/hardware-frames-context.js +477 -0
  199. package/dist/lib/hardware-frames-context.js.map +1 -0
  200. package/dist/lib/index.d.ts +35 -0
  201. package/dist/lib/index.js +60 -0
  202. package/dist/lib/index.js.map +1 -0
  203. package/dist/lib/input-format.d.ts +249 -0
  204. package/dist/lib/input-format.js +306 -0
  205. package/dist/lib/input-format.js.map +1 -0
  206. package/dist/lib/io-context.d.ts +696 -0
  207. package/dist/lib/io-context.js +769 -0
  208. package/dist/lib/io-context.js.map +1 -0
  209. package/dist/lib/log.d.ts +174 -0
  210. package/dist/lib/log.js +184 -0
  211. package/dist/lib/log.js.map +1 -0
  212. package/dist/lib/native-types.d.ts +946 -0
  213. package/dist/lib/native-types.js +2 -0
  214. package/dist/lib/native-types.js.map +1 -0
  215. package/dist/lib/option.d.ts +927 -0
  216. package/dist/lib/option.js +1583 -0
  217. package/dist/lib/option.js.map +1 -0
  218. package/dist/lib/output-format.d.ts +180 -0
  219. package/dist/lib/output-format.js +213 -0
  220. package/dist/lib/output-format.js.map +1 -0
  221. package/dist/lib/packet.d.ts +501 -0
  222. package/dist/lib/packet.js +590 -0
  223. package/dist/lib/packet.js.map +1 -0
  224. package/dist/lib/rational.d.ts +251 -0
  225. package/dist/lib/rational.js +278 -0
  226. package/dist/lib/rational.js.map +1 -0
  227. package/dist/lib/software-resample-context.d.ts +552 -0
  228. package/dist/lib/software-resample-context.js +592 -0
  229. package/dist/lib/software-resample-context.js.map +1 -0
  230. package/dist/lib/software-scale-context.d.ts +344 -0
  231. package/dist/lib/software-scale-context.js +366 -0
  232. package/dist/lib/software-scale-context.js.map +1 -0
  233. package/dist/lib/stream.d.ts +379 -0
  234. package/dist/lib/stream.js +526 -0
  235. package/dist/lib/stream.js.map +1 -0
  236. package/dist/lib/sync-queue.d.ts +179 -0
  237. package/dist/lib/sync-queue.js +197 -0
  238. package/dist/lib/sync-queue.js.map +1 -0
  239. package/dist/lib/types.d.ts +34 -0
  240. package/dist/lib/types.js +2 -0
  241. package/dist/lib/types.js.map +1 -0
  242. package/dist/lib/utilities.d.ts +1127 -0
  243. package/dist/lib/utilities.js +1225 -0
  244. package/dist/lib/utilities.js.map +1 -0
  245. package/dist/utils/electron.d.ts +49 -0
  246. package/dist/utils/electron.js +63 -0
  247. package/dist/utils/electron.js.map +1 -0
  248. package/dist/utils/index.d.ts +4 -0
  249. package/dist/utils/index.js +5 -0
  250. package/dist/utils/index.js.map +1 -0
  251. package/install/check.js +121 -0
  252. package/install/ffmpeg.js +66 -0
  253. package/jellyfin-ffmpeg.patch +181 -0
  254. package/package.json +129 -0
@@ -0,0 +1,1222 @@
1
+ import { HardwareFramesContext } from './hardware-frames-context.js';
2
+ import { Rational } from './rational.js';
3
+ import type { AVChromaLocation, AVColorPrimaries, AVColorRange, AVColorSpace, AVColorTransferCharacteristic, AVFrameSideDataType, AVMediaType, AVPictureType, AVPixelFormat, AVSampleFormat } from '../constants/constants.js';
4
+ import { Dictionary } from './dictionary.js';
5
+ import type { HardwareDeviceContext } from './hardware-device-context.js';
6
+ import type { NativeFrame, NativeWrapper } from './native-types.js';
7
+ import type { ChannelLayout, IRational } from './types.js';
8
+ /**
9
+ * Video Frame
10
+ */
11
+ export interface VideoFrame {
12
+ width: number;
13
+ height: number;
14
+ format: AVPixelFormat;
15
+ timeBase?: IRational;
16
+ sampleAspectRatio?: IRational;
17
+ pts?: bigint;
18
+ }
19
+ /**
20
+ * Audio Frame
21
+ */
22
+ export interface AudioFrame {
23
+ nbSamples: number;
24
+ format: AVSampleFormat;
25
+ sampleRate: number;
26
+ channelLayout: ChannelLayout;
27
+ timeBase?: IRational;
28
+ pts?: bigint;
29
+ }
30
+ /**
31
+ * Options for {@link Frame.fromIOSurface} (macOS only).
32
+ *
33
+ * Creates a zero-copy hardware frame from an IOSurface handle.
34
+ * Width and height are auto-detected from the IOSurface.
35
+ */
36
+ export interface IOSurfaceFrame {
37
+ hwFramesCtx: HardwareFramesContext;
38
+ timeBase?: IRational;
39
+ pts?: bigint;
40
+ }
41
+ /**
42
+ * Options for {@link Frame.fromD3D11Texture} (Windows only).
43
+ *
44
+ * Creates a zero-copy hardware frame from a D3D11 shared texture handle.
45
+ * Width and height are auto-detected from the texture descriptor.
46
+ */
47
+ export interface D3D11TextureFrame {
48
+ hwDeviceCtx: HardwareDeviceContext;
49
+ timeBase?: IRational;
50
+ pts?: bigint;
51
+ }
52
+ /**
53
+ * DMA-BUF plane descriptors for Linux GPU buffer sharing.
54
+ */
55
+ export interface DmaBufPlanes {
56
+ planes: {
57
+ fd: number;
58
+ stride: number;
59
+ offset: number;
60
+ size: number;
61
+ }[];
62
+ modifier: string;
63
+ }
64
+ /**
65
+ * Options for {@link Frame.fromDmaBuf} (Linux only).
66
+ *
67
+ * Creates a zero-copy DRM PRIME frame from DMA-BUF file descriptors.
68
+ */
69
+ export interface DmaBufFrame {
70
+ width: number;
71
+ height: number;
72
+ swFormat?: AVPixelFormat;
73
+ timeBase?: IRational;
74
+ pts?: bigint;
75
+ }
76
+ /**
77
+ * Container for uncompressed audio/video data.
78
+ *
79
+ * Stores decoded audio samples or video pixels. Each frame contains raw data
80
+ * for a single video frame or a set of audio samples. Includes format information,
81
+ * timing data, and metadata. Supports both software and hardware (GPU) frames.
82
+ * Essential for decoding, encoding, and filter operations.
83
+ *
84
+ * Direct mapping to FFmpeg's AVFrame.
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * import { Frame, FFmpegError } from 'node-av';
89
+ * import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
90
+ *
91
+ * // Create and allocate frame
92
+ * const frame = new Frame();
93
+ * frame.alloc();
94
+ *
95
+ * // Configure video frame
96
+ * frame.format = AV_PIX_FMT_YUV420P;
97
+ * frame.width = 1920;
98
+ * frame.height = 1080;
99
+ * const ret = frame.allocBuffer();
100
+ * FFmpegError.throwIfError(ret, 'allocBuffer');
101
+ *
102
+ * // Receive decoded frame
103
+ * const ret2 = await codecContext.receiveFrame(frame);
104
+ * if (ret2 >= 0) {
105
+ * console.log(`Frame PTS: ${frame.pts}`);
106
+ * console.log(`Frame type: ${frame.pictType}`);
107
+ * console.log(`Keyframe: ${frame.keyFrame}`);
108
+ * }
109
+ *
110
+ * // Cleanup
111
+ * frame.unref();
112
+ * ```
113
+ *
114
+ * @see [AVFrame](https://ffmpeg.org/doxygen/trunk/structAVFrame.html) - FFmpeg Doxygen
115
+ * @see {@link CodecContext} For encoding/decoding frames
116
+ * @see {@link FilterContext} For filtering frames
117
+ */
118
+ export declare class Frame implements Disposable, NativeWrapper<NativeFrame> {
119
+ private native;
120
+ private _hwFramesCtx?;
121
+ constructor();
122
+ /**
123
+ * Create a video frame from a buffer with pixel data.
124
+ *
125
+ * Allocates frame buffers, sets properties, and copies buffer data.
126
+ * Convenience factory method that combines frame allocation and data copy.
127
+ *
128
+ * @param buffer - Buffer containing raw pixel data
129
+ *
130
+ * @param props - Video Frame properties
131
+ *
132
+ * @returns Allocated frame with data from buffer
133
+ *
134
+ * @throws {FFmpegError} If allocation or buffer copy fails
135
+ *
136
+ * @example
137
+ * ```typescript
138
+ * import { Frame, AV_PIX_FMT_RGBA, FFmpegError } from 'node-av';
139
+ *
140
+ * const rawPixels = Buffer.alloc(1920 * 1080 * 4); // RGBA data
141
+ * using frame = Frame.fromVideoBuffer(rawPixels, {
142
+ * width: 1920,
143
+ * height: 1080,
144
+ * format: AV_PIX_FMT_RGBA,
145
+ * timeBase: { num: 1, den: 30 }
146
+ * });
147
+ * ```
148
+ */
149
+ static fromVideoBuffer(buffer: Buffer, props: VideoFrame): Frame;
150
+ /**
151
+ * Create an audio frame from a buffer with sample data.
152
+ *
153
+ * Allocates frame buffers, sets properties, and copies buffer data.
154
+ * Convenience factory method that combines frame allocation and data copy.
155
+ *
156
+ * @param buffer - Buffer containing raw audio samples
157
+ *
158
+ * @param props - Frame properties
159
+ *
160
+ * @returns Allocated frame with data from buffer
161
+ *
162
+ * @throws {FFmpegError} If allocation or buffer copy fails
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * import { Frame, AV_SAMPLE_FMT_FLT, AV_CH_LAYOUT_STEREO, FFmpegError } from 'node-av';
167
+ *
168
+ * const samples = Buffer.alloc(960 * 2 * 4); // 960 samples, stereo, float32
169
+ * using frame = Frame.fromAudioBuffer(samples, {
170
+ * nbSamples: 960,
171
+ * format: AV_SAMPLE_FMT_FLT,
172
+ * sampleRate: 48000,
173
+ * channelLayout: AV_CH_LAYOUT_STEREO,
174
+ * timeBase: { num: 1, den: 48000 }
175
+ * });
176
+ * ```
177
+ */
178
+ static fromAudioBuffer(buffer: Buffer, props: AudioFrame): Frame;
179
+ /**
180
+ * Create a hardware frame from an IOSurface handle (macOS only).
181
+ *
182
+ * Zero-copy: the frame references the same GPU memory as the IOSurface.
183
+ * Width and height are auto-detected from the IOSurface.
184
+ *
185
+ * @param ioSurface - IOSurfaceRef pointer as Buffer
186
+ *
187
+ * @param props - Hardware context and timing options
188
+ *
189
+ * @returns Hardware frame referencing the IOSurface GPU memory
190
+ *
191
+ * @throws {FFmpegError} If the import fails (e.g., invalid handle, wrong platform)
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * import { Frame, HardwareFramesContext } from 'node-av/lib';
196
+ *
197
+ * const frame = Frame.fromIOSurface(ioSurfaceBuffer, {
198
+ * hwFramesCtx,
199
+ * pts: 0n,
200
+ * timeBase: { num: 1, den: 90000 },
201
+ * });
202
+ * ```
203
+ */
204
+ static fromIOSurface(ioSurface: Buffer, props: IOSurfaceFrame): Frame;
205
+ /**
206
+ * Create a hardware frame from a D3D11 shared texture (Windows only).
207
+ *
208
+ * Zero-copy: the frame references the shared GPU texture.
209
+ * Width and height are auto-detected from the texture descriptor.
210
+ *
211
+ * @param handle - D3D11 shared texture handle as Buffer
212
+ *
213
+ * @param props - Hardware context and timing options
214
+ *
215
+ * @returns Hardware frame referencing the D3D11 texture
216
+ *
217
+ * @throws {FFmpegError} If the import fails (e.g., invalid handle, wrong platform)
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * import { Frame, HardwareDeviceContext } from 'node-av/lib';
222
+ *
223
+ * const frame = Frame.fromD3D11Texture(sharedTextureHandle, {
224
+ * hwDeviceCtx,
225
+ * pts: 0n,
226
+ * timeBase: { num: 1, den: 90000 },
227
+ * });
228
+ * ```
229
+ */
230
+ static fromD3D11Texture(handle: Buffer, props: D3D11TextureFrame): Frame;
231
+ /**
232
+ * Create a DRM PRIME frame from DMA-BUF file descriptors (Linux only).
233
+ *
234
+ * Zero-copy: the frame references the DMA-BUF GPU memory.
235
+ *
236
+ * @param dmaBuf - DMA-BUF plane descriptors
237
+ *
238
+ * @param props - Dimensions and timing options
239
+ *
240
+ * @returns Hardware frame referencing the DMA-BUF memory
241
+ *
242
+ * @throws {FFmpegError} If the import fails (e.g., invalid descriptors, wrong platform)
243
+ *
244
+ * @example
245
+ * ```typescript
246
+ * import { Frame } from 'node-av/lib';
247
+ *
248
+ * // Create DRM PRIME frame from DMA-BUF
249
+ * const drmFrame = Frame.fromDmaBuf(dmaBufPlanes, {
250
+ * width: 1920,
251
+ * height: 1080,
252
+ * pts: 0n,
253
+ * timeBase: { num: 1, den: 90000 },
254
+ * });
255
+ * ```
256
+ */
257
+ static fromDmaBuf(dmaBuf: DmaBufPlanes, props: DmaBufFrame): Frame;
258
+ /**
259
+ * Pixel format for video frames or sample format for audio.
260
+ *
261
+ * Direct mapping to AVFrame->format.
262
+ */
263
+ get format(): AVPixelFormat | AVSampleFormat;
264
+ set format(value: AVPixelFormat | AVSampleFormat);
265
+ /**
266
+ * Width of video frame in pixels.
267
+ *
268
+ * Direct mapping to AVFrame->width.
269
+ */
270
+ get width(): number;
271
+ set width(value: number);
272
+ /**
273
+ * Height of video frame in pixels.
274
+ *
275
+ * Direct mapping to AVFrame->height.
276
+ */
277
+ get height(): number;
278
+ set height(value: number);
279
+ /**
280
+ * Number of audio samples per channel.
281
+ *
282
+ * Direct mapping to AVFrame->nb_samples.
283
+ */
284
+ get nbSamples(): number;
285
+ set nbSamples(value: number);
286
+ /**
287
+ * Presentation timestamp.
288
+ *
289
+ * Time when the frame should be presented.
290
+ * In time base units. AV_NOPTS_VALUE if unknown.
291
+ *
292
+ * Direct mapping to AVFrame->pts.
293
+ */
294
+ get pts(): bigint;
295
+ set pts(value: bigint);
296
+ /**
297
+ * DTS from the packet that produced this frame.
298
+ *
299
+ * Copy of packet DTS for reference.
300
+ * In time base units. AV_NOPTS_VALUE if unknown.
301
+ *
302
+ * Direct mapping to AVFrame->pkt_dts.
303
+ */
304
+ get pktDts(): bigint;
305
+ set pktDts(value: bigint);
306
+ /**
307
+ * Best effort timestamp.
308
+ *
309
+ * Frame timestamp estimated using various heuristics.
310
+ * In time base units.
311
+ *
312
+ * Direct mapping to AVFrame->best_effort_timestamp.
313
+ */
314
+ get bestEffortTimestamp(): bigint;
315
+ set bestEffortTimestamp(value: bigint);
316
+ /**
317
+ * Time base for timestamps.
318
+ *
319
+ * Defines the unit of the timestamps (seconds per tick).
320
+ *
321
+ * Direct mapping to AVFrame->time_base.
322
+ */
323
+ get timeBase(): Rational;
324
+ set timeBase(value: Rational);
325
+ /**
326
+ * Whether this frame is a keyframe.
327
+ *
328
+ * 1 if keyframe, 0 otherwise.
329
+ *
330
+ * Direct mapping to AVFrame->key_frame.
331
+ */
332
+ get keyFrame(): number;
333
+ set keyFrame(value: number);
334
+ /**
335
+ * Picture type of the frame.
336
+ *
337
+ * Type of frame (I, P, B, etc.).
338
+ *
339
+ * Direct mapping to AVFrame->pict_type.
340
+ */
341
+ get pictType(): AVPictureType;
342
+ set pictType(value: AVPictureType);
343
+ /**
344
+ * Quality (between 1 (good) and FF_LAMBDA_MAX (bad)).
345
+ *
346
+ * Set by libavcodec for some coded frames.
347
+ * Can be set before encoding to specify desired quality for encoders that support it.
348
+ * Used by FFmpeg CLI's frame_encode() to propagate encoder's global_quality setting.
349
+ *
350
+ * Direct mapping to AVFrame->quality.
351
+ */
352
+ get quality(): number;
353
+ set quality(value: number);
354
+ /**
355
+ * Sample aspect ratio.
356
+ *
357
+ * Pixel width/height ratio. 0/1 if unknown.
358
+ *
359
+ * Direct mapping to AVFrame->sample_aspect_ratio.
360
+ */
361
+ get sampleAspectRatio(): Rational;
362
+ set sampleAspectRatio(value: Rational);
363
+ /**
364
+ * Audio sample rate.
365
+ *
366
+ * Number of samples per second.
367
+ *
368
+ * Direct mapping to AVFrame->sample_rate.
369
+ */
370
+ get sampleRate(): number;
371
+ set sampleRate(value: number);
372
+ /**
373
+ * Audio channel layout.
374
+ *
375
+ * Describes the channel configuration.
376
+ *
377
+ * Direct mapping to AVFrame->ch_layout.
378
+ */
379
+ get channelLayout(): ChannelLayout;
380
+ set channelLayout(value: ChannelLayout);
381
+ /**
382
+ * Number of audio channels.
383
+ *
384
+ * Derived from channel layout.
385
+ */
386
+ get channels(): number;
387
+ /**
388
+ * Line sizes for each plane.
389
+ *
390
+ * Number of bytes per line for each data plane.
391
+ *
392
+ * Direct mapping to AVFrame->linesize.
393
+ */
394
+ get linesize(): number[];
395
+ /**
396
+ * Color range.
397
+ *
398
+ * MPEG (limited) or JPEG (full) range.
399
+ *
400
+ * Direct mapping to AVFrame->color_range.
401
+ */
402
+ get colorRange(): AVColorRange;
403
+ set colorRange(value: AVColorRange);
404
+ /**
405
+ * Color primaries.
406
+ *
407
+ * Chromaticity coordinates of the source primaries.
408
+ *
409
+ * Direct mapping to AVFrame->color_primaries.
410
+ */
411
+ get colorPrimaries(): AVColorPrimaries;
412
+ set colorPrimaries(value: AVColorPrimaries);
413
+ /**
414
+ * Color transfer characteristic.
415
+ *
416
+ * Transfer function (gamma).
417
+ *
418
+ * Direct mapping to AVFrame->color_trc.
419
+ */
420
+ get colorTrc(): AVColorTransferCharacteristic;
421
+ set colorTrc(value: AVColorTransferCharacteristic);
422
+ /**
423
+ * YUV color space.
424
+ *
425
+ * Color space type for YUV content.
426
+ *
427
+ * Direct mapping to AVFrame->colorspace.
428
+ */
429
+ get colorSpace(): AVColorSpace;
430
+ set colorSpace(value: AVColorSpace);
431
+ /**
432
+ * Chroma sample location.
433
+ *
434
+ * Position of chroma samples.
435
+ *
436
+ * Direct mapping to AVFrame->chroma_location.
437
+ */
438
+ get chromaLocation(): AVChromaLocation;
439
+ set chromaLocation(value: AVChromaLocation);
440
+ /**
441
+ * Raw frame data planes.
442
+ *
443
+ * Array of buffers containing the frame data.
444
+ * One buffer per plane (e.g., Y, U, V for YUV420P).
445
+ *
446
+ * Direct mapping to AVFrame->data.
447
+ */
448
+ get data(): Buffer[] | null;
449
+ /**
450
+ * Extended data planes.
451
+ *
452
+ * For audio with >8 channels or planar audio.
453
+ * Points to data planes beyond the first 8.
454
+ *
455
+ * Direct mapping to AVFrame->extended_data.
456
+ */
457
+ get extendedData(): Buffer[] | null;
458
+ /**
459
+ * Check if frame data is writable.
460
+ *
461
+ * True if the frame data can be modified.
462
+ */
463
+ get isWritable(): boolean;
464
+ /**
465
+ * Hardware frames context.
466
+ *
467
+ * Reference to hardware frames context for GPU frames.
468
+ * Null for software frames.
469
+ *
470
+ * Direct mapping to AVFrame->hw_frames_ctx.
471
+ */
472
+ get hwFramesCtx(): HardwareFramesContext | null;
473
+ set hwFramesCtx(value: HardwareFramesContext | null);
474
+ /**
475
+ * Frame flags.
476
+ *
477
+ * Combination of AVFrameFlags (e.g., AV_FRAME_FLAG_CORRUPT, AV_FRAME_FLAG_KEY).
478
+ *
479
+ * Direct mapping to AVFrame->flags.
480
+ */
481
+ get flags(): number;
482
+ set flags(value: number);
483
+ /**
484
+ * Decode error flags.
485
+ *
486
+ * Indicates errors detected during decoding.
487
+ * Non-zero value means the frame may be corrupted.
488
+ *
489
+ * Direct mapping to AVFrame->decode_error_flags.
490
+ */
491
+ get decodeErrorFlags(): number;
492
+ set decodeErrorFlags(value: number);
493
+ /**
494
+ * Frame duration.
495
+ *
496
+ * Duration of this frame in units of time_base.
497
+ * This is FFmpeg's best guess for how long the frame should be displayed.
498
+ * May be 0 if unknown or unavailable.
499
+ *
500
+ * Direct mapping to AVFrame->duration.
501
+ */
502
+ get duration(): bigint;
503
+ set duration(value: bigint);
504
+ /**
505
+ * Number of fields in this frame that should be repeated.
506
+ *
507
+ * For interlaced video, indicates how many times the frame should be repeated
508
+ * when displayed. For progressive video, this is typically 0.
509
+ * Formula: display_time = (repeat_pict / (2*fps))
510
+ *
511
+ * Direct mapping to AVFrame->repeat_pict.
512
+ */
513
+ get repeatPict(): number;
514
+ set repeatPict(value: number);
515
+ /**
516
+ * Set frame flags.
517
+ *
518
+ * Sets one or more flags using bitwise OR. Allows setting multiple flags
519
+ * without manually performing bitwise operations.
520
+ *
521
+ * @param flags - One or more flag values to set
522
+ *
523
+ * @example
524
+ * ```typescript
525
+ * import { AV_FRAME_FLAG_KEY } from 'node-av/constants';
526
+ *
527
+ * // Mark frame as key frame
528
+ * frame.setFlags(AV_FRAME_FLAG_KEY);
529
+ * ```
530
+ *
531
+ * @see {@link clearFlags} To unset flags
532
+ * @see {@link hasFlags} To check flags
533
+ * @see {@link flags} For direct flag access
534
+ */
535
+ setFlags(...flags: number[]): void;
536
+ /**
537
+ * Clear frame flags.
538
+ *
539
+ * Clears one or more flags using bitwise AND NOT. Allows clearing multiple
540
+ * flags without manually performing bitwise operations.
541
+ *
542
+ * @param flags - One or more flag values to clear
543
+ *
544
+ * @example
545
+ * ```typescript
546
+ * import { AV_FRAME_FLAG_CORRUPT } from 'node-av/constants';
547
+ *
548
+ * // Clear corrupt flag
549
+ * frame.clearFlags(AV_FRAME_FLAG_CORRUPT);
550
+ * ```
551
+ *
552
+ * @see {@link setFlags} To set flags
553
+ * @see {@link hasFlags} To check flags
554
+ * @see {@link flags} For direct flag access
555
+ */
556
+ clearFlags(...flags: number[]): void;
557
+ /**
558
+ * Check if frame has specific flags.
559
+ *
560
+ * Tests whether all specified flags are set using bitwise AND.
561
+ *
562
+ * @param flags - One or more flag values to check
563
+ *
564
+ * @returns true if all specified flags are set, false otherwise
565
+ *
566
+ * @example
567
+ * ```typescript
568
+ * import { AV_FRAME_FLAG_CORRUPT } from 'node-av/constants';
569
+ *
570
+ * if (frame.hasFlags(AV_FRAME_FLAG_CORRUPT)) {
571
+ * console.log('Frame is corrupted');
572
+ * }
573
+ * ```
574
+ *
575
+ * @see {@link setFlags} To set flags
576
+ * @see {@link clearFlags} To unset flags
577
+ * @see {@link flags} For direct flag access
578
+ */
579
+ hasFlags(...flags: number[]): boolean;
580
+ /**
581
+ * Check if frame has decode errors.
582
+ *
583
+ * Tests whether all specified decode error flags are set using bitwise AND.
584
+ *
585
+ * @param flags - One or more decode error flag values to check
586
+ *
587
+ * @returns true if all specified error flags are set, false otherwise
588
+ *
589
+ * @example
590
+ * ```typescript
591
+ * import { FF_DECODE_ERROR_INVALID_BITSTREAM } from 'node-av/constants';
592
+ *
593
+ * if (frame.hasDecodeErrorFlags(FF_DECODE_ERROR_INVALID_BITSTREAM)) {
594
+ * console.log('Frame has invalid bitstream error');
595
+ * }
596
+ * ```
597
+ *
598
+ * @see {@link decodeErrorFlags} For direct error flag access
599
+ */
600
+ hasDecodeErrorFlags(...flags: number[]): boolean;
601
+ /**
602
+ * Check if this is a video frame.
603
+ *
604
+ * Video frames have width and height > 0.
605
+ *
606
+ * @returns true if this is a video frame
607
+ *
608
+ * @example
609
+ * ```typescript
610
+ * if (frame.isVideo()) {
611
+ * console.log(`Video frame: ${frame.width}x${frame.height}`);
612
+ * }
613
+ * ```
614
+ */
615
+ isVideo(): boolean;
616
+ /**
617
+ * Check if this is an audio frame.
618
+ *
619
+ * Audio frames have sampleRate > 0 and nbSamples > 0.
620
+ *
621
+ * @returns true if this is an audio frame
622
+ *
623
+ * @example
624
+ * ```typescript
625
+ * if (frame.isAudio()) {
626
+ * console.log(`Audio frame: ${frame.sampleRate}Hz, ${frame.nbSamples} samples`);
627
+ * }
628
+ * ```
629
+ */
630
+ isAudio(): boolean;
631
+ /**
632
+ * Get the media type of this frame.
633
+ *
634
+ * @returns AVMEDIA_TYPE_VIDEO for video frames, AVMEDIA_TYPE_AUDIO for audio frames, or AVMEDIA_TYPE_UNKNOWN
635
+ *
636
+ * @example
637
+ * ```typescript
638
+ * const type = frame.getMediaType();
639
+ * console.log(`Frame type: ${type}`);
640
+ * ```
641
+ */
642
+ getMediaType(): AVMediaType;
643
+ /**
644
+ * Allocate a new frame.
645
+ *
646
+ * Allocates the frame structure. Must be called before using the frame
647
+ * unless it was created by another function (e.g., clone()).
648
+ *
649
+ * Direct mapping to av_frame_alloc().
650
+ *
651
+ * @throws {Error} If allocation fails (ENOMEM)
652
+ *
653
+ * @example
654
+ * ```typescript
655
+ * const frame = new Frame();
656
+ * frame.alloc();
657
+ * // Frame structure is now ready
658
+ * ```
659
+ *
660
+ * @see {@link allocBuffer} To allocate data buffers
661
+ * @see {@link free} To deallocate the frame
662
+ */
663
+ alloc(): void;
664
+ /**
665
+ * Free the frame.
666
+ *
667
+ * Deallocates the frame and its data. The frame becomes invalid after this.
668
+ *
669
+ * Direct mapping to av_frame_free().
670
+ *
671
+ * @example
672
+ * ```typescript
673
+ * frame.free();
674
+ * // Frame is now invalid
675
+ * ```
676
+ *
677
+ * @see {@link unref} To only free data, keeping structure
678
+ */
679
+ free(): void;
680
+ /**
681
+ * Create a reference to another frame.
682
+ *
683
+ * Sets up this frame as a reference to the source frame's data.
684
+ * Both frames will share the same data buffers.
685
+ *
686
+ * Direct mapping to av_frame_ref().
687
+ *
688
+ * @param src - Source frame to reference
689
+ *
690
+ * @returns 0 on success, negative AVERROR on error:
691
+ * - AVERROR_ENOMEM: Memory allocation failure
692
+ * - AVERROR_EINVAL: Invalid parameters
693
+ *
694
+ * @example
695
+ * ```typescript
696
+ * import { FFmpegError } from 'node-av';
697
+ *
698
+ * const frame2 = new Frame();
699
+ * frame2.alloc();
700
+ * const ret = frame2.ref(frame1);
701
+ * FFmpegError.throwIfError(ret, 'ref');
702
+ * // frame2 now references frame1's data
703
+ * ```
704
+ *
705
+ * @see {@link unref} To remove reference
706
+ * @see {@link clone} To create independent copy
707
+ */
708
+ ref(src: Frame): number;
709
+ /**
710
+ * Unreference the frame.
711
+ *
712
+ * Frees the frame data if this was the last reference.
713
+ * The frame structure remains allocated and can be reused.
714
+ *
715
+ * Direct mapping to av_frame_unref().
716
+ *
717
+ * @example
718
+ * ```typescript
719
+ * frame.unref();
720
+ * // Frame data is freed, structure can be reused
721
+ * ```
722
+ *
723
+ * @see {@link ref} To create reference
724
+ * @see {@link free} To free everything
725
+ */
726
+ unref(): void;
727
+ /**
728
+ * Clone the frame.
729
+ *
730
+ * Creates an independent copy of the frame with its own data buffers.
731
+ * The new frame has the same content but can be modified independently.
732
+ *
733
+ * Direct mapping to av_frame_clone().
734
+ *
735
+ * @returns New frame instance, or null on allocation failure
736
+ *
737
+ * @example
738
+ * ```typescript
739
+ * const copy = frame.clone();
740
+ * if (copy) {
741
+ * // Modify copy without affecting original
742
+ * copy.pts = frame.pts + 1000n;
743
+ * }
744
+ * ```
745
+ *
746
+ * @see {@link ref} To create reference instead of copy
747
+ * @see {@link copy} To copy into existing frame
748
+ */
749
+ clone(): Frame | null;
750
+ /**
751
+ * Get required buffer size for the frame.
752
+ *
753
+ * Calculates the required buffer size based on frame parameters.
754
+ * Must set format, width/height (video) or format, nb_samples, channel_layout (audio) first.
755
+ *
756
+ * Direct mapping to av_frame_get_buffer().
757
+ *
758
+ * @param align - Buffer size alignment (0 for default)
759
+ *
760
+ * @returns Required buffer size in bytes, or negative AVERROR:
761
+ * - AVERROR_EINVAL: Invalid frame parameters
762
+ *
763
+ * @example
764
+ * ```typescript
765
+ * import { FFmpegError } from 'node-av';
766
+ *
767
+ * const size = frame.getBuffer();
768
+ * FFmpegError.throwIfError(size, 'getBuffer');
769
+ * console.log(`Buffer size: ${size} bytes`);
770
+ * ```
771
+ *
772
+ * @see {@link allocBuffer} To allocate the buffer
773
+ */
774
+ getBuffer(align?: number): number;
775
+ /**
776
+ * Allocate data buffers for the frame.
777
+ *
778
+ * Allocates buffers based on frame format and dimensions.
779
+ * Frame parameters must be set before calling.
780
+ *
781
+ * Direct mapping to av_frame_get_buffer().
782
+ *
783
+ * @returns 0 on success, negative AVERROR on error:
784
+ * - AVERROR_EINVAL: Invalid frame parameters
785
+ * - AVERROR_ENOMEM: Memory allocation failure
786
+ *
787
+ * @example
788
+ * ```typescript
789
+ * import { FFmpegError } from 'node-av';
790
+ * import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
791
+ *
792
+ * frame.format = AV_PIX_FMT_YUV420P;
793
+ * frame.width = 1920;
794
+ * frame.height = 1080;
795
+ * const ret = frame.allocBuffer();
796
+ * FFmpegError.throwIfError(ret, 'allocBuffer');
797
+ * ```
798
+ *
799
+ * @see {@link getBuffer} To get required size
800
+ */
801
+ allocBuffer(): number;
802
+ /**
803
+ * Ensure frame data is writable.
804
+ *
805
+ * Creates a private copy of the data if it's shared with other frames.
806
+ * Call before modifying frame data to avoid affecting other references.
807
+ *
808
+ * Direct mapping to av_frame_make_writable().
809
+ *
810
+ * @returns 0 on success, negative AVERROR on error:
811
+ * - AVERROR_ENOMEM: Memory allocation failure
812
+ * - AVERROR_EINVAL: Invalid frame
813
+ *
814
+ * @example
815
+ * ```typescript
816
+ * import { FFmpegError } from 'node-av';
817
+ *
818
+ * // Ensure we can safely modify data
819
+ * const ret = frame.makeWritable();
820
+ * FFmpegError.throwIfError(ret, 'makeWritable');
821
+ * // Now safe to modify frame.data
822
+ * ```
823
+ */
824
+ makeWritable(): number;
825
+ /**
826
+ * Copy non-layout frame properties without copying data.
827
+ *
828
+ * Copies metadata like timestamp, duration, etc., but not the actual data.
829
+ * Layout-defining properties, such as width, height, channel count, format, etc., are not copied.
830
+ * Useful for preparing output frames with same properties.
831
+ *
832
+ * Direct mapping to av_frame_copy_props().
833
+ *
834
+ * @param src - Source frame to copy properties from
835
+ *
836
+ * @returns 0 on success, negative AVERROR on error:
837
+ * - AVERROR_ENOMEM: Memory allocation failure
838
+ *
839
+ * @example
840
+ * ```typescript
841
+ * import { FFmpegError } from 'node-av';
842
+ *
843
+ * const ret = dstFrame.copyProps(srcFrame);
844
+ * FFmpegError.throwIfError(ret, 'copyProps');
845
+ * // dstFrame now has same non-layout properties as srcFrame
846
+ * ```
847
+ *
848
+ * @see {@link copy} To copy data
849
+ */
850
+ copyProps(src: Frame): number;
851
+ /**
852
+ * Copy frame data.
853
+ *
854
+ * Copies only data (but not metadata) from source frame.
855
+ * Destination must have allocated buffers of correct size.
856
+ *
857
+ * Direct mapping to av_frame_copy().
858
+ *
859
+ * @param src - Source frame to copy from
860
+ *
861
+ * @returns 0 on success, negative AVERROR on error:
862
+ * - AVERROR_EINVAL: Incompatible frames
863
+ *
864
+ * @example
865
+ * ```typescript
866
+ * import { FFmpegError } from 'node-av';
867
+ *
868
+ * // Allocate destination with same format
869
+ * dstFrame.format = srcFrame.format;
870
+ * dstFrame.width = srcFrame.width;
871
+ * dstFrame.height = srcFrame.height;
872
+ * dstFrame.allocBuffer();
873
+ *
874
+ * const ret = dstFrame.copy(srcFrame);
875
+ * FFmpegError.throwIfError(ret, 'copy');
876
+ * ```
877
+ *
878
+ * @see {@link copyProps} To copy non-format metadata
879
+ * @see {@link clone} To create new frame with copy
880
+ */
881
+ copy(src: Frame): number;
882
+ /**
883
+ * Fill frame data from buffer.
884
+ *
885
+ * Copies data from buffer into frame data planes.
886
+ * Frame must have allocated buffers.
887
+ *
888
+ * @param buffer - Source buffer with frame data
889
+ *
890
+ * @returns 0 on success, negative AVERROR on error:
891
+ * - AVERROR_EINVAL: Invalid parameters
892
+ *
893
+ * @example
894
+ * ```typescript
895
+ * import { FFmpegError } from 'node-av';
896
+ *
897
+ * const buffer = Buffer.from(rawVideoData);
898
+ * const ret = frame.fromBuffer(buffer);
899
+ * FFmpegError.throwIfError(ret, 'fromBuffer');
900
+ * ```
901
+ */
902
+ fromBuffer(buffer: Buffer): number;
903
+ /**
904
+ * Convert frame data to buffer.
905
+ *
906
+ * Copies frame data into a single contiguous buffer.
907
+ * For video frames, converts all planes into packed format.
908
+ * For audio frames, handles both planar and interleaved formats.
909
+ * Cannot be used with hardware frames - use hwframeTransferData first.
910
+ *
911
+ * @returns Buffer containing frame data
912
+ *
913
+ * @throws {Error} If frame is not allocated, has no data, or is a hardware frame
914
+ *
915
+ * @example Video frame to buffer
916
+ * ```typescript
917
+ * // Get YUV420P video frame as buffer
918
+ * const buffer = frame.toBuffer();
919
+ * console.log(`Frame buffer size: ${buffer.length} bytes`);
920
+ * // Buffer contains Y plane, then U plane, then V plane
921
+ * ```
922
+ *
923
+ * @example Audio frame to buffer
924
+ * ```typescript
925
+ * // Get audio samples as buffer
926
+ * const audioBuffer = frame.toBuffer();
927
+ * console.log(`Audio buffer size: ${audioBuffer.length} bytes`);
928
+ * // For planar audio: channel 0 samples, then channel 1 samples, etc.
929
+ * // For interleaved audio: sample0_ch0, sample0_ch1, sample1_ch0, sample1_ch1, etc.
930
+ * ```
931
+ *
932
+ * @example Error handling
933
+ * ```typescript
934
+ * try {
935
+ * const buffer = frame.toBuffer();
936
+ * // Process buffer...
937
+ * } catch (error) {
938
+ * if (frame.isHwFrame()) {
939
+ * // Transfer to software first
940
+ * const swFrame = new Frame();
941
+ * swFrame.alloc();
942
+ * await frame.hwframeTransferData(swFrame);
943
+ * const buffer = swFrame.toBuffer();
944
+ * }
945
+ * }
946
+ * ```
947
+ *
948
+ * @see {@link fromBuffer} To create frame from buffer
949
+ * @see {@link hwframeTransferData} To transfer hardware frames to software
950
+ * @see {@link isHwFrame} To check if frame is hardware
951
+ * @see {@link data} To access individual planes
952
+ */
953
+ toBuffer(): Buffer;
954
+ /**
955
+ * Transfer data between hardware and software frames.
956
+ *
957
+ * Copies frame data between GPU and system memory.
958
+ * Direction depends on source and destination frame types.
959
+ *
960
+ * Direct mapping to av_hwframe_transfer_data().
961
+ *
962
+ * @param dst - Destination frame (software or hardware)
963
+ *
964
+ * @param flags - Transfer flags (0 for default)
965
+ *
966
+ * @returns 0 on success, negative AVERROR on error:
967
+ * - AVERROR_EINVAL: Invalid parameters
968
+ * - AVERROR_ENOMEM: Memory allocation failure
969
+ *
970
+ * @example
971
+ * ```typescript
972
+ * import { FFmpegError } from 'node-av';
973
+ *
974
+ * // Download from GPU to CPU
975
+ * const swFrame = new Frame();
976
+ * swFrame.alloc();
977
+ * const ret = await hwFrame.hwframeTransferData(swFrame);
978
+ * FFmpegError.throwIfError(ret, 'hwframeTransferData');
979
+ * ```
980
+ *
981
+ * @see {@link isHwFrame} To check if frame is hardware
982
+ * @see {@link isSwFrame} To check if frame is software
983
+ */
984
+ hwframeTransferData(dst: Frame, flags?: number): Promise<number>;
985
+ /**
986
+ * Transfer data between hardware and software frames synchronously.
987
+ * Synchronous version of hwframeTransferData.
988
+ *
989
+ * Copies frame data between GPU and system memory.
990
+ * Direction depends on source and destination frame types.
991
+ *
992
+ * Direct mapping to av_hwframe_transfer_data().
993
+ *
994
+ * @param dst - Destination frame (software or hardware)
995
+ *
996
+ * @param flags - Transfer flags (0 for default)
997
+ *
998
+ * @returns 0 on success, negative AVERROR on error:
999
+ * - AVERROR_EINVAL: Invalid parameters
1000
+ * - AVERROR_ENOMEM: Memory allocation failure
1001
+ *
1002
+ * @example
1003
+ * ```typescript
1004
+ * import { FFmpegError } from 'node-av';
1005
+ *
1006
+ * // Download from GPU to CPU
1007
+ * const swFrame = new Frame();
1008
+ * swFrame.alloc();
1009
+ * const ret = hwFrame.hwframeTransferData(swFrame);
1010
+ * FFmpegError.throwIfError(ret, 'hwframeTransferData');
1011
+ * ```
1012
+ *
1013
+ * @see {@link hwframeTransferData} For async version
1014
+ */
1015
+ hwframeTransferDataSync(dst: Frame, flags?: number): number;
1016
+ /**
1017
+ * Check if this is a hardware frame.
1018
+ *
1019
+ * Returns true if frame data is in GPU memory.
1020
+ *
1021
+ * @returns True if hardware frame, false otherwise
1022
+ *
1023
+ * @example
1024
+ * ```typescript
1025
+ * if (frame.isHwFrame()) {
1026
+ * console.log('Frame is in GPU memory');
1027
+ * }
1028
+ * ```
1029
+ *
1030
+ * @see {@link isSwFrame} To check for software frame
1031
+ * @see {@link hwframeTransferData} To transfer between GPU/CPU
1032
+ */
1033
+ isHwFrame(): boolean;
1034
+ /**
1035
+ * Check if this is a software frame.
1036
+ *
1037
+ * Returns true if frame data is in system memory.
1038
+ *
1039
+ * @returns True if software frame, false otherwise
1040
+ *
1041
+ * @example
1042
+ * ```typescript
1043
+ * if (frame.isSwFrame()) {
1044
+ * console.log('Frame is in system memory');
1045
+ * }
1046
+ * ```
1047
+ *
1048
+ * @see {@link isHwFrame} To check for hardware frame
1049
+ * @see {@link hwframeTransferData} To transfer between GPU/CPU
1050
+ */
1051
+ isSwFrame(): boolean;
1052
+ /**
1053
+ * Get frame side data.
1054
+ *
1055
+ * Retrieves additional data associated with the frame
1056
+ * (e.g., motion vectors, film grain, HDR metadata).
1057
+ *
1058
+ * Direct mapping to av_frame_get_side_data().
1059
+ *
1060
+ * @param type - Type of side data to retrieve
1061
+ *
1062
+ * @returns Side data buffer, or null if not present
1063
+ *
1064
+ * @example
1065
+ * ```typescript
1066
+ * import { AV_FRAME_DATA_MOTION_VECTORS } from 'node-av/constants';
1067
+ *
1068
+ * const motionVectors = frame.getSideData(AV_FRAME_DATA_MOTION_VECTORS);
1069
+ * if (motionVectors) {
1070
+ * console.log(`Motion data size: ${motionVectors.length} bytes`);
1071
+ * }
1072
+ * ```
1073
+ *
1074
+ * @see {@link newSideData} To add side data
1075
+ * @see {@link removeSideData} To remove side data
1076
+ */
1077
+ getSideData(type: AVFrameSideDataType): Buffer | null;
1078
+ /**
1079
+ * Allocate new side data.
1080
+ *
1081
+ * Allocates side data buffer attached to the frame.
1082
+ * Returns buffer that can be written to directly.
1083
+ *
1084
+ * Direct mapping to av_frame_new_side_data().
1085
+ *
1086
+ * @param type - Type of side data
1087
+ *
1088
+ * @param size - Size in bytes to allocate
1089
+ *
1090
+ * @returns Allocated buffer for writing
1091
+ *
1092
+ * @throws {Error} If allocation fails
1093
+ *
1094
+ * @example
1095
+ * ```typescript
1096
+ * import { AV_FRAME_DATA_MASTERING_DISPLAY_METADATA } from 'node-av/constants';
1097
+ *
1098
+ * // Allocate and write HDR metadata
1099
+ * const hdrData = frame.newSideData(
1100
+ * AV_FRAME_DATA_MASTERING_DISPLAY_METADATA,
1101
+ * 40
1102
+ * );
1103
+ * // Write metadata to buffer...
1104
+ * ```
1105
+ *
1106
+ * @see {@link getSideData} To retrieve side data
1107
+ * @see {@link removeSideData} To remove side data
1108
+ */
1109
+ newSideData(type: AVFrameSideDataType, size: number): Buffer;
1110
+ /**
1111
+ * Remove side data from frame.
1112
+ *
1113
+ * Removes specific type of side data.
1114
+ *
1115
+ * Direct mapping to av_frame_remove_side_data().
1116
+ *
1117
+ * @param type - Type of side data to remove
1118
+ *
1119
+ * @example
1120
+ * ```typescript
1121
+ * import { AV_FRAME_DATA_MOTION_VECTORS } from 'node-av/constants';
1122
+ *
1123
+ * frame.removeSideData(AV_FRAME_DATA_MOTION_VECTORS);
1124
+ * // Motion vectors removed
1125
+ * ```
1126
+ *
1127
+ * @see {@link getSideData} To retrieve side data
1128
+ * @see {@link newSideData} To add side data
1129
+ */
1130
+ removeSideData(type: AVFrameSideDataType): void;
1131
+ /**
1132
+ * Get frame metadata dictionary.
1133
+ *
1134
+ * Returns metadata attached to the frame by filters or demuxers.
1135
+ * Metadata is stored as key-value pairs in a Dictionary.
1136
+ * Useful for reading filter-generated metadata (e.g., whisper transcription).
1137
+ *
1138
+ * Direct mapping to AVFrame->metadata.
1139
+ *
1140
+ * @returns Dictionary containing frame metadata
1141
+ *
1142
+ * @example
1143
+ * ```typescript
1144
+ * // Read whisper filter metadata
1145
+ * const metadata = frame.getMetadata();
1146
+ * const text = metadata.get('lavfi.whisper.text');
1147
+ * const duration = metadata.get('lavfi.whisper.duration');
1148
+ *
1149
+ * if (text) {
1150
+ * console.log(`Transcribed: ${text}`);
1151
+ * console.log(`Duration: ${duration}s`);
1152
+ * }
1153
+ * ```
1154
+ *
1155
+ * @example
1156
+ * ```typescript
1157
+ * // Read scene detection metadata
1158
+ * const metadata = frame.getMetadata();
1159
+ * const score = metadata.get('lavfi.scene_score');
1160
+ * if (score) {
1161
+ * console.log(`Scene change score: ${score}`);
1162
+ * }
1163
+ * ```
1164
+ *
1165
+ * @see {@link Dictionary} For metadata dictionary operations
1166
+ */
1167
+ getMetadata(): Dictionary;
1168
+ /**
1169
+ * Apply cropping to the frame.
1170
+ *
1171
+ * Crops the frame according to its crop metadata (AVFrame crop fields).
1172
+ * This adjusts the frame dimensions and data pointers to reflect the cropped region.
1173
+ * The cropped-out area is discarded, reducing frame size.
1174
+ *
1175
+ * Direct mapping to av_frame_apply_cropping().
1176
+ *
1177
+ * @param flags - Cropping flags (default: AV_FRAME_CROP_UNALIGNED = 1)
1178
+ * AV_FRAME_CROP_UNALIGNED allows unaligned cropping for lavfi compatibility
1179
+ *
1180
+ * @returns 0 on success, negative error code on failure
1181
+ *
1182
+ * @example
1183
+ * ```typescript
1184
+ * import { Frame, FFmpegError } from 'node-av';
1185
+ *
1186
+ * const frame = new Frame();
1187
+ * // ... decode frame with crop metadata ...
1188
+ *
1189
+ * // Apply cropping based on metadata
1190
+ * const ret = frame.applyCropping();
1191
+ * FFmpegError.throwIfError(ret, 'Failed to apply cropping');
1192
+ *
1193
+ * // Frame dimensions are now updated to cropped size
1194
+ * console.log(`Cropped to ${frame.width}x${frame.height}`);
1195
+ * ```
1196
+ */
1197
+ applyCropping(flags?: number): number;
1198
+ /**
1199
+ * Get the underlying native Frame object.
1200
+ *
1201
+ * @returns The native Frame binding object
1202
+ *
1203
+ * @internal
1204
+ */
1205
+ getNative(): NativeFrame;
1206
+ /**
1207
+ * Dispose of the frame.
1208
+ *
1209
+ * Implements the Disposable interface for automatic cleanup.
1210
+ * Equivalent to calling free().
1211
+ *
1212
+ * @example
1213
+ * ```typescript
1214
+ * {
1215
+ * using frame = new Frame();
1216
+ * frame.alloc();
1217
+ * // Use frame...
1218
+ * } // Automatically freed when leaving scope
1219
+ * ```
1220
+ */
1221
+ [Symbol.dispose](): void;
1222
+ }