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