node-av 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +22 -0
  3. package/README.md +377 -0
  4. package/binding.gyp +78 -0
  5. package/dist/api/bitstream-filter.d.ts +246 -0
  6. package/dist/api/bitstream-filter.js +369 -0
  7. package/dist/api/bitstream-filter.js.map +1 -0
  8. package/dist/api/decoder.d.ts +257 -0
  9. package/dist/api/decoder.js +424 -0
  10. package/dist/api/decoder.js.map +1 -0
  11. package/dist/api/encoder.d.ts +298 -0
  12. package/dist/api/encoder.js +574 -0
  13. package/dist/api/encoder.js.map +1 -0
  14. package/dist/api/filter.d.ts +457 -0
  15. package/dist/api/filter.js +876 -0
  16. package/dist/api/filter.js.map +1 -0
  17. package/dist/api/hardware.d.ts +318 -0
  18. package/dist/api/hardware.js +558 -0
  19. package/dist/api/hardware.js.map +1 -0
  20. package/dist/api/index.d.ts +12 -0
  21. package/dist/api/index.js +20 -0
  22. package/dist/api/index.js.map +1 -0
  23. package/dist/api/io-stream.d.ts +109 -0
  24. package/dist/api/io-stream.js +124 -0
  25. package/dist/api/io-stream.js.map +1 -0
  26. package/dist/api/media-input.d.ts +295 -0
  27. package/dist/api/media-input.js +456 -0
  28. package/dist/api/media-input.js.map +1 -0
  29. package/dist/api/media-output.d.ts +274 -0
  30. package/dist/api/media-output.js +486 -0
  31. package/dist/api/media-output.js.map +1 -0
  32. package/dist/api/pipeline.d.ts +117 -0
  33. package/dist/api/pipeline.js +836 -0
  34. package/dist/api/pipeline.js.map +1 -0
  35. package/dist/api/types.d.ts +440 -0
  36. package/dist/api/types.js +2 -0
  37. package/dist/api/types.js.map +1 -0
  38. package/dist/api/utilities/audio-sample.d.ts +115 -0
  39. package/dist/api/utilities/audio-sample.js +110 -0
  40. package/dist/api/utilities/audio-sample.js.map +1 -0
  41. package/dist/api/utilities/channel-layout.d.ts +83 -0
  42. package/dist/api/utilities/channel-layout.js +87 -0
  43. package/dist/api/utilities/channel-layout.js.map +1 -0
  44. package/dist/api/utilities/image.d.ts +177 -0
  45. package/dist/api/utilities/image.js +183 -0
  46. package/dist/api/utilities/image.js.map +1 -0
  47. package/dist/api/utilities/index.d.ts +8 -0
  48. package/dist/api/utilities/index.js +17 -0
  49. package/dist/api/utilities/index.js.map +1 -0
  50. package/dist/api/utilities/media-type.d.ts +56 -0
  51. package/dist/api/utilities/media-type.js +60 -0
  52. package/dist/api/utilities/media-type.js.map +1 -0
  53. package/dist/api/utilities/pixel-format.d.ts +94 -0
  54. package/dist/api/utilities/pixel-format.js +102 -0
  55. package/dist/api/utilities/pixel-format.js.map +1 -0
  56. package/dist/api/utilities/sample-format.d.ts +132 -0
  57. package/dist/api/utilities/sample-format.js +144 -0
  58. package/dist/api/utilities/sample-format.js.map +1 -0
  59. package/dist/api/utilities/streaming.d.ts +104 -0
  60. package/dist/api/utilities/streaming.js +137 -0
  61. package/dist/api/utilities/streaming.js.map +1 -0
  62. package/dist/api/utilities/timestamp.d.ts +187 -0
  63. package/dist/api/utilities/timestamp.js +200 -0
  64. package/dist/api/utilities/timestamp.js.map +1 -0
  65. package/dist/api/utils.d.ts +61 -0
  66. package/dist/api/utils.js +330 -0
  67. package/dist/api/utils.js.map +1 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.js +5 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/lib/audio-fifo.d.ts +339 -0
  72. package/dist/lib/audio-fifo.js +365 -0
  73. package/dist/lib/audio-fifo.js.map +1 -0
  74. package/dist/lib/binding.d.ts +192 -0
  75. package/dist/lib/binding.js +70 -0
  76. package/dist/lib/binding.js.map +1 -0
  77. package/dist/lib/bitstream-filter-context.d.ts +345 -0
  78. package/dist/lib/bitstream-filter-context.js +407 -0
  79. package/dist/lib/bitstream-filter-context.js.map +1 -0
  80. package/dist/lib/bitstream-filter.d.ts +124 -0
  81. package/dist/lib/bitstream-filter.js +138 -0
  82. package/dist/lib/bitstream-filter.js.map +1 -0
  83. package/dist/lib/channel-layouts.d.ts +51 -0
  84. package/dist/lib/channel-layouts.js +55 -0
  85. package/dist/lib/channel-layouts.js.map +1 -0
  86. package/dist/lib/codec-context.d.ts +763 -0
  87. package/dist/lib/codec-context.js +974 -0
  88. package/dist/lib/codec-context.js.map +1 -0
  89. package/dist/lib/codec-parameters.d.ts +362 -0
  90. package/dist/lib/codec-parameters.js +460 -0
  91. package/dist/lib/codec-parameters.js.map +1 -0
  92. package/dist/lib/codec-parser.d.ts +185 -0
  93. package/dist/lib/codec-parser.js +193 -0
  94. package/dist/lib/codec-parser.js.map +1 -0
  95. package/dist/lib/codec.d.ts +432 -0
  96. package/dist/lib/codec.js +492 -0
  97. package/dist/lib/codec.js.map +1 -0
  98. package/dist/lib/constants.d.ts +2037 -0
  99. package/dist/lib/constants.js +1659 -0
  100. package/dist/lib/constants.js.map +1 -0
  101. package/dist/lib/dictionary.d.ts +371 -0
  102. package/dist/lib/dictionary.js +406 -0
  103. package/dist/lib/dictionary.js.map +1 -0
  104. package/dist/lib/error.d.ts +216 -0
  105. package/dist/lib/error.js +254 -0
  106. package/dist/lib/error.js.map +1 -0
  107. package/dist/lib/filter-context.d.ts +445 -0
  108. package/dist/lib/filter-context.js +505 -0
  109. package/dist/lib/filter-context.js.map +1 -0
  110. package/dist/lib/filter-graph.d.ts +556 -0
  111. package/dist/lib/filter-graph.js +608 -0
  112. package/dist/lib/filter-graph.js.map +1 -0
  113. package/dist/lib/filter-inout.d.ts +205 -0
  114. package/dist/lib/filter-inout.js +264 -0
  115. package/dist/lib/filter-inout.js.map +1 -0
  116. package/dist/lib/filter.d.ts +231 -0
  117. package/dist/lib/filter.js +260 -0
  118. package/dist/lib/filter.js.map +1 -0
  119. package/dist/lib/format-context.d.ts +798 -0
  120. package/dist/lib/format-context.js +845 -0
  121. package/dist/lib/format-context.js.map +1 -0
  122. package/dist/lib/frame.d.ts +784 -0
  123. package/dist/lib/frame.js +933 -0
  124. package/dist/lib/frame.js.map +1 -0
  125. package/dist/lib/hardware-device-context.d.ts +407 -0
  126. package/dist/lib/hardware-device-context.js +429 -0
  127. package/dist/lib/hardware-device-context.js.map +1 -0
  128. package/dist/lib/hardware-frames-context.d.ts +374 -0
  129. package/dist/lib/hardware-frames-context.js +430 -0
  130. package/dist/lib/hardware-frames-context.js.map +1 -0
  131. package/dist/lib/index.d.ts +31 -0
  132. package/dist/lib/index.js +54 -0
  133. package/dist/lib/index.js.map +1 -0
  134. package/dist/lib/input-format.d.ts +216 -0
  135. package/dist/lib/input-format.js +246 -0
  136. package/dist/lib/input-format.js.map +1 -0
  137. package/dist/lib/io-context.d.ts +495 -0
  138. package/dist/lib/io-context.js +550 -0
  139. package/dist/lib/io-context.js.map +1 -0
  140. package/dist/lib/log.d.ts +201 -0
  141. package/dist/lib/log.js +219 -0
  142. package/dist/lib/log.js.map +1 -0
  143. package/dist/lib/native-types.d.ts +719 -0
  144. package/dist/lib/native-types.js +2 -0
  145. package/dist/lib/native-types.js.map +1 -0
  146. package/dist/lib/option.d.ts +589 -0
  147. package/dist/lib/option.js +853 -0
  148. package/dist/lib/option.js.map +1 -0
  149. package/dist/lib/output-format.d.ts +179 -0
  150. package/dist/lib/output-format.js +205 -0
  151. package/dist/lib/output-format.js.map +1 -0
  152. package/dist/lib/packet.d.ts +487 -0
  153. package/dist/lib/packet.js +558 -0
  154. package/dist/lib/packet.js.map +1 -0
  155. package/dist/lib/rational.d.ts +210 -0
  156. package/dist/lib/rational.js +233 -0
  157. package/dist/lib/rational.js.map +1 -0
  158. package/dist/lib/software-resample-context.d.ts +572 -0
  159. package/dist/lib/software-resample-context.js +610 -0
  160. package/dist/lib/software-resample-context.js.map +1 -0
  161. package/dist/lib/software-scale-context.d.ts +290 -0
  162. package/dist/lib/software-scale-context.js +308 -0
  163. package/dist/lib/software-scale-context.js.map +1 -0
  164. package/dist/lib/stream.d.ts +322 -0
  165. package/dist/lib/stream.js +408 -0
  166. package/dist/lib/stream.js.map +1 -0
  167. package/dist/lib/types.d.ts +59 -0
  168. package/dist/lib/types.js +8 -0
  169. package/dist/lib/types.js.map +1 -0
  170. package/dist/lib/utilities.d.ts +346 -0
  171. package/dist/lib/utilities.js +424 -0
  172. package/dist/lib/utilities.js.map +1 -0
  173. package/install/check.js +113 -0
  174. package/install/ffmpeg.js +163 -0
  175. package/package.json +107 -0
