node-av 1.0.3 → 1.2.0

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