node-av 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +51 -59
  2. package/dist/api/bitstream-filter.d.ts +183 -123
  3. package/dist/api/bitstream-filter.js +185 -127
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +282 -130
  6. package/dist/api/decoder.js +290 -142
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +249 -160
  9. package/dist/api/encoder.js +276 -207
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +1944 -96
  12. package/dist/api/filter-presets.js +2059 -105
  13. package/dist/api/filter-presets.js.map +1 -1
  14. package/dist/api/filter.d.ts +264 -200
  15. package/dist/api/filter.js +269 -231
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +246 -117
  18. package/dist/api/hardware.js +440 -217
  19. package/dist/api/hardware.js.map +1 -1
  20. package/dist/api/index.d.ts +3 -3
  21. package/dist/api/index.js +1 -1
  22. package/dist/api/index.js.map +1 -1
  23. package/dist/api/io-stream.d.ts +65 -55
  24. package/dist/api/io-stream.js +43 -40
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +242 -139
  27. package/dist/api/media-input.js +205 -103
  28. package/dist/api/media-input.js.map +1 -1
  29. package/dist/api/media-output.d.ts +208 -126
  30. package/dist/api/media-output.js +212 -126
  31. package/dist/api/media-output.js.map +1 -1
  32. package/dist/api/pipeline.d.ts +361 -38
  33. package/dist/api/pipeline.js +255 -14
  34. package/dist/api/pipeline.js.map +1 -1
  35. package/dist/api/types.d.ts +26 -187
  36. package/dist/api/utilities/audio-sample.d.ts +0 -8
  37. package/dist/api/utilities/audio-sample.js +0 -8
  38. package/dist/api/utilities/audio-sample.js.map +1 -1
  39. package/dist/api/utilities/channel-layout.d.ts +0 -8
  40. package/dist/api/utilities/channel-layout.js +0 -8
  41. package/dist/api/utilities/channel-layout.js.map +1 -1
  42. package/dist/api/utilities/image.d.ts +0 -8
  43. package/dist/api/utilities/image.js +0 -8
  44. package/dist/api/utilities/image.js.map +1 -1
  45. package/dist/api/utilities/index.d.ts +3 -3
  46. package/dist/api/utilities/index.js +3 -3
  47. package/dist/api/utilities/index.js.map +1 -1
  48. package/dist/api/utilities/media-type.d.ts +1 -9
  49. package/dist/api/utilities/media-type.js +1 -9
  50. package/dist/api/utilities/media-type.js.map +1 -1
  51. package/dist/api/utilities/pixel-format.d.ts +1 -9
  52. package/dist/api/utilities/pixel-format.js +1 -9
  53. package/dist/api/utilities/pixel-format.js.map +1 -1
  54. package/dist/api/utilities/sample-format.d.ts +1 -9
  55. package/dist/api/utilities/sample-format.js +1 -9
  56. package/dist/api/utilities/sample-format.js.map +1 -1
  57. package/dist/api/utilities/streaming.d.ts +0 -8
  58. package/dist/api/utilities/streaming.js +0 -8
  59. package/dist/api/utilities/streaming.js.map +1 -1
  60. package/dist/api/utilities/timestamp.d.ts +0 -8
  61. package/dist/api/utilities/timestamp.js +0 -8
  62. package/dist/api/utilities/timestamp.js.map +1 -1
  63. package/dist/api/utils.d.ts +1 -2
  64. package/dist/api/utils.js +11 -0
  65. package/dist/api/utils.js.map +1 -1
  66. package/dist/constants/constants.d.ts +1 -1
  67. package/dist/constants/constants.js +2 -0
  68. package/dist/constants/constants.js.map +1 -1
  69. package/dist/lib/audio-fifo.d.ts +127 -170
  70. package/dist/lib/audio-fifo.js +130 -173
  71. package/dist/lib/audio-fifo.js.map +1 -1
  72. package/dist/lib/binding.d.ts +1 -0
  73. package/dist/lib/binding.js +7 -0
  74. package/dist/lib/binding.js.map +1 -1
  75. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  76. package/dist/lib/bitstream-filter-context.js +139 -188
  77. package/dist/lib/bitstream-filter-context.js.map +1 -1
  78. package/dist/lib/bitstream-filter.d.ts +68 -54
  79. package/dist/lib/bitstream-filter.js +68 -54
  80. package/dist/lib/bitstream-filter.js.map +1 -1
  81. package/dist/lib/codec-context.d.ts +316 -380
  82. package/dist/lib/codec-context.js +316 -381
  83. package/dist/lib/codec-context.js.map +1 -1
  84. package/dist/lib/codec-parameters.d.ts +160 -170
  85. package/dist/lib/codec-parameters.js +162 -172
  86. package/dist/lib/codec-parameters.js.map +1 -1
  87. package/dist/lib/codec-parser.d.ts +91 -104
  88. package/dist/lib/codec-parser.js +92 -103
  89. package/dist/lib/codec-parser.js.map +1 -1
  90. package/dist/lib/codec.d.ts +266 -283
  91. package/dist/lib/codec.js +270 -287
  92. package/dist/lib/codec.js.map +1 -1
  93. package/dist/lib/dictionary.d.ts +149 -203
  94. package/dist/lib/dictionary.js +158 -212
  95. package/dist/lib/dictionary.js.map +1 -1
  96. package/dist/lib/error.d.ts +96 -130
  97. package/dist/lib/error.js +98 -128
  98. package/dist/lib/error.js.map +1 -1
  99. package/dist/lib/filter-context.d.ts +284 -218
  100. package/dist/lib/filter-context.js +290 -227
  101. package/dist/lib/filter-context.js.map +1 -1
  102. package/dist/lib/filter-graph.d.ts +251 -292
  103. package/dist/lib/filter-graph.js +253 -294
  104. package/dist/lib/filter-graph.js.map +1 -1
  105. package/dist/lib/filter-inout.d.ts +87 -95
  106. package/dist/lib/filter-inout.js +87 -95
  107. package/dist/lib/filter-inout.js.map +1 -1
  108. package/dist/lib/filter.d.ts +93 -111
  109. package/dist/lib/filter.js +93 -111
  110. package/dist/lib/filter.js.map +1 -1
  111. package/dist/lib/format-context.d.ts +320 -428
  112. package/dist/lib/format-context.js +313 -385
  113. package/dist/lib/format-context.js.map +1 -1
  114. package/dist/lib/frame.d.ts +262 -405
  115. package/dist/lib/frame.js +263 -408
  116. package/dist/lib/frame.js.map +1 -1
  117. package/dist/lib/hardware-device-context.d.ts +149 -203
  118. package/dist/lib/hardware-device-context.js +149 -203
  119. package/dist/lib/hardware-device-context.js.map +1 -1
  120. package/dist/lib/hardware-frames-context.d.ts +170 -180
  121. package/dist/lib/hardware-frames-context.js +171 -181
  122. package/dist/lib/hardware-frames-context.js.map +1 -1
  123. package/dist/lib/index.d.ts +3 -2
  124. package/dist/lib/index.js +3 -3
  125. package/dist/lib/index.js.map +1 -1
  126. package/dist/lib/input-format.d.ts +89 -117
  127. package/dist/lib/input-format.js +89 -117
  128. package/dist/lib/input-format.js.map +1 -1
  129. package/dist/lib/io-context.d.ts +209 -241
  130. package/dist/lib/io-context.js +220 -252
  131. package/dist/lib/io-context.js.map +1 -1
  132. package/dist/lib/log.d.ts +85 -119
  133. package/dist/lib/log.js +85 -122
  134. package/dist/lib/log.js.map +1 -1
  135. package/dist/lib/native-types.d.ts +118 -106
  136. package/dist/lib/native-types.js +0 -7
  137. package/dist/lib/native-types.js.map +1 -1
  138. package/dist/lib/option.d.ts +437 -218
  139. package/dist/lib/option.js +462 -226
  140. package/dist/lib/option.js.map +1 -1
  141. package/dist/lib/output-format.d.ts +77 -101
  142. package/dist/lib/output-format.js +77 -101
  143. package/dist/lib/output-format.js.map +1 -1
  144. package/dist/lib/packet.d.ts +172 -240
  145. package/dist/lib/packet.js +172 -241
  146. package/dist/lib/packet.js.map +1 -1
  147. package/dist/lib/rational.d.ts +0 -2
  148. package/dist/lib/rational.js +0 -2
  149. package/dist/lib/rational.js.map +1 -1
  150. package/dist/lib/software-resample-context.d.ts +241 -325
  151. package/dist/lib/software-resample-context.js +242 -326
  152. package/dist/lib/software-resample-context.js.map +1 -1
  153. package/dist/lib/software-scale-context.d.ts +129 -173
  154. package/dist/lib/software-scale-context.js +131 -175
  155. package/dist/lib/software-scale-context.js.map +1 -1
  156. package/dist/lib/stream.d.ts +87 -197
  157. package/dist/lib/stream.js +87 -197
  158. package/dist/lib/stream.js.map +1 -1
  159. package/dist/lib/utilities.d.ts +435 -181
  160. package/dist/lib/utilities.js +438 -182
  161. package/dist/lib/utilities.js.map +1 -1
  162. package/install/check.js +0 -1
  163. package/install/ffmpeg.js +0 -11
  164. package/package.json +25 -18
  165. package/release_notes.md +24 -59
  166. package/CHANGELOG.md +0 -8
