node-av 1.1.0 → 1.3.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 -59
- package/dist/api/bitstream-filter.d.ts +183 -123
- package/dist/api/bitstream-filter.js +185 -127
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +282 -130
- package/dist/api/decoder.js +290 -142
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/encoder.d.ts +249 -160
- package/dist/api/encoder.js +276 -207
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-presets.d.ts +1944 -96
- package/dist/api/filter-presets.js +2059 -105
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +264 -200
- package/dist/api/filter.js +269 -231
- package/dist/api/filter.js.map +1 -1
- package/dist/api/hardware.d.ts +246 -117
- package/dist/api/hardware.js +440 -217
- 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 -55
- package/dist/api/io-stream.js +43 -40
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/media-input.d.ts +242 -139
- package/dist/api/media-input.js +205 -103
- package/dist/api/media-input.js.map +1 -1
- package/dist/api/media-output.d.ts +208 -126
- package/dist/api/media-output.js +212 -126
- package/dist/api/media-output.js.map +1 -1
- package/dist/api/pipeline.d.ts +361 -38
- package/dist/api/pipeline.js +255 -14
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/types.d.ts +26 -187
- package/dist/api/utilities/audio-sample.d.ts +0 -8
- package/dist/api/utilities/audio-sample.js +0 -8
- package/dist/api/utilities/audio-sample.js.map +1 -1
- package/dist/api/utilities/channel-layout.d.ts +0 -8
- package/dist/api/utilities/channel-layout.js +0 -8
- package/dist/api/utilities/channel-layout.js.map +1 -1
- package/dist/api/utilities/image.d.ts +0 -8
- package/dist/api/utilities/image.js +0 -8
- package/dist/api/utilities/image.js.map +1 -1
- package/dist/api/utilities/index.d.ts +3 -3
- package/dist/api/utilities/index.js +3 -3
- package/dist/api/utilities/index.js.map +1 -1
- package/dist/api/utilities/media-type.d.ts +1 -9
- package/dist/api/utilities/media-type.js +1 -9
- package/dist/api/utilities/media-type.js.map +1 -1
- package/dist/api/utilities/pixel-format.d.ts +1 -9
- package/dist/api/utilities/pixel-format.js +1 -9
- package/dist/api/utilities/pixel-format.js.map +1 -1
- package/dist/api/utilities/sample-format.d.ts +1 -9
- package/dist/api/utilities/sample-format.js +1 -9
- package/dist/api/utilities/sample-format.js.map +1 -1
- package/dist/api/utilities/streaming.d.ts +0 -8
- package/dist/api/utilities/streaming.js +0 -8
- package/dist/api/utilities/streaming.js.map +1 -1
- package/dist/api/utilities/timestamp.d.ts +0 -8
- package/dist/api/utilities/timestamp.js +0 -8
- package/dist/api/utilities/timestamp.js.map +1 -1
- package/dist/api/utils.d.ts +1 -2
- package/dist/api/utils.js +11 -0
- package/dist/api/utils.js.map +1 -1
- package/dist/constants/constants.d.ts +1 -1
- package/dist/constants/constants.js +2 -0
- package/dist/constants/constants.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.d.ts +1 -0
- package/dist/lib/binding.js +7 -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 +266 -283
- package/dist/lib/codec.js +270 -287
- 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 +3 -2
- package/dist/lib/index.js +3 -3
- 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 +118 -106
- package/dist/lib/native-types.js +0 -7
- package/dist/lib/native-types.js.map +1 -1
- package/dist/lib/option.d.ts +437 -218
- package/dist/lib/option.js +462 -226
- 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 +435 -181
- package/dist/lib/utilities.js +438 -182
- package/dist/lib/utilities.js.map +1 -1
- package/install/check.js +0 -1
- package/install/ffmpeg.js +0 -11
- package/package.json +25 -18
- package/release_notes.md +24 -59
- package/CHANGELOG.md +0 -8
package/dist/lib/option.js
CHANGED
|
@@ -1,43 +1,48 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Option - FFmpeg AVOption System Bindings
|
|
3
|
-
*
|
|
4
|
-
* Provides low-level access to FFmpeg's AVOption API for getting and setting
|
|
5
|
-
* options on various FFmpeg objects (CodecContext, FormatContext, FilterContext, etc).
|
|
6
|
-
*
|
|
7
|
-
* The AVOption API is FFmpeg's unified system for runtime configuration,
|
|
8
|
-
* allowing type-safe access to object properties with validation.
|
|
9
|
-
*
|
|
10
|
-
* @module lib/option
|
|
11
|
-
*/
|
|
12
1
|
import { AV_OPT_SEARCH_CHILDREN, AV_OPT_TYPE_BINARY, AV_OPT_TYPE_BINARY_INT_ARRAY, AV_OPT_TYPE_BOOL, AV_OPT_TYPE_CHLAYOUT, AV_OPT_TYPE_COLOR, AV_OPT_TYPE_CONST, AV_OPT_TYPE_DICT, AV_OPT_TYPE_DOUBLE, AV_OPT_TYPE_DURATION, AV_OPT_TYPE_FLAGS, AV_OPT_TYPE_FLOAT, AV_OPT_TYPE_IMAGE_SIZE, AV_OPT_TYPE_INT, AV_OPT_TYPE_INT64, AV_OPT_TYPE_PIXEL_FMT, AV_OPT_TYPE_RATIONAL, AV_OPT_TYPE_SAMPLE_FMT, AV_OPT_TYPE_STRING, AV_OPT_TYPE_UINT, AV_OPT_TYPE_UINT64, AV_OPT_TYPE_VIDEO_RATE, AVFLAG_NONE, } from '../constants/constants.js';
|
|
13
2
|
import { bindings } from './binding.js';
|
|
14
3
|
import { Dictionary } from './dictionary.js';
|
|
15
4
|
import { Rational } from './rational.js';
|
|
16
5
|
/**
|
|
17
|
-
*
|
|
6
|
+
* Option information descriptor.
|
|
18
7
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
8
|
+
* Describes a single option available on an FFmpeg object.
|
|
9
|
+
* Contains metadata about the option including name, type, default value,
|
|
10
|
+
* valid range, and documentation. Used to discover and validate options.
|
|
11
|
+
*
|
|
12
|
+
* Direct mapping to FFmpeg's AVOption.
|
|
21
13
|
*
|
|
22
14
|
* @example
|
|
23
15
|
* ```typescript
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
16
|
+
* import { Option } from 'node-av';
|
|
17
|
+
*
|
|
18
|
+
* // Get option info
|
|
19
|
+
* const optInfo = Option.find(obj, 'bitrate');
|
|
20
|
+
* if (optInfo) {
|
|
21
|
+
* console.log(`Option: ${optInfo.name}`);
|
|
22
|
+
* console.log(`Help: ${optInfo.help}`);
|
|
23
|
+
* console.log(`Type: ${optInfo.type}`);
|
|
24
|
+
* console.log(`Default: ${optInfo.defaultValue}`);
|
|
25
|
+
* console.log(`Range: ${optInfo.min} - ${optInfo.max}`);
|
|
28
26
|
* }
|
|
29
27
|
* ```
|
|
28
|
+
*
|
|
29
|
+
* @see [AVOption](https://ffmpeg.org/doxygen/trunk/structAVOption.html) - FFmpeg Doxygen
|
|
30
30
|
*/
|
|
31
31
|
export class OptionInfo {
|
|
32
32
|
native;
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* @param native - The native option instance
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
34
37
|
constructor(native) {
|
|
35
38
|
this.native = native;
|
|
36
39
|
}
|
|
37
40
|
/**
|
|
38
41
|
* Option name.
|
|
39
42
|
*
|
|
40
|
-
* The
|
|
43
|
+
* The name used to get/set this option.
|
|
44
|
+
*
|
|
45
|
+
* Direct mapping to AVOption->name.
|
|
41
46
|
*/
|
|
42
47
|
get name() {
|
|
43
48
|
return this.native.name;
|
|
@@ -45,7 +50,9 @@ export class OptionInfo {
|
|
|
45
50
|
/**
|
|
46
51
|
* Option help text.
|
|
47
52
|
*
|
|
48
|
-
* Human-readable description of the option.
|
|
53
|
+
* Human-readable description of the option's purpose.
|
|
54
|
+
*
|
|
55
|
+
* Direct mapping to AVOption->help.
|
|
49
56
|
*/
|
|
50
57
|
get help() {
|
|
51
58
|
return this.native.help;
|
|
@@ -53,7 +60,9 @@ export class OptionInfo {
|
|
|
53
60
|
/**
|
|
54
61
|
* Option type.
|
|
55
62
|
*
|
|
56
|
-
*
|
|
63
|
+
* Data type of the option value (AV_OPT_TYPE_*).
|
|
64
|
+
*
|
|
65
|
+
* Direct mapping to AVOption->type.
|
|
57
66
|
*/
|
|
58
67
|
get type() {
|
|
59
68
|
return this.native.type;
|
|
@@ -61,8 +70,10 @@ export class OptionInfo {
|
|
|
61
70
|
/**
|
|
62
71
|
* Default value.
|
|
63
72
|
*
|
|
64
|
-
* The value
|
|
73
|
+
* The default value for this option.
|
|
65
74
|
* Type depends on the option type.
|
|
75
|
+
*
|
|
76
|
+
* Direct mapping to AVOption->default_val.
|
|
66
77
|
*/
|
|
67
78
|
get defaultValue() {
|
|
68
79
|
return this.native.defaultValue;
|
|
@@ -70,7 +81,9 @@ export class OptionInfo {
|
|
|
70
81
|
/**
|
|
71
82
|
* Minimum value.
|
|
72
83
|
*
|
|
73
|
-
*
|
|
84
|
+
* Minimum valid value for numeric options.
|
|
85
|
+
*
|
|
86
|
+
* Direct mapping to AVOption->min.
|
|
74
87
|
*/
|
|
75
88
|
get min() {
|
|
76
89
|
return this.native.min;
|
|
@@ -78,7 +91,9 @@ export class OptionInfo {
|
|
|
78
91
|
/**
|
|
79
92
|
* Maximum value.
|
|
80
93
|
*
|
|
81
|
-
*
|
|
94
|
+
* Maximum valid value for numeric options.
|
|
95
|
+
*
|
|
96
|
+
* Direct mapping to AVOption->max.
|
|
82
97
|
*/
|
|
83
98
|
get max() {
|
|
84
99
|
return this.native.max;
|
|
@@ -86,7 +101,9 @@ export class OptionInfo {
|
|
|
86
101
|
/**
|
|
87
102
|
* Option flags.
|
|
88
103
|
*
|
|
89
|
-
*
|
|
104
|
+
* Combination of AV_OPT_FLAG_* indicating option properties.
|
|
105
|
+
*
|
|
106
|
+
* Direct mapping to AVOption->flags.
|
|
90
107
|
*/
|
|
91
108
|
get flags() {
|
|
92
109
|
return this.native.flags;
|
|
@@ -94,65 +111,81 @@ export class OptionInfo {
|
|
|
94
111
|
/**
|
|
95
112
|
* Option unit.
|
|
96
113
|
*
|
|
97
|
-
*
|
|
114
|
+
* Unit string for grouping related options.
|
|
115
|
+
*
|
|
116
|
+
* Direct mapping to AVOption->unit.
|
|
98
117
|
*/
|
|
99
118
|
get unit() {
|
|
100
119
|
return this.native.unit;
|
|
101
120
|
}
|
|
102
121
|
/**
|
|
103
|
-
* Get the native
|
|
122
|
+
* Get the underlying native Option object.
|
|
123
|
+
*
|
|
124
|
+
* @returns The native Option binding object
|
|
104
125
|
*
|
|
105
|
-
* @internal
|
|
106
|
-
* @returns The underlying native option object
|
|
126
|
+
* @internal
|
|
107
127
|
*/
|
|
108
128
|
getNative() {
|
|
109
129
|
return this.native;
|
|
110
130
|
}
|
|
111
131
|
}
|
|
112
132
|
/**
|
|
113
|
-
*
|
|
133
|
+
* FFmpeg option management utilities.
|
|
114
134
|
*
|
|
115
|
-
* Provides static methods for
|
|
116
|
-
*
|
|
135
|
+
* Provides static methods for getting, setting, and querying options
|
|
136
|
+
* on FFmpeg objects that support the AVOption API. Handles type conversion
|
|
137
|
+
* and validation for various option types including strings, numbers,
|
|
138
|
+
* rationals, pixel formats, and more.
|
|
117
139
|
*
|
|
118
|
-
*
|
|
140
|
+
* Direct mapping to FFmpeg's AVOption API.
|
|
119
141
|
*
|
|
120
142
|
* @example
|
|
121
143
|
* ```typescript
|
|
122
|
-
*
|
|
123
|
-
*
|
|
144
|
+
* import { Option, FFmpegError } from 'node-av';
|
|
145
|
+
* import { AV_OPT_SEARCH_CHILDREN, AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
146
|
+
*
|
|
147
|
+
* // Set various option types
|
|
148
|
+
* let ret = Option.set(obj, 'preset', 'fast');
|
|
149
|
+
* FFmpegError.throwIfError(ret, 'set preset');
|
|
150
|
+
*
|
|
151
|
+
* ret = Option.setInt(obj, 'bitrate', 2000000);
|
|
152
|
+
* FFmpegError.throwIfError(ret, 'set bitrate');
|
|
124
153
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
154
|
+
* ret = Option.setRational(obj, 'framerate', { num: 30, den: 1 });
|
|
155
|
+
* FFmpegError.throwIfError(ret, 'set framerate');
|
|
127
156
|
*
|
|
128
|
-
* //
|
|
157
|
+
* // Get option values
|
|
158
|
+
* const preset = Option.get(obj, 'preset');
|
|
159
|
+
* const bitrate = Option.getInt(obj, 'bitrate');
|
|
160
|
+
* const framerate = Option.getRational(obj, 'framerate');
|
|
161
|
+
*
|
|
162
|
+
* // List all options
|
|
129
163
|
* let opt = null;
|
|
130
|
-
* while ((opt = Option.next(
|
|
164
|
+
* while ((opt = Option.next(obj, opt))) {
|
|
131
165
|
* console.log(`${opt.name}: ${opt.help}`);
|
|
132
166
|
* }
|
|
133
167
|
* ```
|
|
168
|
+
*
|
|
169
|
+
* @see [AVOption API](https://ffmpeg.org/doxygen/trunk/group__avoptions.html) - FFmpeg Doxygen
|
|
170
|
+
* @see {@link OptionMember} For inherited option support
|
|
134
171
|
*/
|
|
135
172
|
export class Option {
|
|
136
|
-
// Private constructor - static class only
|
|
137
|
-
constructor() {
|
|
138
|
-
throw new Error('Option is a static class and cannot be instantiated');
|
|
139
|
-
}
|
|
140
|
-
// Static Methods - Iteration
|
|
141
173
|
/**
|
|
142
|
-
* Iterate
|
|
174
|
+
* Iterate to next option.
|
|
143
175
|
*
|
|
144
|
-
*
|
|
176
|
+
* Iterates through available options on an object.
|
|
145
177
|
*
|
|
146
|
-
*
|
|
147
|
-
* @param prev - Previous option for iteration, or null to start
|
|
178
|
+
* Direct mapping to av_opt_next().
|
|
148
179
|
*
|
|
149
|
-
* @
|
|
180
|
+
* @param obj - Object with options
|
|
181
|
+
* @param prev - Previous option (null to get first)
|
|
182
|
+
* @returns Next option, or null if no more
|
|
150
183
|
*
|
|
151
184
|
* @example
|
|
152
185
|
* ```typescript
|
|
153
186
|
* let opt = null;
|
|
154
|
-
* while ((opt = Option.next(
|
|
155
|
-
* console.log(
|
|
187
|
+
* while ((opt = Option.next(obj, opt))) {
|
|
188
|
+
* console.log(`Option: ${opt.name}`);
|
|
156
189
|
* }
|
|
157
190
|
* ```
|
|
158
191
|
*/
|
|
@@ -161,21 +194,22 @@ export class Option {
|
|
|
161
194
|
return result ? new OptionInfo(result) : null;
|
|
162
195
|
}
|
|
163
196
|
/**
|
|
164
|
-
* Find
|
|
197
|
+
* Find option by name.
|
|
165
198
|
*
|
|
166
|
-
*
|
|
199
|
+
* Searches for an option with the specified name.
|
|
167
200
|
*
|
|
168
|
-
*
|
|
169
|
-
* @param name - Option name to find
|
|
170
|
-
* @param searchFlags - Search flags (default: 0)
|
|
201
|
+
* Direct mapping to av_opt_find().
|
|
171
202
|
*
|
|
172
|
-
* @
|
|
203
|
+
* @param obj - Object to search
|
|
204
|
+
* @param name - Option name
|
|
205
|
+
* @param searchFlags - Search flags
|
|
206
|
+
* @returns Option info if found, null otherwise
|
|
173
207
|
*
|
|
174
208
|
* @example
|
|
175
209
|
* ```typescript
|
|
176
|
-
* const opt = Option.find(
|
|
210
|
+
* const opt = Option.find(obj, 'bitrate');
|
|
177
211
|
* if (opt) {
|
|
178
|
-
* console.log(`Found
|
|
212
|
+
* console.log(`Found: ${opt.name}, Type: ${opt.type}`);
|
|
179
213
|
* }
|
|
180
214
|
* ```
|
|
181
215
|
*/
|
|
@@ -184,15 +218,24 @@ export class Option {
|
|
|
184
218
|
return result ? new OptionInfo(result) : null;
|
|
185
219
|
}
|
|
186
220
|
/**
|
|
187
|
-
* Find
|
|
221
|
+
* Find option with target info.
|
|
222
|
+
*
|
|
223
|
+
* Like find() but also indicates if option was found on different target.
|
|
188
224
|
*
|
|
189
|
-
*
|
|
225
|
+
* Direct mapping to av_opt_find2().
|
|
190
226
|
*
|
|
191
|
-
* @param obj -
|
|
192
|
-
* @param name - Option name
|
|
193
|
-
* @param searchFlags - Search flags
|
|
227
|
+
* @param obj - Object to search
|
|
228
|
+
* @param name - Option name
|
|
229
|
+
* @param searchFlags - Search flags
|
|
230
|
+
* @returns Object with option and target info
|
|
194
231
|
*
|
|
195
|
-
* @
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* const result = Option.find2(obj, 'bitrate', AV_OPT_SEARCH_CHILDREN);
|
|
235
|
+
* if (result?.option) {
|
|
236
|
+
* console.log(`Found on ${result.isDifferentTarget ? 'child' : 'object'}`);
|
|
237
|
+
* }
|
|
238
|
+
* ```
|
|
196
239
|
*/
|
|
197
240
|
static find2(obj, name, searchFlags = AVFLAG_NONE) {
|
|
198
241
|
const result = bindings.Option.find2(obj, name, searchFlags);
|
|
@@ -204,336 +247,455 @@ export class Option {
|
|
|
204
247
|
};
|
|
205
248
|
}
|
|
206
249
|
/**
|
|
207
|
-
* Get option value
|
|
250
|
+
* Get string option value.
|
|
208
251
|
*
|
|
209
|
-
*
|
|
210
|
-
* Converts any option type to its string representation.
|
|
252
|
+
* Direct mapping to av_opt_get().
|
|
211
253
|
*
|
|
212
|
-
* @param obj -
|
|
254
|
+
* @param obj - Object to query
|
|
213
255
|
* @param name - Option name
|
|
214
|
-
* @param searchFlags - Search flags
|
|
256
|
+
* @param searchFlags - Search flags
|
|
257
|
+
* @returns Option value as string, or null
|
|
215
258
|
*
|
|
216
|
-
* @
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* // Get codec preset option
|
|
262
|
+
* const preset = Option.get(codecContext, 'preset', AV_OPT_SEARCH_CHILDREN);
|
|
263
|
+
* console.log('Codec preset:', preset); // 'medium', 'fast', etc.
|
|
264
|
+
* ```
|
|
217
265
|
*/
|
|
218
266
|
static get(obj, name, searchFlags = AVFLAG_NONE) {
|
|
219
267
|
return bindings.Option.get(obj, name, searchFlags);
|
|
220
268
|
}
|
|
221
269
|
/**
|
|
222
|
-
* Get option value
|
|
270
|
+
* Get integer option value.
|
|
223
271
|
*
|
|
224
|
-
*
|
|
225
|
-
* Option must be of integer type.
|
|
272
|
+
* Direct mapping to av_opt_get_int().
|
|
226
273
|
*
|
|
227
|
-
* @param obj -
|
|
274
|
+
* @param obj - Object to query
|
|
228
275
|
* @param name - Option name
|
|
229
|
-
* @param searchFlags - Search flags
|
|
276
|
+
* @param searchFlags - Search flags
|
|
277
|
+
* @returns Option value as integer, or null
|
|
230
278
|
*
|
|
231
|
-
* @
|
|
279
|
+
* @example
|
|
280
|
+
* ```typescript
|
|
281
|
+
* // Get codec GOP size
|
|
282
|
+
* const gopSize = Option.getInt(codecContext, 'g', AV_OPT_SEARCH_CHILDREN);
|
|
283
|
+
* console.log('GOP size:', gopSize); // 60, 120, etc.
|
|
284
|
+
* ```
|
|
232
285
|
*/
|
|
233
286
|
static getInt(obj, name, searchFlags = AVFLAG_NONE) {
|
|
234
287
|
return bindings.Option.getInt(obj, name, searchFlags);
|
|
235
288
|
}
|
|
236
289
|
/**
|
|
237
|
-
* Get option value
|
|
290
|
+
* Get double option value.
|
|
238
291
|
*
|
|
239
|
-
*
|
|
240
|
-
* Option must be of double/float type.
|
|
292
|
+
* Direct mapping to av_opt_get_double().
|
|
241
293
|
*
|
|
242
|
-
* @param obj -
|
|
294
|
+
* @param obj - Object to query
|
|
243
295
|
* @param name - Option name
|
|
244
|
-
* @param searchFlags - Search flags
|
|
296
|
+
* @param searchFlags - Search flags
|
|
297
|
+
* @returns Option value as double, or null
|
|
245
298
|
*
|
|
246
|
-
* @
|
|
299
|
+
* @example
|
|
300
|
+
* ```typescript
|
|
301
|
+
* // Get codec quality scale
|
|
302
|
+
* const crf = Option.getDouble(codecContext, 'crf', AV_OPT_SEARCH_CHILDREN);
|
|
303
|
+
* console.log('CRF value:', crf); // 23.0, 18.0, etc.
|
|
304
|
+
* ```
|
|
247
305
|
*/
|
|
248
306
|
static getDouble(obj, name, searchFlags = AVFLAG_NONE) {
|
|
249
307
|
return bindings.Option.getDouble(obj, name, searchFlags);
|
|
250
308
|
}
|
|
251
309
|
/**
|
|
252
|
-
* Get option value
|
|
310
|
+
* Get rational option value.
|
|
253
311
|
*
|
|
254
|
-
*
|
|
255
|
-
* Option must be of rational type.
|
|
312
|
+
* Direct mapping to av_opt_get_q().
|
|
256
313
|
*
|
|
257
|
-
* @param obj -
|
|
314
|
+
* @param obj - Object to query
|
|
258
315
|
* @param name - Option name
|
|
259
|
-
* @param searchFlags - Search flags
|
|
316
|
+
* @param searchFlags - Search flags
|
|
317
|
+
* @returns Option value as rational, or null
|
|
260
318
|
*
|
|
261
|
-
* @
|
|
319
|
+
* @example
|
|
320
|
+
* ```typescript
|
|
321
|
+
* // Get codec time base
|
|
322
|
+
* const timeBase = Option.getRational(codecContext, 'time_base', AV_OPT_SEARCH_CHILDREN);
|
|
323
|
+
* console.log('Time base:', timeBase); // { num: 1, den: 30 }
|
|
324
|
+
* ```
|
|
262
325
|
*/
|
|
263
326
|
static getRational(obj, name, searchFlags = AVFLAG_NONE) {
|
|
264
327
|
return bindings.Option.getRational(obj, name, searchFlags);
|
|
265
328
|
}
|
|
266
329
|
/**
|
|
267
|
-
* Get option value
|
|
330
|
+
* Get pixel format option value.
|
|
268
331
|
*
|
|
269
|
-
*
|
|
270
|
-
* Option must be of pixel format type.
|
|
332
|
+
* Direct mapping to av_opt_get_pixel_fmt().
|
|
271
333
|
*
|
|
272
|
-
* @param obj -
|
|
334
|
+
* @param obj - Object to query
|
|
273
335
|
* @param name - Option name
|
|
274
|
-
* @param searchFlags - Search flags
|
|
336
|
+
* @param searchFlags - Search flags
|
|
337
|
+
* @returns Pixel format value, or null
|
|
275
338
|
*
|
|
276
|
-
* @
|
|
339
|
+
* @example
|
|
340
|
+
* ```typescript
|
|
341
|
+
* // Get filter pixel format
|
|
342
|
+
* const pixFmt = Option.getPixelFormat(filterContext, 'pix_fmt', AV_OPT_SEARCH_CHILDREN);
|
|
343
|
+
* console.log('Pixel format:', pixFmt); // AV_PIX_FMT_YUV420P, etc.
|
|
344
|
+
* ```
|
|
277
345
|
*/
|
|
278
346
|
static getPixelFormat(obj, name, searchFlags = AVFLAG_NONE) {
|
|
279
347
|
return bindings.Option.getPixelFormat(obj, name, searchFlags);
|
|
280
348
|
}
|
|
281
349
|
/**
|
|
282
|
-
* Get option value
|
|
350
|
+
* Get sample format option value.
|
|
283
351
|
*
|
|
284
|
-
*
|
|
285
|
-
* Option must be of sample format type.
|
|
352
|
+
* Direct mapping to av_opt_get_sample_fmt().
|
|
286
353
|
*
|
|
287
|
-
* @param obj -
|
|
354
|
+
* @param obj - Object to query
|
|
288
355
|
* @param name - Option name
|
|
289
|
-
* @param searchFlags - Search flags
|
|
356
|
+
* @param searchFlags - Search flags
|
|
357
|
+
* @returns Sample format value, or null
|
|
290
358
|
*
|
|
291
|
-
* @
|
|
359
|
+
* @example
|
|
360
|
+
* ```typescript
|
|
361
|
+
* // Get audio codec sample format
|
|
362
|
+
* const sampleFmt = Option.getSampleFormat(codecContext, 'sample_fmt', AV_OPT_SEARCH_CHILDREN);
|
|
363
|
+
* console.log('Sample format:', sampleFmt); // AV_SAMPLE_FMT_FLTP, etc.
|
|
364
|
+
* ```
|
|
292
365
|
*/
|
|
293
366
|
static getSampleFormat(obj, name, searchFlags = AVFLAG_NONE) {
|
|
294
367
|
return bindings.Option.getSampleFormat(obj, name, searchFlags);
|
|
295
368
|
}
|
|
296
369
|
/**
|
|
297
|
-
* Get option value
|
|
370
|
+
* Get image size option value.
|
|
298
371
|
*
|
|
299
|
-
*
|
|
300
|
-
* Option must be of image size type.
|
|
372
|
+
* Direct mapping to av_opt_get_image_size().
|
|
301
373
|
*
|
|
302
|
-
* @param obj -
|
|
374
|
+
* @param obj - Object to query
|
|
303
375
|
* @param name - Option name
|
|
304
|
-
* @param searchFlags - Search flags
|
|
376
|
+
* @param searchFlags - Search flags
|
|
377
|
+
* @returns Width and height, or null
|
|
305
378
|
*
|
|
306
|
-
* @
|
|
379
|
+
* @example
|
|
380
|
+
* ```typescript
|
|
381
|
+
* // Get filter output size
|
|
382
|
+
* const size = Option.getImageSize(filterContext, 'size', AV_OPT_SEARCH_CHILDREN);
|
|
383
|
+
* console.log('Output size:', size); // { width: 1920, height: 1080 }
|
|
384
|
+
* ```
|
|
307
385
|
*/
|
|
308
386
|
static getImageSize(obj, name, searchFlags = AVFLAG_NONE) {
|
|
309
387
|
return bindings.Option.getImageSize(obj, name, searchFlags);
|
|
310
388
|
}
|
|
311
389
|
/**
|
|
312
|
-
* Get option value
|
|
390
|
+
* Get channel layout option value.
|
|
313
391
|
*
|
|
314
|
-
*
|
|
315
|
-
* Option must be of channel layout type.
|
|
392
|
+
* Direct mapping to av_opt_get_chlayout().
|
|
316
393
|
*
|
|
317
|
-
* @param obj -
|
|
394
|
+
* @param obj - Object to query
|
|
318
395
|
* @param name - Option name
|
|
319
|
-
* @param searchFlags - Search flags
|
|
396
|
+
* @param searchFlags - Search flags
|
|
397
|
+
* @returns Channel layout, or null
|
|
320
398
|
*
|
|
321
|
-
* @
|
|
399
|
+
* @example
|
|
400
|
+
* ```typescript
|
|
401
|
+
* // Get audio channel layout
|
|
402
|
+
* const layout = Option.getChannelLayout(codecContext, 'channel_layout', AV_OPT_SEARCH_CHILDREN);
|
|
403
|
+
* console.log('Channel layout:', layout); // stereo, 5.1, etc.
|
|
404
|
+
* ```
|
|
322
405
|
*/
|
|
323
406
|
static getChannelLayout(obj, name, searchFlags = AVFLAG_NONE) {
|
|
324
407
|
return bindings.Option.getChannelLayout(obj, name, searchFlags);
|
|
325
408
|
}
|
|
326
409
|
/**
|
|
327
|
-
* Get option value
|
|
410
|
+
* Get dictionary option value.
|
|
328
411
|
*
|
|
329
|
-
*
|
|
330
|
-
* Option must be of dictionary type.
|
|
412
|
+
* Direct mapping to av_opt_get_dict_val().
|
|
331
413
|
*
|
|
332
|
-
* @param obj -
|
|
414
|
+
* @param obj - Object to query
|
|
333
415
|
* @param name - Option name
|
|
334
|
-
* @param searchFlags - Search flags
|
|
416
|
+
* @param searchFlags - Search flags
|
|
417
|
+
* @returns Dictionary value, or null
|
|
335
418
|
*
|
|
336
|
-
* @
|
|
419
|
+
* @example
|
|
420
|
+
* ```typescript
|
|
421
|
+
* // Get metadata dictionary
|
|
422
|
+
* const metadata = Option.getDict(formatContext, 'metadata', AV_OPT_SEARCH_CHILDREN);
|
|
423
|
+
* console.log('Metadata:', metadata?.get('title'));
|
|
424
|
+
* ```
|
|
337
425
|
*/
|
|
338
426
|
static getDict(obj, name, searchFlags = AVFLAG_NONE) {
|
|
339
427
|
const native = bindings.Option.getDict(obj, name, searchFlags);
|
|
340
428
|
return native ? Dictionary.fromNative(native) : null;
|
|
341
429
|
}
|
|
342
430
|
/**
|
|
343
|
-
* Set option value
|
|
431
|
+
* Set string option value.
|
|
344
432
|
*
|
|
345
|
-
*
|
|
346
|
-
* Can be used for any option type - FFmpeg will parse the string.
|
|
433
|
+
* Direct mapping to av_opt_set().
|
|
347
434
|
*
|
|
348
|
-
* @param obj -
|
|
435
|
+
* @param obj - Object to modify
|
|
349
436
|
* @param name - Option name
|
|
350
|
-
* @param value - String value
|
|
351
|
-
* @param searchFlags - Search flags
|
|
437
|
+
* @param value - String value
|
|
438
|
+
* @param searchFlags - Search flags
|
|
439
|
+
* @returns 0 on success, negative AVERROR on error
|
|
352
440
|
*
|
|
353
|
-
* @
|
|
441
|
+
* @example
|
|
442
|
+
* ```typescript
|
|
443
|
+
* // Set codec preset
|
|
444
|
+
* const ret = Option.set(codecContext, 'preset', 'fast', AV_OPT_SEARCH_CHILDREN);
|
|
445
|
+
* FFmpegError.throwIfError(ret, 'Failed to set preset');
|
|
446
|
+
* ```
|
|
354
447
|
*/
|
|
355
448
|
static set(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
356
449
|
return bindings.Option.set(obj, name, value, searchFlags);
|
|
357
450
|
}
|
|
358
451
|
/**
|
|
359
|
-
* Set option value
|
|
452
|
+
* Set integer option value.
|
|
360
453
|
*
|
|
361
|
-
*
|
|
362
|
-
* More efficient than set() for numeric options.
|
|
454
|
+
* Direct mapping to av_opt_set_int().
|
|
363
455
|
*
|
|
364
|
-
* @param obj -
|
|
456
|
+
* @param obj - Object to modify
|
|
365
457
|
* @param name - Option name
|
|
366
|
-
* @param value -
|
|
367
|
-
* @param searchFlags - Search flags
|
|
458
|
+
* @param value - Integer value
|
|
459
|
+
* @param searchFlags - Search flags
|
|
460
|
+
* @returns 0 on success, negative AVERROR on error
|
|
368
461
|
*
|
|
369
|
-
* @
|
|
462
|
+
* @example
|
|
463
|
+
* ```typescript
|
|
464
|
+
* // Set codec bitrate
|
|
465
|
+
* const ret = Option.setInt(codecContext, 'b', 2000000, AV_OPT_SEARCH_CHILDREN);
|
|
466
|
+
* FFmpegError.throwIfError(ret, 'Failed to set bitrate');
|
|
467
|
+
* ```
|
|
370
468
|
*/
|
|
371
469
|
static setInt(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
372
470
|
return bindings.Option.setInt(obj, name, value, searchFlags);
|
|
373
471
|
}
|
|
374
472
|
/**
|
|
375
|
-
* Set option value
|
|
473
|
+
* Set double option value.
|
|
376
474
|
*
|
|
377
|
-
*
|
|
378
|
-
* More efficient than set() for floating point options.
|
|
475
|
+
* Direct mapping to av_opt_set_double().
|
|
379
476
|
*
|
|
380
|
-
* @param obj -
|
|
477
|
+
* @param obj - Object to modify
|
|
381
478
|
* @param name - Option name
|
|
382
|
-
* @param value - Double value
|
|
383
|
-
* @param searchFlags - Search flags
|
|
479
|
+
* @param value - Double value
|
|
480
|
+
* @param searchFlags - Search flags
|
|
481
|
+
* @returns 0 on success, negative AVERROR on error
|
|
384
482
|
*
|
|
385
|
-
* @
|
|
483
|
+
* @example
|
|
484
|
+
* ```typescript
|
|
485
|
+
* // Set codec CRF value
|
|
486
|
+
* const ret = Option.setDouble(codecContext, 'crf', 23.0, AV_OPT_SEARCH_CHILDREN);
|
|
487
|
+
* FFmpegError.throwIfError(ret, 'Failed to set CRF');
|
|
488
|
+
* ```
|
|
386
489
|
*/
|
|
387
490
|
static setDouble(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
388
491
|
return bindings.Option.setDouble(obj, name, value, searchFlags);
|
|
389
492
|
}
|
|
390
493
|
/**
|
|
391
|
-
* Set option value
|
|
494
|
+
* Set rational option value.
|
|
392
495
|
*
|
|
393
|
-
*
|
|
394
|
-
* For framerates, aspect ratios, time bases, etc.
|
|
496
|
+
* Direct mapping to av_opt_set_q().
|
|
395
497
|
*
|
|
396
|
-
* @param obj -
|
|
498
|
+
* @param obj - Object to modify
|
|
397
499
|
* @param name - Option name
|
|
398
|
-
* @param value - Rational
|
|
399
|
-
* @param searchFlags - Search flags
|
|
500
|
+
* @param value - Rational value
|
|
501
|
+
* @param searchFlags - Search flags
|
|
502
|
+
* @returns 0 on success, negative AVERROR on error
|
|
400
503
|
*
|
|
401
|
-
* @
|
|
504
|
+
* @example
|
|
505
|
+
* ```typescript
|
|
506
|
+
* // Set codec frame rate
|
|
507
|
+
* const ret = Option.setRational(codecContext, 'framerate', { num: 30, den: 1 }, AV_OPT_SEARCH_CHILDREN);
|
|
508
|
+
* FFmpegError.throwIfError(ret, 'Failed to set framerate');
|
|
509
|
+
* ```
|
|
402
510
|
*/
|
|
403
511
|
static setRational(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
404
512
|
return bindings.Option.setRational(obj, name, value, searchFlags);
|
|
405
513
|
}
|
|
406
514
|
/**
|
|
407
|
-
* Set option value
|
|
515
|
+
* Set pixel format option value.
|
|
408
516
|
*
|
|
409
|
-
*
|
|
410
|
-
* More type-safe than using set() with string names.
|
|
517
|
+
* Direct mapping to av_opt_set_pixel_fmt().
|
|
411
518
|
*
|
|
412
|
-
* @param obj -
|
|
519
|
+
* @param obj - Object to modify
|
|
413
520
|
* @param name - Option name
|
|
414
|
-
* @param value -
|
|
415
|
-
* @param searchFlags - Search flags
|
|
521
|
+
* @param value - Pixel format
|
|
522
|
+
* @param searchFlags - Search flags
|
|
523
|
+
* @returns 0 on success, negative AVERROR on error
|
|
416
524
|
*
|
|
417
|
-
* @
|
|
525
|
+
* @example
|
|
526
|
+
* ```typescript
|
|
527
|
+
* // Set filter pixel format
|
|
528
|
+
* const ret = Option.setPixelFormat(filterContext, 'pix_fmt', AV_PIX_FMT_YUV420P, AV_OPT_SEARCH_CHILDREN);
|
|
529
|
+
* FFmpegError.throwIfError(ret, 'Failed to set pixel format');
|
|
530
|
+
* ```
|
|
418
531
|
*/
|
|
419
532
|
static setPixelFormat(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
420
533
|
return bindings.Option.setPixelFormat(obj, name, value, searchFlags);
|
|
421
534
|
}
|
|
422
535
|
/**
|
|
423
|
-
* Set option value
|
|
536
|
+
* Set sample format option value.
|
|
424
537
|
*
|
|
425
|
-
*
|
|
426
|
-
* More type-safe than using set() with string names.
|
|
538
|
+
* Direct mapping to av_opt_set_sample_fmt().
|
|
427
539
|
*
|
|
428
|
-
* @param obj -
|
|
540
|
+
* @param obj - Object to modify
|
|
429
541
|
* @param name - Option name
|
|
430
|
-
* @param value -
|
|
431
|
-
* @param searchFlags - Search flags
|
|
542
|
+
* @param value - Sample format
|
|
543
|
+
* @param searchFlags - Search flags
|
|
544
|
+
* @returns 0 on success, negative AVERROR on error
|
|
432
545
|
*
|
|
433
|
-
* @
|
|
546
|
+
* @example
|
|
547
|
+
* ```typescript
|
|
548
|
+
* // Set audio codec sample format
|
|
549
|
+
* const ret = Option.setSampleFormat(codecContext, 'sample_fmt', AV_SAMPLE_FMT_FLTP, AV_OPT_SEARCH_CHILDREN);
|
|
550
|
+
* FFmpegError.throwIfError(ret, 'Failed to set sample format');
|
|
551
|
+
* ```
|
|
434
552
|
*/
|
|
435
553
|
static setSampleFormat(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
436
554
|
return bindings.Option.setSampleFormat(obj, name, value, searchFlags);
|
|
437
555
|
}
|
|
438
556
|
/**
|
|
439
|
-
* Set option value
|
|
557
|
+
* Set image size option value.
|
|
440
558
|
*
|
|
441
|
-
*
|
|
442
|
-
* Convenient for setting width and height together.
|
|
559
|
+
* Direct mapping to av_opt_set_image_size().
|
|
443
560
|
*
|
|
444
|
-
* @param obj -
|
|
561
|
+
* @param obj - Object to modify
|
|
445
562
|
* @param name - Option name
|
|
446
|
-
* @param width -
|
|
447
|
-
* @param height -
|
|
448
|
-
* @param searchFlags - Search flags
|
|
563
|
+
* @param width - Image width
|
|
564
|
+
* @param height - Image height
|
|
565
|
+
* @param searchFlags - Search flags
|
|
566
|
+
* @returns 0 on success, negative AVERROR on error
|
|
449
567
|
*
|
|
450
|
-
* @
|
|
568
|
+
* @example
|
|
569
|
+
* ```typescript
|
|
570
|
+
* // Set filter output size
|
|
571
|
+
* const ret = Option.setImageSize(filterContext, 'size', 1920, 1080, AV_OPT_SEARCH_CHILDREN);
|
|
572
|
+
* FFmpegError.throwIfError(ret, 'Failed to set image size');
|
|
573
|
+
* ```
|
|
451
574
|
*/
|
|
452
575
|
static setImageSize(obj, name, width, height, searchFlags = AVFLAG_NONE) {
|
|
453
576
|
return bindings.Option.setImageSize(obj, name, width, height, searchFlags);
|
|
454
577
|
}
|
|
455
578
|
/**
|
|
456
|
-
* Set option value
|
|
579
|
+
* Set channel layout option value.
|
|
457
580
|
*
|
|
458
|
-
*
|
|
459
|
-
* For audio channel configuration.
|
|
581
|
+
* Direct mapping to av_opt_set_chlayout().
|
|
460
582
|
*
|
|
461
|
-
* @param obj -
|
|
583
|
+
* @param obj - Object to modify
|
|
462
584
|
* @param name - Option name
|
|
463
|
-
* @param value - Channel layout
|
|
464
|
-
* @param searchFlags - Search flags
|
|
585
|
+
* @param value - Channel layout
|
|
586
|
+
* @param searchFlags - Search flags
|
|
587
|
+
* @returns 0 on success, negative AVERROR on error
|
|
465
588
|
*
|
|
466
|
-
* @
|
|
589
|
+
* @example
|
|
590
|
+
* ```typescript
|
|
591
|
+
* // Set audio channel layout to stereo
|
|
592
|
+
* const ret = Option.setChannelLayout(codecContext, 'channel_layout', AV_CHANNEL_LAYOUT_STEREO, AV_OPT_SEARCH_CHILDREN);
|
|
593
|
+
* FFmpegError.throwIfError(ret, 'Failed to set channel layout');
|
|
594
|
+
* ```
|
|
467
595
|
*/
|
|
468
596
|
static setChannelLayout(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
469
597
|
return bindings.Option.setChannelLayout(obj, name, value, searchFlags);
|
|
470
598
|
}
|
|
471
599
|
/**
|
|
472
|
-
* Set option value
|
|
600
|
+
* Set dictionary option value.
|
|
473
601
|
*
|
|
474
|
-
*
|
|
475
|
-
* For options that accept key-value pairs.
|
|
602
|
+
* Direct mapping to av_opt_set_dict_val().
|
|
476
603
|
*
|
|
477
|
-
* @param obj -
|
|
604
|
+
* @param obj - Object to modify
|
|
478
605
|
* @param name - Option name
|
|
479
|
-
* @param value - Dictionary
|
|
480
|
-
* @param searchFlags - Search flags
|
|
606
|
+
* @param value - Dictionary value
|
|
607
|
+
* @param searchFlags - Search flags
|
|
608
|
+
* @returns 0 on success, negative AVERROR on error
|
|
481
609
|
*
|
|
482
|
-
* @
|
|
610
|
+
* @example
|
|
611
|
+
* ```typescript
|
|
612
|
+
* // Set metadata dictionary
|
|
613
|
+
* const dict = new Dictionary();
|
|
614
|
+
* dict.set('title', 'My Video');
|
|
615
|
+
* const ret = Option.setDict(formatContext, 'metadata', dict, AV_OPT_SEARCH_CHILDREN);
|
|
616
|
+
* FFmpegError.throwIfError(ret, 'Failed to set metadata');
|
|
617
|
+
* ```
|
|
483
618
|
*/
|
|
484
619
|
static setDict(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
485
620
|
return bindings.Option.setDict(obj, name, value.getNative(), searchFlags);
|
|
486
621
|
}
|
|
487
622
|
/**
|
|
488
|
-
* Set option value
|
|
623
|
+
* Set binary option value.
|
|
489
624
|
*
|
|
490
|
-
*
|
|
491
|
-
* For options that accept raw binary data.
|
|
625
|
+
* Direct mapping to av_opt_set_bin().
|
|
492
626
|
*
|
|
493
|
-
* @param obj -
|
|
627
|
+
* @param obj - Object to modify
|
|
494
628
|
* @param name - Option name
|
|
495
|
-
* @param value - Binary data
|
|
496
|
-
* @param searchFlags - Search flags
|
|
629
|
+
* @param value - Binary data
|
|
630
|
+
* @param searchFlags - Search flags
|
|
631
|
+
* @returns 0 on success, negative AVERROR on error
|
|
497
632
|
*
|
|
498
|
-
* @
|
|
633
|
+
* @example
|
|
634
|
+
* ```typescript
|
|
635
|
+
* // Set binary extradata
|
|
636
|
+
* const extradata = Buffer.from([0x00, 0x01, 0x02, 0x03]);
|
|
637
|
+
* const ret = Option.setBin(codecContext, 'extradata', extradata, AV_OPT_SEARCH_CHILDREN);
|
|
638
|
+
* FFmpegError.throwIfError(ret, 'Failed to set extradata');
|
|
639
|
+
* ```
|
|
499
640
|
*/
|
|
500
641
|
static setBin(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
501
642
|
return bindings.Option.setBin(obj, name, value, searchFlags);
|
|
502
643
|
}
|
|
503
644
|
/**
|
|
504
|
-
* Set
|
|
645
|
+
* Set defaults on object.
|
|
646
|
+
*
|
|
647
|
+
* Sets all options to their default values.
|
|
505
648
|
*
|
|
506
|
-
*
|
|
649
|
+
* Direct mapping to av_opt_set_defaults().
|
|
507
650
|
*
|
|
508
|
-
* @param obj -
|
|
651
|
+
* @param obj - Object to reset
|
|
652
|
+
*
|
|
653
|
+
* @example
|
|
654
|
+
* ```typescript
|
|
655
|
+
* // Reset all codec options to defaults
|
|
656
|
+
* Option.setDefaults(codecContext);
|
|
657
|
+
* ```
|
|
509
658
|
*/
|
|
510
659
|
static setDefaults(obj) {
|
|
511
660
|
bindings.Option.setDefaults(obj);
|
|
512
661
|
}
|
|
513
662
|
/**
|
|
514
|
-
* Copy options
|
|
663
|
+
* Copy options between objects.
|
|
515
664
|
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
665
|
+
* Copies option values from source to destination.
|
|
666
|
+
*
|
|
667
|
+
* Direct mapping to av_opt_copy().
|
|
518
668
|
*
|
|
519
669
|
* @param dest - Destination object
|
|
520
670
|
* @param src - Source object
|
|
671
|
+
* @returns 0 on success, negative AVERROR on error
|
|
521
672
|
*
|
|
522
|
-
* @
|
|
673
|
+
* @example
|
|
674
|
+
* ```typescript
|
|
675
|
+
* // Copy options from one codec context to another
|
|
676
|
+
* const ret = Option.copy(destCodecContext, srcCodecContext);
|
|
677
|
+
* FFmpegError.throwIfError(ret, 'Failed to copy options');
|
|
678
|
+
* ```
|
|
523
679
|
*/
|
|
524
680
|
static copy(dest, src) {
|
|
525
681
|
return bindings.Option.copy(dest, src);
|
|
526
682
|
}
|
|
527
683
|
/**
|
|
528
|
-
* Check if option is set to
|
|
684
|
+
* Check if option is set to default.
|
|
529
685
|
*
|
|
530
|
-
*
|
|
686
|
+
* Direct mapping to av_opt_is_set_to_default().
|
|
531
687
|
*
|
|
532
|
-
* @param obj -
|
|
688
|
+
* @param obj - Object to check
|
|
533
689
|
* @param name - Option name
|
|
534
|
-
* @param searchFlags - Search flags
|
|
690
|
+
* @param searchFlags - Search flags
|
|
691
|
+
* @returns True if default, false if modified, null if not found
|
|
535
692
|
*
|
|
536
|
-
* @
|
|
693
|
+
* @example
|
|
694
|
+
* ```typescript
|
|
695
|
+
* // Check if bitrate is at default value
|
|
696
|
+
* const isDefault = Option.isSetToDefault(codecContext, 'b', AV_OPT_SEARCH_CHILDREN);
|
|
697
|
+
* console.log('Bitrate is default:', isDefault);
|
|
698
|
+
* ```
|
|
537
699
|
*/
|
|
538
700
|
static isSetToDefault(obj, name, searchFlags = AVFLAG_NONE) {
|
|
539
701
|
return bindings.Option.isSetToDefault(obj, name, searchFlags);
|
|
@@ -541,41 +703,57 @@ export class Option {
|
|
|
541
703
|
/**
|
|
542
704
|
* Serialize options to string.
|
|
543
705
|
*
|
|
544
|
-
*
|
|
545
|
-
* Converts all non-default options to a string representation.
|
|
706
|
+
* Direct mapping to av_opt_serialize().
|
|
546
707
|
*
|
|
547
|
-
* @param obj -
|
|
548
|
-
* @param optFlags - Option flags
|
|
549
|
-
* @param flags - Serialization flags
|
|
550
|
-
* @param keyValSep - Key-value separator
|
|
551
|
-
* @param pairsSep - Pairs separator
|
|
708
|
+
* @param obj - Object to serialize
|
|
709
|
+
* @param optFlags - Option flags filter
|
|
710
|
+
* @param flags - Serialization flags
|
|
711
|
+
* @param keyValSep - Key-value separator
|
|
712
|
+
* @param pairsSep - Pairs separator
|
|
713
|
+
* @returns Serialized string, or null on error
|
|
552
714
|
*
|
|
553
|
-
* @
|
|
715
|
+
* @example
|
|
716
|
+
* ```typescript
|
|
717
|
+
* // Serialize codec options to string
|
|
718
|
+
* const serialized = Option.serialize(codecContext, 0, 0, '=', ':');
|
|
719
|
+
* console.log('Options:', serialized); // 'bitrate=2000000:preset=fast'
|
|
720
|
+
* ```
|
|
554
721
|
*/
|
|
555
722
|
static serialize(obj, optFlags = 0, flags = 0, keyValSep = '=', pairsSep = ',') {
|
|
556
723
|
return bindings.Option.serialize(obj, optFlags, flags, keyValSep, pairsSep);
|
|
557
724
|
}
|
|
558
725
|
/**
|
|
559
|
-
* Free
|
|
726
|
+
* Free option resources.
|
|
560
727
|
*
|
|
561
|
-
*
|
|
728
|
+
* Direct mapping to av_opt_free().
|
|
562
729
|
*
|
|
563
|
-
* @param obj -
|
|
730
|
+
* @param obj - Object to free options from
|
|
731
|
+
*
|
|
732
|
+
* @example
|
|
733
|
+
* ```typescript
|
|
734
|
+
* // Free codec context options
|
|
735
|
+
* Option.free(codecContext);
|
|
736
|
+
* ```
|
|
564
737
|
*/
|
|
565
738
|
static free(obj) {
|
|
566
739
|
bindings.Option.free(obj);
|
|
567
740
|
}
|
|
568
741
|
/**
|
|
569
|
-
* Show options
|
|
742
|
+
* Show options for debugging.
|
|
570
743
|
*
|
|
571
|
-
*
|
|
572
|
-
* Prints all available options to stderr.
|
|
744
|
+
* Direct mapping to av_opt_show2().
|
|
573
745
|
*
|
|
574
|
-
* @param obj -
|
|
575
|
-
* @param reqFlags - Required flags
|
|
576
|
-
* @param rejFlags - Rejected flags
|
|
746
|
+
* @param obj - Object to show options for
|
|
747
|
+
* @param reqFlags - Required flags
|
|
748
|
+
* @param rejFlags - Rejected flags
|
|
749
|
+
* @returns 0 on success, negative AVERROR on error
|
|
577
750
|
*
|
|
578
|
-
* @
|
|
751
|
+
* @example
|
|
752
|
+
* ```typescript
|
|
753
|
+
* // Show all codec options for debugging
|
|
754
|
+
* const ret = Option.show(codecContext, 0, 0);
|
|
755
|
+
* FFmpegError.throwIfError(ret, 'Failed to show options');
|
|
756
|
+
* ```
|
|
579
757
|
*/
|
|
580
758
|
static show(obj, reqFlags = 0, rejFlags = 0) {
|
|
581
759
|
return bindings.Option.show(obj, reqFlags, rejFlags);
|
|
@@ -595,10 +773,42 @@ export class Option {
|
|
|
595
773
|
*
|
|
596
774
|
* @example
|
|
597
775
|
* ```typescript
|
|
776
|
+
* import { OptionMember, FFmpegError } from 'node-av';
|
|
777
|
+
* import { AV_OPT_TYPE_INT, AV_OPT_TYPE_STRING, AV_OPT_TYPE_RATIONAL } from 'node-av/constants';
|
|
778
|
+
*
|
|
598
779
|
* class CodecContext extends OptionMember<NativeCodecContext> {
|
|
599
|
-
*
|
|
780
|
+
* constructor(native: NativeCodecContext) {
|
|
781
|
+
* super(native);
|
|
782
|
+
* }
|
|
783
|
+
* }
|
|
784
|
+
*
|
|
785
|
+
* // Use inherited methods
|
|
786
|
+
* const codec = new CodecContext(native);
|
|
787
|
+
*
|
|
788
|
+
* // Set options with automatic type handling
|
|
789
|
+
* let ret = codec.setOption('preset', 'fast');
|
|
790
|
+
* FFmpegError.throwIfError(ret, 'set preset');
|
|
791
|
+
*
|
|
792
|
+
* ret = codec.setOption('bitrate', 2000000, AV_OPT_TYPE_INT);
|
|
793
|
+
* FFmpegError.throwIfError(ret, 'set bitrate');
|
|
794
|
+
*
|
|
795
|
+
* ret = codec.setOption('framerate', { num: 30, den: 1 }, AV_OPT_TYPE_RATIONAL);
|
|
796
|
+
* FFmpegError.throwIfError(ret, 'set framerate');
|
|
797
|
+
*
|
|
798
|
+
* // Get typed options
|
|
799
|
+
* const preset = codec.getOption('preset');
|
|
800
|
+
* const bitrate = codec.getOption('bitrate', AV_OPT_TYPE_INT);
|
|
801
|
+
* const framerate = codec.getOption('framerate', AV_OPT_TYPE_RATIONAL);
|
|
802
|
+
*
|
|
803
|
+
* // List all available options
|
|
804
|
+
* const options = codec.listOptions();
|
|
805
|
+
* for (const opt of options) {
|
|
806
|
+
* console.log(`${opt.name}: ${opt.help}`);
|
|
600
807
|
* }
|
|
601
808
|
* ```
|
|
809
|
+
*
|
|
810
|
+
* @see {@link Option} For static option methods
|
|
811
|
+
* @see {@link OptionInfo} For option metadata
|
|
602
812
|
*/
|
|
603
813
|
export class OptionMember {
|
|
604
814
|
native;
|
|
@@ -611,25 +821,42 @@ export class OptionMember {
|
|
|
611
821
|
* Uses the AVOption API to set options.
|
|
612
822
|
* Available options depend on the specific object type.
|
|
613
823
|
*
|
|
824
|
+
* Direct mapping to av_opt_set* functions.
|
|
825
|
+
*
|
|
614
826
|
* @param name - Option name
|
|
615
827
|
* @param value - Option value
|
|
616
828
|
* @param type - Option type (defaults to AV_OPT_TYPE_STRING)
|
|
617
829
|
* @param searchFlags - Search flags (default: AV_OPT_SEARCH_CHILDREN)
|
|
618
|
-
* @returns 0 on success, negative AVERROR
|
|
830
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
831
|
+
* - AVERROR_ENOENT: Option not found
|
|
832
|
+
* - AVERROR_ERANGE: Value out of range
|
|
833
|
+
* - AVERROR_EINVAL: Invalid value
|
|
619
834
|
*
|
|
620
835
|
* @example
|
|
621
836
|
* ```typescript
|
|
837
|
+
* import { FFmpegError } from 'node-av';
|
|
838
|
+
* import { AV_OPT_TYPE_STRING, AV_OPT_TYPE_INT64, AV_OPT_TYPE_RATIONAL, AV_OPT_TYPE_PIXEL_FMT } from 'node-av/constants';
|
|
839
|
+
*
|
|
622
840
|
* // String options (default)
|
|
623
|
-
* ret = obj.setOption('preset', 'fast');
|
|
841
|
+
* let ret = obj.setOption('preset', 'fast');
|
|
842
|
+
* FFmpegError.throwIfError(ret, 'set preset');
|
|
843
|
+
*
|
|
624
844
|
* ret = obj.setOption('codec', 'h264', AV_OPT_TYPE_STRING);
|
|
845
|
+
* FFmpegError.throwIfError(ret, 'set codec');
|
|
625
846
|
*
|
|
626
847
|
* // Integer options
|
|
627
848
|
* ret = obj.setOption('bitrate', 2000000, AV_OPT_TYPE_INT64);
|
|
849
|
+
* FFmpegError.throwIfError(ret, 'set bitrate');
|
|
850
|
+
*
|
|
628
851
|
* ret = obj.setOption('threads', 4, AV_OPT_TYPE_INT);
|
|
852
|
+
* FFmpegError.throwIfError(ret, 'set threads');
|
|
629
853
|
*
|
|
630
854
|
* // Complex types with proper types
|
|
631
855
|
* ret = obj.setOption('framerate', {num: 30, den: 1}, AV_OPT_TYPE_RATIONAL);
|
|
856
|
+
* FFmpegError.throwIfError(ret, 'set framerate');
|
|
857
|
+
*
|
|
632
858
|
* ret = obj.setOption('pix_fmt', AV_PIX_FMT_YUV420P, AV_OPT_TYPE_PIXEL_FMT);
|
|
859
|
+
* FFmpegError.throwIfError(ret, 'set pixel format');
|
|
633
860
|
* ```
|
|
634
861
|
*/
|
|
635
862
|
setOption(name, value, type = AV_OPT_TYPE_STRING, searchFlags = AV_OPT_SEARCH_CHILDREN) {
|
|
@@ -758,13 +985,17 @@ export class OptionMember {
|
|
|
758
985
|
*
|
|
759
986
|
* Uses the AVOption API to retrieve options.
|
|
760
987
|
*
|
|
988
|
+
* Direct mapping to av_opt_get* functions.
|
|
989
|
+
*
|
|
761
990
|
* @param name - Option name
|
|
762
991
|
* @param type - Option type (defaults to AV_OPT_TYPE_STRING)
|
|
763
992
|
* @param searchFlags - Search flags (default: AV_OPT_SEARCH_CHILDREN)
|
|
764
|
-
* @returns Option value (type depends on type parameter)
|
|
993
|
+
* @returns Option value (type depends on type parameter), or null if not found
|
|
765
994
|
*
|
|
766
995
|
* @example
|
|
767
996
|
* ```typescript
|
|
997
|
+
* import { AV_OPT_TYPE_STRING, AV_OPT_TYPE_RATIONAL, AV_OPT_TYPE_PIXEL_FMT, AV_OPT_TYPE_INT64 } from 'node-av/constants';
|
|
998
|
+
*
|
|
768
999
|
* // String options (default)
|
|
769
1000
|
* const preset = obj.getOption('preset');
|
|
770
1001
|
* const codec = obj.getOption('codec', AV_OPT_TYPE_STRING);
|
|
@@ -772,7 +1003,7 @@ export class OptionMember {
|
|
|
772
1003
|
* // Typed options
|
|
773
1004
|
* const framerate = obj.getOption('framerate', AV_OPT_TYPE_RATIONAL); // Returns {num, den}
|
|
774
1005
|
* const pixFmt = obj.getOption('pix_fmt', AV_OPT_TYPE_PIXEL_FMT); // Returns AVPixelFormat
|
|
775
|
-
* const bitrate = obj.getOption('bitrate', AV_OPT_TYPE_INT64); // Returns
|
|
1006
|
+
* const bitrate = obj.getOption('bitrate', AV_OPT_TYPE_INT64); // Returns bigint
|
|
776
1007
|
* ```
|
|
777
1008
|
*/
|
|
778
1009
|
getOption(name, type = AV_OPT_TYPE_STRING, searchFlags = AV_OPT_SEARCH_CHILDREN) {
|
|
@@ -830,6 +1061,8 @@ export class OptionMember {
|
|
|
830
1061
|
* Uses the AVOption API to enumerate all options.
|
|
831
1062
|
* Useful for discovering available settings and their types.
|
|
832
1063
|
*
|
|
1064
|
+
* Direct mapping to av_opt_next() iteration.
|
|
1065
|
+
*
|
|
833
1066
|
* @returns Array of option information objects
|
|
834
1067
|
*
|
|
835
1068
|
* @example
|
|
@@ -838,8 +1071,11 @@ export class OptionMember {
|
|
|
838
1071
|
* for (const opt of options) {
|
|
839
1072
|
* console.log(`${opt.name}: ${opt.help}`);
|
|
840
1073
|
* console.log(` Type: ${opt.type}, Default: ${opt.defaultValue}`);
|
|
1074
|
+
* console.log(` Range: ${opt.min} - ${opt.max}`);
|
|
841
1075
|
* }
|
|
842
1076
|
* ```
|
|
1077
|
+
*
|
|
1078
|
+
* @see {@link OptionInfo} For option metadata structure
|
|
843
1079
|
*/
|
|
844
1080
|
listOptions() {
|
|
845
1081
|
const options = [];
|