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/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
|
-
*/
|
|
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';
|
|
12
2
|
import { bindings } from './binding.js';
|
|
13
|
-
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.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';
|
|
124
146
|
*
|
|
125
|
-
* //
|
|
126
|
-
*
|
|
147
|
+
* // Set various option types
|
|
148
|
+
* let ret = Option.set(obj, 'preset', 'fast');
|
|
149
|
+
* FFmpegError.throwIfError(ret, 'set preset');
|
|
127
150
|
*
|
|
128
|
-
*
|
|
151
|
+
* ret = Option.setInt(obj, 'bitrate', 2000000);
|
|
152
|
+
* FFmpegError.throwIfError(ret, 'set bitrate');
|
|
153
|
+
*
|
|
154
|
+
* ret = Option.setRational(obj, 'framerate', { num: 30, den: 1 });
|
|
155
|
+
* FFmpegError.throwIfError(ret, 'set framerate');
|
|
156
|
+
*
|
|
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.
|
|
188
222
|
*
|
|
189
|
-
*
|
|
223
|
+
* Like find() but also indicates if option was found on different target.
|
|
190
224
|
*
|
|
191
|
-
*
|
|
192
|
-
* @param name - Option name to find
|
|
193
|
-
* @param searchFlags - Search flags (default: 0)
|
|
225
|
+
* Direct mapping to av_opt_find2().
|
|
194
226
|
*
|
|
195
|
-
* @
|
|
227
|
+
* @param obj - Object to search
|
|
228
|
+
* @param name - Option name
|
|
229
|
+
* @param searchFlags - Search flags
|
|
230
|
+
* @returns Object with option and target info
|
|
231
|
+
*
|
|
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,299 @@ 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
|
|
215
|
-
*
|
|
216
|
-
* @returns Value string on success, null if option not found or on error
|
|
256
|
+
* @param searchFlags - Search flags
|
|
257
|
+
* @returns Option value as string, or null
|
|
217
258
|
*/
|
|
218
259
|
static get(obj, name, searchFlags = AVFLAG_NONE) {
|
|
219
260
|
return bindings.Option.get(obj, name, searchFlags);
|
|
220
261
|
}
|
|
221
262
|
/**
|
|
222
|
-
* Get option value
|
|
263
|
+
* Get integer option value.
|
|
223
264
|
*
|
|
224
|
-
*
|
|
225
|
-
* Option must be of integer type.
|
|
265
|
+
* Direct mapping to av_opt_get_int().
|
|
226
266
|
*
|
|
227
|
-
* @param obj -
|
|
267
|
+
* @param obj - Object to query
|
|
228
268
|
* @param name - Option name
|
|
229
|
-
* @param searchFlags - Search flags
|
|
230
|
-
*
|
|
231
|
-
* @returns Integer value on success, null if option not found or on error
|
|
269
|
+
* @param searchFlags - Search flags
|
|
270
|
+
* @returns Option value as integer, or null
|
|
232
271
|
*/
|
|
233
272
|
static getInt(obj, name, searchFlags = AVFLAG_NONE) {
|
|
234
273
|
return bindings.Option.getInt(obj, name, searchFlags);
|
|
235
274
|
}
|
|
236
275
|
/**
|
|
237
|
-
* Get option value
|
|
276
|
+
* Get double option value.
|
|
238
277
|
*
|
|
239
|
-
*
|
|
240
|
-
* Option must be of double/float type.
|
|
278
|
+
* Direct mapping to av_opt_get_double().
|
|
241
279
|
*
|
|
242
|
-
* @param obj -
|
|
280
|
+
* @param obj - Object to query
|
|
243
281
|
* @param name - Option name
|
|
244
|
-
* @param searchFlags - Search flags
|
|
245
|
-
*
|
|
246
|
-
* @returns Double value on success, null if option not found or on error
|
|
282
|
+
* @param searchFlags - Search flags
|
|
283
|
+
* @returns Option value as double, or null
|
|
247
284
|
*/
|
|
248
285
|
static getDouble(obj, name, searchFlags = AVFLAG_NONE) {
|
|
249
286
|
return bindings.Option.getDouble(obj, name, searchFlags);
|
|
250
287
|
}
|
|
251
288
|
/**
|
|
252
|
-
* Get option value
|
|
289
|
+
* Get rational option value.
|
|
253
290
|
*
|
|
254
|
-
*
|
|
255
|
-
* Option must be of rational type.
|
|
291
|
+
* Direct mapping to av_opt_get_q().
|
|
256
292
|
*
|
|
257
|
-
* @param obj -
|
|
293
|
+
* @param obj - Object to query
|
|
258
294
|
* @param name - Option name
|
|
259
|
-
* @param searchFlags - Search flags
|
|
260
|
-
*
|
|
261
|
-
* @returns Rational object {num, den} on success, null if option not found or on error
|
|
295
|
+
* @param searchFlags - Search flags
|
|
296
|
+
* @returns Option value as rational, or null
|
|
262
297
|
*/
|
|
263
298
|
static getRational(obj, name, searchFlags = AVFLAG_NONE) {
|
|
264
299
|
return bindings.Option.getRational(obj, name, searchFlags);
|
|
265
300
|
}
|
|
266
301
|
/**
|
|
267
|
-
* Get option value
|
|
302
|
+
* Get pixel format option value.
|
|
268
303
|
*
|
|
269
|
-
*
|
|
270
|
-
* Option must be of pixel format type.
|
|
304
|
+
* Direct mapping to av_opt_get_pixel_fmt().
|
|
271
305
|
*
|
|
272
|
-
* @param obj -
|
|
306
|
+
* @param obj - Object to query
|
|
273
307
|
* @param name - Option name
|
|
274
|
-
* @param searchFlags - Search flags
|
|
275
|
-
*
|
|
276
|
-
* @returns AVPixelFormat enum value on success, null if option not found or on error
|
|
308
|
+
* @param searchFlags - Search flags
|
|
309
|
+
* @returns Pixel format value, or null
|
|
277
310
|
*/
|
|
278
311
|
static getPixelFormat(obj, name, searchFlags = AVFLAG_NONE) {
|
|
279
312
|
return bindings.Option.getPixelFormat(obj, name, searchFlags);
|
|
280
313
|
}
|
|
281
314
|
/**
|
|
282
|
-
* Get option value
|
|
315
|
+
* Get sample format option value.
|
|
283
316
|
*
|
|
284
|
-
*
|
|
285
|
-
* Option must be of sample format type.
|
|
317
|
+
* Direct mapping to av_opt_get_sample_fmt().
|
|
286
318
|
*
|
|
287
|
-
* @param obj -
|
|
319
|
+
* @param obj - Object to query
|
|
288
320
|
* @param name - Option name
|
|
289
|
-
* @param searchFlags - Search flags
|
|
290
|
-
*
|
|
291
|
-
* @returns AVSampleFormat enum value on success, null if option not found or on error
|
|
321
|
+
* @param searchFlags - Search flags
|
|
322
|
+
* @returns Sample format value, or null
|
|
292
323
|
*/
|
|
293
324
|
static getSampleFormat(obj, name, searchFlags = AVFLAG_NONE) {
|
|
294
325
|
return bindings.Option.getSampleFormat(obj, name, searchFlags);
|
|
295
326
|
}
|
|
296
327
|
/**
|
|
297
|
-
* Get option value
|
|
328
|
+
* Get image size option value.
|
|
298
329
|
*
|
|
299
|
-
*
|
|
300
|
-
* Option must be of image size type.
|
|
330
|
+
* Direct mapping to av_opt_get_image_size().
|
|
301
331
|
*
|
|
302
|
-
* @param obj -
|
|
332
|
+
* @param obj - Object to query
|
|
303
333
|
* @param name - Option name
|
|
304
|
-
* @param searchFlags - Search flags
|
|
305
|
-
*
|
|
306
|
-
* @returns Size object {width, height} on success, null if option not found or on error
|
|
334
|
+
* @param searchFlags - Search flags
|
|
335
|
+
* @returns Width and height, or null
|
|
307
336
|
*/
|
|
308
337
|
static getImageSize(obj, name, searchFlags = AVFLAG_NONE) {
|
|
309
338
|
return bindings.Option.getImageSize(obj, name, searchFlags);
|
|
310
339
|
}
|
|
311
340
|
/**
|
|
312
|
-
* Get option value
|
|
341
|
+
* Get channel layout option value.
|
|
313
342
|
*
|
|
314
|
-
*
|
|
315
|
-
* Option must be of channel layout type.
|
|
343
|
+
* Direct mapping to av_opt_get_chlayout().
|
|
316
344
|
*
|
|
317
|
-
* @param obj -
|
|
345
|
+
* @param obj - Object to query
|
|
318
346
|
* @param name - Option name
|
|
319
|
-
* @param searchFlags - Search flags
|
|
320
|
-
*
|
|
321
|
-
* @returns ChannelLayout object on success, null if option not found or on error
|
|
347
|
+
* @param searchFlags - Search flags
|
|
348
|
+
* @returns Channel layout, or null
|
|
322
349
|
*/
|
|
323
350
|
static getChannelLayout(obj, name, searchFlags = AVFLAG_NONE) {
|
|
324
351
|
return bindings.Option.getChannelLayout(obj, name, searchFlags);
|
|
325
352
|
}
|
|
326
353
|
/**
|
|
327
|
-
* Get option value
|
|
354
|
+
* Get dictionary option value.
|
|
328
355
|
*
|
|
329
|
-
*
|
|
330
|
-
* Option must be of dictionary type.
|
|
356
|
+
* Direct mapping to av_opt_get_dict_val().
|
|
331
357
|
*
|
|
332
|
-
* @param obj -
|
|
358
|
+
* @param obj - Object to query
|
|
333
359
|
* @param name - Option name
|
|
334
|
-
* @param searchFlags - Search flags
|
|
335
|
-
*
|
|
336
|
-
* @returns Dictionary object on success, null if option not found or on error
|
|
360
|
+
* @param searchFlags - Search flags
|
|
361
|
+
* @returns Dictionary value, or null
|
|
337
362
|
*/
|
|
338
363
|
static getDict(obj, name, searchFlags = AVFLAG_NONE) {
|
|
339
364
|
const native = bindings.Option.getDict(obj, name, searchFlags);
|
|
340
365
|
return native ? Dictionary.fromNative(native) : null;
|
|
341
366
|
}
|
|
342
367
|
/**
|
|
343
|
-
* Set option value
|
|
368
|
+
* Set string option value.
|
|
344
369
|
*
|
|
345
|
-
*
|
|
346
|
-
* Can be used for any option type - FFmpeg will parse the string.
|
|
370
|
+
* Direct mapping to av_opt_set().
|
|
347
371
|
*
|
|
348
|
-
* @param obj -
|
|
372
|
+
* @param obj - Object to modify
|
|
349
373
|
* @param name - Option name
|
|
350
|
-
* @param value - String value
|
|
351
|
-
* @param searchFlags - Search flags
|
|
352
|
-
*
|
|
353
|
-
* @returns 0 on success, negative AVERROR code on failure
|
|
374
|
+
* @param value - String value
|
|
375
|
+
* @param searchFlags - Search flags
|
|
376
|
+
* @returns 0 on success, negative AVERROR on error
|
|
354
377
|
*/
|
|
355
378
|
static set(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
356
379
|
return bindings.Option.set(obj, name, value, searchFlags);
|
|
357
380
|
}
|
|
358
381
|
/**
|
|
359
|
-
* Set option value
|
|
382
|
+
* Set integer option value.
|
|
360
383
|
*
|
|
361
|
-
*
|
|
362
|
-
* More efficient than set() for numeric options.
|
|
384
|
+
* Direct mapping to av_opt_set_int().
|
|
363
385
|
*
|
|
364
|
-
* @param obj -
|
|
386
|
+
* @param obj - Object to modify
|
|
365
387
|
* @param name - Option name
|
|
366
|
-
* @param value -
|
|
367
|
-
* @param searchFlags - Search flags
|
|
368
|
-
*
|
|
369
|
-
* @returns 0 on success, negative AVERROR code on failure
|
|
388
|
+
* @param value - Integer value
|
|
389
|
+
* @param searchFlags - Search flags
|
|
390
|
+
* @returns 0 on success, negative AVERROR on error
|
|
370
391
|
*/
|
|
371
392
|
static setInt(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
372
393
|
return bindings.Option.setInt(obj, name, value, searchFlags);
|
|
373
394
|
}
|
|
374
395
|
/**
|
|
375
|
-
* Set option value
|
|
396
|
+
* Set double option value.
|
|
376
397
|
*
|
|
377
|
-
*
|
|
378
|
-
* More efficient than set() for floating point options.
|
|
398
|
+
* Direct mapping to av_opt_set_double().
|
|
379
399
|
*
|
|
380
|
-
* @param obj -
|
|
400
|
+
* @param obj - Object to modify
|
|
381
401
|
* @param name - Option name
|
|
382
|
-
* @param value - Double value
|
|
383
|
-
* @param searchFlags - Search flags
|
|
384
|
-
*
|
|
385
|
-
* @returns 0 on success, negative AVERROR code on failure
|
|
402
|
+
* @param value - Double value
|
|
403
|
+
* @param searchFlags - Search flags
|
|
404
|
+
* @returns 0 on success, negative AVERROR on error
|
|
386
405
|
*/
|
|
387
406
|
static setDouble(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
388
407
|
return bindings.Option.setDouble(obj, name, value, searchFlags);
|
|
389
408
|
}
|
|
390
409
|
/**
|
|
391
|
-
* Set option value
|
|
410
|
+
* Set rational option value.
|
|
392
411
|
*
|
|
393
|
-
*
|
|
394
|
-
* For framerates, aspect ratios, time bases, etc.
|
|
412
|
+
* Direct mapping to av_opt_set_q().
|
|
395
413
|
*
|
|
396
|
-
* @param obj -
|
|
414
|
+
* @param obj - Object to modify
|
|
397
415
|
* @param name - Option name
|
|
398
|
-
* @param value - Rational
|
|
399
|
-
* @param searchFlags - Search flags
|
|
400
|
-
*
|
|
401
|
-
* @returns 0 on success, negative AVERROR code on failure
|
|
416
|
+
* @param value - Rational value
|
|
417
|
+
* @param searchFlags - Search flags
|
|
418
|
+
* @returns 0 on success, negative AVERROR on error
|
|
402
419
|
*/
|
|
403
420
|
static setRational(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
404
421
|
return bindings.Option.setRational(obj, name, value, searchFlags);
|
|
405
422
|
}
|
|
406
423
|
/**
|
|
407
|
-
* Set option value
|
|
424
|
+
* Set pixel format option value.
|
|
408
425
|
*
|
|
409
|
-
*
|
|
410
|
-
* More type-safe than using set() with string names.
|
|
426
|
+
* Direct mapping to av_opt_set_pixel_fmt().
|
|
411
427
|
*
|
|
412
|
-
* @param obj -
|
|
428
|
+
* @param obj - Object to modify
|
|
413
429
|
* @param name - Option name
|
|
414
|
-
* @param value -
|
|
415
|
-
* @param searchFlags - Search flags
|
|
416
|
-
*
|
|
417
|
-
* @returns 0 on success, negative AVERROR code on failure
|
|
430
|
+
* @param value - Pixel format
|
|
431
|
+
* @param searchFlags - Search flags
|
|
432
|
+
* @returns 0 on success, negative AVERROR on error
|
|
418
433
|
*/
|
|
419
434
|
static setPixelFormat(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
420
435
|
return bindings.Option.setPixelFormat(obj, name, value, searchFlags);
|
|
421
436
|
}
|
|
422
437
|
/**
|
|
423
|
-
* Set option value
|
|
438
|
+
* Set sample format option value.
|
|
424
439
|
*
|
|
425
|
-
*
|
|
426
|
-
* More type-safe than using set() with string names.
|
|
440
|
+
* Direct mapping to av_opt_set_sample_fmt().
|
|
427
441
|
*
|
|
428
|
-
* @param obj -
|
|
442
|
+
* @param obj - Object to modify
|
|
429
443
|
* @param name - Option name
|
|
430
|
-
* @param value -
|
|
431
|
-
* @param searchFlags - Search flags
|
|
432
|
-
*
|
|
433
|
-
* @returns 0 on success, negative AVERROR code on failure
|
|
444
|
+
* @param value - Sample format
|
|
445
|
+
* @param searchFlags - Search flags
|
|
446
|
+
* @returns 0 on success, negative AVERROR on error
|
|
434
447
|
*/
|
|
435
448
|
static setSampleFormat(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
436
449
|
return bindings.Option.setSampleFormat(obj, name, value, searchFlags);
|
|
437
450
|
}
|
|
438
451
|
/**
|
|
439
|
-
* Set option value
|
|
452
|
+
* Set image size option value.
|
|
440
453
|
*
|
|
441
|
-
*
|
|
442
|
-
* Convenient for setting width and height together.
|
|
454
|
+
* Direct mapping to av_opt_set_image_size().
|
|
443
455
|
*
|
|
444
|
-
* @param obj -
|
|
456
|
+
* @param obj - Object to modify
|
|
445
457
|
* @param name - Option name
|
|
446
|
-
* @param width -
|
|
447
|
-
* @param height -
|
|
448
|
-
* @param searchFlags - Search flags
|
|
449
|
-
*
|
|
450
|
-
* @returns 0 on success, negative AVERROR code on failure
|
|
458
|
+
* @param width - Image width
|
|
459
|
+
* @param height - Image height
|
|
460
|
+
* @param searchFlags - Search flags
|
|
461
|
+
* @returns 0 on success, negative AVERROR on error
|
|
451
462
|
*/
|
|
452
463
|
static setImageSize(obj, name, width, height, searchFlags = AVFLAG_NONE) {
|
|
453
464
|
return bindings.Option.setImageSize(obj, name, width, height, searchFlags);
|
|
454
465
|
}
|
|
455
466
|
/**
|
|
456
|
-
* Set option value
|
|
467
|
+
* Set channel layout option value.
|
|
457
468
|
*
|
|
458
|
-
*
|
|
459
|
-
* For audio channel configuration.
|
|
469
|
+
* Direct mapping to av_opt_set_chlayout().
|
|
460
470
|
*
|
|
461
|
-
* @param obj -
|
|
471
|
+
* @param obj - Object to modify
|
|
462
472
|
* @param name - Option name
|
|
463
|
-
* @param value - Channel layout
|
|
464
|
-
* @param searchFlags - Search flags
|
|
465
|
-
*
|
|
466
|
-
* @returns 0 on success, negative AVERROR code on failure
|
|
473
|
+
* @param value - Channel layout
|
|
474
|
+
* @param searchFlags - Search flags
|
|
475
|
+
* @returns 0 on success, negative AVERROR on error
|
|
467
476
|
*/
|
|
468
477
|
static setChannelLayout(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
469
478
|
return bindings.Option.setChannelLayout(obj, name, value, searchFlags);
|
|
470
479
|
}
|
|
471
480
|
/**
|
|
472
|
-
* Set option value
|
|
481
|
+
* Set dictionary option value.
|
|
473
482
|
*
|
|
474
|
-
*
|
|
475
|
-
* For options that accept key-value pairs.
|
|
483
|
+
* Direct mapping to av_opt_set_dict_val().
|
|
476
484
|
*
|
|
477
|
-
* @param obj -
|
|
485
|
+
* @param obj - Object to modify
|
|
478
486
|
* @param name - Option name
|
|
479
|
-
* @param value - Dictionary
|
|
480
|
-
* @param searchFlags - Search flags
|
|
481
|
-
*
|
|
482
|
-
* @returns 0 on success, negative AVERROR code on failure
|
|
487
|
+
* @param value - Dictionary value
|
|
488
|
+
* @param searchFlags - Search flags
|
|
489
|
+
* @returns 0 on success, negative AVERROR on error
|
|
483
490
|
*/
|
|
484
491
|
static setDict(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
485
492
|
return bindings.Option.setDict(obj, name, value.getNative(), searchFlags);
|
|
486
493
|
}
|
|
487
494
|
/**
|
|
488
|
-
* Set option value
|
|
495
|
+
* Set binary option value.
|
|
489
496
|
*
|
|
490
|
-
*
|
|
491
|
-
* For options that accept raw binary data.
|
|
497
|
+
* Direct mapping to av_opt_set_bin().
|
|
492
498
|
*
|
|
493
|
-
* @param obj -
|
|
499
|
+
* @param obj - Object to modify
|
|
494
500
|
* @param name - Option name
|
|
495
|
-
* @param value - Binary data
|
|
496
|
-
* @param searchFlags - Search flags
|
|
497
|
-
*
|
|
498
|
-
* @returns 0 on success, negative AVERROR code on failure
|
|
501
|
+
* @param value - Binary data
|
|
502
|
+
* @param searchFlags - Search flags
|
|
503
|
+
* @returns 0 on success, negative AVERROR on error
|
|
499
504
|
*/
|
|
500
505
|
static setBin(obj, name, value, searchFlags = AVFLAG_NONE) {
|
|
501
506
|
return bindings.Option.setBin(obj, name, value, searchFlags);
|
|
502
507
|
}
|
|
503
508
|
/**
|
|
504
|
-
* Set
|
|
509
|
+
* Set defaults on object.
|
|
505
510
|
*
|
|
506
|
-
*
|
|
511
|
+
* Sets all options to their default values.
|
|
507
512
|
*
|
|
508
|
-
*
|
|
513
|
+
* Direct mapping to av_opt_set_defaults().
|
|
514
|
+
*
|
|
515
|
+
* @param obj - Object to reset
|
|
509
516
|
*/
|
|
510
517
|
static setDefaults(obj) {
|
|
511
518
|
bindings.Option.setDefaults(obj);
|
|
512
519
|
}
|
|
513
520
|
/**
|
|
514
|
-
* Copy options
|
|
521
|
+
* Copy options between objects.
|
|
522
|
+
*
|
|
523
|
+
* Copies option values from source to destination.
|
|
515
524
|
*
|
|
516
|
-
*
|
|
517
|
-
* Copies all option values from one object to another.
|
|
525
|
+
* Direct mapping to av_opt_copy().
|
|
518
526
|
*
|
|
519
527
|
* @param dest - Destination object
|
|
520
528
|
* @param src - Source object
|
|
521
|
-
*
|
|
522
|
-
* @returns 0 on success, negative AVERROR code on failure
|
|
529
|
+
* @returns 0 on success, negative AVERROR on error
|
|
523
530
|
*/
|
|
524
531
|
static copy(dest, src) {
|
|
525
532
|
return bindings.Option.copy(dest, src);
|
|
526
533
|
}
|
|
527
534
|
/**
|
|
528
|
-
* Check if option is set to
|
|
535
|
+
* Check if option is set to default.
|
|
529
536
|
*
|
|
530
|
-
*
|
|
537
|
+
* Direct mapping to av_opt_is_set_to_default().
|
|
531
538
|
*
|
|
532
|
-
* @param obj -
|
|
539
|
+
* @param obj - Object to check
|
|
533
540
|
* @param name - Option name
|
|
534
|
-
* @param searchFlags - Search flags
|
|
535
|
-
*
|
|
536
|
-
* @returns true if set to default, false if not, null if option not found or on error
|
|
541
|
+
* @param searchFlags - Search flags
|
|
542
|
+
* @returns True if default, false if modified, null if not found
|
|
537
543
|
*/
|
|
538
544
|
static isSetToDefault(obj, name, searchFlags = AVFLAG_NONE) {
|
|
539
545
|
return bindings.Option.isSetToDefault(obj, name, searchFlags);
|
|
@@ -541,41 +547,37 @@ export class Option {
|
|
|
541
547
|
/**
|
|
542
548
|
* Serialize options to string.
|
|
543
549
|
*
|
|
544
|
-
*
|
|
545
|
-
* Converts all non-default options to a string representation.
|
|
550
|
+
* Direct mapping to av_opt_serialize().
|
|
546
551
|
*
|
|
547
|
-
* @param obj -
|
|
548
|
-
* @param optFlags - Option flags
|
|
549
|
-
* @param flags - Serialization flags
|
|
550
|
-
* @param keyValSep - Key-value separator
|
|
551
|
-
* @param pairsSep - Pairs separator
|
|
552
|
-
*
|
|
553
|
-
* @returns Serialized string on success, null on error or if no options to serialize
|
|
552
|
+
* @param obj - Object to serialize
|
|
553
|
+
* @param optFlags - Option flags filter
|
|
554
|
+
* @param flags - Serialization flags
|
|
555
|
+
* @param keyValSep - Key-value separator
|
|
556
|
+
* @param pairsSep - Pairs separator
|
|
557
|
+
* @returns Serialized string, or null on error
|
|
554
558
|
*/
|
|
555
559
|
static serialize(obj, optFlags = 0, flags = 0, keyValSep = '=', pairsSep = ',') {
|
|
556
560
|
return bindings.Option.serialize(obj, optFlags, flags, keyValSep, pairsSep);
|
|
557
561
|
}
|
|
558
562
|
/**
|
|
559
|
-
* Free
|
|
563
|
+
* Free option resources.
|
|
560
564
|
*
|
|
561
|
-
*
|
|
565
|
+
* Direct mapping to av_opt_free().
|
|
562
566
|
*
|
|
563
|
-
* @param obj -
|
|
567
|
+
* @param obj - Object to free options from
|
|
564
568
|
*/
|
|
565
569
|
static free(obj) {
|
|
566
570
|
bindings.Option.free(obj);
|
|
567
571
|
}
|
|
568
572
|
/**
|
|
569
|
-
* Show options
|
|
570
|
-
*
|
|
571
|
-
* Uses av_opt_show2() internally.
|
|
572
|
-
* Prints all available options to stderr.
|
|
573
|
+
* Show options for debugging.
|
|
573
574
|
*
|
|
574
|
-
*
|
|
575
|
-
* @param reqFlags - Required flags (default: 0)
|
|
576
|
-
* @param rejFlags - Rejected flags (default: 0)
|
|
575
|
+
* Direct mapping to av_opt_show2().
|
|
577
576
|
*
|
|
578
|
-
* @
|
|
577
|
+
* @param obj - Object to show options for
|
|
578
|
+
* @param reqFlags - Required flags
|
|
579
|
+
* @param rejFlags - Rejected flags
|
|
580
|
+
* @returns 0 on success, negative AVERROR on error
|
|
579
581
|
*/
|
|
580
582
|
static show(obj, reqFlags = 0, rejFlags = 0) {
|
|
581
583
|
return bindings.Option.show(obj, reqFlags, rejFlags);
|
|
@@ -595,10 +597,42 @@ export class Option {
|
|
|
595
597
|
*
|
|
596
598
|
* @example
|
|
597
599
|
* ```typescript
|
|
600
|
+
* import { OptionMember, FFmpegError } from 'node-av';
|
|
601
|
+
* import { AV_OPT_TYPE_INT, AV_OPT_TYPE_STRING, AV_OPT_TYPE_RATIONAL } from 'node-av/constants';
|
|
602
|
+
*
|
|
598
603
|
* class CodecContext extends OptionMember<NativeCodecContext> {
|
|
599
|
-
*
|
|
604
|
+
* constructor(native: NativeCodecContext) {
|
|
605
|
+
* super(native);
|
|
606
|
+
* }
|
|
607
|
+
* }
|
|
608
|
+
*
|
|
609
|
+
* // Use inherited methods
|
|
610
|
+
* const codec = new CodecContext(native);
|
|
611
|
+
*
|
|
612
|
+
* // Set options with automatic type handling
|
|
613
|
+
* let ret = codec.setOption('preset', 'fast');
|
|
614
|
+
* FFmpegError.throwIfError(ret, 'set preset');
|
|
615
|
+
*
|
|
616
|
+
* ret = codec.setOption('bitrate', 2000000, AV_OPT_TYPE_INT);
|
|
617
|
+
* FFmpegError.throwIfError(ret, 'set bitrate');
|
|
618
|
+
*
|
|
619
|
+
* ret = codec.setOption('framerate', { num: 30, den: 1 }, AV_OPT_TYPE_RATIONAL);
|
|
620
|
+
* FFmpegError.throwIfError(ret, 'set framerate');
|
|
621
|
+
*
|
|
622
|
+
* // Get typed options
|
|
623
|
+
* const preset = codec.getOption('preset');
|
|
624
|
+
* const bitrate = codec.getOption('bitrate', AV_OPT_TYPE_INT);
|
|
625
|
+
* const framerate = codec.getOption('framerate', AV_OPT_TYPE_RATIONAL);
|
|
626
|
+
*
|
|
627
|
+
* // List all available options
|
|
628
|
+
* const options = codec.listOptions();
|
|
629
|
+
* for (const opt of options) {
|
|
630
|
+
* console.log(`${opt.name}: ${opt.help}`);
|
|
600
631
|
* }
|
|
601
632
|
* ```
|
|
633
|
+
*
|
|
634
|
+
* @see {@link Option} For static option methods
|
|
635
|
+
* @see {@link OptionInfo} For option metadata
|
|
602
636
|
*/
|
|
603
637
|
export class OptionMember {
|
|
604
638
|
native;
|
|
@@ -611,25 +645,42 @@ export class OptionMember {
|
|
|
611
645
|
* Uses the AVOption API to set options.
|
|
612
646
|
* Available options depend on the specific object type.
|
|
613
647
|
*
|
|
648
|
+
* Direct mapping to av_opt_set* functions.
|
|
649
|
+
*
|
|
614
650
|
* @param name - Option name
|
|
615
651
|
* @param value - Option value
|
|
616
652
|
* @param type - Option type (defaults to AV_OPT_TYPE_STRING)
|
|
617
653
|
* @param searchFlags - Search flags (default: AV_OPT_SEARCH_CHILDREN)
|
|
618
|
-
* @returns 0 on success, negative AVERROR
|
|
654
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
655
|
+
* - AVERROR_ENOENT: Option not found
|
|
656
|
+
* - AVERROR_ERANGE: Value out of range
|
|
657
|
+
* - AVERROR_EINVAL: Invalid value
|
|
619
658
|
*
|
|
620
659
|
* @example
|
|
621
660
|
* ```typescript
|
|
661
|
+
* import { FFmpegError } from 'node-av';
|
|
662
|
+
* import { AV_OPT_TYPE_STRING, AV_OPT_TYPE_INT64, AV_OPT_TYPE_RATIONAL, AV_OPT_TYPE_PIXEL_FMT } from 'node-av/constants';
|
|
663
|
+
*
|
|
622
664
|
* // String options (default)
|
|
623
|
-
* ret = obj.setOption('preset', 'fast');
|
|
665
|
+
* let ret = obj.setOption('preset', 'fast');
|
|
666
|
+
* FFmpegError.throwIfError(ret, 'set preset');
|
|
667
|
+
*
|
|
624
668
|
* ret = obj.setOption('codec', 'h264', AV_OPT_TYPE_STRING);
|
|
669
|
+
* FFmpegError.throwIfError(ret, 'set codec');
|
|
625
670
|
*
|
|
626
671
|
* // Integer options
|
|
627
672
|
* ret = obj.setOption('bitrate', 2000000, AV_OPT_TYPE_INT64);
|
|
673
|
+
* FFmpegError.throwIfError(ret, 'set bitrate');
|
|
674
|
+
*
|
|
628
675
|
* ret = obj.setOption('threads', 4, AV_OPT_TYPE_INT);
|
|
676
|
+
* FFmpegError.throwIfError(ret, 'set threads');
|
|
629
677
|
*
|
|
630
678
|
* // Complex types with proper types
|
|
631
679
|
* ret = obj.setOption('framerate', {num: 30, den: 1}, AV_OPT_TYPE_RATIONAL);
|
|
680
|
+
* FFmpegError.throwIfError(ret, 'set framerate');
|
|
681
|
+
*
|
|
632
682
|
* ret = obj.setOption('pix_fmt', AV_PIX_FMT_YUV420P, AV_OPT_TYPE_PIXEL_FMT);
|
|
683
|
+
* FFmpegError.throwIfError(ret, 'set pixel format');
|
|
633
684
|
* ```
|
|
634
685
|
*/
|
|
635
686
|
setOption(name, value, type = AV_OPT_TYPE_STRING, searchFlags = AV_OPT_SEARCH_CHILDREN) {
|
|
@@ -758,13 +809,17 @@ export class OptionMember {
|
|
|
758
809
|
*
|
|
759
810
|
* Uses the AVOption API to retrieve options.
|
|
760
811
|
*
|
|
812
|
+
* Direct mapping to av_opt_get* functions.
|
|
813
|
+
*
|
|
761
814
|
* @param name - Option name
|
|
762
815
|
* @param type - Option type (defaults to AV_OPT_TYPE_STRING)
|
|
763
816
|
* @param searchFlags - Search flags (default: AV_OPT_SEARCH_CHILDREN)
|
|
764
|
-
* @returns Option value (type depends on type parameter)
|
|
817
|
+
* @returns Option value (type depends on type parameter), or null if not found
|
|
765
818
|
*
|
|
766
819
|
* @example
|
|
767
820
|
* ```typescript
|
|
821
|
+
* import { AV_OPT_TYPE_STRING, AV_OPT_TYPE_RATIONAL, AV_OPT_TYPE_PIXEL_FMT, AV_OPT_TYPE_INT64 } from 'node-av/constants';
|
|
822
|
+
*
|
|
768
823
|
* // String options (default)
|
|
769
824
|
* const preset = obj.getOption('preset');
|
|
770
825
|
* const codec = obj.getOption('codec', AV_OPT_TYPE_STRING);
|
|
@@ -772,7 +827,7 @@ export class OptionMember {
|
|
|
772
827
|
* // Typed options
|
|
773
828
|
* const framerate = obj.getOption('framerate', AV_OPT_TYPE_RATIONAL); // Returns {num, den}
|
|
774
829
|
* const pixFmt = obj.getOption('pix_fmt', AV_OPT_TYPE_PIXEL_FMT); // Returns AVPixelFormat
|
|
775
|
-
* const bitrate = obj.getOption('bitrate', AV_OPT_TYPE_INT64); // Returns
|
|
830
|
+
* const bitrate = obj.getOption('bitrate', AV_OPT_TYPE_INT64); // Returns bigint
|
|
776
831
|
* ```
|
|
777
832
|
*/
|
|
778
833
|
getOption(name, type = AV_OPT_TYPE_STRING, searchFlags = AV_OPT_SEARCH_CHILDREN) {
|
|
@@ -830,6 +885,8 @@ export class OptionMember {
|
|
|
830
885
|
* Uses the AVOption API to enumerate all options.
|
|
831
886
|
* Useful for discovering available settings and their types.
|
|
832
887
|
*
|
|
888
|
+
* Direct mapping to av_opt_next() iteration.
|
|
889
|
+
*
|
|
833
890
|
* @returns Array of option information objects
|
|
834
891
|
*
|
|
835
892
|
* @example
|
|
@@ -838,8 +895,11 @@ export class OptionMember {
|
|
|
838
895
|
* for (const opt of options) {
|
|
839
896
|
* console.log(`${opt.name}: ${opt.help}`);
|
|
840
897
|
* console.log(` Type: ${opt.type}, Default: ${opt.defaultValue}`);
|
|
898
|
+
* console.log(` Range: ${opt.min} - ${opt.max}`);
|
|
841
899
|
* }
|
|
842
900
|
* ```
|
|
901
|
+
*
|
|
902
|
+
* @see {@link OptionInfo} For option metadata structure
|
|
843
903
|
*/
|
|
844
904
|
listOptions() {
|
|
845
905
|
const options = [];
|