@@ -5,174 +5,157 @@ import type { FFEncoderCodec } from '../constants/encoders.js';
5
5
  import type { NativeCodec, NativeWrapper } from './native-types.js';
6
6
  import type { ChannelLayout, CodecProfile } from './types.js';
7
7
  /**
8
- * Codec (encoder/decoder) definition.
8
+ * Codec descriptor for audio/video encoding and decoding.
9
9
  *
10
- * Represents a codec implementation for encoding or decoding media.
11
- * Provides codec information, capabilities, and supported formats.
12
- * This is an immutable descriptor - actual encoding/decoding happens via CodecContext.
10
+ * Represents an encoder or decoder implementation that can process media data.
11
+ * Contains codec capabilities, supported formats, and hardware acceleration information.
12
+ * Used to create codec contexts for actual encoding/decoding operations.
13
+ * Supports both software and hardware-accelerated codecs.
13
14
  *
14
15
  * Direct mapping to FFmpeg's AVCodec.
15
16
  *
16
17
  * @example
17
18
  * ```typescript
18
- * import { Codec } from 'node-av';
19
- * import { AV_CODEC_ID_H264 } from 'node-av/constants';
19
+ * import { Codec, FFmpegError } from 'node-av';
20
+ * import { AV_CODEC_ID_H264, FF_ENCODER_LIBX264 } from 'node-av/constants';
20
21
  *
21
22
  * // Find decoder by ID
22
- * const h264Decoder = Codec.findDecoder(AV_CODEC_ID_H264);
23
- * if (!h264Decoder) throw new Error('H264 decoder not found');
23
+ * const decoder = Codec.findDecoder(AV_CODEC_ID_H264);
24
+ * if (!decoder) {
25
+ * throw new Error('H.264 decoder not available');
26
+ * }
24
27
  *
25
28
  * // Find encoder by name
26
- * const x264Encoder = Codec.findEncoderByName('libx264');
27
- * if (!x264Encoder) throw new Error('x264 encoder not found');
28
- *
29
- * // Check codec capabilities
30
- * console.log(`Codec: ${h264Decoder.name}`);
31
- * console.log(`Long name: ${h264Decoder.longName}`);
32
- * console.log(`Type: ${h264Decoder.type}`);
33
- * console.log(`Is decoder: ${h264Decoder.isDecoder()}`);
29
+ * const encoder = Codec.findEncoderByName(FF_ENCODER_LIBX264);
30
+ * if (!encoder) {
31
+ * throw new Error('libx264 encoder not available');
32
+ * }
34
33
  *
35
- * // Get supported formats
36
- * const pixelFormats = h264Decoder.pixelFormats;
37
- * console.log(`Supported pixel formats: ${pixelFormats}`);
34
+ * // Check capabilities
35
+ * console.log(`Codec: ${decoder.name}`);
36
+ * console.log(`Type: ${decoder.type}`);
37
+ * console.log(`Hardware: ${decoder.hasHardwareAcceleration()}`);
38
38
  *
39
- * // Iterate through all codecs
40
- * let iter = null;
41
- * while (true) {
42
- * const result = Codec.iterateCodecs(iter);
43
- * if (!result) break;
44
- * console.log(`Found codec: ${result.codec.name}`);
45
- * iter = result.opaque;
39
+ * // Get supported pixel formats
40
+ * const formats = decoder.pixelFormats;
41
+ * if (formats) {
42
+ * console.log(`Supported formats: ${formats.join(', ')}`);
46
43
  * }
47
44
  * ```
45
+ *
46
+ * @see [AVCodec](https://ffmpeg.org/doxygen/trunk/structAVCodec.html) - FFmpeg Doxygen
47
+ * @see {@link CodecContext} For encoding/decoding operations
48
48
  */
