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.
Files changed (166) hide show
  1. package/README.md +51 -59
  2. package/dist/api/bitstream-filter.d.ts +183 -123
  3. package/dist/api/bitstream-filter.js +185 -127
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +282 -130
  6. package/dist/api/decoder.js +290 -142
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +249 -160
  9. package/dist/api/encoder.js +276 -207
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +1944 -96
  12. package/dist/api/filter-presets.js +2059 -105
  13. package/dist/api/filter-presets.js.map +1 -1
  14. package/dist/api/filter.d.ts +264 -200
  15. package/dist/api/filter.js +269 -231
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +246 -117
  18. package/dist/api/hardware.js +440 -217
  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 -55
  24. package/dist/api/io-stream.js +43 -40
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +242 -139
  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 +208 -126
  30. package/dist/api/media-output.js +212 -126
  31. package/dist/api/media-output.js.map +1 -1
  32. package/dist/api/pipeline.d.ts +361 -38
  33. package/dist/api/pipeline.js +255 -14
  34. package/dist/api/pipeline.js.map +1 -1
  35. package/dist/api/types.d.ts +26 -187
  36. package/dist/api/utilities/audio-sample.d.ts +0 -8
  37. package/dist/api/utilities/audio-sample.js +0 -8
  38. package/dist/api/utilities/audio-sample.js.map +1 -1
  39. package/dist/api/utilities/channel-layout.d.ts +0 -8
  40. package/dist/api/utilities/channel-layout.js +0 -8
  41. package/dist/api/utilities/channel-layout.js.map +1 -1
  42. package/dist/api/utilities/image.d.ts +0 -8
  43. package/dist/api/utilities/image.js +0 -8
  44. package/dist/api/utilities/image.js.map +1 -1
  45. package/dist/api/utilities/index.d.ts +3 -3
  46. package/dist/api/utilities/index.js +3 -3
  47. package/dist/api/utilities/index.js.map +1 -1
  48. package/dist/api/utilities/media-type.d.ts +1 -9
  49. package/dist/api/utilities/media-type.js +1 -9
  50. package/dist/api/utilities/media-type.js.map +1 -1
  51. package/dist/api/utilities/pixel-format.d.ts +1 -9
  52. package/dist/api/utilities/pixel-format.js +1 -9
  53. package/dist/api/utilities/pixel-format.js.map +1 -1
  54. package/dist/api/utilities/sample-format.d.ts +1 -9
  55. package/dist/api/utilities/sample-format.js +1 -9
  56. package/dist/api/utilities/sample-format.js.map +1 -1
  57. package/dist/api/utilities/streaming.d.ts +0 -8
  58. package/dist/api/utilities/streaming.js +0 -8
  59. package/dist/api/utilities/streaming.js.map +1 -1
  60. package/dist/api/utilities/timestamp.d.ts +0 -8
  61. package/dist/api/utilities/timestamp.js +0 -8
  62. package/dist/api/utilities/timestamp.js.map +1 -1
  63. package/dist/api/utils.d.ts +1 -2
  64. package/dist/api/utils.js +11 -0
  65. package/dist/api/utils.js.map +1 -1
  66. package/dist/constants/constants.d.ts +1 -1
  67. package/dist/constants/constants.js +2 -0
  68. package/dist/constants/constants.js.map +1 -1
  69. package/dist/lib/audio-fifo.d.ts +127 -170
  70. package/dist/lib/audio-fifo.js +130 -173
  71. package/dist/lib/audio-fifo.js.map +1 -1
  72. package/dist/lib/binding.d.ts +1 -0
  73. package/dist/lib/binding.js +7 -0
  74. package/dist/lib/binding.js.map +1 -1
  75. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  76. package/dist/lib/bitstream-filter-context.js +139 -188
  77. package/dist/lib/bitstream-filter-context.js.map +1 -1
  78. package/dist/lib/bitstream-filter.d.ts +68 -54
  79. package/dist/lib/bitstream-filter.js +68 -54
  80. package/dist/lib/bitstream-filter.js.map +1 -1
  81. package/dist/lib/codec-context.d.ts +316 -380
  82. package/dist/lib/codec-context.js +316 -381
  83. package/dist/lib/codec-context.js.map +1 -1
  84. package/dist/lib/codec-parameters.d.ts +160 -170
  85. package/dist/lib/codec-parameters.js +162 -172
  86. package/dist/lib/codec-parameters.js.map +1 -1
  87. package/dist/lib/codec-parser.d.ts +91 -104
  88. package/dist/lib/codec-parser.js +92 -103
  89. package/dist/lib/codec-parser.js.map +1 -1
  90. package/dist/lib/codec.d.ts +266 -283
  91. package/dist/lib/codec.js +270 -287
  92. package/dist/lib/codec.js.map +1 -1
  93. package/dist/lib/dictionary.d.ts +149 -203
  94. package/dist/lib/dictionary.js +158 -212
  95. package/dist/lib/dictionary.js.map +1 -1
  96. package/dist/lib/error.d.ts +96 -130
  97. package/dist/lib/error.js +98 -128
  98. package/dist/lib/error.js.map +1 -1
  99. package/dist/lib/filter-context.d.ts +284 -218
  100. package/dist/lib/filter-context.js +290 -227
  101. package/dist/lib/filter-context.js.map +1 -1
  102. package/dist/lib/filter-graph.d.ts +251 -292
  103. package/dist/lib/filter-graph.js +253 -294
  104. package/dist/lib/filter-graph.js.map +1 -1
  105. package/dist/lib/filter-inout.d.ts +87 -95
  106. package/dist/lib/filter-inout.js +87 -95
  107. package/dist/lib/filter-inout.js.map +1 -1
  108. package/dist/lib/filter.d.ts +93 -111
  109. package/dist/lib/filter.js +93 -111
  110. package/dist/lib/filter.js.map +1 -1
  111. package/dist/lib/format-context.d.ts +320 -428
  112. package/dist/lib/format-context.js +313 -385
  113. package/dist/lib/format-context.js.map +1 -1
  114. package/dist/lib/frame.d.ts +262 -405
  115. package/dist/lib/frame.js +263 -408
  116. package/dist/lib/frame.js.map +1 -1
  117. package/dist/lib/hardware-device-context.d.ts +149 -203
  118. package/dist/lib/hardware-device-context.js +149 -203
  119. package/dist/lib/hardware-device-context.js.map +1 -1
  120. package/dist/lib/hardware-frames-context.d.ts +170 -180
  121. package/dist/lib/hardware-frames-context.js +171 -181
  122. package/dist/lib/hardware-frames-context.js.map +1 -1
  123. package/dist/lib/index.d.ts +3 -2
  124. package/dist/lib/index.js +3 -3
  125. package/dist/lib/index.js.map +1 -1
  126. package/dist/lib/input-format.d.ts +89 -117
  127. package/dist/lib/input-format.js +89 -117
  128. package/dist/lib/input-format.js.map +1 -1
  129. package/dist/lib/io-context.d.ts +209 -241
  130. package/dist/lib/io-context.js +220 -252
  131. package/dist/lib/io-context.js.map +1 -1
  132. package/dist/lib/log.d.ts +85 -119
  133. package/dist/lib/log.js +85 -122
  134. package/dist/lib/log.js.map +1 -1
  135. package/dist/lib/native-types.d.ts +118 -106
  136. package/dist/lib/native-types.js +0 -7
  137. package/dist/lib/native-types.js.map +1 -1
  138. package/dist/lib/option.d.ts +437 -218
  139. package/dist/lib/option.js +462 -226
  140. package/dist/lib/option.js.map +1 -1
  141. package/dist/lib/output-format.d.ts +77 -101
  142. package/dist/lib/output-format.js +77 -101
  143. package/dist/lib/output-format.js.map +1 -1
  144. package/dist/lib/packet.d.ts +172 -240
  145. package/dist/lib/packet.js +172 -241
  146. package/dist/lib/packet.js.map +1 -1
  147. package/dist/lib/rational.d.ts +0 -2
  148. package/dist/lib/rational.js +0 -2
  149. package/dist/lib/rational.js.map +1 -1
  150. package/dist/lib/software-resample-context.d.ts +241 -325
  151. package/dist/lib/software-resample-context.js +242 -326
  152. package/dist/lib/software-resample-context.js.map +1 -1
  153. package/dist/lib/software-scale-context.d.ts +129 -173
  154. package/dist/lib/software-scale-context.js +131 -175
  155. package/dist/lib/software-scale-context.js.map +1 -1
  156. package/dist/lib/stream.d.ts +87 -197
  157. package/dist/lib/stream.js +87 -197
  158. package/dist/lib/stream.js.map +1 -1
  159. package/dist/lib/utilities.d.ts +435 -181
  160. package/dist/lib/utilities.js +438 -182
  161. package/dist/lib/utilities.js.map +1 -1
  162. package/install/check.js +0 -1
  163. package/install/ffmpeg.js +0 -11
  164. package/package.json +25 -18
  165. package/release_notes.md +24 -59
  166. 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';
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
- * // Get current bitrate
126
- * const bitrate = Option.getInt(codecContext, 'b');
154
+ * ret = Option.setRational(obj, 'framerate', { num: 30, den: 1 });
155
+ * FFmpegError.throwIfError(ret, 'set framerate');
127
156
  *
