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,193 @@
1
+ import { bindings } from './binding.js';
2
+ /**
3
+ * Codec parser for splitting elementary streams into frames.
4
+ *
5
+ * Parsers split raw byte streams (currently only video) into coded frames.
6
+ * Many decoders require that coded video frames are preceded by a start code,
7
+ * and this parser splits the stream at these boundaries. Parsers are essential
8
+ * for handling raw elementary streams from sources like network streams or
9
+ * raw video files without container format.
10
+ *
11
+ * Direct wrapper around AVCodecParserContext.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { CodecParser, CodecContext, Packet, FFmpegError } from 'node-av';
16
+ * import { AV_CODEC_ID_H264, AV_NOPTS_VALUE } from 'node-av/constants';
17
+ *
18
+ * const parser = new CodecParser();
19
+ * parser.init(AV_CODEC_ID_H264);
20
+ *
21
+ * // Parse raw H.264 stream
22
+ * const packet = new Packet();
23
+ * packet.alloc();
24
+ *
25
+ * const bytesConsumed = parser.parse2(
26
+ * codecContext,
27
+ * packet,
28
+ * inputBuffer,
29
+ * AV_NOPTS_VALUE,
30
+ * AV_NOPTS_VALUE,
31
+ * 0
32
+ * );
33
+ *
34
+ * if (packet.size > 0) {
35
+ * // We have a complete frame in packet
36
+ * const ret = await codecContext.sendPacket(packet);
37
+ * FFmpegError.throwIfError(ret, 'sendPacket');
38
+ * }
39
+ *
40
+ * parser.close();
41
+ * ```
42
+ *
43
+ * @see {@link CodecContext} For decoding parsed packets
44
+ * @see {@link Packet} For storing parsed frame data
45
+ */
46
+ export class CodecParser {
47
+ native;
48
+ /**
49
+ * Create a new CodecParser instance.
50
+ *
51
+ * The parser is uninitialized - you must call init() before use.
52
+ * No FFmpeg resources are allocated until init() is called.
53
+ *
54
+ * Direct wrapper around AVCodecParserContext allocation.
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * import { CodecParser } from 'node-av';
59
+ * import { AV_CODEC_ID_MPEG1VIDEO } from 'node-av/constants';
60
+ *
61
+ * const parser = new CodecParser();
62
+ * parser.init(AV_CODEC_ID_MPEG1VIDEO);
63
+ * // parser is now ready for use
64
+ * ```
65
+ */
66
+ constructor() {
67
+ this.native = new bindings.CodecParser();
68
+ }
69
+ /**
70
+ * Initialize the parser with a specific codec ID.
71
+ *
72
+ * Allocates and initializes the AVCodecParserContext for the specified codec.
73
+ * Must be called before parse2() can be used.
74
+ *
75
+ * Direct mapping to av_parser_init()
76
+ *
77
+ * @param codecId - AVCodecID of the codec to parse
78
+ *
79
+ * @throws {Error} Parser for codec ID not found
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * import { CodecParser } from 'node-av';
84
+ * import { AV_CODEC_ID_H264, AV_CODEC_ID_HEVC } from 'node-av/constants';
85
+ *
86
+ * const parser = new CodecParser();
87
+ *
88
+ * // Initialize for H.264
89
+ * parser.init(AV_CODEC_ID_H264);
90
+ * // Parser is now ready to parse H.264 streams
91
+ *
92
+ * // For HEVC/H.265
93
+ * const hevcParser = new CodecParser();
94
+ * hevcParser.init(AV_CODEC_ID_HEVC);
95
+ * ```
96
+ *
97
+ * @see {@link parse2} For parsing data after initialization
98
+ */
99
+ init(codecId) {
100
+ this.native.init(codecId);
101
+ }
102
+ /**
103
+ * Parse a buffer and extract packets from elementary stream.
104
+ *
105
+ * Parses the input buffer and extracts complete coded frames. The parser
106
+ * maintains internal state to handle partial frames across multiple calls.
107
+ * The parser may combine multiple frames into one packet or split one frame
108
+ * into multiple packets, depending on the codec and stream format.
109
+ *
110
+ * Direct mapping to av_parser_parse2()
111
+ *
112
+ * @param codecContext - Codec context (used for stream parameters)
113
+ * @param packet - Packet to fill with parsed data
114
+ * @param data - Input buffer containing elementary stream data
115
+ * @param pts - Presentation timestamp of the first byte in data
116
+ * @param dts - Decoding timestamp of the first byte in data
117
+ * @param pos - Byte position of the first byte in data in the stream
118
+ *
119
+ * @returns Number of bytes consumed from the input buffer:
120
+ * - >0: Number of bytes consumed from input
121
+ * - 0: More data needed to complete a frame
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * import { CodecParser, CodecContext, Packet, FFmpegError } from 'node-av';
126
+ * import { AV_NOPTS_VALUE } from 'node-av/constants';
127
+ * import * as fs from 'fs';
128
+ *
129
+ * const inbuf = Buffer.alloc(4096);
130
+ * const bytesRead = fs.readSync(fd, inbuf, 0, 4096, null);
131
+ *
132
+ * let offset = 0;
133
+ * while (offset < bytesRead) {
134
+ * const consumed = parser.parse2(
135
+ * codecContext,
136
+ * packet,
137
+ * inbuf.subarray(offset),
138
+ * AV_NOPTS_VALUE,
139
+ * AV_NOPTS_VALUE,
140
+ * 0
141
+ * );
142
+ *
143
+ * offset += consumed;
144
+ *
145
+ * if (packet.size > 0) {
146
+ * // Complete packet ready for decoding
147
+ * const ret = await codecContext.sendPacket(packet);
148
+ * FFmpegError.throwIfError(ret, 'sendPacket');
149
+ * }
150
+ * }
151
+ * ```
152
+ *
153
+ * @see {@link init} Must be called before parse2
154
+ * @see {@link close} Should be called when done parsing
155
+ */
156
+ parse2(codecContext, packet, data, pts, dts, pos) {
157
+ return this.native.parse2(codecContext.getNative(), packet.getNative(), data, pts, dts, pos);
158
+ }
159
+ /**
160
+ * Close the parser and free all resources.
161
+ *
162
+ * Releases all resources associated with the parser context.
163
+ * After calling close(), the parser instance should not be used anymore.
164
+ *
165
+ * Direct mapping to av_parser_close()
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * import { CodecParser } from 'node-av';
170
+ *
171
+ * const parser = new CodecParser();
172
+ * // ... use parser ...
173
+ *
174
+ * parser.close();
175
+ * // Parser resources are now freed
176
+ * // Do not use parser after this point
177
+ * ```
178
+ */
179
+ close() {
180
+ this.native.close();
181
+ }
182
+ /**
183
+ * @internal
184
+ * Get the underlying native codec parser object.
185
+ * This method is for internal use by other FFmpeg classes.
186
+ *
187
+ * @returns The underlying native codec parser object
188
+ */
189
+ getNative() {
190
+ return this.native;
191
+ }
192
+ }
193
+ //# sourceMappingURL=codec-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec-parser.js","sourceRoot":"","sources":["../../src/lib/codec-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAOxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,OAAO,WAAW;IACd,MAAM,CAAoB;IAElC;;;;;;;;;;;;;;;;;OAiBG;IACH;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,IAAI,CAAC,OAAkB;QACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqDG;IACH,MAAM,CAAC,YAA0B,EAAE,MAAc,EAAE,IAAY,EAAE,GAAW,EAAE,GAAW,EAAE,GAAW;QACpG,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAC/F,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}
@@ -0,0 +1,432 @@
1
+ import { Rational } from './rational.js';
2
+ import type { AVCodecCap, AVCodecID, AVHWDeviceType, AVMediaType, AVPixelFormat, AVSampleFormat } from './constants.js';
3
+ import type { NativeCodec, NativeWrapper } from './native-types.js';
4
+ import type { ChannelLayout, CodecProfile } from './types.js';
5
+ /**
6
+ * Codec (encoder/decoder) definition.
7
+ *
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.
11
+ *
12
+ * Direct mapping to FFmpeg's AVCodec.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { Codec } from 'node-av';
17
+ * import { AV_CODEC_ID_H264 } from 'node-av/constants';
18
+ *
19
+ * // Find decoder by ID
20
+ * const h264Decoder = Codec.findDecoder(AV_CODEC_ID_H264);
21
+ * if (!h264Decoder) throw new Error('H264 decoder not found');
22
+ *
23
+ * // 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()}`);
32
+ *
33
+ * // Get supported formats
34
+ * const pixelFormats = h264Decoder.pixelFormats;
35
+ * console.log(`Supported pixel formats: ${pixelFormats}`);
36
+ *
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;
44
+ * }
45
+ * ```
46
+ */
47
+ export declare class Codec implements NativeWrapper<NativeCodec> {
48
+ private native;
49
+ /**
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
+ *
55
+ * @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
+ */
72
+ constructor(native: NativeCodec);
73
+ /**
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.
80
+ *
81
+ * Searches for a decoder that can decode the specified codec format.
82
+ *
83
+ * Direct mapping to avcodec_find_decoder()
84
+ *
85
+ * @param id - AVCodecID of the requested decoder
86
+ *
87
+ * @returns Codec object or null if no decoder found
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * import { Codec } from 'node-av';
92
+ * import { AV_CODEC_ID_H264 } from 'node-av/constants';
93
+ *
94
+ * const decoder = Codec.findDecoder(AV_CODEC_ID_H264);
95
+ * if (!decoder) {
96
+ * throw new Error('H.264 decoder not available');
97
+ * }
98
+ * ```
99
+ *
100
+ * @see {@link findDecoderByName} To find by name
101
+ * @see {@link findEncoder} To find encoder
102
+ */
103
+ static findDecoder(id: AVCodecID): Codec | null;
104
+ /**
105
+ * Find a registered decoder with the specified name.
106
+ *
107
+ * Searches for a decoder by its exact name.
108
+ * Useful for selecting specific decoder implementations.
109
+ *
110
+ * Direct mapping to avcodec_find_decoder_by_name()
111
+ *
112
+ * @param name - Name of the requested decoder
113
+ *
114
+ * @returns Codec object or null if no decoder found
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * import { Codec } from 'node-av';
119
+ *
120
+ * const decoder = Codec.findDecoderByName('h264');
121
+ * // Can also use specific implementations:
122
+ * const cudaDecoder = Codec.findDecoderByName('h264_cuvid'); // NVIDIA hardware decoder
123
+ * ```
124
+ *
125
+ * @see {@link findDecoder} To find by codec ID
126
+ */
127
+ static findDecoderByName(name: string): Codec | null;
128
+ /**
129
+ * Find a registered encoder with a matching codec ID.
130
+ *
131
+ * Searches for an encoder that can encode to the specified codec format.
132
+ *
133
+ * Direct mapping to avcodec_find_encoder()
134
+ *
135
+ * @param id - AVCodecID of the requested encoder
136
+ *
137
+ * @returns Codec object or null if no encoder found
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * import { Codec } from 'node-av';
142
+ * import { AV_CODEC_ID_H264 } from 'node-av/constants';
143
+ *
144
+ * const encoder = Codec.findEncoder(AV_CODEC_ID_H264);
145
+ * if (!encoder) {
146
+ * throw new Error('H.264 encoder not available');
147
+ * }
148
+ * ```
149
+ *
150
+ * @see {@link findEncoderByName} To find by name
151
+ * @see {@link findDecoder} To find decoder
152
+ */
153
+ static findEncoder(id: AVCodecID): Codec | null;
154
+ /**
155
+ * Find a registered encoder with the specified name.
156
+ *
157
+ * Searches for an encoder by its exact name.
158
+ * Useful for selecting specific encoder implementations.
159
+ *
160
+ * Direct mapping to avcodec_find_encoder_by_name()
161
+ *
162
+ * @param name - Name of the requested encoder
163
+ *
164
+ * @returns Codec object or null if no encoder found
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * import { Codec } from 'node-av';
169
+ *
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
174
+ * ```
175
+ *
176
+ * @see {@link findEncoder} To find by codec ID
177
+ */
178
+ static findEncoderByName(name: string): Codec | null;
179
+ /**
180
+ * Get list of all available codecs.
181
+ *
182
+ * Returns all registered codecs in the system.
183
+ * Internally uses av_codec_iterate() to collect all codecs.
184
+ *
185
+ * @returns Array of all registered codecs
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * import { Codec } from 'node-av';
190
+ * import { AVMEDIA_TYPE_VIDEO } from 'node-av/constants';
191
+ *
192
+ * 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
+ * ```
198
+ *
199
+ * @note This loads all codecs at once. For large codec lists,
200
+ * consider using iterateCodecs() instead.
201
+ *
202
+ * @see {@link iterateCodecs} For memory-efficient iteration
203
+ */
204
+ static getCodecList(): Codec[];
205
+ /**
206
+ * Iterate through codecs one by one.
207
+ *
208
+ * Memory-efficient codec iteration.
209
+ * Processes codecs one at a time instead of loading all at once.
210
+ *
211
+ * Direct mapping to av_codec_iterate()
212
+ *
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
216
+ *
217
+ * @example
218
+ * ```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;
233
+ * }
234
+ * ```
235
+ *
236
+ * @see {@link getCodecList} To get all codecs at once
237
+ */
238
+ static iterateCodecs(opaque?: bigint | null): {
239
+ codec: Codec;
240
+ opaque: bigint;
241
+ } | null;
242
+ /**
243
+ * Short name of the codec.
244
+ *
245
+ * Direct mapping to AVCodec->name
246
+ * Typically matches the name of the codec specification.
247
+ * For example: "h264", "aac", "vp9", "opus"
248
+ */
249
+ get name(): string | null;
250
+ /**
251
+ * Descriptive name for the codec.
252
+ *
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"
256
+ */
257
+ get longName(): string | null;
258
+ /**
259
+ * Media type handled by this codec.
260
+ *
261
+ * Direct mapping to AVCodec->type
262
+ * AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_SUBTITLE, etc.
263
+ */
264
+ get type(): AVMediaType;
265
+ /**
266
+ * Codec ID.
267
+ *
268
+ * Direct mapping to AVCodec->id
269
+ * Unique identifier for this codec type (AV_CODEC_ID_H264, AV_CODEC_ID_AAC, etc.)
270
+ */
271
+ get id(): AVCodecID;
272
+ /**
273
+ * Codec capabilities.
274
+ *
275
+ * Direct mapping to AVCodec->capabilities
276
+ * Bitfield of AV_CODEC_CAP_* flags describing codec features.
277
+ */
278
+ get capabilities(): AVCodecCap;
279
+ /**
280
+ * Maximum lowres value supported by the decoder.
281
+ *
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
288
+ */
289
+ get maxLowres(): number;
290
+ /**
291
+ * Array of supported codec profiles.
292
+ *
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
297
+ */
298
+ get profiles(): CodecProfile[] | null;
299
+ /**
300
+ * Group name of the codec implementation.
301
+ *
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
306
+ */
307
+ get wrapper(): string | null;
308
+ /**
309
+ * Supported framerates (video only).
310
+ *
311
+ * Terminated by {0,0}. null if any framerate is supported.
312
+ * Some codecs like MPEG-1/2 only support specific framerates.
313
+ * @readonly
314
+ */
315
+ get supportedFramerates(): Rational[] | null;
316
+ /**
317
+ * Array of supported pixel formats (video only).
318
+ *
319
+ * Terminated by AV_PIX_FMT_NONE. null if unknown.
320
+ * Lists all pixel formats this codec can encode/decode.
321
+ * @readonly
322
+ */
323
+ get pixelFormats(): AVPixelFormat[] | null;
324
+ /**
325
+ * Supported sample rates (audio only).
326
+ *
327
+ * Terminated by 0. null if any sample rate is supported.
328
+ * Common rates: 8000, 16000, 22050, 44100, 48000, 96000, 192000 Hz.
329
+ * @readonly
330
+ */
331
+ get supportedSamplerates(): number[] | null;
332
+ /**
333
+ * Array of supported sample formats (audio only).
334
+ *
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
339
+ */
340
+ get sampleFormats(): AVSampleFormat[] | null;
341
+ /**
342
+ * Array of supported channel layouts (audio only).
343
+ *
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
348
+ */
349
+ get channelLayouts(): ChannelLayout[] | null;
350
+ /**
351
+ * Check if the codec is an encoder.
352
+ *
353
+ * Direct mapping to av_codec_is_encoder()
354
+ *
355
+ * @returns true if the codec is an encoder, false otherwise
356
+ *
357
+ * @example
358
+ * ```typescript
359
+ * const codec = Codec.findEncoderByName('libx264');
360
+ * if (codec && codec.isEncoder()) {
361
+ * console.log('Found H.264 encoder');
362
+ * }
363
+ * ```
364
+ */
365
+ isEncoder(): boolean;
366
+ /**
367
+ * Check if the codec is a decoder.
368
+ *
369
+ * Direct mapping to av_codec_is_decoder()
370
+ *
371
+ * @returns true if the codec is a decoder, false otherwise
372
+ *
373
+ * @example
374
+ * ```typescript
375
+ * const codec = Codec.findDecoder(AV_CODEC_ID_H264);
376
+ * if (codec && codec.isDecoder()) {
377
+ * console.log('Found H.264 decoder');
378
+ * }
379
+ * ```
380
+ */
381
+ isDecoder(): boolean;
382
+ /**
383
+ * Check if the codec is experimental.
384
+ *
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.
388
+ *
389
+ * @returns true if the codec is experimental, false otherwise
390
+ *
391
+ * @example
392
+ * ```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;
397
+ * }
398
+ * ```
399
+ */
400
+ isExperimental(): boolean;
401
+ /**
402
+ * Get hardware configuration at specified index.
403
+ *
404
+ * Direct mapping to avcodec_get_hw_config()
405
+ *
406
+ * @param index - Configuration index (0-based)
407
+ * @returns Hardware configuration or null if not available
408
+ *
409
+ * @example
410
+ * ```typescript
411
+ * const codec = Codec.findDecoder(AV_CODEC_ID_H264);
412
+ * for (let i = 0; ; i++) {
413
+ * const config = codec.getHwConfig(i);
414
+ * if (!config) break;
415
+ *
416
+ * if (config.methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) {
417
+ * console.log(`Supports device type: ${config.deviceType}`);
418
+ * }
419
+ * }
420
+ * ```
421
+ */
422
+ getHwConfig(index: number): {
423
+ pixFmt: AVPixelFormat;
424
+ methods: number;
425
+ deviceType: AVHWDeviceType;
426
+ } | null;
427
+ /**
428
+ * Get the native codec object for use with C++ bindings
429
+ * @internal
430
+ */
431
+ getNative(): NativeCodec;
432
+ }