@@ -0,0 +1,558 @@
1
+ /**
2
+ * HardwareContext - High-level Hardware Acceleration API
3
+ *
4
+ * Provides simplified access to hardware acceleration features.
5
+ * Automatically detects and configures hardware devices for encoding/decoding.
6
+ *
7
+ * Wraps the low-level HardwareDeviceContext and HardwareFramesContext.
8
+ * Manages lifecycle of hardware resources with automatic cleanup.
9
+ *
10
+ * @module api/hardware
11
+ */
12
+ import { AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX, AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, AV_HWDEVICE_TYPE_CUDA, AV_HWDEVICE_TYPE_D3D11VA, AV_HWDEVICE_TYPE_D3D12VA, AV_HWDEVICE_TYPE_DRM, AV_HWDEVICE_TYPE_DXVA2, AV_HWDEVICE_TYPE_MEDIACODEC, AV_HWDEVICE_TYPE_NONE, AV_HWDEVICE_TYPE_OPENCL, AV_HWDEVICE_TYPE_QSV, AV_HWDEVICE_TYPE_VAAPI, AV_HWDEVICE_TYPE_VDPAU, AV_HWDEVICE_TYPE_VIDEOTOOLBOX, AV_HWDEVICE_TYPE_VULKAN, AV_PIX_FMT_CUDA, AV_PIX_FMT_D3D11, AV_PIX_FMT_D3D12, AV_PIX_FMT_DRM_PRIME, AV_PIX_FMT_DXVA2_VLD, AV_PIX_FMT_MEDIACODEC, AV_PIX_FMT_NV12, AV_PIX_FMT_OPENCL, AV_PIX_FMT_QSV, AV_PIX_FMT_VAAPI, AV_PIX_FMT_VIDEOTOOLBOX, AV_PIX_FMT_VULKAN, Codec, Dictionary, FFmpegError, HardwareDeviceContext, HardwareFramesContext, } from '../lib/index.js';
13
+ /**
14
+ * HardwareContext - Simplified hardware acceleration management.
15
+ *
16
+ * Provides automatic detection and configuration of hardware acceleration.
17
+ * Manages device contexts and frame contexts for hardware encoding/decoding.
18
+ *
19
+ * Supports various hardware types including VideoToolbox (macOS), CUDA,
20
+ * VAAPI (Linux), D3D11VA/D3D12VA (Windows), and more.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * import { HardwareContext } from 'node-av/api';
25
+ *
26
+ * // Auto-detect best available hardware
27
+ * const hw = await HardwareContext.auto();
28
+ * if (hw) {
29
+ * console.log(`Using hardware: ${hw.deviceType}`);
30
+ * decoder.hwDeviceCtx = hw.deviceContext;
31
+ * }
32
+ *
33
+ * // Use specific hardware
34
+ * const cuda = await HardwareContext.create(AV_HWDEVICE_TYPE_CUDA);
35
+ * encoder.hwDeviceCtx = cuda.deviceContext;
36
+ *
37
+ * // Clean up when done
38
+ * hw?.dispose();
39
+ * cuda.dispose();
40
+ * ```
41
+ */
42
+ export class HardwareContext {
43
+ _deviceContext;
44
+ _framesContext;
45
+ _deviceType;
46
+ _deviceName;
47
+ _devicePixelFormat;
48
+ _isDisposed = false;
49
+ waitingComponents = new Set();
50
+ /**
51
+ * Create a new HardwareContext instance.
52
+ *
53
+ * Private constructor - use HardwareContext.create() or HardwareContext.auto() to create instances.
54
+ *
55
+ * Stores the device context and type for later use.
56
+ *
57
+ * @param deviceContext - Initialized hardware device context
58
+ * @param deviceType - Hardware device type
59
+ * @param deviceName - Optional device name/identifier
60
+ */
61
+ constructor(deviceContext, deviceType, deviceName) {
62
+ this._deviceContext = deviceContext;
63
+ this._deviceType = deviceType;
64
+ this._deviceName = deviceName;
65
+ this._devicePixelFormat = this.getHardwarePixelFormat();
66
+ }
67
+ /**
68
+ * Auto-detect and create the best available hardware context.
69
+ *
70
+ * Tries hardware types in order of preference based on platform.
71
+ * Returns null if no hardware acceleration is available.
72
+ *
73
+ * Platform-specific preferences:
74
+ * - macOS: VideoToolbox
75
+ * - Windows: D3D12VA, D3D11VA, DXVA2, QSV, CUDA
76
+ * - Linux: VAAPI, VDPAU, CUDA, Vulkan, DRM
77
+ *
78
+ * @param options - Optional hardware configuration
79
+ *
80
+ * @returns Promise resolving to HardwareContext or null
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * const hw = await HardwareContext.auto();
85
+ * if (hw) {
86
+ * console.log(`Auto-detected: ${hw.deviceTypeName}`);
87
+ * }
88
+ * ```
89
+ */
90
+ static async auto(options = {}) {
91
+ // Platform-specific preference order
92
+ const preferenceOrder = this.getPreferenceOrder();
93
+ for (const deviceType of preferenceOrder) {
94
+ try {
95
+ const hw = await this.createFromType(deviceType, options.deviceName, options.options);
96
+ if (hw) {
97
+ return hw;
98
+ }
99
+ }
100
+ catch {
101
+ // Try next device type
102
+ continue;
103
+ }
104
+ }
105
+ return null;
106
+ }
107
+ /**
108
+ * Create a hardware context for a specific device type.
109
+ *
110
+ * Creates and initializes a hardware device context using FFmpeg's
111
+ * av_hwdevice_ctx_create() internally.
112
+ *
113
+ * @param device - Device type name (e.g., AV_HWDEVICE_TYPE_CUDA, AV_HWDEVICE_TYPE_VAAPI, AV_HWDEVICE_TYPE_VIDEOTOOLBOX)
114
+ * @param deviceName - Optional device name/index
115
+ * @param options - Optional device initialization options
116
+ *
117
+ * @returns Promise resolving to HardwareContext
118
+ *
119
+ * @throws {Error} If device type is not supported or initialization fails
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * // Create CUDA context
124
+ * const cuda = await HardwareContext.create(AV_HWDEVICE_TYPE_CUDA, '0');
125
+ *
126
+ * // Create VAAPI context
127
+ * const vaapi = await HardwareContext.create(AV_HWDEVICE_TYPE_VAAPI, '/dev/dri/renderD128');
128
+ * ```
129
+ */
130
+ static async create(device, deviceName, options) {
131
+ if (device === AV_HWDEVICE_TYPE_NONE) {
132
+ throw new Error(`Unknown hardware device type: ${device}`);
133
+ }
134
+ const hw = await this.createFromType(device, deviceName, options);
135
+ if (!hw) {
136
+ throw new Error(`Failed to create hardware context for ${device}`);
137
+ }
138
+ return hw;
139
+ }
140
+ /**
141
+ * List all available hardware device types.
142
+ *
143
+ * Uses av_hwdevice_iterate_types() internally to enumerate
144
+ * all hardware types supported by the FFmpeg build.
145
+ *
146
+ * @returns Array of available device type names
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * const available = HardwareContext.listAvailable();
151
+ * console.log('Available hardware:', available.join(', '));
152
+ * ```
153
+ */
154
+ static listAvailable() {
155
+ const types = HardwareDeviceContext.iterateTypes();
156
+ const available = [];
157
+ for (const type of types) {
158
+ const name = HardwareDeviceContext.getTypeName(type);
159
+ if (name) {
160
+ available.push(name);
161
+ }
162
+ }
163
+ return available;
164
+ }
165
+ /**
166
+ * Get the hardware device context.
167
+ *
168
+ * This can be assigned to CodecContext.hwDeviceCtx for hardware acceleration.
169
+ *
170
+ * @returns Hardware device context
171
+ */
172
+ get deviceContext() {
173
+ return this._deviceContext;
174
+ }
175
+ /**
176
+ * Get the hardware frames context.
177
+ *
178
+ * Created on-demand when needed for frame allocation.
179
+ *
180
+ * @returns Hardware frames context or undefined
181
+ */
182
+ get framesContext() {
183
+ return this._framesContext;
184
+ }
185
+ /**
186
+ * Set the hardware frames context.
187
+ *
188
+ * First component to set it "wins" - subsequent sets are ignored.
189
+ * This is typically called by the decoder after decoding the first frame,
190
+ * allowing other components (encoder, filters) to share the same frames context.
191
+ *
192
+ * @param framesContext - The hardware frames context to set
193
+ */
194
+ set framesContext(framesContext) {
195
+ // Only set if we don't have one yet (first wins)
196
+ if (framesContext && !this._framesContext) {
197
+ this._framesContext = framesContext;
198
+ // Notify all waiting components
199
+ for (const waiter of this.waitingComponents) {
200
+ waiter.resolve(this._framesContext);
201
+ }
202
+ this.waitingComponents.clear();
203
+ }
204
+ }
205
+ /**
206
+ * Get the device type enum value.
207
+ *
208
+ * @returns AVHWDeviceType enum value
209
+ */
210
+ get deviceType() {
211
+ return this._deviceType;
212
+ }
213
+ /**
214
+ * Get the hardware device type name.
215
+ *
216
+ * Uses FFmpeg's native av_hwdevice_get_type_name() function.
217
+ *
218
+ * @returns Device type name as string (e.g., 'cuda', 'videotoolbox')
219
+ */
220
+ get deviceTypeName() {
221
+ return HardwareDeviceContext.getTypeName(this._deviceType) ?? 'unknown';
222
+ }
223
+ /**
224
+ * Get the device name/identifier.
225
+ *
226
+ * @returns Device name or undefined
227
+ */
228
+ get deviceName() {
229
+ return this._deviceName;
230
+ }
231
+ /**
232
+ * Get the device pixel format.
233
+ *
234
+ * @returns Device pixel format
235
+ */
236
+ get devicePixelFormat() {
237
+ return this._devicePixelFormat;
238
+ }
239
+ /**
240
+ * Check if this hardware context has been disposed.
241
+ *
242
+ * @returns True if disposed
243
+ */
244
+ get isDisposed() {
245
+ return this._isDisposed;
246
+ }
247
+ /**
248
+ * Create or ensure a frames context exists for this hardware device.
249
+ *
250
+ * If a frames context already exists with different dimensions, throws an error.
251
+ * This is used for raw/generated frames that need hardware processing.
252
+ *
253
+ * @param width - Frame width
254
+ * @param height - Frame height
255
+ * @param swFormat - Software pixel format (default: AV_PIX_FMT_NV12)
256
+ * @param initialPoolSize - Initial frame pool size (default: 20)
257
+ *
258
+ * @returns HardwareFramesContext - Either existing or newly created
259
+ *
260
+ * @throws {Error} If frames context exists with incompatible dimensions
261
+ *
262
+ * @example
263
+ * ```typescript
264
+ * // For raw frames
265
+ * hw.ensureFramesContext(1920, 1080, AV_PIX_FMT_YUV420P);
266
+ * ```
267
+ */
268
+ ensureFramesContext(width, height, swFormat = AV_PIX_FMT_NV12, initialPoolSize = 20) {
269
+ if (this._framesContext) {
270
+ // Validate compatibility
271
+ if (this._framesContext.width !== width || this._framesContext.height !== height) {
272
+ // prettier-ignore
273
+ throw new Error(`Incompatible frames context: existing ${this._framesContext.width}x${this._framesContext.height} ` +
274
+ `vs requested ${width}x${height}. Use separate HardwareContext instances for different sizes.`);
275
+ }
276
+ return this._framesContext;
277
+ }
278
+ // Create new frames context on our device
279
+ const frames = new HardwareFramesContext();
280
+ frames.alloc(this._deviceContext);
281
+ frames.format = this.getHardwarePixelFormat();
282
+ frames.swFormat = swFormat;
283
+ frames.width = width;
284
+ frames.height = height;
285
+ frames.initialPoolSize = initialPoolSize;
286
+ const ret = frames.init();
287
+ FFmpegError.throwIfError(ret, 'Failed to initialize hardware frames context');
288
+ this._framesContext = frames;
289
+ // Notify waiting components
290
+ for (const waiter of this.waitingComponents) {
291
+ waiter.resolve(this._framesContext);
292
+ }
293
+ this.waitingComponents.clear();
294
+ return frames;
295
+ }
296
+ /**
297
+ * Wait for frames context to become available.
298
+ *
299
+ * Used by components that need hw_frames_ctx but don't have it yet.
300
+ * Resolves when another component (typically decoder) sets the frames context.
301
+ *
302
+ * @param timeout - Maximum time to wait in milliseconds (default: 5000)
303
+ *
304
+ * @returns Promise that resolves with the frames context
305
+ *
306
+ * @throws {Error} If timeout expires or HardwareContext is disposed
307
+ *
308
+ * @example
309
+ * ```typescript
310
+ * // Wait up to 3 seconds for frames context
311
+ * const framesCtx = await hw.waitForFramesContext(3000);
312
+ * ```
313
+ */
314
+ async waitForFramesContext(timeout = 5000) {
315
+ if (this._framesContext) {
316
+ return Promise.resolve(this._framesContext);
317
+ }
318
+ return Promise.race([
319
+ new Promise((resolve, reject) => {
320
+ this.waitingComponents.add({ resolve, reject });
321
+ }),
322
+ new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout waiting for frames context')), timeout)),
323
+ ]);
324
+ }
325
+ /**
326
+ * Get the hardware pixel format for this device type.
327
+ *
328
+ * Maps device types to their corresponding pixel formats.
329
+ *
330
+ * Returns the appropriate AV_PIX_FMT_* constant for the hardware type.
331
+ *
332
+ * @returns Hardware pixel format
333
+ */
334
+ getHardwarePixelFormat() {
335
+ switch (this._deviceType) {
336
+ case AV_HWDEVICE_TYPE_VIDEOTOOLBOX:
337
+ return AV_PIX_FMT_VIDEOTOOLBOX;
338
+ case AV_HWDEVICE_TYPE_VAAPI:
339
+ return AV_PIX_FMT_VAAPI;
340
+ case AV_HWDEVICE_TYPE_CUDA:
341
+ return AV_PIX_FMT_CUDA;
342
+ case AV_HWDEVICE_TYPE_QSV:
343
+ return AV_PIX_FMT_QSV;
344
+ case AV_HWDEVICE_TYPE_D3D11VA:
345
+ return AV_PIX_FMT_D3D11;
346
+ case AV_HWDEVICE_TYPE_DXVA2:
347
+ return AV_PIX_FMT_DXVA2_VLD;
348
+ case AV_HWDEVICE_TYPE_DRM:
349
+ return AV_PIX_FMT_DRM_PRIME;
350
+ case AV_HWDEVICE_TYPE_OPENCL:
351
+ return AV_PIX_FMT_OPENCL;
352
+ case AV_HWDEVICE_TYPE_MEDIACODEC:
353
+ return AV_PIX_FMT_MEDIACODEC;
354
+ case AV_HWDEVICE_TYPE_VULKAN:
355
+ return AV_PIX_FMT_VULKAN;
356
+ case AV_HWDEVICE_TYPE_D3D12VA:
357
+ return AV_PIX_FMT_D3D12;
358
+ default:
359
+ return AV_PIX_FMT_NV12; // Common hardware format
360
+ }
361
+ }
362
+ /**
363
+ * Check if this hardware type supports a specific codec.
364
+ *
365
+ * Checks both decoder and encoder support by querying FFmpeg's codec configurations.
366
+ *
367
+ * Uses avcodec_get_hw_config() internally to check hardware support.
368
+ *
369
+ * @param codecId - Codec ID from AVCodecID enum
370
+ * @param isEncoder - Check for encoder support (default: false for decoder)
371
+ *
372
+ * @returns True if codec is supported by this hardware
373
+ */
374
+ supportsCodec(codecId, isEncoder = false) {
375
+ // Try to find the codec
376
+ const codec = isEncoder ? Codec.findEncoder(codecId) : Codec.findDecoder(codecId);
377
+ if (!codec) {
378
+ return false;
379
+ }
380
+ // Check hardware configurations
381
+ for (let i = 0;; i++) {
382
+ const config = codec.getHwConfig(i);
383
+ if (!config) {
384
+ break; // No more configurations
385
+ }
386
+ // Check if this hardware device type is supported
387
+ // Accept both HW_DEVICE_CTX and HW_FRAMES_CTX methods
388
+ const supportsDeviceCtx = (config.methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) !== 0;
389
+ const supportsFramesCtx = (config.methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX) !== 0;
390
+ if ((supportsDeviceCtx || supportsFramesCtx) && config.deviceType === this._deviceType) {
391
+ return true;
392
+ }
393
+ }
394
+ return false;
395
+ }
396
+ /**
397
+ * Check if this hardware device type supports a specific pixel format.
398
+ *
399
+ * @param codecId - Codec ID from AVCodecID enum
400
+ * @param pixelFormat - Pixel format to check
401
+ * @param isEncoder - Check for encoder support (default: false for decoder)
402
+ *
403
+ * @returns True if pixel format is supported by this hardware
404
+ */
405
+ supportsPixelFormat(codecId, pixelFormat, isEncoder = false) {
406
+ const codec = isEncoder ? Codec.findEncoder(codecId) : Codec.findDecoder(codecId);
407
+ if (!codec) {
408
+ return false;
409
+ }
410
+ const pixelFormats = codec.pixelFormats ?? [];
411
+ if (pixelFormats.length === 0) {
412
+ return false;
413
+ }
414
+ return pixelFormats.some((fmt) => fmt === pixelFormat);
415
+ }
416
+ /**
417
+ * Find all codecs that support this hardware device.
418
+ *
419
+ * Uses FFmpeg's native codec list to find compatible codecs.
420
+ *
421
+ * Iterates through all codecs using av_codec_iterate() and checks
422
+ * their hardware configurations.
423
+ *
424
+ * @param isEncoder - Find encoders (true) or decoders (false)
425
+ *
426
+ * @returns Array of codec names that support this hardware
427
+ */
428
+ findSupportedCodecs(isEncoder = false) {
429
+ const supportedCodecs = [];
430
+ const codecs = Codec.getCodecList();
431
+ for (const codec of codecs) {
432
+ // Skip if wrong type (encoder vs decoder)
433
+ if (isEncoder && !codec.isEncoder())
434
+ continue;
435
+ if (!isEncoder && !codec.isDecoder())
436
+ continue;
437
+ // Check if this codec supports our hardware device type
438
+ for (let i = 0;; i++) {
439
+ const config = codec.getHwConfig(i);
440
+ if (!config)
441
+ break;
442
+ // Accept both HW_DEVICE_CTX and HW_FRAMES_CTX methods
443
+ const supportsDeviceCtx = (config.methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) !== 0;
444
+ const supportsFramesCtx = (config.methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX) !== 0;
445
+ if ((supportsDeviceCtx || supportsFramesCtx) && config.deviceType === this._deviceType) {
446
+ if (codec.name) {
447
+ supportedCodecs.push(codec.name);
448
+ }
449
+ break; // Found support, move to next codec
450
+ }
451
+ }
452
+ }
453
+ return supportedCodecs;
454
+ }
455
+ /**
456
+ * Clean up and free hardware resources.
457
+ *
458
+ * Safe to call multiple times - subsequent calls are no-ops.
459
+ * Called automatically by Decoder/Encoder on close.
460
+ *
461
+ * Frees both frames context (if created) and device context.
462
+ * Notifies any waiting components that disposal occurred.
463
+ */
464
+ dispose() {
465
+ if (this._isDisposed) {
466
+ return; // Already disposed, safe to return
467
+ }
468
+ // Notify waiting components that we're disposing
469
+ for (const waiter of this.waitingComponents) {
470
+ waiter.reject(new Error('HardwareContext disposed'));
471
+ }
472
+ this.waitingComponents.clear();
473
+ if (this._framesContext) {
474
+ this._framesContext.free();
475
+ this._framesContext = undefined;
476
+ }
477
+ this._deviceContext.free();
478
+ this._isDisposed = true;
479
+ }
480
+ /**
481
+ * Create hardware context from device type.
482
+ *
483
+ * Internal factory method using av_hwdevice_ctx_create().
484
+ *
485
+ * @param deviceType - AVHWDeviceType enum value
486
+ * @param deviceName - Optional device name/index
487
+ * @param options - Optional device options
488
+ *
489
+ * @returns HardwareContext or null if creation fails
490
+ */
491
+ static async createFromType(deviceType, deviceName, options) {
492
+ const device = new HardwareDeviceContext();
493
+ // Convert options to Dictionary if provided
494
+ let optionsDict = null;
495
+ if (options && Object.keys(options).length > 0) {
496
+ optionsDict = Dictionary.fromObject(options);
497
+ }
498
+ const ret = device.create(deviceType, deviceName ?? null, optionsDict);
499
+ // Clean up dictionary if used
500
+ if (optionsDict) {
501
+ optionsDict.free();
502
+ }
503
+ if (ret < 0) {
504
+ device.free();
505
+ return null;
506
+ }
507
+ return new HardwareContext(device, deviceType, deviceName);
508
+ }
509
+ /**
510
+ * Get platform-specific preference order for hardware types.
511
+ *
512
+ * Returns the optimal hardware types for the current platform.
513
+ *
514
+ * @returns Array of AVHWDeviceType values in preference order
515
+ */
516
+ static getPreferenceOrder() {
517
+ const platform = process.platform;
518
+ if (platform === 'darwin') {
519
+ // macOS: VideoToolbox is preferred
520
+ return [AV_HWDEVICE_TYPE_VIDEOTOOLBOX, AV_HWDEVICE_TYPE_VULKAN, AV_HWDEVICE_TYPE_OPENCL];
521
+ }
522
+ else if (platform === 'win32') {
523
+ // Windows: D3D12VA (newest), D3D11VA, DXVA2, QSV, CUDA
524
+ return [
525
+ AV_HWDEVICE_TYPE_D3D12VA,
526
+ AV_HWDEVICE_TYPE_D3D11VA,
527
+ AV_HWDEVICE_TYPE_DXVA2,
528
+ AV_HWDEVICE_TYPE_QSV,
529
+ AV_HWDEVICE_TYPE_CUDA,
530
+ AV_HWDEVICE_TYPE_VULKAN,
531
+ AV_HWDEVICE_TYPE_OPENCL,
532
+ ];
533
+ }
534
+ else {
535
+ // Linux: VAAPI, VDPAU, CUDA, Vulkan, DRM
536
+ return [AV_HWDEVICE_TYPE_VAAPI, AV_HWDEVICE_TYPE_VDPAU, AV_HWDEVICE_TYPE_CUDA, AV_HWDEVICE_TYPE_VULKAN, AV_HWDEVICE_TYPE_DRM, AV_HWDEVICE_TYPE_OPENCL];
537
+ }
538
+ }
539
+ /**
540
+ * Automatic cleanup when using 'using' statement.
541
+ *
542
+ * Implements the Disposable interface for automatic cleanup.
543
+ *
544
+ * Calls dispose() to free hardware resources.
545
+ *
546
+ * @example
547
+ * ```typescript
548
+ * {
549
+ * using hw = await HardwareContext.auto();
550
+ * // Use hardware context...
551
+ * } // Automatically disposed
552
+ * ```
553
+ */
554
+ [Symbol.dispose]() {
555
+ this.dispose();
556
+ }
557
+ }
558
+ //# sourceMappingURL=hardware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hardware.js","sourceRoot":"","sources":["../../src/api/hardware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,uCAAu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IACK,MAAM,CAAC,kBAAkB;QAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAElC,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC1B,mCAAmC;YACnC,OAAO,CAAC,6BAA6B,EAAE,uBAAuB,EAAE,uBAAuB,CAAC,CAAC;QAC3F,CAAC;aAAM,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;YAChC,uDAAuD;YACvD,OAAO;gBACL,wBAAwB;gBACxB,wBAAwB;gBACxB,sBAAsB;gBACtB,oBAAoB;gBACpB,qBAAqB;gBACrB,uBAAuB;gBACvB,uBAAuB;aACxB,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,yCAAyC;YACzC,OAAO,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,uBAAuB,CAAC,CAAC;QACzJ,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ export { IOStream } from './io-stream.js';
2
+ export { MediaInput } from './media-input.js';
3
+ export { MediaOutput } from './media-output.js';
4
+ export { Decoder } from './decoder.js';
5
+ export { Encoder } from './encoder.js';
6
+ export { HardwareContext } from './hardware.js';
7
+ export { FilterAPI } from './filter.js';
8
+ export { BitStreamFilterAPI } from './bitstream-filter.js';
9
+ export { pipeline } from './pipeline.js';
10
+ export * from './utilities/index.js';
11
+ export * from './utils.js';
12
+ export type * from './types.js';
@@ -0,0 +1,20 @@
1
+ // IOStream
2
+ export { IOStream } from './io-stream.js';
3
+ // MediaInput/MediaOutput
4
+ export { MediaInput } from './media-input.js';
5
+ export { MediaOutput } from './media-output.js';
6
+ // Decoder/Encoder
7
+ export { Decoder } from './decoder.js';
8
+ export { Encoder } from './encoder.js';
9
+ // Hardware
10
+ export { HardwareContext } from './hardware.js';
11
+ // Filter
12
+ export { FilterAPI } from './filter.js';
13
+ // BitStreamFilter
14
+ export { BitStreamFilterAPI } from './bitstream-filter.js';
15
+ // Pipeline
16
+ export { pipeline } from './pipeline.js';
17
+ // Utilities
18
+ export * from './utilities/index.js';
19
+ export * from './utils.js';
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,yBAAyB;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,kBAAkB;AAClB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,WAAW;AACX,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,SAAS;AACT,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,kBAAkB;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,WAAW;AACX,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,YAAY;AACZ,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC"}