128
- * // Iterate through all options
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.
222
+ *
223
+ * Like find() but also indicates if option was found on different target.
188
224
  *
189
- * Uses av_opt_find2() internally.
225
+ * Direct mapping to av_opt_find2().
190
226
  *
191
- * @param obj - Native object
192
- * @param name - Option name to find
193
- * @param searchFlags - Search flags (default: 0)
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
- * @returns Object with option and whether target differs, or null
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 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)
256
+ * @param searchFlags - Search flags
257
+ * @returns Option value as string, or null
215
258
  *
216
- * @returns Value string on success, null if option not found or on error
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 as integer.
270
+ * Get integer option value.
223
271
  *
224
- * Uses av_opt_get_int() internally.
225
- * Option must be of integer type.
272
+ * Direct mapping to av_opt_get_int().
226
273
  *
227
- * @param obj - Native object
274
+ * @param obj - Object to query
228
275
  * @param name - Option name
229
- * @param searchFlags - Search flags (default: 0)
276
+ * @param searchFlags - Search flags
277
+ * @returns Option value as integer, or null
230
278
  *
231
- * @returns Integer value on success, null if option not found or on error
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 as double.
290
+ * Get double option value.
238
291
  *
239
- * Uses av_opt_get_double() internally.
240
- * Option must be of double/float type.
292
+ * Direct mapping to av_opt_get_double().
241
293
  *
