node-av 1.1.0 → 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.
- package/README.md +51 -38
- package/dist/api/bitstream-filter.d.ts +180 -123
- package/dist/api/bitstream-filter.js +180 -125
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +279 -132
- package/dist/api/decoder.js +285 -142
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/encoder.d.ts +246 -162
- package/dist/api/encoder.js +272 -208
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-presets.d.ts +690 -94
- package/dist/api/filter-presets.js +686 -102
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +249 -213
- package/dist/api/filter.js +252 -242
- package/dist/api/filter.js.map +1 -1
- package/dist/api/hardware.d.ts +224 -117
- package/dist/api/hardware.js +380 -214
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/index.d.ts +3 -3
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/io-stream.d.ts +65 -61
- package/dist/api/io-stream.js +43 -46
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/media-input.d.ts +242 -140
- package/dist/api/media-input.js +205 -103
- package/dist/api/media-input.js.map +1 -1
- package/dist/api/media-output.d.ts +206 -128
- package/dist/api/media-output.js +210 -128
- package/dist/api/media-output.js.map +1 -1
- package/dist/api/pipeline.d.ts +168 -38
- package/dist/api/pipeline.js +238 -14
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/types.d.ts +21 -187
- package/dist/api/utils.d.ts +1 -2
- package/dist/api/utils.js +9 -0
- package/dist/api/utils.js.map +1 -1
- package/dist/lib/audio-fifo.d.ts +127 -170
- package/dist/lib/audio-fifo.js +130 -173
- package/dist/lib/audio-fifo.js.map +1 -1
- package/dist/lib/binding.js +5 -0
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/bitstream-filter-context.d.ts +139 -184
- package/dist/lib/bitstream-filter-context.js +139 -188
- package/dist/lib/bitstream-filter-context.js.map +1 -1
- package/dist/lib/bitstream-filter.d.ts +68 -54
- package/dist/lib/bitstream-filter.js +68 -54
- package/dist/lib/bitstream-filter.js.map +1 -1
- package/dist/lib/codec-context.d.ts +316 -380
- package/dist/lib/codec-context.js +316 -381
- package/dist/lib/codec-context.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +160 -170
- package/dist/lib/codec-parameters.js +162 -172
- package/dist/lib/codec-parameters.js.map +1 -1
- package/dist/lib/codec-parser.d.ts +91 -104
- package/dist/lib/codec-parser.js +92 -103
- package/dist/lib/codec-parser.js.map +1 -1
- package/dist/lib/codec.d.ts +264 -281
- package/dist/lib/codec.js +268 -285
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/dictionary.d.ts +149 -203
- package/dist/lib/dictionary.js +158 -212
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/error.d.ts +96 -130
- package/dist/lib/error.js +98 -128
- package/dist/lib/error.js.map +1 -1
- package/dist/lib/filter-context.d.ts +284 -218
- package/dist/lib/filter-context.js +290 -227
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/filter-graph.d.ts +251 -292
- package/dist/lib/filter-graph.js +253 -294
- package/dist/lib/filter-graph.js.map +1 -1
- package/dist/lib/filter-inout.d.ts +87 -95
- package/dist/lib/filter-inout.js +87 -95
- package/dist/lib/filter-inout.js.map +1 -1
- package/dist/lib/filter.d.ts +93 -111
- package/dist/lib/filter.js +93 -111
- package/dist/lib/filter.js.map +1 -1
- package/dist/lib/format-context.d.ts +320 -428
- package/dist/lib/format-context.js +313 -385
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +262 -405
- package/dist/lib/frame.js +263 -408
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/hardware-device-context.d.ts +149 -203
- package/dist/lib/hardware-device-context.js +149 -203
- package/dist/lib/hardware-device-context.js.map +1 -1
- package/dist/lib/hardware-frames-context.d.ts +170 -180
- package/dist/lib/hardware-frames-context.js +171 -181
- package/dist/lib/hardware-frames-context.js.map +1 -1
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/input-format.d.ts +89 -117
- package/dist/lib/input-format.js +89 -117
- package/dist/lib/input-format.js.map +1 -1
- package/dist/lib/io-context.d.ts +209 -241
- package/dist/lib/io-context.js +220 -252
- package/dist/lib/io-context.js.map +1 -1
- package/dist/lib/log.d.ts +85 -119
- package/dist/lib/log.js +85 -122
- package/dist/lib/log.js.map +1 -1
- package/dist/lib/native-types.d.ts +117 -106
- package/dist/lib/native-types.js +0 -7
- package/dist/lib/native-types.js.map +1 -1
- package/dist/lib/option.d.ts +284 -241
- package/dist/lib/option.js +309 -249
- package/dist/lib/option.js.map +1 -1
- package/dist/lib/output-format.d.ts +77 -101
- package/dist/lib/output-format.js +77 -101
- package/dist/lib/output-format.js.map +1 -1
- package/dist/lib/packet.d.ts +172 -240
- package/dist/lib/packet.js +172 -241
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/rational.d.ts +0 -2
- package/dist/lib/rational.js +0 -2
- package/dist/lib/rational.js.map +1 -1
- package/dist/lib/software-resample-context.d.ts +241 -325
- package/dist/lib/software-resample-context.js +242 -326
- package/dist/lib/software-resample-context.js.map +1 -1
- package/dist/lib/software-scale-context.d.ts +129 -173
- package/dist/lib/software-scale-context.js +131 -175
- package/dist/lib/software-scale-context.js.map +1 -1
- package/dist/lib/stream.d.ts +87 -197
- package/dist/lib/stream.js +87 -197
- package/dist/lib/stream.js.map +1 -1
- package/dist/lib/utilities.d.ts +372 -181
- package/dist/lib/utilities.js +373 -182
- package/dist/lib/utilities.js.map +1 -1
- package/install/check.js +0 -1
- package/package.json +21 -12
- package/release_notes.md +43 -59
- package/CHANGELOG.md +0 -8
package/dist/lib/codec.d.ts
CHANGED
|
@@ -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
|
|
8
|
+
* Codec descriptor for audio/video encoding and decoding.
|
|
9
9
|
*
|
|
10
|
-
* Represents
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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 { Codec, FFmpegError } from 'node-av';
|
|
19
20
|
* import { AV_CODEC_ID_H264 } from 'node-av/constants';
|
|
20
21
|
*
|
|
21
22
|
* // Find decoder by ID
|
|
22
|
-
* const
|
|
23
|
-
* if (!
|
|
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
|
|
27
|
-
* if (!
|
|
28
|
-
*
|
|
29
|
-
*
|
|
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('libx264');
|
|
30
|
+
* if (!encoder) {
|
|
31
|
+
* throw new Error('libx264 encoder not available');
|
|
32
|
+
* }
|
|
34
33
|
*
|
|
35
|
-
* //
|
|
36
|
-
*
|
|
37
|
-
* console.log(`
|
|
34
|
+
* // Check capabilities
|
|
35
|
+
* console.log(`Codec: ${decoder.name}`);
|
|
36
|
+
* console.log(`Type: ${decoder.type}`);
|
|
37
|
+
* console.log(`Hardware: ${decoder.hasHardwareAcceleration()}`);
|
|
38
38
|
*
|
|
39
|
-
* //
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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 {
|
|
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
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
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
|
|
81
|
+
* @see {@link findEncoder} To find encoders
|
|
104
82
|
*/
|
|
105
83
|
static findDecoder(id: AVCodecID): Codec | null;
|
|
106
84
|
/**
|
|
107
|
-
* Find a
|
|
85
|
+
* Find a decoder by name.
|
|
108
86
|
*
|
|
109
|
-
* Searches for a decoder by
|
|
110
|
-
* Useful for
|
|
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 -
|
|
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
|
-
*
|
|
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
|
-
*
|
|
123
|
-
*
|
|
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
|
|
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 -
|
|
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 {
|
|
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
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
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
|
|
135
|
+
* @see {@link findDecoder} To find decoders
|
|
154
136
|
*/
|
|
155
137
|
static findEncoder(id: AVCodecID): Codec | null;
|
|
156
138
|
/**
|
|
157
|
-
* Find
|
|
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
|
-
*
|
|
141
|
+
* Searches for a specific encoder implementation by name.
|
|
142
|
+
* Useful when multiple encoders exist for the same codec.
|
|
163
143
|
*
|
|
164
|
-
*
|
|
144
|
+
* Direct mapping to avcodec_find_encoder_by_name().
|
|
165
145
|
*
|
|
166
|
-
* @
|
|
146
|
+
* @param name - Encoder name
|
|
147
|
+
* @returns Encoder if found, null otherwise
|
|
167
148
|
*
|
|
168
149
|
* @example
|
|
169
150
|
* ```typescript
|
|
170
|
-
*
|
|
151
|
+
* // Find specific H.264 encoder
|
|
152
|
+
* const x264 = Codec.findEncoderByName('libx264');
|
|
153
|
+
* if (x264) {
|
|
154
|
+
* console.log('Found x264 encoder');
|
|
155
|
+
* }
|
|
171
156
|
*
|
|
172
|
-
* // Find
|
|
173
|
-
* const
|
|
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
|
|
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
|
|
169
|
+
* @returns Array of all available codecs
|
|
188
170
|
*
|
|
189
171
|
* @example
|
|
190
172
|
* ```typescript
|
|
191
|
-
*
|
|
192
|
-
* import { AVMEDIA_TYPE_VIDEO } from 'node-av/constants';
|
|
193
|
-
*
|
|
173
|
+
* // List all codecs
|
|
194
174
|
* const codecs = Codec.getCodecList();
|
|
195
|
-
*
|
|
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}`);
|
|
200
176
|
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
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
|
+
* ```
|
|
203
185
|
*
|
|
204
186
|
* @see {@link iterateCodecs} For memory-efficient iteration
|
|
205
187
|
*/
|
|
206
188
|
static getCodecList(): Codec[];
|
|
207
189
|
/**
|
|
208
|
-
* Iterate through codecs
|
|
209
|
-
*
|
|
210
|
-
* Memory-efficient codec iteration.
|
|
211
|
-
* Processes codecs one at a time instead of loading all at once.
|
|
190
|
+
* Iterate through available codecs.
|
|
212
191
|
*
|
|
213
|
-
*
|
|
192
|
+
* Memory-efficient way to iterate through all codecs.
|
|
193
|
+
* Uses an opaque pointer to track iteration state.
|
|
214
194
|
*
|
|
215
|
-
*
|
|
195
|
+
* Direct mapping to av_codec_iterate().
|
|
216
196
|
*
|
|
217
|
-
* @
|
|
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
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
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}
|
|
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
|
-
*
|
|
218
|
+
* Codec name.
|
|
219
|
+
*
|
|
220
|
+
* Short name identifier for the codec (e.g., 'h264', 'aac').
|
|
246
221
|
*
|
|
247
|
-
* Direct mapping to AVCodec->name
|
|
248
|
-
* Typically matches the name of the codec specification.
|
|
249
|
-
* For example: "h264", "aac", "vp9", "opus"
|
|
222
|
+
* Direct mapping to AVCodec->name.
|
|
250
223
|
*/
|
|
251
224
|
get name(): string | null;
|
|
252
225
|
/**
|
|
253
|
-
*
|
|
226
|
+
* Codec long name.
|
|
254
227
|
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
228
|
+
* Human-readable description of the codec.
|
|
229
|
+
*
|
|
230
|
+
* Direct mapping to AVCodec->long_name.
|
|
258
231
|
*/
|
|
259
232
|
get longName(): string | null;
|
|
260
233
|
/**
|
|
261
|
-
* Media type
|
|
234
|
+
* Media type.
|
|
235
|
+
*
|
|
236
|
+
* Type of media this codec processes (video, audio, subtitle, etc.).
|
|
262
237
|
*
|
|
263
|
-
* Direct mapping to AVCodec->type
|
|
264
|
-
* AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_SUBTITLE, etc.
|
|
238
|
+
* Direct mapping to AVCodec->type.
|
|
265
239
|
*/
|
|
266
240
|
get type(): AVMediaType;
|
|
267
241
|
/**
|
|
268
242
|
* Codec ID.
|
|
269
243
|
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
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
|
-
*
|
|
278
|
-
*
|
|
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
|
|
258
|
+
* Maximum lowres value.
|
|
259
|
+
*
|
|
260
|
+
* Maximum value for lowres decoding (0 = no lowres support).
|
|
283
261
|
*
|
|
284
|
-
*
|
|
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
|
-
*
|
|
266
|
+
* Supported profiles.
|
|
294
267
|
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
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
|
-
*
|
|
274
|
+
* Wrapper name.
|
|
275
|
+
*
|
|
276
|
+
* Name of the codec wrapper, if this is a wrapper codec.
|
|
303
277
|
*
|
|
304
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
-
*
|
|
291
|
+
* Supported pixel formats.
|
|
320
292
|
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
-
*
|
|
309
|
+
* Supported sample formats.
|
|
336
310
|
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
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
|
-
*
|
|
318
|
+
* Supported channel layouts.
|
|
319
|
+
*
|
|
320
|
+
* Array of channel layouts this audio codec supports.
|
|
321
|
+
* Null for video codecs.
|
|
345
322
|
*
|
|
346
|
-
*
|
|
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
|
|
354
|
-
*
|
|
355
|
-
* Direct mapping to av_codec_is_encoder()
|
|
327
|
+
* Check if codec is an encoder.
|
|
356
328
|
*
|
|
357
|
-
* @returns
|
|
329
|
+
* @returns True if this codec can encode
|
|
358
330
|
*
|
|
359
331
|
* @example
|
|
360
332
|
* ```typescript
|
|
361
333
|
* const codec = Codec.findEncoderByName('libx264');
|
|
362
|
-
* if (codec
|
|
363
|
-
* console.log('
|
|
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
|
|
370
|
-
*
|
|
371
|
-
* Direct mapping to av_codec_is_decoder()
|
|
343
|
+
* Check if codec is a decoder.
|
|
372
344
|
*
|
|
373
|
-
* @returns
|
|
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
|
|
379
|
-
* console.log('
|
|
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
|
|
359
|
+
* Check if codec is experimental.
|
|
386
360
|
*
|
|
387
|
-
* Experimental codecs require explicit
|
|
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
|
|
363
|
+
* @returns True if codec is marked experimental
|
|
392
364
|
*
|
|
393
365
|
* @example
|
|
394
366
|
* ```typescript
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
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
|
|
375
|
+
* Check if codec supports hardware acceleration.
|
|
405
376
|
*
|
|
406
|
-
*
|
|
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
|
|
379
|
+
* @returns True if hardware acceleration is available
|
|
412
380
|
*
|
|
413
381
|
* @example
|
|
414
382
|
* ```typescript
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
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
|
|
393
|
+
* Check if codec supports specific device type.
|
|
432
394
|
*
|
|
433
|
-
* @param deviceType -
|
|
434
|
-
* @returns
|
|
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 {
|
|
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
|
-
*
|
|
445
|
-
*
|
|
446
|
-
*
|
|
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
|
|
411
|
+
* Check if decoder supports hardware acceleration.
|
|
452
412
|
*
|
|
453
|
-
* @param deviceType - Optional
|
|
454
|
-
* @returns
|
|
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
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
420
|
+
* // Check any hardware support
|
|
421
|
+
* if (codec.isHardwareAcceleratedDecoder()) {
|
|
422
|
+
* console.log('Hardware decoding available');
|
|
423
|
+
* }
|
|
463
424
|
*
|
|
464
|
-
*
|
|
465
|
-
*
|
|
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
|
|
433
|
+
* Check if encoder supports hardware acceleration.
|
|
471
434
|
*
|
|
472
|
-
* @param deviceType - Optional
|
|
473
|
-
* @returns
|
|
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 {
|
|
440
|
+
* import { AV_HWDEVICE_TYPE_VAAPI } from 'node-av/constants';
|
|
478
441
|
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
442
|
+
* // Check any hardware support
|
|
443
|
+
* if (codec.isHardwareAcceleratedEncoder()) {
|
|
444
|
+
* console.log('Hardware encoding available');
|
|
445
|
+
* }
|
|
482
446
|
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
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
|
|
455
|
+
* Get supported hardware device types.
|
|
490
456
|
*
|
|
491
|
-
*
|
|
457
|
+
* Returns all hardware acceleration types this codec supports.
|
|
492
458
|
*
|
|
493
|
-
* @returns Array of supported
|
|
459
|
+
* @returns Array of supported device types
|
|
494
460
|
*
|
|
495
461
|
* @example
|
|
496
462
|
* ```typescript
|
|
497
|
-
* const
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
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
|
|
477
|
+
* Get hardware method flags for device type.
|
|
507
478
|
*
|
|
508
|
-
* Returns the
|
|
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 -
|
|
515
|
-
* @returns
|
|
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 {
|
|
486
|
+
* import { AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
|
|
520
487
|
*
|
|
521
|
-
* const
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
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
|
|
498
|
+
* Get hardware configuration at index.
|
|
531
499
|
*
|
|
532
|
-
*
|
|
500
|
+
* Retrieves hardware acceleration configuration details.
|
|
533
501
|
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
545
|
-
*
|
|
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
|
|
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
|
}
|