49
49
  export declare class Codec implements NativeWrapper<NativeCodec> {
50
50
  private native;
51
51
  /**
52
- * Constructor is internal - use static factory methods.
53
- *
54
- * Codecs are global immutable objects managed by FFmpeg.
55
- * Use the static find methods to obtain codec instances.
56
- *
52
+ * @param native - The native codec instance
57
53
  * @internal
58
- *
59
- * @param native - Native AVCodec to wrap
60
- *
61
- * @example
62
- * ```typescript
63
- * import { Codec } from 'node-av';
64
- * import { AV_CODEC_ID_H264 } from 'node-av/constants';
65
- *
66
- * // Don't use constructor directly
67
- * // const codec = new Codec(); // Wrong
68
- *
69
- * // Use static factory methods instead
70
- * const decoder = Codec.findDecoder(AV_CODEC_ID_H264); // Correct
71
- * const encoder = Codec.findEncoderByName('libx264'); // Correct
72
- * ```
73
54
  */
74
55
  constructor(native: NativeCodec);
75
56
  /**
76
- * Create a Codec instance from a native codec object.
77
- * @internal Used by the bindings layer
78
- */
79
- static fromNative(native: NativeCodec | null): Codec | null;
80
- /**
81
- * Find a registered decoder with a matching codec ID.
57
+ * Find a decoder by codec ID.
82
58
  *
83
59
  * Searches for a decoder that can decode the specified codec format.
84
60
  *
85
- * Direct mapping to avcodec_find_decoder()
86
- *
87
- * @param id - AVCodecID of the requested decoder
61
+ * Direct mapping to avcodec_find_decoder().
88
62
  *
89
- * @returns Codec object or null if no decoder found
63
+ * @param id - Codec ID to search for
64
+ * @returns Decoder if found, null otherwise
90
65
  *
91
66
  * @example
92
67
  * ```typescript
93
- * import { Codec } from 'node-av';
94
- * import { AV_CODEC_ID_H264 } from 'node-av/constants';
68
+ * import { AV_CODEC_ID_H264, AV_CODEC_ID_AAC } from 'node-av/constants';
95
69
  *
96
- * const decoder = Codec.findDecoder(AV_CODEC_ID_H264);
97
- * if (!decoder) {
98
- * throw new Error('H.264 decoder not available');
70
+ * // Find H.264 video decoder
71
+ * const h264 = Codec.findDecoder(AV_CODEC_ID_H264);
72
+ * if (h264) {
73
+ * console.log(`Found: ${h264.name}`);
99
74
  * }
75
+ *
76
+ * // Find AAC audio decoder
77
+ * const aac = Codec.findDecoder(AV_CODEC_ID_AAC);
100
78
  * ```
101
79
  *
102
80
  * @see {@link findDecoderByName} To find by name
103
- * @see {@link findEncoder} To find encoder
81
+ * @see {@link findEncoder} To find encoders
104
82
  */
105
83
  static findDecoder(id: AVCodecID): Codec | null;
106
84
  /**
107
- * Find a registered decoder with the specified name.
85
+ * Find a decoder by name.
108
86
  *
109
- * Searches for a decoder by its exact name.
110
- * Useful for selecting specific decoder implementations.
87
+ * Searches for a specific decoder implementation by name.
88
+ * Useful when multiple decoders exist for the same codec.
111
89
  *
112
- * Direct mapping to avcodec_find_decoder_by_name()
90
+ * Direct mapping to avcodec_find_decoder_by_name().
113
91
  *
114
- * @param name - Name of the requested decoder
115
- *
116
- * @returns Codec object or null if no decoder found
92
+ * @param name - Decoder name
93
+ * @returns Decoder if found, null otherwise
117
94
  *
118
95
  * @example
119
96
  * ```typescript
120
- * import { Codec } from 'node-av';
97
+ * // Find specific H.264 decoder
98
+ * const decoder = Codec.findDecoderByName('h264_cuvid');
99
+ * if (decoder) {
100
+ * console.log('Found NVIDIA hardware decoder');
101
+ * }
121
102
  *
122
- * const decoder = Codec.findDecoderByName('h264');
123
- * // Can also use specific implementations:
124
- * const cudaDecoder = Codec.findDecoderByName('h264_cuvid'); // NVIDIA hardware decoder
103
+ * // Find software decoder
104
+ * const sw = Codec.findDecoderByName('h264');
125
105
  * ```
126
106
  *
127
107
  * @see {@link findDecoder} To find by codec ID
128
108
  */
129
109
  static findDecoderByName(name: FFDecoderCodec): Codec | null;
130
110
  /**
131
- * Find a registered encoder with a matching codec ID.
111
+ * Find an encoder by codec ID.
132
112
  *
133
113
  * Searches for an encoder that can encode to the specified codec format.
134
114
  *
135
- * Direct mapping to avcodec_find_encoder()
115
+ * Direct mapping to avcodec_find_encoder().
136
116
  *
137
- * @param id - AVCodecID of the requested encoder
138
- *
139
- * @returns Codec object or null if no encoder found
117
+ * @param id - Codec ID to search for
118
+ * @returns Encoder if found, null otherwise
140
119
  *
141
120
  * @example
142
121
  * ```typescript
143
- * import { Codec } from 'node-av';
144
- * import { AV_CODEC_ID_H264 } from 'node-av/constants';
122
+ * import { AV_CODEC_ID_H264, AV_CODEC_ID_AAC } from 'node-av/constants';
145
123
  *
146
- * const encoder = Codec.findEncoder(AV_CODEC_ID_H264);
147
- * if (!encoder) {
148
- * throw new Error('H.264 encoder not available');
124
+ * // Find H.264 video encoder
125
+ * const h264 = Codec.findEncoder(AV_CODEC_ID_H264);
126
+ * if (h264) {
127
+ * console.log(`Found: ${h264.name}`);
149
128
  * }
129
+ *
130
+ * // Find AAC audio encoder
131
+ * const aac = Codec.findEncoder(AV_CODEC_ID_AAC);
150
132
  * ```
151
133
  *
152
134
  * @see {@link findEncoderByName} To find by name
153
- * @see {@link findDecoder} To find decoder
135
+ * @see {@link findDecoder} To find decoders
154
136
  */
155
137
  static findEncoder(id: AVCodecID): Codec | null;
156
138
  /**
157
- * Find a registered encoder with the specified name.
158
- *
159
- * Searches for an encoder by its exact name.
160
- * Useful for selecting specific encoder implementations.
139
+ * Find an encoder by name.
161
140
  *
162
- * Direct mapping to avcodec_find_encoder_by_name()
141
+ * Searches for a specific encoder implementation by name.
142
+ * Useful when multiple encoders exist for the same codec.
163
143
  *
164
- * @param name - Name of the requested encoder
144
+ * Direct mapping to avcodec_find_encoder_by_name().
165
145
  *
166
- * @returns Codec object or null if no encoder found
146
+ * @param name - Encoder name
147
+ * @returns Encoder if found, null otherwise
167
148
  *
168
149
  * @example
169
150
  * ```typescript
170
- * import { Codec } from 'node-av';
151
+ * // Find specific H.264 encoder
152
+ * const x264 = Codec.findEncoderByName(FF_ENCODER_LIBX264);
153
+ * if (x264) {
154
+ * console.log('Found x264 encoder');
155
+ * }
171
156
  *
172
- * // Find specific encoder implementation
173
- * const x264 = Codec.findEncoderByName('libx264'); // Software H.264 encoder
174
- * const nvenc = Codec.findEncoderByName('h264_nvenc'); // NVIDIA hardware encoder
175
- * const vaapi = Codec.findEncoderByName('h264_vaapi'); // VAAPI hardware encoder
157
+ * // Find hardware encoder
158
+ * const nvenc = Codec.findEncoderByName('h264_nvenc');
176
159
  * ```
177
160
  *
178
161
  * @see {@link findEncoder} To find by codec ID
@@ -181,369 +164,357 @@ export declare class Codec implements NativeWrapper<NativeCodec> {
181
164
  /**
182
165
  * Get list of all available codecs.
183
166
  *
184
- * Returns all registered codecs in the system.
185
- * Internally uses av_codec_iterate() to collect all codecs.
167
+ * Returns all registered codecs (both encoders and decoders).
186
168
  *
187
- * @returns Array of all registered codecs
169
+ * @returns Array of all available codecs
188
170
  *
189
171
  * @example
190
172
  * ```typescript
191
- * import { Codec } from 'node-av';
192
- * import { AVMEDIA_TYPE_VIDEO } from 'node-av/constants';
193
- *
173
+ * // List all codecs
194
174
  * const codecs = Codec.getCodecList();
195
- * const videoEncoders = codecs.filter(c =>
196
- * c.type === AVMEDIA_TYPE_VIDEO && c.isEncoder()
197
- * );
198
- * console.log(`Found ${videoEncoders.length} video encoders`);
199
- * ```
175
+ * console.log(`Total codecs: ${codecs.length}`);
176
+ *
177
+ * // Filter encoders
178
+ * const encoders = codecs.filter(c => c.isEncoder());
179
+ * console.log(`Encoders: ${encoders.length}`);
200
180
  *
201
- * @note This loads all codecs at once. For large codec lists,
202
- * consider using iterateCodecs() instead.
181
+ * // Filter hardware codecs
182
+ * const hw = codecs.filter(c => c.hasHardwareAcceleration());
183
+ * console.log(`Hardware codecs: ${hw.length}`);
184
+ * ```
203
185
  *
204
186
  * @see {@link iterateCodecs} For memory-efficient iteration
205
187
  */
206
188
  static getCodecList(): Codec[];
207
189
  /**
208
- * Iterate through codecs one by one.
190
+ * Iterate through available codecs.
209
191
  *
210
- * Memory-efficient codec iteration.
211
- * Processes codecs one at a time instead of loading all at once.
192
+ * Memory-efficient way to iterate through all codecs.
193
+ * Uses an opaque pointer to track iteration state.
212
194
  *
213
- * Direct mapping to av_codec_iterate()
195
+ * Direct mapping to av_codec_iterate().
214
196
  *
215
- * @param opaque - Iterator state (null to start, or value from previous call)
216
- *
217
- * @returns Object with codec and next iterator state, or null when done
197
+ * @param opaque - Iteration state (null to start)
198
+ * @returns Next codec and state, or null when done
218
199
  *
219
200
  * @example
220
201
  * ```typescript
221
- * import { Codec } from 'node-av';
222
- * import { AVMEDIA_TYPE_VIDEO } from 'node-av/constants';
223
- *
224
- * let opaque = null;
225
- * while (true) {
226
- * const result = Codec.iterateCodecs(opaque);
227
- * if (!result) break;
228
- *
229
- * const codec = result.codec;
230
- * if (codec.type === AVMEDIA_TYPE_VIDEO && codec.isEncoder()) {
231
- * console.log(`Video encoder: ${codec.name}`);
232
- * }
233
- *
234
- * opaque = result.opaque;
202
+ * // Iterate all codecs
203
+ * let iter = null;
204
+ * let result;
205
+ * while ((result = Codec.iterateCodecs(iter))) {
206
+ * console.log(`Codec: ${result.codec.name}`);
207
+ * iter = result.opaque;
235
208
  * }
236
209
  * ```
237
210
  *
238
- * @see {@link getCodecList} To get all codecs at once
211
+ * @see {@link getCodecList} For simple array access
239
212
  */
240
213
  static iterateCodecs(opaque?: bigint | null): {
241
214
  codec: Codec;
242
215
  opaque: bigint;
243
216
  } | null;
244
217
  /**
245
- * Short name of the codec.
218
+ * Codec name.
246
219
  *
247
- * Direct mapping to AVCodec->name
248
- * Typically matches the name of the codec specification.
249
- * For example: "h264", "aac", "vp9", "opus"
220
+ * Short name identifier for the codec (e.g., 'h264', 'aac').
221
+ *
222
+ * Direct mapping to AVCodec->name.
250
223
  */
251
224
  get name(): string | null;
252
225
  /**
253
- * Descriptive name for the codec.
226
+ * Codec long name.
227
+ *
228
+ * Human-readable description of the codec.
254
229
  *
255
- * Direct mapping to AVCodec->long_name
256
- * More human-readable than name.
257
- * For example: "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"
230
+ * Direct mapping to AVCodec->long_name.
258
231
  */
259
232
  get longName(): string | null;
260
233
  /**
261
- * Media type handled by this codec.
234
+ * Media type.
262
235
  *
263
- * Direct mapping to AVCodec->type
264
- * AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_SUBTITLE, etc.
236
+ * Type of media this codec processes (video, audio, subtitle, etc.).
237
+ *
238
+ * Direct mapping to AVCodec->type.
265
239
  */
266
240
  get type(): AVMediaType;
267
241
  /**
268
242
  * Codec ID.
269
243
  *
270
- * Direct mapping to AVCodec->id
271
- * Unique identifier for this codec type (AV_CODEC_ID_H264, AV_CODEC_ID_AAC, etc.)
244
+ * Unique identifier for the codec format.
245
+ *
246
+ * Direct mapping to AVCodec->id.
272
247
  */
273
248
  get id(): AVCodecID;
274
249
  /**
275
250
  * Codec capabilities.
276
251
  *
277
- * Direct mapping to AVCodec->capabilities
278
- * Bitfield of AV_CODEC_CAP_* flags describing codec features.
252
+ * Bitfield of AV_CODEC_CAP_* flags indicating codec features.
253
+ *
254
+ * Direct mapping to AVCodec->capabilities.
279
255
  */
280
256
  get capabilities(): AVCodecCap;
281
257
  /**
282
- * Maximum lowres value supported by the decoder.
258
+ * Maximum lowres value.
259
+ *
260
+ * Maximum value for lowres decoding (0 = no lowres support).
283
261
  *
284
- * Lowres decoding allows decoding at reduced resolution for faster preview.
285
- * 0 means lowres decoding is not supported.
286
- * 1 means 1/2 resolution is supported.
287
- * 2 means 1/4 resolution is supported.
288
- * 3 means 1/8 resolution is supported.
289
- * @readonly
262
+ * Direct mapping to AVCodec->max_lowres.
290
263
  */
291
264
  get maxLowres(): number;
292
265
  /**
293
- * Array of supported codec profiles.
266
+ * Supported profiles.
294
267
  *
295
- * Profiles define subsets of codec features.
296
- * For example, H.264 has Baseline, Main, High profiles.
297
- * null if codec doesn't support profiles or none are defined.
298
- * @readonly
268
+ * Array of profiles this codec can handle (e.g., baseline, main, high).
269
+ *
270
+ * Direct mapping to AVCodec->profiles.
299
271
  */
300
272
  get profiles(): CodecProfile[] | null;
301
273
  /**
302
- * Group name of the codec implementation.
274
+ * Wrapper name.
275
+ *
276
+ * Name of the codec wrapper, if this is a wrapper codec.
303
277
  *
304
- * This is a short symbolic name of the wrapper backing this codec.
305
- * For example "lavc" for internal codecs, "libopenh264" for OpenH264 wrapper.
306
- * null if codec is not wrapped.
307
- * @readonly
278
+ * Direct mapping to AVCodec->wrapper_name.
308
279
  */
309
280
  get wrapper(): string | null;
310
281
  /**
311
- * Supported framerates (video only).
282
+ * Supported frame rates.
283
+ *
284
+ * Array of frame rates this video codec supports.
285
+ * Null for audio codecs or if all rates are supported.
312
286
  *
313
- * Terminated by {0,0}. null if any framerate is supported.
314
- * Some codecs like MPEG-1/2 only support specific framerates.
315
- * @readonly
287
+ * Direct mapping to AVCodec->supported_framerates.
316
288
  */
317
289
  get supportedFramerates(): Rational[] | null;
318
290
  /**
319
- * Array of supported pixel formats (video only).
291
+ * Supported pixel formats.
320
292
  *
321
- * Terminated by AV_PIX_FMT_NONE. null if unknown.
322
- * Lists all pixel formats this codec can encode/decode.
323
- * @readonly
293
+ * Array of pixel formats this video codec supports.
294
+ * Null for audio codecs.
295
+ *
296
+ * Direct mapping to AVCodec->pix_fmts.
324
297
  */
325
298
  get pixelFormats(): AVPixelFormat[] | null;
326
299
  /**
327
- * Supported sample rates (audio only).
300
+ * Supported sample rates.
301
+ *
302
+ * Array of sample rates this audio codec supports.
303
+ * Null for video codecs or if all rates are supported.
328
304
  *
329
- * Terminated by 0. null if any sample rate is supported.
330
- * Common rates: 8000, 16000, 22050, 44100, 48000, 96000, 192000 Hz.
331
- * @readonly
305
+ * Direct mapping to AVCodec->supported_samplerates.
332
306
  */
333
307
  get supportedSamplerates(): number[] | null;
334
308
  /**
335
- * Array of supported sample formats (audio only).
309
+ * Supported sample formats.
336
310
  *
337
- * Terminated by AV_SAMPLE_FMT_NONE. null if unknown.
338
- * Lists all sample formats this codec can encode/decode.
339
- * Common formats: S16, S32, FLT, DBL (planar and interleaved variants).
340
- * @readonly
311
+ * Array of sample formats this audio codec supports.
312
+ * Null for video codecs.
313
+ *
314
+ * Direct mapping to AVCodec->sample_fmts.
341
315
  */
342
316
  get sampleFormats(): AVSampleFormat[] | null;
343
317
  /**
344
- * Array of supported channel layouts (audio only).
318
+ * Supported channel layouts.
319
+ *
320
+ * Array of channel layouts this audio codec supports.
321
+ * Null for video codecs.
345
322
  *
346
- * Lists all channel configurations this codec supports.
347
- * Common layouts: mono, stereo, 5.1, 7.1.
348
- * null if unknown or all layouts are supported.
349
- * @readonly
323
+ * Direct mapping to AVCodec->ch_layouts.
350
324
  */
351
325
  get channelLayouts(): ChannelLayout[] | null;
352
326
  /**
353
- * Check if the codec is an encoder.
354
- *
355
- * Direct mapping to av_codec_is_encoder()
327
+ * Check if codec is an encoder.
356
328
  *
357
- * @returns true if the codec is an encoder, false otherwise
329
+ * @returns True if this codec can encode
358
330
  *
359
331
  * @example
360
332
  * ```typescript
361
- * const codec = Codec.findEncoderByName('libx264');
362
- * if (codec && codec.isEncoder()) {
363
- * console.log('Found H.264 encoder');
333
+ * const codec = Codec.findEncoderByName(FF_ENCODER_LIBX264);
334
+ * if (codec?.isEncoder()) {
335
+ * console.log('This is an encoder');
364
336
  * }
365
337
  * ```
338
+ *
339
+ * @see {@link isDecoder} To check for decoders
366
340
  */
367
341
  isEncoder(): boolean;
368
342
  /**
369
- * Check if the codec is a decoder.
370
- *
371
- * Direct mapping to av_codec_is_decoder()
343
+ * Check if codec is a decoder.
372
344
  *
373
- * @returns true if the codec is a decoder, false otherwise
345
+ * @returns True if this codec can decode
374
346
  *
375
347
  * @example
376
348
  * ```typescript
377
349
  * const codec = Codec.findDecoder(AV_CODEC_ID_H264);
378
- * if (codec && codec.isDecoder()) {
379
- * console.log('Found H.264 decoder');
350
+ * if (codec?.isDecoder()) {
351
+ * console.log('This is a decoder');
380
352
  * }
381
353
  * ```
354
+ *
355
+ * @see {@link isEncoder} To check for encoders
382
356
  */
383
357
  isDecoder(): boolean;
384
358
  /**
385
- * Check if the codec is experimental.
359
+ * Check if codec is experimental.
386
360
  *
387
- * Experimental codecs require explicit allowance to use.
388
- * You must set strict_std_compliance to FF_COMPLIANCE_EXPERIMENTAL
389
- * or lower in the codec context to use experimental codecs.
361
+ * Experimental codecs require explicit opt-in to use.
390
362
  *
391
- * @returns true if the codec is experimental, false otherwise
363
+ * @returns True if codec is marked experimental
392
364
  *
393
365
  * @example
394
366
  * ```typescript
395
- * const codec = Codec.findEncoderByName('some_experimental_codec');
396
- * if (codec && codec.isExperimental()) {
397
- * console.warn('This codec is experimental and may not be stable');
398
- * // codecContext.strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
367
+ * if (codec.isExperimental()) {
368
+ * console.warn('This codec is experimental');
369
+ * // Need to set strict_std_compliance = -2
399
370
  * }
400
371
  * ```
401
372
  */
402
373
  isExperimental(): boolean;
403
374
  /**
404
- * Check if codec has any hardware acceleration support.
375
+ * Check if codec supports hardware acceleration.
405
376
  *
406
- * Returns true if hw_configs are present (both generic and dedicated hw codecs).
407
- * This includes:
408
- * - Generic decoders with hardware acceleration support (e.g., 'h264' with VideoToolbox)
409
- * - Dedicated hardware codecs (e.g., 'h264_videotoolbox', 'h264_nvenc')
377
+ * Checks if the codec has any hardware configuration.
410
378
  *
411
- * @returns true if the codec supports hardware acceleration
379
+ * @returns True if hardware acceleration is available
412
380
  *
413
381
  * @example
414
382
  * ```typescript
415
- * import { Codec } from 'node-av';
416
- *
417
- * // Check software codec
418
- * const x264 = Codec.findEncoderByName('libx264');
419
- * console.log(x264?.hasHardwareAcceleration()); // false
420
- *
421
- * // Check hardware codecs
422
- * const h264 = Codec.findDecoderByName('h264');
423
- * console.log(h264?.hasHardwareAcceleration()); // true
424
- *
425
- * const videotoolbox = Codec.findEncoderByName('h264_videotoolbox');
426
- * console.log(videotoolbox?.hasHardwareAcceleration()); // true
383
+ * const codec = Codec.findDecoderByName('h264_cuvid');
384
+ * if (codec?.hasHardwareAcceleration()) {
385
+ * console.log('Hardware acceleration available');
386
+ * }
427
387
  * ```
388
+ *
389
+ * @see {@link getSupportedDeviceTypes} For specific device types
428
390
  */
429
391
  hasHardwareAcceleration(): boolean;
430
392
  /**
431
- * Check if codec supports a specific hardware device type.
393
+ * Check if codec supports specific device type.
432
394
  *
433
- * @param deviceType - The hardware device type to check for
434
- * @returns true if the codec supports the specified hardware device type
395
+ * @param deviceType - Hardware device type to check
396
+ * @returns True if device type is supported
435
397
  *
436
398
  * @example
437
399
  * ```typescript
438
- * import { Codec } from 'node-av';
439
- * import { AV_HWDEVICE_TYPE_VIDEOTOOLBOX, AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
440
- *
441
- * const h264 = Codec.findDecoderByName('h264');
442
- * console.log(h264?.supportsDevice(AV_HWDEVICE_TYPE_VIDEOTOOLBOX)); // true on macOS
400
+ * import { AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
443
401
  *
444
- * const h264VT = Codec.findEncoderByName('h264_videotoolbox');
445
- * console.log(h264VT?.supportsDevice(AV_HWDEVICE_TYPE_VIDEOTOOLBOX)); // true
446
- * console.log(h264VT?.supportsDevice(AV_HWDEVICE_TYPE_CUDA)); // false
402
+ * if (codec.supportsDevice(AV_HWDEVICE_TYPE_CUDA)) {
403
+ * console.log('Supports NVIDIA CUDA');
404
+ * }
447
405
  * ```
406
+ *
407
+ * @see {@link getSupportedDeviceTypes} For all supported types
448
408
  */
449
409
  supportsDevice(deviceType: AVHWDeviceType): boolean;
450
410
  /**
451
- * Check if this is a hardware-accelerated decoder.
411
+ * Check if decoder supports hardware acceleration.
452
412
  *
453
- * @param deviceType - Optional: check for specific device support
454
- * @returns true if the codec is a decoder with hardware acceleration
413
+ * @param deviceType - Optional specific device type
414
+ * @returns True if hardware decoding is supported
455
415
  *
456
416
  * @example
457
417
  * ```typescript
458
418
  * import { AV_HWDEVICE_TYPE_VIDEOTOOLBOX } from 'node-av/constants';
459
419
  *
460
- * const h264 = Codec.findDecoderByName('h264');
461
- * console.log(h264?.isHardwareAcceleratedDecoder()); // true on macOS
462
- * console.log(h264?.isHardwareAcceleratedDecoder(AV_HWDEVICE_TYPE_VIDEOTOOLBOX)); // true
420
+ * // Check any hardware support
421
+ * if (codec.isHardwareAcceleratedDecoder()) {
422
+ * console.log('Hardware decoding available');
423
+ * }
463
424
  *
464
- * const libx264 = Codec.findEncoderByName('libx264');
465
- * console.log(libx264?.isHardwareAcceleratedDecoder()); // false (encoder)
425
+ * // Check specific device
426
+ * if (codec.isHardwareAcceleratedDecoder(AV_HWDEVICE_TYPE_VIDEOTOOLBOX)) {
427
+ * console.log('VideoToolbox decoding available');
428
+ * }
466
429
  * ```
467
430
  */
468
431
  isHardwareAcceleratedDecoder(deviceType?: AVHWDeviceType): boolean;
469
432
  /**
470
- * Check if this is a hardware-accelerated encoder.
433
+ * Check if encoder supports hardware acceleration.
471
434
  *
472
- * @param deviceType - Optional: check for specific device support
473
- * @returns true if the codec is an encoder with hardware acceleration
435
+ * @param deviceType - Optional specific device type
436
+ * @returns True if hardware encoding is supported
474
437
  *
475
438
  * @example
476
439
  * ```typescript
477
- * import { AV_HWDEVICE_TYPE_VIDEOTOOLBOX } from 'node-av/constants';
440
+ * import { AV_HWDEVICE_TYPE_VAAPI } from 'node-av/constants';
478
441
  *
479
- * const h264VT = Codec.findEncoderByName('h264_videotoolbox');
480
- * console.log(h264VT?.isHardwareAcceleratedEncoder()); // true
481
- * console.log(h264VT?.isHardwareAcceleratedEncoder(AV_HWDEVICE_TYPE_VIDEOTOOLBOX)); // true
442
+ * // Check any hardware support
443
+ * if (codec.isHardwareAcceleratedEncoder()) {
444
+ * console.log('Hardware encoding available');
445
+ * }
482
446
  *
483
- * const libx264 = Codec.findEncoderByName('libx264');
484
- * console.log(libx264?.isHardwareAcceleratedEncoder()); // false
447
+ * // Check specific device
448
+ * if (codec.isHardwareAcceleratedEncoder(AV_HWDEVICE_TYPE_VAAPI)) {
449
+ * console.log('VAAPI encoding available');
450
+ * }
485
451
  * ```
486
452
  */
487
453
  isHardwareAcceleratedEncoder(deviceType?: AVHWDeviceType): boolean;
488
454
  /**
489
- * Get list of all supported hardware device types.
455
+ * Get supported hardware device types.
490
456
  *
491
- * Useful for discovery of available hardware acceleration options.
457
+ * Returns all hardware acceleration types this codec supports.
492
458
  *
493
- * @returns Array of supported hardware device types
459
+ * @returns Array of supported device types
494
460
  *
495
461
  * @example
496
462
  * ```typescript
497
- * const h264 = Codec.findDecoderByName('h264');
498
- * const devices = h264?.getSupportedDeviceTypes() ?? [];
499
- * console.log('Supported devices:', devices);
500
- * // On macOS: [AV_HWDEVICE_TYPE_VIDEOTOOLBOX]
501
- * // On Linux with VAAPI: [AV_HWDEVICE_TYPE_VAAPI]
463
+ * const devices = codec.getSupportedDeviceTypes();
464
+ * console.log('Supported devices:', devices.map(d => {
465
+ * switch(d) {
466
+ * case AV_HWDEVICE_TYPE_CUDA: return 'CUDA';
467
+ * case AV_HWDEVICE_TYPE_VAAPI: return 'VAAPI';
468
+ * default: return 'Unknown';
469
+ * }
470
+ * }));
502
471
  * ```
472
+ *
473
+ * @see {@link supportsDevice} To check specific device
503
474
  */
504
475
  getSupportedDeviceTypes(): AVHWDeviceType[];
505
476
  /**
506
- * Get the hardware acceleration method for a specific device type.
477
+ * Get hardware method flags for device type.
507
478
  *
508
- * Returns the methods flags or null if not supported.
509
- * Useful to know HOW the codec uses hardware:
510
- * - HW_DEVICE_CTX: Uses global device context (typical for decoders)
511
- * - HW_FRAMES_CTX: Uses frame-level context (typical for encoders)
512
- * - Both: Full hardware pipeline support
479
+ * Returns the hardware configuration methods for a specific device.
513
480
  *
514
- * @param deviceType - The hardware device type
515
- * @returns Hardware methods flags or null
481
+ * @param deviceType - Device type to query
482
+ * @returns Method flags, or null if not supported
516
483
  *
517
484
  * @example
518
485
  * ```typescript
519
- * import { AV_HWDEVICE_TYPE_VIDEOTOOLBOX, AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX } from 'node-av/constants';
486
+ * import { AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
520
487
  *
521
- * const h264 = Codec.findDecoderByName('h264');
522
- * const methods = h264?.getHardwareMethod(AV_HWDEVICE_TYPE_VIDEOTOOLBOX);
523
- * if (methods && (methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX)) {
524
- * console.log('Uses device context');
488
+ * const methods = codec.getHardwareMethod(AV_HWDEVICE_TYPE_CUDA);
489
+ * if (methods) {
490
+ * if (methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) {
491
+ * console.log('Supports device context');
492
+ * }
525
493
  * }
526
494
  * ```
527
495
  */
528
496
  getHardwareMethod(deviceType: AVHWDeviceType): number | null;
529
497
  /**
530
- * Get hardware configuration at specified index.
498
+ * Get hardware configuration at index.
531
499
  *
532
- * Direct mapping to avcodec_get_hw_config()
500
+ * Retrieves hardware acceleration configuration details.
533
501
  *
534
- * @param index - Configuration index (0-based)
535
- * @returns Hardware configuration or null if not available
502
+ * Direct mapping to avcodec_get_hw_config().
503
+ *
504
+ * @param index - Configuration index
505
+ * @returns Hardware configuration, or null if index out of range
536
506
  *
537
507
  * @example
538
508
  * ```typescript
539
- * const codec = Codec.findDecoder(AV_CODEC_ID_H264);
509
+ * // Enumerate all hardware configs
540
510
  * for (let i = 0; ; i++) {
541
511
  * const config = codec.getHwConfig(i);
542
512
  * if (!config) break;
543
513
  *
544
- * if (config.methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) {
545
- * console.log(`Supports device type: ${config.deviceType}`);
546
- * }
514
+ * console.log(`Config ${i}:`);
515
+ * console.log(` Pixel format: ${config.pixFmt}`);
516
+ * console.log(` Device type: ${config.deviceType}`);
517
+ * console.log(` Methods: 0x${config.methods.toString(16)}`);
547
518
  * }
548
519
  * ```
549
520
  */
@@ -553,8 +524,20 @@ export declare class Codec implements NativeWrapper<NativeCodec> {
553
524
  deviceType: AVHWDeviceType;
554
525
  } | null;
555
526
  /**
556
- * Get the native codec object for use with C++ bindings
527
+ * Get the underlying native Codec object.
528
+ *
529
+ * @returns The native Codec binding object
530
+ *
557
531
  * @internal
558
532
  */
559
533
  getNative(): NativeCodec;
534
+ /**
535
+ * Create codec from native instance.
536
+ *
537
+ * @param native - Native codec instance
538
+ * @returns Codec wrapper or null
539
+ *
540
+ * @internal
541
+ */
542
+ static fromNative(native: NativeCodec | null): Codec | null;
560
543
  }