node-av 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +51 -38
  2. package/dist/api/bitstream-filter.d.ts +180 -123
  3. package/dist/api/bitstream-filter.js +180 -125
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +279 -132
  6. package/dist/api/decoder.js +285 -142
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +246 -162
  9. package/dist/api/encoder.js +272 -208
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +690 -94
  12. package/dist/api/filter-presets.js +686 -102
  13. package/dist/api/filter-presets.js.map +1 -1
  14. package/dist/api/filter.d.ts +249 -213
  15. package/dist/api/filter.js +252 -242
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +224 -117
  18. package/dist/api/hardware.js +380 -214
  19. package/dist/api/hardware.js.map +1 -1
  20. package/dist/api/index.d.ts +3 -3
  21. package/dist/api/index.js +1 -1
  22. package/dist/api/index.js.map +1 -1
  23. package/dist/api/io-stream.d.ts +65 -61
  24. package/dist/api/io-stream.js +43 -46
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +242 -140
  27. package/dist/api/media-input.js +205 -103
  28. package/dist/api/media-input.js.map +1 -1
  29. package/dist/api/media-output.d.ts +206 -128
  30. package/dist/api/media-output.js +210 -128
  31. package/dist/api/media-output.js.map +1 -1
  32. package/dist/api/pipeline.d.ts +168 -38
  33. package/dist/api/pipeline.js +238 -14
  34. package/dist/api/pipeline.js.map +1 -1
  35. package/dist/api/types.d.ts +21 -187
  36. package/dist/api/utils.d.ts +1 -2
  37. package/dist/api/utils.js +9 -0
  38. package/dist/api/utils.js.map +1 -1
  39. package/dist/lib/audio-fifo.d.ts +127 -170
  40. package/dist/lib/audio-fifo.js +130 -173
  41. package/dist/lib/audio-fifo.js.map +1 -1
  42. package/dist/lib/binding.js +5 -0
  43. package/dist/lib/binding.js.map +1 -1
  44. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  45. package/dist/lib/bitstream-filter-context.js +139 -188
  46. package/dist/lib/bitstream-filter-context.js.map +1 -1
  47. package/dist/lib/bitstream-filter.d.ts +68 -54
  48. package/dist/lib/bitstream-filter.js +68 -54
  49. package/dist/lib/bitstream-filter.js.map +1 -1
  50. package/dist/lib/codec-context.d.ts +316 -380
  51. package/dist/lib/codec-context.js +316 -381
  52. package/dist/lib/codec-context.js.map +1 -1
  53. package/dist/lib/codec-parameters.d.ts +160 -170
  54. package/dist/lib/codec-parameters.js +162 -172
  55. package/dist/lib/codec-parameters.js.map +1 -1
  56. package/dist/lib/codec-parser.d.ts +91 -104
  57. package/dist/lib/codec-parser.js +92 -103
  58. package/dist/lib/codec-parser.js.map +1 -1
  59. package/dist/lib/codec.d.ts +264 -281
  60. package/dist/lib/codec.js +268 -285
  61. package/dist/lib/codec.js.map +1 -1
  62. package/dist/lib/dictionary.d.ts +149 -203
  63. package/dist/lib/dictionary.js +158 -212
  64. package/dist/lib/dictionary.js.map +1 -1
  65. package/dist/lib/error.d.ts +96 -130
  66. package/dist/lib/error.js +98 -128
  67. package/dist/lib/error.js.map +1 -1
  68. package/dist/lib/filter-context.d.ts +284 -218
  69. package/dist/lib/filter-context.js +290 -227
  70. package/dist/lib/filter-context.js.map +1 -1
  71. package/dist/lib/filter-graph.d.ts +251 -292
  72. package/dist/lib/filter-graph.js +253 -294
  73. package/dist/lib/filter-graph.js.map +1 -1
  74. package/dist/lib/filter-inout.d.ts +87 -95
  75. package/dist/lib/filter-inout.js +87 -95
  76. package/dist/lib/filter-inout.js.map +1 -1
  77. package/dist/lib/filter.d.ts +93 -111
  78. package/dist/lib/filter.js +93 -111
  79. package/dist/lib/filter.js.map +1 -1
  80. package/dist/lib/format-context.d.ts +320 -428
  81. package/dist/lib/format-context.js +313 -385
  82. package/dist/lib/format-context.js.map +1 -1
  83. package/dist/lib/frame.d.ts +262 -405
  84. package/dist/lib/frame.js +263 -408
  85. package/dist/lib/frame.js.map +1 -1
  86. package/dist/lib/hardware-device-context.d.ts +149 -203
  87. package/dist/lib/hardware-device-context.js +149 -203
  88. package/dist/lib/hardware-device-context.js.map +1 -1
  89. package/dist/lib/hardware-frames-context.d.ts +170 -180
  90. package/dist/lib/hardware-frames-context.js +171 -181
  91. package/dist/lib/hardware-frames-context.js.map +1 -1
  92. package/dist/lib/index.d.ts +2 -1
  93. package/dist/lib/index.js +2 -2
  94. package/dist/lib/index.js.map +1 -1
  95. package/dist/lib/input-format.d.ts +89 -117
  96. package/dist/lib/input-format.js +89 -117
  97. package/dist/lib/input-format.js.map +1 -1
  98. package/dist/lib/io-context.d.ts +209 -241
  99. package/dist/lib/io-context.js +220 -252
  100. package/dist/lib/io-context.js.map +1 -1
  101. package/dist/lib/log.d.ts +85 -119
  102. package/dist/lib/log.js +85 -122
  103. package/dist/lib/log.js.map +1 -1
  104. package/dist/lib/native-types.d.ts +117 -106
  105. package/dist/lib/native-types.js +0 -7
  106. package/dist/lib/native-types.js.map +1 -1
  107. package/dist/lib/option.d.ts +284 -241
  108. package/dist/lib/option.js +309 -249
  109. package/dist/lib/option.js.map +1 -1
  110. package/dist/lib/output-format.d.ts +77 -101
  111. package/dist/lib/output-format.js +77 -101
  112. package/dist/lib/output-format.js.map +1 -1
  113. package/dist/lib/packet.d.ts +172 -240
  114. package/dist/lib/packet.js +172 -241
  115. package/dist/lib/packet.js.map +1 -1
  116. package/dist/lib/rational.d.ts +0 -2
  117. package/dist/lib/rational.js +0 -2
  118. package/dist/lib/rational.js.map +1 -1
  119. package/dist/lib/software-resample-context.d.ts +241 -325
  120. package/dist/lib/software-resample-context.js +242 -326
  121. package/dist/lib/software-resample-context.js.map +1 -1
  122. package/dist/lib/software-scale-context.d.ts +129 -173
  123. package/dist/lib/software-scale-context.js +131 -175
  124. package/dist/lib/software-scale-context.js.map +1 -1
  125. package/dist/lib/stream.d.ts +87 -197
  126. package/dist/lib/stream.js +87 -197
  127. package/dist/lib/stream.js.map +1 -1
  128. package/dist/lib/utilities.d.ts +372 -181
  129. package/dist/lib/utilities.js +373 -182
  130. package/dist/lib/utilities.js.map +1 -1
  131. package/install/check.js +0 -1
  132. package/package.json +21 -12
  133. package/release_notes.md +43 -59
  134. package/CHANGELOG.md +0 -8