242
- * @param obj - Native object
294
+ * @param obj - Object to query
243
295
  * @param name - Option name
244
- * @param searchFlags - Search flags (default: 0)
296
+ * @param searchFlags - Search flags
297
+ * @returns Option value as double, or null
245
298
  *
246
- * @returns Double value on success, null if option not found or on error
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 as rational.
310
+ * Get rational option value.
253
311
  *
254
- * Uses av_opt_get_q() internally.
255
- * Option must be of rational type.
312
+ * Direct mapping to av_opt_get_q().
256
313
  *
257
- * @param obj - Native object
314
+ * @param obj - Object to query
258
315
  * @param name - Option name
259
- * @param searchFlags - Search flags (default: 0)
316
+ * @param searchFlags - Search flags
317
+ * @returns Option value as rational, or null
260
318
  *
261
- * @returns Rational object {num, den} on success, null if option not found or on error
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 as pixel format.
330
+ * Get pixel format option value.
268
331
  *
269
- * Uses av_opt_get_pixel_fmt() internally.
270
- * Option must be of pixel format type.
332
+ * Direct mapping to av_opt_get_pixel_fmt().
271
333
  *
272
- * @param obj - Native object
334
+ * @param obj - Object to query
273
335
  * @param name - Option name
274
- * @param searchFlags - Search flags (default: 0)
336
+ * @param searchFlags - Search flags
337
+ * @returns Pixel format value, or null
275
338
  *
