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.js
CHANGED
|
@@ -2,132 +2,108 @@ import { AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX, AV_CODEC_HW_CONFIG_METHOD_HW_F
|
|
|
2
2
|
import { bindings } from './binding.js';
|
|
3
3
|
import { Rational } from './rational.js';
|
|
4
4
|
/**
|
|
5
|
-
* Codec
|
|
5
|
+
* Codec descriptor for audio/video encoding and decoding.
|
|
6
6
|
*
|
|
7
|
-
* Represents
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Represents an encoder or decoder implementation that can process media data.
|
|
8
|
+
* Contains codec capabilities, supported formats, and hardware acceleration information.
|
|
9
|
+
* Used to create codec contexts for actual encoding/decoding operations.
|
|
10
|
+
* Supports both software and hardware-accelerated codecs.
|
|
10
11
|
*
|
|
11
12
|
* Direct mapping to FFmpeg's AVCodec.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* ```typescript
|
|
15
|
-
* import { Codec } from 'node-av';
|
|
16
|
+
* import { Codec, FFmpegError } from 'node-av';
|
|
16
17
|
* import { AV_CODEC_ID_H264 } from 'node-av/constants';
|
|
17
18
|
*
|
|
18
19
|
* // Find decoder by ID
|
|
19
|
-
* const
|
|
20
|
-
* if (!
|
|
20
|
+
* const decoder = Codec.findDecoder(AV_CODEC_ID_H264);
|
|
21
|
+
* if (!decoder) {
|
|
22
|
+
* throw new Error('H.264 decoder not available');
|
|
23
|
+
* }
|
|
21
24
|
*
|
|
22
25
|
* // Find encoder by name
|
|
23
|
-
* const
|
|
24
|
-
* if (!
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* console.log(`Codec: ${h264Decoder.name}`);
|
|
28
|
-
* console.log(`Long name: ${h264Decoder.longName}`);
|
|
29
|
-
* console.log(`Type: ${h264Decoder.type}`);
|
|
30
|
-
* console.log(`Is decoder: ${h264Decoder.isDecoder()}`);
|
|
26
|
+
* const encoder = Codec.findEncoderByName('libx264');
|
|
27
|
+
* if (!encoder) {
|
|
28
|
+
* throw new Error('libx264 encoder not available');
|
|
29
|
+
* }
|
|
31
30
|
*
|
|
32
|
-
* //
|
|
33
|
-
*
|
|
34
|
-
* console.log(`
|
|
31
|
+
* // Check capabilities
|
|
32
|
+
* console.log(`Codec: ${decoder.name}`);
|
|
33
|
+
* console.log(`Type: ${decoder.type}`);
|
|
34
|
+
* console.log(`Hardware: ${decoder.hasHardwareAcceleration()}`);
|
|
35
35
|
*
|
|
36
|
-
* //
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* if (!result) break;
|
|
41
|
-
* console.log(`Found codec: ${result.codec.name}`);
|
|
42
|
-
* iter = result.opaque;
|
|
36
|
+
* // Get supported pixel formats
|
|
37
|
+
* const formats = decoder.pixelFormats;
|
|
38
|
+
* if (formats) {
|
|
39
|
+
* console.log(`Supported formats: ${formats.join(', ')}`);
|
|
43
40
|
* }
|
|
44
41
|
* ```
|
|
42
|
+
*
|
|
43
|
+
* @see [AVCodec](https://ffmpeg.org/doxygen/trunk/structAVCodec.html) - FFmpeg Doxygen
|
|
44
|
+
* @see {@link CodecContext} For encoding/decoding operations
|
|
45
45
|
*/
|
|
46
46
|
export class Codec {
|
|
47
47
|
native;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* Codecs are global immutable objects managed by FFmpeg.
|
|
52
|
-
* Use the static find methods to obtain codec instances.
|
|
53
|
-
*
|
|
49
|
+
* @param native - The native codec instance
|
|
54
50
|
* @internal
|
|
55
|
-
*
|
|
56
|
-
* @param native - Native AVCodec to wrap
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* import { Codec } from 'node-av';
|
|
61
|
-
* import { AV_CODEC_ID_H264 } from 'node-av/constants';
|
|
62
|
-
*
|
|
63
|
-
* // Don't use constructor directly
|
|
64
|
-
* // const codec = new Codec(); // Wrong
|
|
65
|
-
*
|
|
66
|
-
* // Use static factory methods instead
|
|
67
|
-
* const decoder = Codec.findDecoder(AV_CODEC_ID_H264); // Correct
|
|
68
|
-
* const encoder = Codec.findEncoderByName('libx264'); // Correct
|
|
69
|
-
* ```
|
|
70
51
|
*/
|
|
71
52
|
constructor(native) {
|
|
72
53
|
this.native = native;
|
|
73
54
|
}
|
|
74
55
|
/**
|
|
75
|
-
*
|
|
76
|
-
* @internal Used by the bindings layer
|
|
77
|
-
*/
|
|
78
|
-
static fromNative(native) {
|
|
79
|
-
if (!native)
|
|
80
|
-
return null;
|
|
81
|
-
return new Codec(native);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Find a registered decoder with a matching codec ID.
|
|
56
|
+
* Find a decoder by codec ID.
|
|
85
57
|
*
|
|
86
58
|
* Searches for a decoder that can decode the specified codec format.
|
|
87
59
|
*
|
|
88
|
-
* Direct mapping to avcodec_find_decoder()
|
|
60
|
+
* Direct mapping to avcodec_find_decoder().
|
|
89
61
|
*
|
|
90
|
-
* @param id -
|
|
91
|
-
*
|
|
92
|
-
* @returns Codec object or null if no decoder found
|
|
62
|
+
* @param id - Codec ID to search for
|
|
63
|
+
* @returns Decoder if found, null otherwise
|
|
93
64
|
*
|
|
94
65
|
* @example
|
|
95
66
|
* ```typescript
|
|
96
|
-
* import {
|
|
97
|
-
* import { AV_CODEC_ID_H264 } from 'node-av/constants';
|
|
67
|
+
* import { AV_CODEC_ID_H264, AV_CODEC_ID_AAC } from 'node-av/constants';
|
|
98
68
|
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
69
|
+
* // Find H.264 video decoder
|
|
70
|
+
* const h264 = Codec.findDecoder(AV_CODEC_ID_H264);
|
|
71
|
+
* if (h264) {
|
|
72
|
+
* console.log(`Found: ${h264.name}`);
|
|
102
73
|
* }
|
|
74
|
+
*
|
|
75
|
+
* // Find AAC audio decoder
|
|
76
|
+
* const aac = Codec.findDecoder(AV_CODEC_ID_AAC);
|
|
103
77
|
* ```
|
|
104
78
|
*
|
|
105
79
|
* @see {@link findDecoderByName} To find by name
|
|
106
|
-
* @see {@link findEncoder} To find
|
|
80
|
+
* @see {@link findEncoder} To find encoders
|
|
107
81
|
*/
|
|
108
82
|
static findDecoder(id) {
|
|
109
83
|
const native = bindings.Codec.findDecoder(id);
|
|
110
84
|
return native ? new Codec(native) : null;
|
|
111
85
|
}
|
|
112
86
|
/**
|
|
113
|
-
* Find a
|
|
87
|
+
* Find a decoder by name.
|
|
114
88
|
*
|
|
115
|
-
* Searches for a decoder by
|
|
116
|
-
* Useful for
|
|
89
|
+
* Searches for a specific decoder implementation by name.
|
|
90
|
+
* Useful when multiple decoders exist for the same codec.
|
|
117
91
|
*
|
|
118
|
-
* Direct mapping to avcodec_find_decoder_by_name()
|
|
92
|
+
* Direct mapping to avcodec_find_decoder_by_name().
|
|
119
93
|
*
|
|
120
|
-
* @param name -
|
|
121
|
-
*
|
|
122
|
-
* @returns Codec object or null if no decoder found
|
|
94
|
+
* @param name - Decoder name
|
|
95
|
+
* @returns Decoder if found, null otherwise
|
|
123
96
|
*
|
|
124
97
|
* @example
|
|
125
98
|
* ```typescript
|
|
126
|
-
*
|
|
99
|
+
* // Find specific H.264 decoder
|
|
100
|
+
* const decoder = Codec.findDecoderByName('h264_cuvid');
|
|
101
|
+
* if (decoder) {
|
|
102
|
+
* console.log('Found NVIDIA hardware decoder');
|
|
103
|
+
* }
|
|
127
104
|
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
* const cudaDecoder = Codec.findDecoderByName('h264_cuvid'); // NVIDIA hardware decoder
|
|
105
|
+
* // Find software decoder
|
|
106
|
+
* const sw = Codec.findDecoderByName('h264');
|
|
131
107
|
* ```
|
|
132
108
|
*
|
|
133
109
|
* @see {@link findDecoder} To find by codec ID
|
|
@@ -137,54 +113,57 @@ export class Codec {
|
|
|
137
113
|
return native ? new Codec(native) : null;
|
|
138
114
|
}
|
|
139
115
|
/**
|
|
140
|
-
* Find
|
|
116
|
+
* Find an encoder by codec ID.
|
|
141
117
|
*
|
|
142
118
|
* Searches for an encoder that can encode to the specified codec format.
|
|
143
119
|
*
|
|
144
|
-
* Direct mapping to avcodec_find_encoder()
|
|
145
|
-
*
|
|
146
|
-
* @param id - AVCodecID of the requested encoder
|
|
120
|
+
* Direct mapping to avcodec_find_encoder().
|
|
147
121
|
*
|
|
148
|
-
* @
|
|
122
|
+
* @param id - Codec ID to search for
|
|
123
|
+
* @returns Encoder if found, null otherwise
|
|
149
124
|
*
|
|
150
125
|
* @example
|
|
151
126
|
* ```typescript
|
|
152
|
-
* import {
|
|
153
|
-
* import { AV_CODEC_ID_H264 } from 'node-av/constants';
|
|
127
|
+
* import { AV_CODEC_ID_H264, AV_CODEC_ID_AAC } from 'node-av/constants';
|
|
154
128
|
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
129
|
+
* // Find H.264 video encoder
|
|
130
|
+
* const h264 = Codec.findEncoder(AV_CODEC_ID_H264);
|
|
131
|
+
* if (h264) {
|
|
132
|
+
* console.log(`Found: ${h264.name}`);
|
|
158
133
|
* }
|
|
134
|
+
*
|
|
135
|
+
* // Find AAC audio encoder
|
|
136
|
+
* const aac = Codec.findEncoder(AV_CODEC_ID_AAC);
|
|
159
137
|
* ```
|
|
160
138
|
*
|
|
161
139
|
* @see {@link findEncoderByName} To find by name
|
|
162
|
-
* @see {@link findDecoder} To find
|
|
140
|
+
* @see {@link findDecoder} To find decoders
|
|
163
141
|
*/
|
|
164
142
|
static findEncoder(id) {
|
|
165
143
|
const native = bindings.Codec.findEncoder(id);
|
|
166
144
|
return native ? new Codec(native) : null;
|
|
167
145
|
}
|
|
168
146
|
/**
|
|
169
|
-
* Find
|
|
170
|
-
*
|
|
171
|
-
* Searches for an encoder by its exact name.
|
|
172
|
-
* Useful for selecting specific encoder implementations.
|
|
147
|
+
* Find an encoder by name.
|
|
173
148
|
*
|
|
174
|
-
*
|
|
149
|
+
* Searches for a specific encoder implementation by name.
|
|
150
|
+
* Useful when multiple encoders exist for the same codec.
|
|
175
151
|
*
|
|
176
|
-
*
|
|
152
|
+
* Direct mapping to avcodec_find_encoder_by_name().
|
|
177
153
|
*
|
|
178
|
-
* @
|
|
154
|
+
* @param name - Encoder name
|
|
155
|
+
* @returns Encoder if found, null otherwise
|
|
179
156
|
*
|
|
180
157
|
* @example
|
|
181
158
|
* ```typescript
|
|
182
|
-
*
|
|
159
|
+
* // Find specific H.264 encoder
|
|
160
|
+
* const x264 = Codec.findEncoderByName('libx264');
|
|
161
|
+
* if (x264) {
|
|
162
|
+
* console.log('Found x264 encoder');
|
|
163
|
+
* }
|
|
183
164
|
*
|
|
184
|
-
* // Find
|
|
185
|
-
* const
|
|
186
|
-
* const nvenc = Codec.findEncoderByName('h264_nvenc'); // NVIDIA hardware encoder
|
|
187
|
-
* const vaapi = Codec.findEncoderByName('h264_vaapi'); // VAAPI hardware encoder
|
|
165
|
+
* // Find hardware encoder
|
|
166
|
+
* const nvenc = Codec.findEncoderByName('h264_nvenc');
|
|
188
167
|
* ```
|
|
189
168
|
*
|
|
190
169
|
* @see {@link findEncoder} To find by codec ID
|
|
@@ -196,25 +175,24 @@ export class Codec {
|
|
|
196
175
|
/**
|
|
197
176
|
* Get list of all available codecs.
|
|
198
177
|
*
|
|
199
|
-
* Returns all registered codecs
|
|
200
|
-
* Internally uses av_codec_iterate() to collect all codecs.
|
|
178
|
+
* Returns all registered codecs (both encoders and decoders).
|
|
201
179
|
*
|
|
202
|
-
* @returns Array of all
|
|
180
|
+
* @returns Array of all available codecs
|
|
203
181
|
*
|
|
204
182
|
* @example
|
|
205
183
|
* ```typescript
|
|
206
|
-
*
|
|
207
|
-
* import { AVMEDIA_TYPE_VIDEO } from 'node-av/constants';
|
|
208
|
-
*
|
|
184
|
+
* // List all codecs
|
|
209
185
|
* const codecs = Codec.getCodecList();
|
|
210
|
-
*
|
|
211
|
-
* c.type === AVMEDIA_TYPE_VIDEO && c.isEncoder()
|
|
212
|
-
* );
|
|
213
|
-
* console.log(`Found ${videoEncoders.length} video encoders`);
|
|
214
|
-
* ```
|
|
186
|
+
* console.log(`Total codecs: ${codecs.length}`);
|
|
215
187
|
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
188
|
+
* // Filter encoders
|
|
189
|
+
* const encoders = codecs.filter(c => c.isEncoder());
|
|
190
|
+
* console.log(`Encoders: ${encoders.length}`);
|
|
191
|
+
*
|
|
192
|
+
* // Filter hardware codecs
|
|
193
|
+
* const hw = codecs.filter(c => c.hasHardwareAcceleration());
|
|
194
|
+
* console.log(`Hardware codecs: ${hw.length}`);
|
|
195
|
+
* ```
|
|
218
196
|
*
|
|
219
197
|
* @see {@link iterateCodecs} For memory-efficient iteration
|
|
220
198
|
*/
|
|
@@ -223,37 +201,28 @@ export class Codec {
|
|
|
223
201
|
return natives.map((n) => new Codec(n));
|
|
224
202
|
}
|
|
225
203
|
/**
|
|
226
|
-
* Iterate through codecs
|
|
204
|
+
* Iterate through available codecs.
|
|
227
205
|
*
|
|
228
|
-
* Memory-efficient
|
|
229
|
-
*
|
|
206
|
+
* Memory-efficient way to iterate through all codecs.
|
|
207
|
+
* Uses an opaque pointer to track iteration state.
|
|
230
208
|
*
|
|
231
|
-
* Direct mapping to av_codec_iterate()
|
|
209
|
+
* Direct mapping to av_codec_iterate().
|
|
232
210
|
*
|
|
233
|
-
* @param opaque -
|
|
234
|
-
*
|
|
235
|
-
* @returns Object with codec and next iterator state, or null when done
|
|
211
|
+
* @param opaque - Iteration state (null to start)
|
|
212
|
+
* @returns Next codec and state, or null when done
|
|
236
213
|
*
|
|
237
214
|
* @example
|
|
238
215
|
* ```typescript
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* if (!result) break;
|
|
246
|
-
*
|
|
247
|
-
* const codec = result.codec;
|
|
248
|
-
* if (codec.type === AVMEDIA_TYPE_VIDEO && codec.isEncoder()) {
|
|
249
|
-
* console.log(`Video encoder: ${codec.name}`);
|
|
250
|
-
* }
|
|
251
|
-
*
|
|
252
|
-
* opaque = result.opaque;
|
|
216
|
+
* // Iterate all codecs
|
|
217
|
+
* let iter = null;
|
|
218
|
+
* let result;
|
|
219
|
+
* while ((result = Codec.iterateCodecs(iter))) {
|
|
220
|
+
* console.log(`Codec: ${result.codec.name}`);
|
|
221
|
+
* iter = result.opaque;
|
|
253
222
|
* }
|
|
254
223
|
* ```
|
|
255
224
|
*
|
|
256
|
-
* @see {@link getCodecList}
|
|
225
|
+
* @see {@link getCodecList} For simple array access
|
|
257
226
|
*/
|
|
258
227
|
static iterateCodecs(opaque = null) {
|
|
259
228
|
const result = bindings.Codec.iterateCodecs(opaque);
|
|
@@ -265,30 +234,31 @@ export class Codec {
|
|
|
265
234
|
};
|
|
266
235
|
}
|
|
267
236
|
/**
|
|
268
|
-
*
|
|
237
|
+
* Codec name.
|
|
238
|
+
*
|
|
239
|
+
* Short name identifier for the codec (e.g., 'h264', 'aac').
|
|
269
240
|
*
|
|
270
|
-
* Direct mapping to AVCodec->name
|
|
271
|
-
* Typically matches the name of the codec specification.
|
|
272
|
-
* For example: "h264", "aac", "vp9", "opus"
|
|
241
|
+
* Direct mapping to AVCodec->name.
|
|
273
242
|
*/
|
|
274
243
|
get name() {
|
|
275
244
|
return this.native.name;
|
|
276
245
|
}
|
|
277
246
|
/**
|
|
278
|
-
*
|
|
247
|
+
* Codec long name.
|
|
279
248
|
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
249
|
+
* Human-readable description of the codec.
|
|
250
|
+
*
|
|
251
|
+
* Direct mapping to AVCodec->long_name.
|
|
283
252
|
*/
|
|
284
253
|
get longName() {
|
|
285
254
|
return this.native.longName;
|
|
286
255
|
}
|
|
287
256
|
/**
|
|
288
|
-
* Media type
|
|
257
|
+
* Media type.
|
|
258
|
+
*
|
|
259
|
+
* Type of media this codec processes (video, audio, subtitle, etc.).
|
|
289
260
|
*
|
|
290
|
-
* Direct mapping to AVCodec->type
|
|
291
|
-
* AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_SUBTITLE, etc.
|
|
261
|
+
* Direct mapping to AVCodec->type.
|
|
292
262
|
*/
|
|
293
263
|
get type() {
|
|
294
264
|
return this.native.type;
|
|
@@ -296,8 +266,9 @@ export class Codec {
|
|
|
296
266
|
/**
|
|
297
267
|
* Codec ID.
|
|
298
268
|
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
269
|
+
* Unique identifier for the codec format.
|
|
270
|
+
*
|
|
271
|
+
* Direct mapping to AVCodec->id.
|
|
301
272
|
*/
|
|
302
273
|
get id() {
|
|
303
274
|
return this.native.id;
|
|
@@ -305,53 +276,50 @@ export class Codec {
|
|
|
305
276
|
/**
|
|
306
277
|
* Codec capabilities.
|
|
307
278
|
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
279
|
+
* Bitfield of AV_CODEC_CAP_* flags indicating codec features.
|
|
280
|
+
*
|
|
281
|
+
* Direct mapping to AVCodec->capabilities.
|
|
310
282
|
*/
|
|
311
283
|
get capabilities() {
|
|
312
284
|
return this.native.capabilities;
|
|
313
285
|
}
|
|
314
286
|
/**
|
|
315
|
-
* Maximum lowres value
|
|
287
|
+
* Maximum lowres value.
|
|
288
|
+
*
|
|
289
|
+
* Maximum value for lowres decoding (0 = no lowres support).
|
|
316
290
|
*
|
|
317
|
-
*
|
|
318
|
-
* 0 means lowres decoding is not supported.
|
|
319
|
-
* 1 means 1/2 resolution is supported.
|
|
320
|
-
* 2 means 1/4 resolution is supported.
|
|
321
|
-
* 3 means 1/8 resolution is supported.
|
|
322
|
-
* @readonly
|
|
291
|
+
* Direct mapping to AVCodec->max_lowres.
|
|
323
292
|
*/
|
|
324
293
|
get maxLowres() {
|
|
325
294
|
return this.native.maxLowres;
|
|
326
295
|
}
|
|
327
296
|
/**
|
|
328
|
-
*
|
|
297
|
+
* Supported profiles.
|
|
329
298
|
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
* @readonly
|
|
299
|
+
* Array of profiles this codec can handle (e.g., baseline, main, high).
|
|
300
|
+
*
|
|
301
|
+
* Direct mapping to AVCodec->profiles.
|
|
334
302
|
*/
|
|
335
303
|
get profiles() {
|
|
336
304
|
return this.native.profiles;
|
|
337
305
|
}
|
|
338
306
|
/**
|
|
339
|
-
*
|
|
307
|
+
* Wrapper name.
|
|
308
|
+
*
|
|
309
|
+
* Name of the codec wrapper, if this is a wrapper codec.
|
|
340
310
|
*
|
|
341
|
-
*
|
|
342
|
-
* For example "lavc" for internal codecs, "libopenh264" for OpenH264 wrapper.
|
|
343
|
-
* null if codec is not wrapped.
|
|
344
|
-
* @readonly
|
|
311
|
+
* Direct mapping to AVCodec->wrapper_name.
|
|
345
312
|
*/
|
|
346
313
|
get wrapper() {
|
|
347
314
|
return this.native.wrapper;
|
|
348
315
|
}
|
|
349
316
|
/**
|
|
350
|
-
* Supported
|
|
317
|
+
* Supported frame rates.
|
|
318
|
+
*
|
|
319
|
+
* Array of frame rates this video codec supports.
|
|
320
|
+
* Null for audio codecs or if all rates are supported.
|
|
351
321
|
*
|
|
352
|
-
*
|
|
353
|
-
* Some codecs like MPEG-1/2 only support specific framerates.
|
|
354
|
-
* @readonly
|
|
322
|
+
* Direct mapping to AVCodec->supported_framerates.
|
|
355
323
|
*/
|
|
356
324
|
get supportedFramerates() {
|
|
357
325
|
const rates = this.native.supportedFramerates;
|
|
@@ -360,98 +328,97 @@ export class Codec {
|
|
|
360
328
|
return rates.map((r) => new Rational(r.num, r.den));
|
|
361
329
|
}
|
|
362
330
|
/**
|
|
363
|
-
*
|
|
331
|
+
* Supported pixel formats.
|
|
364
332
|
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
333
|
+
* Array of pixel formats this video codec supports.
|
|
334
|
+
* Null for audio codecs.
|
|
335
|
+
*
|
|
336
|
+
* Direct mapping to AVCodec->pix_fmts.
|
|
368
337
|
*/
|
|
369
338
|
get pixelFormats() {
|
|
370
339
|
return this.native.pixelFormats;
|
|
371
340
|
}
|
|
372
341
|
/**
|
|
373
|
-
* Supported sample rates
|
|
342
|
+
* Supported sample rates.
|
|
343
|
+
*
|
|
344
|
+
* Array of sample rates this audio codec supports.
|
|
345
|
+
* Null for video codecs or if all rates are supported.
|
|
374
346
|
*
|
|
375
|
-
*
|
|
376
|
-
* Common rates: 8000, 16000, 22050, 44100, 48000, 96000, 192000 Hz.
|
|
377
|
-
* @readonly
|
|
347
|
+
* Direct mapping to AVCodec->supported_samplerates.
|
|
378
348
|
*/
|
|
379
349
|
get supportedSamplerates() {
|
|
380
350
|
return this.native.supportedSamplerates;
|
|
381
351
|
}
|
|
382
352
|
/**
|
|
383
|
-
*
|
|
353
|
+
* Supported sample formats.
|
|
354
|
+
*
|
|
355
|
+
* Array of sample formats this audio codec supports.
|
|
356
|
+
* Null for video codecs.
|
|
384
357
|
*
|
|
385
|
-
*
|
|
386
|
-
* Lists all sample formats this codec can encode/decode.
|
|
387
|
-
* Common formats: S16, S32, FLT, DBL (planar and interleaved variants).
|
|
388
|
-
* @readonly
|
|
358
|
+
* Direct mapping to AVCodec->sample_fmts.
|
|
389
359
|
*/
|
|
390
360
|
get sampleFormats() {
|
|
391
361
|
return this.native.sampleFormats;
|
|
392
362
|
}
|
|
393
363
|
/**
|
|
394
|
-
*
|
|
364
|
+
* Supported channel layouts.
|
|
395
365
|
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
366
|
+
* Array of channel layouts this audio codec supports.
|
|
367
|
+
* Null for video codecs.
|
|
368
|
+
*
|
|
369
|
+
* Direct mapping to AVCodec->ch_layouts.
|
|
400
370
|
*/
|
|
401
371
|
get channelLayouts() {
|
|
402
372
|
return this.native.channelLayouts;
|
|
403
373
|
}
|
|
404
374
|
/**
|
|
405
|
-
* Check if
|
|
406
|
-
*
|
|
407
|
-
* Direct mapping to av_codec_is_encoder()
|
|
375
|
+
* Check if codec is an encoder.
|
|
408
376
|
*
|
|
409
|
-
* @returns
|
|
377
|
+
* @returns True if this codec can encode
|
|
410
378
|
*
|
|
411
379
|
* @example
|
|
412
380
|
* ```typescript
|
|
413
381
|
* const codec = Codec.findEncoderByName('libx264');
|
|
414
|
-
* if (codec
|
|
415
|
-
* console.log('
|
|
382
|
+
* if (codec?.isEncoder()) {
|
|
383
|
+
* console.log('This is an encoder');
|
|
416
384
|
* }
|
|
417
385
|
* ```
|
|
386
|
+
*
|
|
387
|
+
* @see {@link isDecoder} To check for decoders
|
|
418
388
|
*/
|
|
419
389
|
isEncoder() {
|
|
420
390
|
return this.native.isEncoder();
|
|
421
391
|
}
|
|
422
392
|
/**
|
|
423
|
-
* Check if
|
|
393
|
+
* Check if codec is a decoder.
|
|
424
394
|
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
* @returns true if the codec is a decoder, false otherwise
|
|
395
|
+
* @returns True if this codec can decode
|
|
428
396
|
*
|
|
429
397
|
* @example
|
|
430
398
|
* ```typescript
|
|
431
399
|
* const codec = Codec.findDecoder(AV_CODEC_ID_H264);
|
|
432
|
-
* if (codec
|
|
433
|
-
* console.log('
|
|
400
|
+
* if (codec?.isDecoder()) {
|
|
401
|
+
* console.log('This is a decoder');
|
|
434
402
|
* }
|
|
435
403
|
* ```
|
|
404
|
+
*
|
|
405
|
+
* @see {@link isEncoder} To check for encoders
|
|
436
406
|
*/
|
|
437
407
|
isDecoder() {
|
|
438
408
|
return this.native.isDecoder();
|
|
439
409
|
}
|
|
440
410
|
/**
|
|
441
|
-
* Check if
|
|
411
|
+
* Check if codec is experimental.
|
|
442
412
|
*
|
|
443
|
-
* Experimental codecs require explicit
|
|
444
|
-
* You must set strict_std_compliance to FF_COMPLIANCE_EXPERIMENTAL
|
|
445
|
-
* or lower in the codec context to use experimental codecs.
|
|
413
|
+
* Experimental codecs require explicit opt-in to use.
|
|
446
414
|
*
|
|
447
|
-
* @returns
|
|
415
|
+
* @returns True if codec is marked experimental
|
|
448
416
|
*
|
|
449
417
|
* @example
|
|
450
418
|
* ```typescript
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* // codecContext.strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
|
|
419
|
+
* if (codec.isExperimental()) {
|
|
420
|
+
* console.warn('This codec is experimental');
|
|
421
|
+
* // Need to set strict_std_compliance = -2
|
|
455
422
|
* }
|
|
456
423
|
* ```
|
|
457
424
|
*/
|
|
@@ -459,30 +426,21 @@ export class Codec {
|
|
|
459
426
|
return this.native.isExperimental();
|
|
460
427
|
}
|
|
461
428
|
/**
|
|
462
|
-
* Check if codec
|
|
429
|
+
* Check if codec supports hardware acceleration.
|
|
463
430
|
*
|
|
464
|
-
*
|
|
465
|
-
* This includes:
|
|
466
|
-
* - Generic decoders with hardware acceleration support (e.g., 'h264' with VideoToolbox)
|
|
467
|
-
* - Dedicated hardware codecs (e.g., 'h264_videotoolbox', 'h264_nvenc')
|
|
431
|
+
* Checks if the codec has any hardware configuration.
|
|
468
432
|
*
|
|
469
|
-
* @returns
|
|
433
|
+
* @returns True if hardware acceleration is available
|
|
470
434
|
*
|
|
471
435
|
* @example
|
|
472
436
|
* ```typescript
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
* console.log(x264?.hasHardwareAcceleration()); // false
|
|
478
|
-
*
|
|
479
|
-
* // Check hardware codecs
|
|
480
|
-
* const h264 = Codec.findDecoderByName('h264');
|
|
481
|
-
* console.log(h264?.hasHardwareAcceleration()); // true
|
|
482
|
-
*
|
|
483
|
-
* const videotoolbox = Codec.findEncoderByName('h264_videotoolbox');
|
|
484
|
-
* console.log(videotoolbox?.hasHardwareAcceleration()); // true
|
|
437
|
+
* const codec = Codec.findDecoderByName('h264_cuvid');
|
|
438
|
+
* if (codec?.hasHardwareAcceleration()) {
|
|
439
|
+
* console.log('Hardware acceleration available');
|
|
440
|
+
* }
|
|
485
441
|
* ```
|
|
442
|
+
*
|
|
443
|
+
* @see {@link getSupportedDeviceTypes} For specific device types
|
|
486
444
|
*/
|
|
487
445
|
hasHardwareAcceleration() {
|
|
488
446
|
// A codec is considered hardware if it has any hw_config with:
|
|
@@ -500,23 +458,21 @@ export class Codec {
|
|
|
500
458
|
return false;
|
|
501
459
|
}
|
|
502
460
|
/**
|
|
503
|
-
* Check if codec supports
|
|
461
|
+
* Check if codec supports specific device type.
|
|
504
462
|
*
|
|
505
|
-
* @param deviceType -
|
|
506
|
-
* @returns
|
|
463
|
+
* @param deviceType - Hardware device type to check
|
|
464
|
+
* @returns True if device type is supported
|
|
507
465
|
*
|
|
508
466
|
* @example
|
|
509
467
|
* ```typescript
|
|
510
|
-
* import {
|
|
511
|
-
* import { AV_HWDEVICE_TYPE_VIDEOTOOLBOX, AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
|
|
468
|
+
* import { AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
|
|
512
469
|
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
* const h264VT = Codec.findEncoderByName('h264_videotoolbox');
|
|
517
|
-
* console.log(h264VT?.supportsDevice(AV_HWDEVICE_TYPE_VIDEOTOOLBOX)); // true
|
|
518
|
-
* console.log(h264VT?.supportsDevice(AV_HWDEVICE_TYPE_CUDA)); // false
|
|
470
|
+
* if (codec.supportsDevice(AV_HWDEVICE_TYPE_CUDA)) {
|
|
471
|
+
* console.log('Supports NVIDIA CUDA');
|
|
472
|
+
* }
|
|
519
473
|
* ```
|
|
474
|
+
*
|
|
475
|
+
* @see {@link getSupportedDeviceTypes} For all supported types
|
|
520
476
|
*/
|
|
521
477
|
supportsDevice(deviceType) {
|
|
522
478
|
for (let i = 0;; i++) {
|
|
@@ -534,21 +490,24 @@ export class Codec {
|
|
|
534
490
|
return false;
|
|
535
491
|
}
|
|
536
492
|
/**
|
|
537
|
-
* Check if
|
|
493
|
+
* Check if decoder supports hardware acceleration.
|
|
538
494
|
*
|
|
539
|
-
* @param deviceType - Optional
|
|
540
|
-
* @returns
|
|
495
|
+
* @param deviceType - Optional specific device type
|
|
496
|
+
* @returns True if hardware decoding is supported
|
|
541
497
|
*
|
|
542
498
|
* @example
|
|
543
499
|
* ```typescript
|
|
544
500
|
* import { AV_HWDEVICE_TYPE_VIDEOTOOLBOX } from 'node-av/constants';
|
|
545
501
|
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
*
|
|
502
|
+
* // Check any hardware support
|
|
503
|
+
* if (codec.isHardwareAcceleratedDecoder()) {
|
|
504
|
+
* console.log('Hardware decoding available');
|
|
505
|
+
* }
|
|
549
506
|
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
507
|
+
* // Check specific device
|
|
508
|
+
* if (codec.isHardwareAcceleratedDecoder(AV_HWDEVICE_TYPE_VIDEOTOOLBOX)) {
|
|
509
|
+
* console.log('VideoToolbox decoding available');
|
|
510
|
+
* }
|
|
552
511
|
* ```
|
|
553
512
|
*/
|
|
554
513
|
isHardwareAcceleratedDecoder(deviceType) {
|
|
@@ -560,21 +519,24 @@ export class Codec {
|
|
|
560
519
|
return this.hasHardwareAcceleration();
|
|
561
520
|
}
|
|
562
521
|
/**
|
|
563
|
-
* Check if
|
|
522
|
+
* Check if encoder supports hardware acceleration.
|
|
564
523
|
*
|
|
565
|
-
* @param deviceType - Optional
|
|
566
|
-
* @returns
|
|
524
|
+
* @param deviceType - Optional specific device type
|
|
525
|
+
* @returns True if hardware encoding is supported
|
|
567
526
|
*
|
|
568
527
|
* @example
|
|
569
528
|
* ```typescript
|
|
570
|
-
* import {
|
|
529
|
+
* import { AV_HWDEVICE_TYPE_VAAPI } from 'node-av/constants';
|
|
571
530
|
*
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
*
|
|
531
|
+
* // Check any hardware support
|
|
532
|
+
* if (codec.isHardwareAcceleratedEncoder()) {
|
|
533
|
+
* console.log('Hardware encoding available');
|
|
534
|
+
* }
|
|
575
535
|
*
|
|
576
|
-
*
|
|
577
|
-
*
|
|
536
|
+
* // Check specific device
|
|
537
|
+
* if (codec.isHardwareAcceleratedEncoder(AV_HWDEVICE_TYPE_VAAPI)) {
|
|
538
|
+
* console.log('VAAPI encoding available');
|
|
539
|
+
* }
|
|
578
540
|
* ```
|
|
579
541
|
*/
|
|
580
542
|
isHardwareAcceleratedEncoder(deviceType) {
|
|
@@ -586,20 +548,25 @@ export class Codec {
|
|
|
586
548
|
return this.hasHardwareAcceleration();
|
|
587
549
|
}
|
|
588
550
|
/**
|
|
589
|
-
* Get
|
|
551
|
+
* Get supported hardware device types.
|
|
590
552
|
*
|
|
591
|
-
*
|
|
553
|
+
* Returns all hardware acceleration types this codec supports.
|
|
592
554
|
*
|
|
593
|
-
* @returns Array of supported
|
|
555
|
+
* @returns Array of supported device types
|
|
594
556
|
*
|
|
595
557
|
* @example
|
|
596
558
|
* ```typescript
|
|
597
|
-
* const
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
559
|
+
* const devices = codec.getSupportedDeviceTypes();
|
|
560
|
+
* console.log('Supported devices:', devices.map(d => {
|
|
561
|
+
* switch(d) {
|
|
562
|
+
* case AV_HWDEVICE_TYPE_CUDA: return 'CUDA';
|
|
563
|
+
* case AV_HWDEVICE_TYPE_VAAPI: return 'VAAPI';
|
|
564
|
+
* default: return 'Unknown';
|
|
565
|
+
* }
|
|
566
|
+
* }));
|
|
602
567
|
* ```
|
|
568
|
+
*
|
|
569
|
+
* @see {@link supportsDevice} To check specific device
|
|
603
570
|
*/
|
|
604
571
|
getSupportedDeviceTypes() {
|
|
605
572
|
const deviceTypes = new Set();
|
|
@@ -615,25 +582,22 @@ export class Codec {
|
|
|
615
582
|
return Array.from(deviceTypes);
|
|
616
583
|
}
|
|
617
584
|
/**
|
|
618
|
-
* Get
|
|
585
|
+
* Get hardware method flags for device type.
|
|
619
586
|
*
|
|
620
|
-
* Returns the
|
|
621
|
-
* Useful to know HOW the codec uses hardware:
|
|
622
|
-
* - HW_DEVICE_CTX: Uses global device context (typical for decoders)
|
|
623
|
-
* - HW_FRAMES_CTX: Uses frame-level context (typical for encoders)
|
|
624
|
-
* - Both: Full hardware pipeline support
|
|
587
|
+
* Returns the hardware configuration methods for a specific device.
|
|
625
588
|
*
|
|
626
|
-
* @param deviceType -
|
|
627
|
-
* @returns
|
|
589
|
+
* @param deviceType - Device type to query
|
|
590
|
+
* @returns Method flags, or null if not supported
|
|
628
591
|
*
|
|
629
592
|
* @example
|
|
630
593
|
* ```typescript
|
|
631
|
-
* import {
|
|
594
|
+
* import { AV_HWDEVICE_TYPE_CUDA } from 'node-av/constants';
|
|
632
595
|
*
|
|
633
|
-
* const
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
596
|
+
* const methods = codec.getHardwareMethod(AV_HWDEVICE_TYPE_CUDA);
|
|
597
|
+
* if (methods) {
|
|
598
|
+
* if (methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) {
|
|
599
|
+
* console.log('Supports device context');
|
|
600
|
+
* }
|
|
637
601
|
* }
|
|
638
602
|
* ```
|
|
639
603
|
*/
|
|
@@ -649,23 +613,26 @@ export class Codec {
|
|
|
649
613
|
return null;
|
|
650
614
|
}
|
|
651
615
|
/**
|
|
652
|
-
* Get hardware configuration at
|
|
616
|
+
* Get hardware configuration at index.
|
|
653
617
|
*
|
|
654
|
-
*
|
|
618
|
+
* Retrieves hardware acceleration configuration details.
|
|
655
619
|
*
|
|
656
|
-
*
|
|
657
|
-
*
|
|
620
|
+
* Direct mapping to avcodec_get_hw_config().
|
|
621
|
+
*
|
|
622
|
+
* @param index - Configuration index
|
|
623
|
+
* @returns Hardware configuration, or null if index out of range
|
|
658
624
|
*
|
|
659
625
|
* @example
|
|
660
626
|
* ```typescript
|
|
661
|
-
*
|
|
627
|
+
* // Enumerate all hardware configs
|
|
662
628
|
* for (let i = 0; ; i++) {
|
|
663
629
|
* const config = codec.getHwConfig(i);
|
|
664
630
|
* if (!config) break;
|
|
665
631
|
*
|
|
666
|
-
*
|
|
667
|
-
*
|
|
668
|
-
* }
|
|
632
|
+
* console.log(`Config ${i}:`);
|
|
633
|
+
* console.log(` Pixel format: ${config.pixFmt}`);
|
|
634
|
+
* console.log(` Device type: ${config.deviceType}`);
|
|
635
|
+
* console.log(` Methods: 0x${config.methods.toString(16)}`);
|
|
669
636
|
* }
|
|
670
637
|
* ```
|
|
671
638
|
*/
|
|
@@ -673,11 +640,27 @@ export class Codec {
|
|
|
673
640
|
return this.native.getHwConfig(index);
|
|
674
641
|
}
|
|
675
642
|
/**
|
|
676
|
-
* Get the native
|
|
643
|
+
* Get the underlying native Codec object.
|
|
644
|
+
*
|
|
645
|
+
* @returns The native Codec binding object
|
|
646
|
+
*
|
|
677
647
|
* @internal
|
|
678
648
|
*/
|
|
679
649
|
getNative() {
|
|
680
650
|
return this.native;
|
|
681
651
|
}
|
|
652
|
+
/**
|
|
653
|
+
* Create codec from native instance.
|
|
654
|
+
*
|
|
655
|
+
* @param native - Native codec instance
|
|
656
|
+
* @returns Codec wrapper or null
|
|
657
|
+
*
|
|
658
|
+
* @internal
|
|
659
|
+
*/
|
|
660
|
+
static fromNative(native) {
|
|
661
|
+
if (!native)
|
|
662
|
+
return null;
|
|
663
|
+
return new Codec(native);
|
|
664
|
+
}
|
|
682
665
|
}
|
|
683
666
|
//# sourceMappingURL=codec.js.map
|