@@ -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
- * Low-level wrapper for a single AVOption.
6
+ * Option information descriptor.
18
7
  *
19
- * Provides metadata about an option including its name, type, range, and default value.
20
- * Options are not created directly but retrieved through Option.next() or Option.find().
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
- * const opt = Option.find(codecContext, 'bitrate');
25
- * if (opt) {
26
- * console.log(`Option ${opt.name}: ${opt.help}`);
27
- * console.log(`Type: ${opt.type}, Default: ${opt.defaultValue}`);
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
- /** @internal */
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 key used to get/set this option.
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
- * Determines the data type and valid range of values.
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 used if not explicitly set.
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
- * For numeric types, the minimum allowed value.
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
- * For numeric types, the maximum allowed value.
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
- * Bitfield of AV_OPT_FLAG_* values indicating option properties.
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
- * For options that are part of a named group.
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 FFmpeg AVOption pointer.
122
+ * Get the underlying native Option object.
123
+ *
124
+ * @returns The native Option binding object
104
125
  *
105
- * @internal For use by other wrapper classes
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
- * Low-level FFmpeg AVOption API.
133
+ * FFmpeg option management utilities.
114
134
  *
115
- * Provides static methods for accessing and modifying options on FFmpeg objects.
116
- * All methods work with native objects from the low-level API.
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
- * Uses av_opt_* functions internally.
140
+ * Direct mapping to FFmpeg's AVOption API.
119
141
  *
120
142
  * @example
121
143
  * ```typescript
122
- * // Set codec bitrate
123
- * Option.setInt(codecContext, 'b', 2000000);
144
+ * import { Option, FFmpegError } from 'node-av';
145
+ * import { AV_OPT_SEARCH_CHILDREN, AV_PIX_FMT_YUV420P } from 'node-av/constants';
124
146
  *
125
- * // Get current bitrate
126
- * const bitrate = Option.getInt(codecContext, 'b');
147
+ * // Set various option types
148
+ * let ret = Option.set(obj, 'preset', 'fast');
149
+ * FFmpegError.throwIfError(ret, 'set preset');
127
150
  *
128
- * // Iterate through all options
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(codecContext, opt))) {
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 through options of an object.
174
+ * Iterate to next option.
143
175
  *
144
- * Uses av_opt_next() internally.
176
+ * Iterates through available options on an object.
145
177
  *
146
- * @param obj - Native object (CodecContext, FormatContext, FilterContext, etc.)
147
- * @param prev - Previous option for iteration, or null to start
178
+ * Direct mapping to av_opt_next().
148
179
  *
149
- * @returns Next option or null when done
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(codecContext, opt))) {
155
- * console.log(`${opt.name}: ${opt.help}`);
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 an option by name.
197
+ * Find option by name.
165
198
  *
166
- * Uses av_opt_find() internally.
199
+ * Searches for an option with the specified name.
167
200
  *
168
- * @param obj - Native object
169
- * @param name - Option name to find
170
- * @param searchFlags - Search flags (default: 0)
201
+ * Direct mapping to av_opt_find().
171
202
  *
172
- * @returns Found option or null
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(codecContext, 'bitrate');
210
+ * const opt = Option.find(obj, 'bitrate');
177
211
  * if (opt) {
178
- * console.log(`Found option: ${opt.name}`);
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 an option by name with target object information.
221
+ * Find option with target info.
188
222
  *
189
- * Uses av_opt_find2() internally.
223
+ * Like find() but also indicates if option was found on different target.
190
224
  *
191
- * @param obj - Native object
192
- * @param name - Option name to find
193
- * @param searchFlags - Search flags (default: 0)
225
+ * Direct mapping to av_opt_find2().
194
226
  *
195
- * @returns Object with option and whether target differs, or null
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 as string.
250
+ * Get string option value.
208
251
  *
209
- * Uses av_opt_get() internally.
210
- * Converts any option type to its string representation.
252
+ * Direct mapping to av_opt_get().
211
253
  *
212
- * @param obj - Native object
254
+ * @param obj - Object to query
213
255
  * @param name - Option name
214
- * @param searchFlags - Search flags (default: 0)
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 as integer.
263
+ * Get integer option value.
223
264
  *
224
- * Uses av_opt_get_int() internally.
225
- * Option must be of integer type.
265
+ * Direct mapping to av_opt_get_int().
226
266
  *
227
- * @param obj - Native object
267
+ * @param obj - Object to query
228
268
  * @param name - Option name
229
- * @param searchFlags - Search flags (default: 0)
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 as double.
276
+ * Get double option value.
238
277
  *
239
- * Uses av_opt_get_double() internally.
240
- * Option must be of double/float type.
278
+ * Direct mapping to av_opt_get_double().
241
279
  *
242
- * @param obj - Native object
280
+ * @param obj - Object to query
243
281
  * @param name - Option name
244
- * @param searchFlags - Search flags (default: 0)
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 as rational.
289
+ * Get rational option value.
253
290
  *
254
- * Uses av_opt_get_q() internally.
255
- * Option must be of rational type.
291
+ * Direct mapping to av_opt_get_q().
256
292
  *
257
- * @param obj - Native object
293
+ * @param obj - Object to query
258
294
  * @param name - Option name
259
- * @param searchFlags - Search flags (default: 0)
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 as pixel format.
302
+ * Get pixel format option value.
268
303
  *
269
- * Uses av_opt_get_pixel_fmt() internally.
270
- * Option must be of pixel format type.
304
+ * Direct mapping to av_opt_get_pixel_fmt().
271
305
  *
272
- * @param obj - Native object
306
+ * @param obj - Object to query
273
307
  * @param name - Option name
274
- * @param searchFlags - Search flags (default: 0)
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 as sample format.
315
+ * Get sample format option value.
283
316
  *
284
- * Uses av_opt_get_sample_fmt() internally.
285
- * Option must be of sample format type.
317
+ * Direct mapping to av_opt_get_sample_fmt().
286
318
  *
287
- * @param obj - Native object
319
+ * @param obj - Object to query
288
320
  * @param name - Option name
289
- * @param searchFlags - Search flags (default: 0)
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 as image size.
328
+ * Get image size option value.
298
329
  *
299
- * Uses av_opt_get_image_size() internally.
300
- * Option must be of image size type.
330
+ * Direct mapping to av_opt_get_image_size().
301
331
  *
302
- * @param obj - Native object
332
+ * @param obj - Object to query
303
333
  * @param name - Option name
304
- * @param searchFlags - Search flags (default: 0)
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 as channel layout.
341
+ * Get channel layout option value.
313
342
  *
314
- * Uses av_opt_get_chlayout() internally.
315
- * Option must be of channel layout type.
343
+ * Direct mapping to av_opt_get_chlayout().
316
344
  *
317
- * @param obj - Native object
345
+ * @param obj - Object to query
318
346
  * @param name - Option name
319
- * @param searchFlags - Search flags (default: 0)
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 as dictionary.
354
+ * Get dictionary option value.
328
355
  *
329
- * Uses av_opt_get_dict_val() internally.
330
- * Option must be of dictionary type.
356
+ * Direct mapping to av_opt_get_dict_val().
331
357
  *
332
- * @param obj - Native object
358
+ * @param obj - Object to query
333
359
  * @param name - Option name
334
- * @param searchFlags - Search flags (default: 0)
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 from string.
368
+ * Set string option value.
344
369
  *
345
- * Uses av_opt_set() internally.
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 - Native object
372
+ * @param obj - Object to modify
349
373
  * @param name - Option name
350
- * @param value - String value to set
351
- * @param searchFlags - Search flags (default: 0)
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 as integer.
382
+ * Set integer option value.
360
383
  *
361
- * Uses av_opt_set_int() internally.
362
- * More efficient than set() for numeric options.
384
+ * Direct mapping to av_opt_set_int().
363
385
  *
364
- * @param obj - Native object
386
+ * @param obj - Object to modify
365
387
  * @param name - Option name
366
- * @param value - Number or BigInt value to set
367
- * @param searchFlags - Search flags (default: 0)
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 as double.
396
+ * Set double option value.
376
397
  *
377
- * Uses av_opt_set_double() internally.
378
- * More efficient than set() for floating point options.
398
+ * Direct mapping to av_opt_set_double().
379
399
  *
380
- * @param obj - Native object
400
+ * @param obj - Object to modify
381
401
  * @param name - Option name
382
- * @param value - Double value to set
383
- * @param searchFlags - Search flags (default: 0)
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 as rational.
410
+ * Set rational option value.
392
411
  *
393
- * Uses av_opt_set_q() internally.
394
- * For framerates, aspect ratios, time bases, etc.
412
+ * Direct mapping to av_opt_set_q().
395
413
  *
396
- * @param obj - Native object
414
+ * @param obj - Object to modify
397
415
  * @param name - Option name
398
- * @param value - Rational object {num, den} to set
399
- * @param searchFlags - Search flags (default: 0)
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 as pixel format.
424
+ * Set pixel format option value.
408
425
  *
409
- * Uses av_opt_set_pixel_fmt() internally.
410
- * More type-safe than using set() with string names.
426
+ * Direct mapping to av_opt_set_pixel_fmt().
411
427
  *
412
- * @param obj - Native object
428
+ * @param obj - Object to modify
413
429
  * @param name - Option name
414
- * @param value - AVPixelFormat enum value
415
- * @param searchFlags - Search flags (default: 0)
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 as sample format.
438
+ * Set sample format option value.
424
439
  *
425
- * Uses av_opt_set_sample_fmt() internally.
426
- * More type-safe than using set() with string names.
440
+ * Direct mapping to av_opt_set_sample_fmt().
427
441
  *
428
- * @param obj - Native object
442
+ * @param obj - Object to modify
429
443
  * @param name - Option name
430
- * @param value - AVSampleFormat enum value
431
- * @param searchFlags - Search flags (default: 0)
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 as image size.
452
+ * Set image size option value.
440
453
  *
441
- * Uses av_opt_set_image_size() internally.
442
- * Convenient for setting width and height together.
454
+ * Direct mapping to av_opt_set_image_size().
443
455
  *
444
- * @param obj - Native object
456
+ * @param obj - Object to modify
445
457
  * @param name - Option name
446
- * @param width - Width in pixels
447
- * @param height - Height in pixels
448
- * @param searchFlags - Search flags (default: 0)
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 as channel layout.
467
+ * Set channel layout option value.
457
468
  *
458
- * Uses av_opt_set_chlayout() internally.
459
- * For audio channel configuration.
469
+ * Direct mapping to av_opt_set_chlayout().
460
470
  *
461
- * @param obj - Native object
471
+ * @param obj - Object to modify
462
472
  * @param name - Option name
463
- * @param value - Channel layout mask (e.g., AV_CH_LAYOUT_STEREO)
464
- * @param searchFlags - Search flags (default: 0)
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 as dictionary.
481
+ * Set dictionary option value.
473
482
  *
474
- * Uses av_opt_set_dict_val() internally.
475
- * For options that accept key-value pairs.
483
+ * Direct mapping to av_opt_set_dict_val().
476
484
  *
477
- * @param obj - Native object
485
+ * @param obj - Object to modify
478
486
  * @param name - Option name
479
- * @param value - Dictionary object
480
- * @param searchFlags - Search flags (default: 0)
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 as binary data.
495
+ * Set binary option value.
489
496
  *
490
- * Uses av_opt_set_bin() internally.
491
- * For options that accept raw binary data.
497
+ * Direct mapping to av_opt_set_bin().
492
498
  *
493
- * @param obj - Native object
499
+ * @param obj - Object to modify
494
500
  * @param name - Option name
495
- * @param value - Binary data as Buffer
496
- * @param searchFlags - Search flags (default: 0)
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 all options to their default values.
509
+ * Set defaults on object.
505
510
  *
506
- * Uses av_opt_set_defaults() internally.
511
+ * Sets all options to their default values.
507
512
  *
508
- * @param obj - Native object
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 from source to destination.
521
+ * Copy options between objects.
522
+ *
523
+ * Copies option values from source to destination.
515
524
  *
516
- * Uses av_opt_copy() internally.
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 its default value.
535
+ * Check if option is set to default.
529
536
  *
530
- * Uses av_opt_is_set_to_default_by_name() internally.
537
+ * Direct mapping to av_opt_is_set_to_default().
531
538
  *
532
- * @param obj - Native object
539
+ * @param obj - Object to check
533
540
  * @param name - Option name
534
- * @param searchFlags - Search flags (default: 0)
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
- * Uses av_opt_serialize() internally.
545
- * Converts all non-default options to a string representation.
550
+ * Direct mapping to av_opt_serialize().
546
551
  *
547
- * @param obj - Native object
548
- * @param optFlags - Option flags to include (default: 0)
549
- * @param flags - Serialization flags (default: 0)
550
- * @param keyValSep - Key-value separator (default: '=')
551
- * @param pairsSep - Pairs separator (default: ',')
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 options of an object.
563
+ * Free option resources.
560
564
  *
561
- * Uses av_opt_free() internally.
565
+ * Direct mapping to av_opt_free().
562
566
  *
563
- * @param obj - Native object
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 to stderr for debugging.
570
- *
571
- * Uses av_opt_show2() internally.
572
- * Prints all available options to stderr.
573
+ * Show options for debugging.
573
574
  *
574
- * @param obj - Native object
575
- * @param reqFlags - Required flags (default: 0)
576
- * @param rejFlags - Rejected flags (default: 0)
575
+ * Direct mapping to av_opt_show2().
577
576
  *
578
- * @returns 0 on success, negative AVERROR code on failure
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
- * // Inherits setOption, getOption, listOptions
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 code on failure
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 number
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 = [];