276
- * @returns AVPixelFormat enum value on success, null if option not found or on error
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 as sample format.
350
+ * Get sample format option value.
283
351
  *
284
- * Uses av_opt_get_sample_fmt() internally.
285
- * Option must be of sample format type.
352
+ * Direct mapping to av_opt_get_sample_fmt().
286
353
  *
287
- * @param obj - Native object
354
+ * @param obj - Object to query
288
355
  * @param name - Option name
289
- * @param searchFlags - Search flags (default: 0)
356
+ * @param searchFlags - Search flags
357
+ * @returns Sample format value, or null
290
358
  *
291
- * @returns AVSampleFormat enum value on success, null if option not found or on error
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 as image size.
370
+ * Get image size option value.
298
371
  *
299
- * Uses av_opt_get_image_size() internally.
300
- * Option must be of image size type.
372
+ * Direct mapping to av_opt_get_image_size().
301
373
  *
302
- * @param obj - Native object
374
+ * @param obj - Object to query
303
375
  * @param name - Option name
304
- * @param searchFlags - Search flags (default: 0)
376
+ * @param searchFlags - Search flags
377
+ * @returns Width and height, or null
305
378
  *
306
- * @returns Size object {width, height} on success, null if option not found or on error
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 as channel layout.
390
+ * Get channel layout option value.
313
391
  *
314
- * Uses av_opt_get_chlayout() internally.
315
- * Option must be of channel layout type.
392
+ * Direct mapping to av_opt_get_chlayout().
316
393
  *
317
- * @param obj - Native object
394
+ * @param obj - Object to query
318
395
  * @param name - Option name
319
- * @param searchFlags - Search flags (default: 0)
396
+ * @param searchFlags - Search flags
397
+ * @returns Channel layout, or null
320
398
  *
321
- * @returns ChannelLayout object on success, null if option not found or on error
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 as dictionary.
410
+ * Get dictionary option value.
328
411
  *
329
- * Uses av_opt_get_dict_val() internally.
330
- * Option must be of dictionary type.
412
+ * Direct mapping to av_opt_get_dict_val().
331
413
  *
332
- * @param obj - Native object
414
+ * @param obj - Object to query
333
415
  * @param name - Option name
334
- * @param searchFlags - Search flags (default: 0)
416
+ * @param searchFlags - Search flags
417
+ * @returns Dictionary value, or null
335
418
  *
336
- * @returns Dictionary object on success, null if option not found or on error
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 from string.
431
+ * Set string option value.
344
432
  *
345
- * Uses av_opt_set() internally.
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 - Native object
435
+ * @param obj - Object to modify
349
436
  * @param name - Option name
350
- * @param value - String value to set
351
- * @param searchFlags - Search flags (default: 0)
437
+ * @param value - String value
438
+ * @param searchFlags - Search flags
439
+ * @returns 0 on success, negative AVERROR on error
352
440
  *
353
- * @returns 0 on success, negative AVERROR code on failure
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 as integer.
452
+ * Set integer option value.
360
453
  *
361
- * Uses av_opt_set_int() internally.
362
- * More efficient than set() for numeric options.
454
+ * Direct mapping to av_opt_set_int().
363
455
  *
364
- * @param obj - Native object
456
+ * @param obj - Object to modify
365
457
  * @param name - Option name
