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,492 @@
1
+ import { bindings } from './binding.js';
2
+ import { Rational } from './rational.js';
3
+ /**
4
+ * Codec (encoder/decoder) definition.
5
+ *
6
+ * Represents a codec implementation for encoding or decoding media.
7
+ * Provides codec information, capabilities, and supported formats.
8
+ * This is an immutable descriptor - actual encoding/decoding happens via CodecContext.
9
+ *
10
+ * Direct mapping to FFmpeg's AVCodec.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { Codec } from 'node-av';
15
+ * import { AV_CODEC_ID_H264 } from 'node-av/constants';
16
+ *
17
+ * // Find decoder by ID
18
+ * const h264Decoder = Codec.findDecoder(AV_CODEC_ID_H264);
19
+ * if (!h264Decoder) throw new Error('H264 decoder not found');
20
+ *
21
+ * // Find encoder by name
22
+ * const x264Encoder = Codec.findEncoderByName('libx264');
23
+ * if (!x264Encoder) throw new Error('x264 encoder not found');
24
+ *
25
+ * // Check codec capabilities
26
+ * console.log(`Codec: ${h264Decoder.name}`);
27
+ * console.log(`Long name: ${h264Decoder.longName}`);
28
+ * console.log(`Type: ${h264Decoder.type}`);
29
+ * console.log(`Is decoder: ${h264Decoder.isDecoder()}`);
30
+ *
31
+ * // Get supported formats
32
+ * const pixelFormats = h264Decoder.pixelFormats;
33
+ * console.log(`Supported pixel formats: ${pixelFormats}`);
34
+ *
35
+ * // Iterate through all codecs
36
+ * let iter = null;
37
+ * while (true) {
38
+ * const result = Codec.iterateCodecs(iter);
39
+ * if (!result) break;
40
+ * console.log(`Found codec: ${result.codec.name}`);
41
+ * iter = result.opaque;
42
+ * }
43
+ * ```
44
+ */
45
+ export class Codec {
46
+ native;
47
+ /**
48
+ * Constructor is internal - use static factory methods.
49
+ *
50
+ * Codecs are global immutable objects managed by FFmpeg.
51
+ * Use the static find methods to obtain codec instances.
52
+ *
53
+ * @internal
54
+ *
55
+ * @param native - Native AVCodec to wrap
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * import { Codec } from 'node-av';
60
+ * import { AV_CODEC_ID_H264 } from 'node-av/constants';
61
+ *
62
+ * // Don't use constructor directly
63
+ * // const codec = new Codec(); // Wrong
64
+ *
65
+ * // Use static factory methods instead
66
+ * const decoder = Codec.findDecoder(AV_CODEC_ID_H264); // Correct
67
+ * const encoder = Codec.findEncoderByName('libx264'); // Correct
68
+ * ```
69
+ */
70
+ constructor(native) {
71
+ this.native = native;
72
+ }
73
+ /**
74
+ * Create a Codec instance from a native codec object.
75
+ * @internal Used by the bindings layer
76
+ */
77
+ static fromNative(native) {
78
+ if (!native)
79
+ return null;
80
+ return new Codec(native);
81
+ }
82
+ /**
83
+ * Find a registered decoder with a matching codec ID.
84
+ *
85
+ * Searches for a decoder that can decode the specified codec format.
86
+ *
87
+ * Direct mapping to avcodec_find_decoder()
88
+ *
89
+ * @param id - AVCodecID of the requested decoder
90
+ *
91
+ * @returns Codec object or null if no decoder found
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * import { Codec } from 'node-av';
96
+ * import { AV_CODEC_ID_H264 } from 'node-av/constants';
97
+ *
98
+ * const decoder = Codec.findDecoder(AV_CODEC_ID_H264);
99
+ * if (!decoder) {
100
+ * throw new Error('H.264 decoder not available');
101
+ * }
102
+ * ```
103
+ *
104
+ * @see {@link findDecoderByName} To find by name
105
+ * @see {@link findEncoder} To find encoder
106
+ */
107
+ static findDecoder(id) {
108
+ const native = bindings.Codec.findDecoder(id);
109
+ return native ? new Codec(native) : null;
110
+ }
111
+ /**
112
+ * Find a registered decoder with the specified name.
113
+ *
114
+ * Searches for a decoder by its exact name.
115
+ * Useful for selecting specific decoder implementations.
116
+ *
117
+ * Direct mapping to avcodec_find_decoder_by_name()
118
+ *
119
+ * @param name - Name of the requested decoder
120
+ *
121
+ * @returns Codec object or null if no decoder found
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * import { Codec } from 'node-av';
126
+ *
127
+ * const decoder = Codec.findDecoderByName('h264');
128
+ * // Can also use specific implementations:
129
+ * const cudaDecoder = Codec.findDecoderByName('h264_cuvid'); // NVIDIA hardware decoder
130
+ * ```
131
+ *
132
+ * @see {@link findDecoder} To find by codec ID
133
+ */
134
+ static findDecoderByName(name) {
135
+ const native = bindings.Codec.findDecoderByName(name);
136
+ return native ? new Codec(native) : null;
137
+ }
138
+ /**
139
+ * Find a registered encoder with a matching codec ID.
140
+ *
141
+ * Searches for an encoder that can encode to the specified codec format.
142
+ *
143
+ * Direct mapping to avcodec_find_encoder()
144
+ *
145
+ * @param id - AVCodecID of the requested encoder
146
+ *
147
+ * @returns Codec object or null if no encoder found
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * import { Codec } from 'node-av';
152
+ * import { AV_CODEC_ID_H264 } from 'node-av/constants';
153
+ *
154
+ * const encoder = Codec.findEncoder(AV_CODEC_ID_H264);
155
+ * if (!encoder) {
156
+ * throw new Error('H.264 encoder not available');
157
+ * }
158
+ * ```
159
+ *
160
+ * @see {@link findEncoderByName} To find by name
161
+ * @see {@link findDecoder} To find decoder
162
+ */
163
+ static findEncoder(id) {
164
+ const native = bindings.Codec.findEncoder(id);
165
+ return native ? new Codec(native) : null;
166
+ }
167
+ /**
168
+ * Find a registered encoder with the specified name.
169
+ *
170
+ * Searches for an encoder by its exact name.
171
+ * Useful for selecting specific encoder implementations.
172
+ *
173
+ * Direct mapping to avcodec_find_encoder_by_name()
174
+ *
175
+ * @param name - Name of the requested encoder
176
+ *
177
+ * @returns Codec object or null if no encoder found
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * import { Codec } from 'node-av';
182
+ *
183
+ * // Find specific encoder implementation
184
+ * const x264 = Codec.findEncoderByName('libx264'); // Software H.264 encoder
185
+ * const nvenc = Codec.findEncoderByName('h264_nvenc'); // NVIDIA hardware encoder
186
+ * const vaapi = Codec.findEncoderByName('h264_vaapi'); // VAAPI hardware encoder
187
+ * ```
188
+ *
189
+ * @see {@link findEncoder} To find by codec ID
190
+ */
191
+ static findEncoderByName(name) {
192
+ const native = bindings.Codec.findEncoderByName(name);
193
+ return native ? new Codec(native) : null;
194
+ }
195
+ /**
196
+ * Get list of all available codecs.
197
+ *
198
+ * Returns all registered codecs in the system.
199
+ * Internally uses av_codec_iterate() to collect all codecs.
200
+ *
201
+ * @returns Array of all registered codecs
202
+ *
203
+ * @example
204
+ * ```typescript
205
+ * import { Codec } from 'node-av';
206
+ * import { AVMEDIA_TYPE_VIDEO } from 'node-av/constants';
207
+ *
208
+ * const codecs = Codec.getCodecList();
209
+ * const videoEncoders = codecs.filter(c =>
210
+ * c.type === AVMEDIA_TYPE_VIDEO && c.isEncoder()
211
+ * );
212
+ * console.log(`Found ${videoEncoders.length} video encoders`);
213
+ * ```
214
+ *
215
+ * @note This loads all codecs at once. For large codec lists,
216
+ * consider using iterateCodecs() instead.
217
+ *
218
+ * @see {@link iterateCodecs} For memory-efficient iteration
219
+ */
220
+ static getCodecList() {
221
+ const natives = bindings.Codec.getCodecList();
222
+ return natives.map((n) => new Codec(n));
223
+ }
224
+ /**
225
+ * Iterate through codecs one by one.
226
+ *
227
+ * Memory-efficient codec iteration.
228
+ * Processes codecs one at a time instead of loading all at once.
229
+ *
230
+ * Direct mapping to av_codec_iterate()
231
+ *
232
+ * @param opaque - Iterator state (null to start, or value from previous call)
233
+ *
234
+ * @returns Object with codec and next iterator state, or null when done
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * import { Codec } from 'node-av';
239
+ * import { AVMEDIA_TYPE_VIDEO } from 'node-av/constants';
240
+ *
241
+ * let opaque = null;
242
+ * while (true) {
243
+ * const result = Codec.iterateCodecs(opaque);
244
+ * if (!result) break;
245
+ *
246
+ * const codec = result.codec;
247
+ * if (codec.type === AVMEDIA_TYPE_VIDEO && codec.isEncoder()) {
248
+ * console.log(`Video encoder: ${codec.name}`);
249
+ * }
250
+ *
251
+ * opaque = result.opaque;
252
+ * }
253
+ * ```
254
+ *
255
+ * @see {@link getCodecList} To get all codecs at once
256
+ */
257
+ static iterateCodecs(opaque = null) {
258
+ const result = bindings.Codec.iterateCodecs(opaque);
259
+ if (!result)
260
+ return null;
261
+ return {
262
+ codec: new Codec(result.codec),
263
+ opaque: result.opaque,
264
+ };
265
+ }
266
+ /**
267
+ * Short name of the codec.
268
+ *
269
+ * Direct mapping to AVCodec->name
270
+ * Typically matches the name of the codec specification.
271
+ * For example: "h264", "aac", "vp9", "opus"
272
+ */
273
+ get name() {
274
+ return this.native.name;
275
+ }
276
+ /**
277
+ * Descriptive name for the codec.
278
+ *
279
+ * Direct mapping to AVCodec->long_name
280
+ * More human-readable than name.
281
+ * For example: "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"
282
+ */
283
+ get longName() {
284
+ return this.native.longName;
285
+ }
286
+ /**
287
+ * Media type handled by this codec.
288
+ *
289
+ * Direct mapping to AVCodec->type
290
+ * AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_SUBTITLE, etc.
291
+ */
292
+ get type() {
293
+ return this.native.type;
294
+ }
295
+ /**
296
+ * Codec ID.
297
+ *
298
+ * Direct mapping to AVCodec->id
299
+ * Unique identifier for this codec type (AV_CODEC_ID_H264, AV_CODEC_ID_AAC, etc.)
300
+ */
301
+ get id() {
302
+ return this.native.id;
303
+ }
304
+ /**
305
+ * Codec capabilities.
306
+ *
307
+ * Direct mapping to AVCodec->capabilities
308
+ * Bitfield of AV_CODEC_CAP_* flags describing codec features.
309
+ */
310
+ get capabilities() {
311
+ return this.native.capabilities;
312
+ }
313
+ /**
314
+ * Maximum lowres value supported by the decoder.
315
+ *
316
+ * Lowres decoding allows decoding at reduced resolution for faster preview.
317
+ * 0 means lowres decoding is not supported.
318
+ * 1 means 1/2 resolution is supported.
319
+ * 2 means 1/4 resolution is supported.
320
+ * 3 means 1/8 resolution is supported.
321
+ * @readonly
322
+ */
323
+ get maxLowres() {
324
+ return this.native.maxLowres;
325
+ }
326
+ /**
327
+ * Array of supported codec profiles.
328
+ *
329
+ * Profiles define subsets of codec features.
330
+ * For example, H.264 has Baseline, Main, High profiles.
331
+ * null if codec doesn't support profiles or none are defined.
332
+ * @readonly
333
+ */
334
+ get profiles() {
335
+ return this.native.profiles;
336
+ }
337
+ /**
338
+ * Group name of the codec implementation.
339
+ *
340
+ * This is a short symbolic name of the wrapper backing this codec.
341
+ * For example "lavc" for internal codecs, "libopenh264" for OpenH264 wrapper.
342
+ * null if codec is not wrapped.
343
+ * @readonly
344
+ */
345
+ get wrapper() {
346
+ return this.native.wrapper;
347
+ }
348
+ /**
349
+ * Supported framerates (video only).
350
+ *
351
+ * Terminated by {0,0}. null if any framerate is supported.
352
+ * Some codecs like MPEG-1/2 only support specific framerates.
353
+ * @readonly
354
+ */
355
+ get supportedFramerates() {
356
+ const rates = this.native.supportedFramerates;
357
+ if (!rates)
358
+ return null;
359
+ return rates.map((r) => new Rational(r.num, r.den));
360
+ }
361
+ /**
362
+ * Array of supported pixel formats (video only).
363
+ *
364
+ * Terminated by AV_PIX_FMT_NONE. null if unknown.
365
+ * Lists all pixel formats this codec can encode/decode.
366
+ * @readonly
367
+ */
368
+ get pixelFormats() {
369
+ return this.native.pixelFormats;
370
+ }
371
+ /**
372
+ * Supported sample rates (audio only).
373
+ *
374
+ * Terminated by 0. null if any sample rate is supported.
375
+ * Common rates: 8000, 16000, 22050, 44100, 48000, 96000, 192000 Hz.
376
+ * @readonly
377
+ */
378
+ get supportedSamplerates() {
379
+ return this.native.supportedSamplerates;
380
+ }
381
+ /**
382
+ * Array of supported sample formats (audio only).
383
+ *
384
+ * Terminated by AV_SAMPLE_FMT_NONE. null if unknown.
385
+ * Lists all sample formats this codec can encode/decode.
386
+ * Common formats: S16, S32, FLT, DBL (planar and interleaved variants).
387
+ * @readonly
388
+ */
389
+ get sampleFormats() {
390
+ return this.native.sampleFormats;
391
+ }
392
+ /**
393
+ * Array of supported channel layouts (audio only).
394
+ *
395
+ * Lists all channel configurations this codec supports.
396
+ * Common layouts: mono, stereo, 5.1, 7.1.
397
+ * null if unknown or all layouts are supported.
398
+ * @readonly
399
+ */
400
+ get channelLayouts() {
401
+ return this.native.channelLayouts;
402
+ }
403
+ /**
404
+ * Check if the codec is an encoder.
405
+ *
406
+ * Direct mapping to av_codec_is_encoder()
407
+ *
408
+ * @returns true if the codec is an encoder, false otherwise
409
+ *
410
+ * @example
411
+ * ```typescript
412
+ * const codec = Codec.findEncoderByName('libx264');
413
+ * if (codec && codec.isEncoder()) {
414
+ * console.log('Found H.264 encoder');
415
+ * }
416
+ * ```
417
+ */
418
+ isEncoder() {
419
+ return this.native.isEncoder();
420
+ }
421
+ /**
422
+ * Check if the codec is a decoder.
423
+ *
424
+ * Direct mapping to av_codec_is_decoder()
425
+ *
426
+ * @returns true if the codec is a decoder, false otherwise
427
+ *
428
+ * @example
429
+ * ```typescript
430
+ * const codec = Codec.findDecoder(AV_CODEC_ID_H264);
431
+ * if (codec && codec.isDecoder()) {
432
+ * console.log('Found H.264 decoder');
433
+ * }
434
+ * ```
435
+ */
436
+ isDecoder() {
437
+ return this.native.isDecoder();
438
+ }
439
+ /**
440
+ * Check if the codec is experimental.
441
+ *
442
+ * Experimental codecs require explicit allowance to use.
443
+ * You must set strict_std_compliance to FF_COMPLIANCE_EXPERIMENTAL
444
+ * or lower in the codec context to use experimental codecs.
445
+ *
446
+ * @returns true if the codec is experimental, false otherwise
447
+ *
448
+ * @example
449
+ * ```typescript
450
+ * const codec = Codec.findEncoderByName('some_experimental_codec');
451
+ * if (codec && codec.isExperimental()) {
452
+ * console.warn('This codec is experimental and may not be stable');
453
+ * // codecContext.strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
454
+ * }
455
+ * ```
456
+ */
457
+ isExperimental() {
458
+ return this.native.isExperimental();
459
+ }
460
+ /**
461
+ * Get hardware configuration at specified index.
462
+ *
463
+ * Direct mapping to avcodec_get_hw_config()
464
+ *
465
+ * @param index - Configuration index (0-based)
466
+ * @returns Hardware configuration or null if not available
467
+ *
468
+ * @example
469
+ * ```typescript
470
+ * const codec = Codec.findDecoder(AV_CODEC_ID_H264);
471
+ * for (let i = 0; ; i++) {
472
+ * const config = codec.getHwConfig(i);
473
+ * if (!config) break;
474
+ *
475
+ * if (config.methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) {
476
+ * console.log(`Supports device type: ${config.deviceType}`);
477
+ * }
478
+ * }
479
+ * ```
480
+ */
481
+ getHwConfig(index) {
482
+ return this.native.getHwConfig(index);
483
+ }
484
+ /**
485
+ * Get the native codec object for use with C++ bindings
486
+ * @internal
487
+ */
488
+ getNative() {
489
+ return this.native;
490
+ }
491
+ }
492
+ //# sourceMappingURL=codec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/lib/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAMzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,OAAO,KAAK;IACR,MAAM,CAAc;IAE5B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,YAAY,MAAmB;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,MAA0B;QAC1C,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACzB,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,MAAM,CAAC,WAAW,CAAC,EAAa;QAC9B,M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