366
- * @param value - Number or BigInt value to set
367
- * @param searchFlags - Search flags (default: 0)
458
+ * @param value - Integer value
459
+ * @param searchFlags - Search flags
460
+ * @returns 0 on success, negative AVERROR on error
368
461
  *
369
- * @returns 0 on success, negative AVERROR code on failure
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 as double.
473
+ * Set double option value.
376
474
  *
377
- * Uses av_opt_set_double() internally.
378
- * More efficient than set() for floating point options.
475
+ * Direct mapping to av_opt_set_double().
379
476
  *
380
- * @param obj - Native object
477
+ * @param obj - Object to modify
381
478
  * @param name - Option name
382
- * @param value - Double value to set
383
- * @param searchFlags - Search flags (default: 0)
479
+ * @param value - Double value
480
+ * @param searchFlags - Search flags
481
+ * @returns 0 on success, negative AVERROR on error
384
482
  *
385
- * @returns 0 on success, negative AVERROR code on failure
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 as rational.
494
+ * Set rational option value.
392
495
  *
393
- * Uses av_opt_set_q() internally.
394
- * For framerates, aspect ratios, time bases, etc.
496
+ * Direct mapping to av_opt_set_q().
395
497
  *
396
- * @param obj - Native object
498
+ * @param obj - Object to modify
397
499
  * @param name - Option name
398
- * @param value - Rational object {num, den} to set
399
- * @param searchFlags - Search flags (default: 0)
500
+ * @param value - Rational value
501
+ * @param searchFlags - Search flags
502
+ * @returns 0 on success, negative AVERROR on error
400
503
  *
401
- * @returns 0 on success, negative AVERROR code on failure
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 as pixel format.
515
+ * Set pixel format option value.
408
516
  *
409
- * Uses av_opt_set_pixel_fmt() internally.
410
- * More type-safe than using set() with string names.
517
+ * Direct mapping to av_opt_set_pixel_fmt().
411
518
  *
412
- * @param obj - Native object
519
+ * @param obj - Object to modify
413
520
  * @param name - Option name
414
- * @param value - AVPixelFormat enum value
415
- * @param searchFlags - Search flags (default: 0)
521
+ * @param value - Pixel format
522
+ * @param searchFlags - Search flags
523
+ * @returns 0 on success, negative AVERROR on error
416
524
  *
417
- * @returns 0 on success, negative AVERROR code on failure
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 as sample format.
536
+ * Set sample format option value.
424
537
  *
425
- * Uses av_opt_set_sample_fmt() internally.
426
- * More type-safe than using set() with string names.
538
+ * Direct mapping to av_opt_set_sample_fmt().
427
539
  *
428
- * @param obj - Native object
540
+ * @param obj - Object to modify
429
541
  * @param name - Option name
430
- * @param value - AVSampleFormat enum value
431
- * @param searchFlags - Search flags (default: 0)
542
+ * @param value - Sample format
543
+ * @param searchFlags - Search flags
544
+ * @returns 0 on success, negative AVERROR on error
432
545
  *
433
- * @returns 0 on success, negative AVERROR code on failure
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 as image size.
557
+ * Set image size option value.
440
558
  *
441
- * Uses av_opt_set_image_size() internally.
442
- * Convenient for setting width and height together.
559
+ * Direct mapping to av_opt_set_image_size().
443
560
  *
444
- * @param obj - Native object
561
+ * @param obj - Object to modify
445
562
  * @param name - Option name
446
- * @param width - Width in pixels
447
- * @param height - Height in pixels
448
- * @param searchFlags - Search flags (default: 0)
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
- * @returns 0 on success, negative AVERROR code on failure
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 as channel layout.
579
+ * Set channel layout option value.
457
580
  *
458
- * Uses av_opt_set_chlayout() internally.
459
- * For audio channel configuration.
581
+ * Direct mapping to av_opt_set_chlayout().
460
582
  *
461
- * @param obj - Native object
583
+ * @param obj - Object to modify
462
584
  * @param name - Option name
463
- * @param value - Channel layout mask (e.g., AV_CH_LAYOUT_STEREO)
464
- * @param searchFlags - Search flags (default: 0)
585
+ * @param value - Channel layout
586
+ * @param searchFlags - Search flags
587
+ * @returns 0 on success, negative AVERROR on error
465
588
  *
466
- * @returns 0 on success, negative AVERROR code on failure
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 as dictionary.
600
+ * Set dictionary option value.
473
601
  *
474
- * Uses av_opt_set_dict_val() internally.
475
- * For options that accept key-value pairs.
602
+ * Direct mapping to av_opt_set_dict_val().
476
603
  *
477
- * @param obj - Native object
604
+ * @param obj - Object to modify
478
605
  * @param name - Option name
479
- * @param value - Dictionary object
480
- * @param searchFlags - Search flags (default: 0)
606
+ * @param value - Dictionary value
607
+ * @param searchFlags - Search flags
608
+ * @returns 0 on success, negative AVERROR on error
481
609
  *
482
- * @returns 0 on success, negative AVERROR code on failure
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 as binary data.
623
+ * Set binary option value.
489
624
  *
490
- * Uses av_opt_set_bin() internally.
491
- * For options that accept raw binary data.
625
+ * Direct mapping to av_opt_set_bin().
492
626
  *
493
- * @param obj - Native object
627
+ * @param obj - Object to modify
494
628
  * @param name - Option name
495
- * @param value - Binary data as Buffer
496
- * @param searchFlags - Search flags (default: 0)
629
+ * @param value - Binary data
630
+ * @param searchFlags - Search flags
631
+ * @returns 0 on success, negative AVERROR on error
497
632
  *
498
- * @returns 0 on success, negative AVERROR code on failure
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 all options to their default values.
645
+ * Set defaults on object.
646
+ *
647
+ * Sets all options to their default values.
505
648
  *
506
- * Uses av_opt_set_defaults() internally.
649
+ * Direct mapping to av_opt_set_defaults().
507
650
  *
508
- * @param obj - Native object
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 from source to destination.
663
+ * Copy options between objects.
515
664
  *
516
- * Uses av_opt_copy() internally.
517
- * Copies all option values from one object to another.
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
- * @returns 0 on success, negative AVERROR code on failure
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 its default value.
684
+ * Check if option is set to default.
529
685
  *
530
- * Uses av_opt_is_set_to_default_by_name() internally.
686
+ * Direct mapping to av_opt_is_set_to_default().
531
687
  *
532
- * @param obj - Native object
688
+ * @param obj - Object to check
533
689
  * @param name - Option name
534
- * @param searchFlags - Search flags (default: 0)
690
+ * @param searchFlags - Search flags
691
+ * @returns True if default, false if modified, null if not found
535
692
  *
536
- * @returns true if set to default, false if not, null if option not found or on error
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
- * Uses av_opt_serialize() internally.
545
- * Converts all non-default options to a string representation.
706
+ * Direct mapping to av_opt_serialize().
546
707
  *
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: ',')
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
- * @returns Serialized string on success, null on error or if no options to serialize
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 options of an object.
726
+ * Free option resources.
560
727
  *
561
- * Uses av_opt_free() internally.
728
+ * Direct mapping to av_opt_free().
562
729
  *
563
- * @param obj - Native object
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 to stderr for debugging.
742
+ * Show options for debugging.
570
743
  *
571
- * Uses av_opt_show2() internally.
572
- * Prints all available options to stderr.
744
+ * Direct mapping to av_opt_show2().
573
745
  *
574
- * @param obj - Native object
575
- * @param reqFlags - Required flags (default: 0)
576
- * @param rejFlags - Rejected flags (default: 0)
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
- * @returns 0 on success, negative AVERROR code on failure
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
- * // Inherits setOption, getOption, listOptions
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 code on failure
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 number
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 = [];