node-av 1.0.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/README.md +56 -41
  2. package/dist/api/bitstream-filter.d.ts +180 -123
  3. package/dist/api/bitstream-filter.js +182 -126
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +286 -130
  6. package/dist/api/decoder.js +321 -159
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +254 -158
  9. package/dist/api/encoder.js +326 -298
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +912 -0
  12. package/dist/api/filter-presets.js +1407 -0
  13. package/dist/api/filter-presets.js.map +1 -0
  14. package/dist/api/filter.d.ts +280 -284
  15. package/dist/api/filter.js +435 -509
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +226 -159
  18. package/dist/api/hardware.js +405 -287
  19. package/dist/api/hardware.js.map +1 -1
  20. package/dist/api/index.d.ts +3 -2
  21. package/dist/api/index.js +1 -0
  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 +45 -47
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +244 -141
  27. package/dist/api/media-input.js +207 -104
  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 +212 -129
  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 +22 -182
  36. package/dist/api/utilities/audio-sample.d.ts +1 -1
  37. package/dist/api/utilities/image.d.ts +1 -1
  38. package/dist/api/utilities/media-type.d.ts +1 -1
  39. package/dist/api/utilities/pixel-format.d.ts +1 -1
  40. package/dist/api/utilities/sample-format.d.ts +1 -1
  41. package/dist/api/utilities/timestamp.d.ts +1 -1
  42. package/dist/api/utils.d.ts +1 -2
  43. package/dist/api/utils.js +9 -0
  44. package/dist/api/utils.js.map +1 -1
  45. package/dist/{lib → constants}/channel-layouts.d.ts +1 -1
  46. package/dist/constants/channel-layouts.js.map +1 -0
  47. package/dist/{lib → constants}/constants.d.ts +19 -4
  48. package/dist/{lib → constants}/constants.js +15 -1
  49. package/dist/constants/constants.js.map +1 -0
  50. package/dist/constants/decoders.d.ts +609 -0
  51. package/dist/constants/decoders.js +617 -0
  52. package/dist/constants/decoders.js.map +1 -0
  53. package/dist/constants/encoders.d.ts +285 -0
  54. package/dist/constants/encoders.js +298 -0
  55. package/dist/constants/encoders.js.map +1 -0
  56. package/dist/constants/index.d.ts +4 -0
  57. package/dist/constants/index.js +5 -0
  58. package/dist/constants/index.js.map +1 -0
  59. package/dist/index.d.ts +1 -0
  60. package/dist/index.js +2 -0
  61. package/dist/index.js.map +1 -1
  62. package/dist/lib/audio-fifo.d.ts +128 -171
  63. package/dist/lib/audio-fifo.js +130 -173
  64. package/dist/lib/audio-fifo.js.map +1 -1
  65. package/dist/lib/binding.d.ts +7 -5
  66. package/dist/lib/binding.js +5 -0
  67. package/dist/lib/binding.js.map +1 -1
  68. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  69. package/dist/lib/bitstream-filter-context.js +139 -188
  70. package/dist/lib/bitstream-filter-context.js.map +1 -1
  71. package/dist/lib/bitstream-filter.d.ts +69 -55
  72. package/dist/lib/bitstream-filter.js +68 -54
  73. package/dist/lib/bitstream-filter.js.map +1 -1
  74. package/dist/lib/codec-context.d.ts +317 -381
  75. package/dist/lib/codec-context.js +316 -381
  76. package/dist/lib/codec-context.js.map +1 -1
  77. package/dist/lib/codec-parameters.d.ts +161 -171
  78. package/dist/lib/codec-parameters.js +162 -172
  79. package/dist/lib/codec-parameters.js.map +1 -1
  80. package/dist/lib/codec-parser.d.ts +92 -105
  81. package/dist/lib/codec-parser.js +92 -103
  82. package/dist/lib/codec-parser.js.map +1 -1
  83. package/dist/lib/codec.d.ts +328 -217
  84. package/dist/lib/codec.js +392 -218
  85. package/dist/lib/codec.js.map +1 -1
  86. package/dist/lib/dictionary.d.ts +150 -204
  87. package/dist/lib/dictionary.js +159 -213
  88. package/dist/lib/dictionary.js.map +1 -1
  89. package/dist/lib/error.d.ts +97 -131
  90. package/dist/lib/error.js +98 -128
  91. package/dist/lib/error.js.map +1 -1
  92. package/dist/lib/filter-context.d.ts +317 -194
  93. package/dist/lib/filter-context.js +335 -200
  94. package/dist/lib/filter-context.js.map +1 -1
  95. package/dist/lib/filter-graph.d.ts +252 -293
  96. package/dist/lib/filter-graph.js +253 -294
  97. package/dist/lib/filter-graph.js.map +1 -1
  98. package/dist/lib/filter-inout.d.ts +87 -95
  99. package/dist/lib/filter-inout.js +87 -95
  100. package/dist/lib/filter-inout.js.map +1 -1
  101. package/dist/lib/filter.d.ts +93 -111
  102. package/dist/lib/filter.js +94 -112
  103. package/dist/lib/filter.js.map +1 -1
  104. package/dist/lib/format-context.d.ts +321 -429
  105. package/dist/lib/format-context.js +314 -386
  106. package/dist/lib/format-context.js.map +1 -1
  107. package/dist/lib/frame.d.ts +263 -406
  108. package/dist/lib/frame.js +263 -408
  109. package/dist/lib/frame.js.map +1 -1
  110. package/dist/lib/hardware-device-context.d.ts +150 -204
  111. package/dist/lib/hardware-device-context.js +149 -203
  112. package/dist/lib/hardware-device-context.js.map +1 -1
  113. package/dist/lib/hardware-frames-context.d.ts +171 -181
  114. package/dist/lib/hardware-frames-context.js +171 -181
  115. package/dist/lib/hardware-frames-context.js.map +1 -1
  116. package/dist/lib/index.d.ts +2 -3
  117. package/dist/lib/index.js +2 -5
  118. package/dist/lib/index.js.map +1 -1
  119. package/dist/lib/input-format.d.ts +90 -118
  120. package/dist/lib/input-format.js +89 -117
  121. package/dist/lib/input-format.js.map +1 -1
  122. package/dist/lib/io-context.d.ts +210 -242
  123. package/dist/lib/io-context.js +221 -253
  124. package/dist/lib/io-context.js.map +1 -1
  125. package/dist/lib/log.d.ts +86 -120
  126. package/dist/lib/log.js +85 -122
  127. package/dist/lib/log.js.map +1 -1
  128. package/dist/lib/native-types.d.ts +127 -112
  129. package/dist/lib/native-types.js +9 -0
  130. package/dist/lib/native-types.js.map +1 -1
  131. package/dist/lib/option.d.ts +285 -242
  132. package/dist/lib/option.js +310 -250
  133. package/dist/lib/option.js.map +1 -1
  134. package/dist/lib/output-format.d.ts +78 -102
  135. package/dist/lib/output-format.js +77 -101
  136. package/dist/lib/output-format.js.map +1 -1
  137. package/dist/lib/packet.d.ts +173 -241
  138. package/dist/lib/packet.js +172 -241
  139. package/dist/lib/packet.js.map +1 -1
  140. package/dist/lib/rational.d.ts +0 -2
  141. package/dist/lib/rational.js +0 -2
  142. package/dist/lib/rational.js.map +1 -1
  143. package/dist/lib/software-resample-context.d.ts +242 -326
  144. package/dist/lib/software-resample-context.js +242 -326
  145. package/dist/lib/software-resample-context.js.map +1 -1
  146. package/dist/lib/software-scale-context.d.ts +130 -174
  147. package/dist/lib/software-scale-context.js +132 -176
  148. package/dist/lib/software-scale-context.js.map +1 -1
  149. package/dist/lib/stream.d.ts +88 -198
  150. package/dist/lib/stream.js +87 -197
  151. package/dist/lib/stream.js.map +1 -1
  152. package/dist/lib/types.d.ts +1 -1
  153. package/dist/lib/utilities.d.ts +372 -181
  154. package/dist/lib/utilities.js +373 -182
  155. package/dist/lib/utilities.js.map +1 -1
  156. package/install/check.js +0 -1
  157. package/package.json +32 -24
  158. package/release_notes.md +43 -13
  159. package/CHANGELOG.md +0 -8
  160. package/dist/lib/channel-layouts.js.map +0 -1
  161. package/dist/lib/constants.js.map +0 -1
  162. /package/dist/{lib → constants}/channel-layouts.js +0 -0
@@ -1,127 +1,75 @@
1
+ import { AVFLAG_NONE } from '../constants/constants.js';
1
2
  import { bindings } from './binding.js';
2
- import { AVFLAG_NONE } from './constants.js';
3
3
  /**
4
- * Dictionary for options and metadata.
4
+ * Key-value dictionary for FFmpeg options and metadata.
5
5
  *
6
- * Key-value storage for codec options, format options, and metadata.
7
- * Used throughout FFmpeg for configuration and information storage.
8
- * Supports parsing from strings and conversion back to strings.
6
+ * Stores string key-value pairs used throughout FFmpeg for options, metadata,
7
+ * and configuration. Provides methods for setting, getting, and manipulating
8
+ * dictionary entries. Used extensively for codec options, format options,
9
+ * and metadata handling.
9
10
  *
10
11
  * Direct mapping to FFmpeg's AVDictionary.
11
12
  *
12
13
  * @example
13
14
  * ```typescript
14
- * import { Dictionary, CodecContext, FFmpegError } from 'node-av';
15
- *
16
- * // Using Dictionary for codec options
17
- * const options = new Dictionary();
18
- * const ret1 = options.set('preset', 'fast', 0);
19
- * FFmpegError.throwIfError(ret1, 'set preset');
20
- * const ret2 = options.set('crf', '23', 0);
21
- * FFmpegError.throwIfError(ret2, 'set crf');
22
- *
23
- * const codecContext = new CodecContext();
24
- * codecContext.allocContext3(codec);
25
- * const openRet = await codecContext.open2(codec, options);
26
- * FFmpegError.throwIfError(openRet, 'open2');
27
- *
28
- * // Using Dictionary for format options
29
- * const formatOptions = new Dictionary();
30
- * const ret3 = formatOptions.set('movflags', 'faststart', 0);
31
- * FFmpegError.throwIfError(ret3, 'set movflags');
32
- * const headerRet = await formatContext.writeHeader(formatOptions);
33
- * FFmpegError.throwIfError(headerRet, 'writeHeader');
34
- *
35
- * // Reading metadata
36
- * const metadata = stream.metadata;
37
- * if (metadata) {
38
- * const title = metadata.get('title', 0);
39
- * const artist = metadata.get('artist', 0);
40
- * console.log(`Title: ${title}, Artist: ${artist}`);
41
- * }
42
- *
43
- * // Cleanup
44
- * options.free();
45
- * formatOptions.free();
46
- * ```
47
- *
48
- * @example
49
- * ```typescript
50
15
  * import { Dictionary, FFmpegError } from 'node-av';
16
+ * import { AV_DICT_IGNORE_SUFFIX } from 'node-av/constants';
51
17
  *
52
- * // Parsing options from string
53
- * const dict = new Dictionary();
54
- * const ret = dict.parseString('bitrate=128k:preset=fast', '=', ':', 0);
55
- * FFmpegError.throwIfError(ret, 'parseString');
18
+ * // Create from object
19
+ * const dict = Dictionary.fromObject({
20
+ * 'title': 'My Video',
21
+ * 'artist': 'Me',
22
+ * 'year': '2024'
23
+ * });
56
24
  *
57
- * // Getting all options as object
58
- * const allOptions = dict.getAll();
59
- * console.log(allOptions); // { bitrate: '128k', preset: 'fast' }
25
+ * // Set individual values
26
+ * const dict2 = new Dictionary();
27
+ * dict2.alloc();
28
+ * let ret = dict2.set('preset', 'fast');
29
+ * FFmpegError.throwIfError(ret, 'set');
60
30
  *
61
- * // Converting back to string
62
- * const str = dict.getString('=', ':');
63
- * console.log(str); // "bitrate=128k:preset=fast"
31
+ * // Parse from string
32
+ * ret = dict2.parseString('key1=value1:key2=value2', '=', ':');
33
+ * FFmpegError.throwIfError(ret, 'parseString');
64
34
  *
65
- * dict.free();
35
+ * // Get all entries
36
+ * const entries = dict2.getAll();
37
+ * console.log(entries); // { key1: 'value1', key2: 'value2' }
66
38
  * ```
39
+ *
40
+ * @see [AVDictionary](https://ffmpeg.org/doxygen/trunk/group__lavu__dict.html) - FFmpeg Doxygen
41
+ * @see {@link CodecContext} For codec options
42
+ * @see {@link FormatContext} For format options
67
43
  */
68
44
  export class Dictionary {
69
45
  native;
70
- /**
71
- * Create a new dictionary.
72
- *
73
- * The dictionary is uninitialized and will be auto-allocated on first set() call.
74
- * No FFmpeg resources are allocated until first use.
75
- *
76
- * Direct wrapper around AVDictionary.
77
- *
78
- * @example
79
- * ```typescript
80
- * import { Dictionary, FFmpegError } from 'node-av';
81
- *
82
- * const dict = new Dictionary();
83
- * const ret = dict.set('key', 'value', 0); // Auto-allocates on first use
84
- * FFmpegError.throwIfError(ret, 'set');
85
- * ```
86
- */
87
46
  constructor() {
88
47
  this.native = new bindings.Dictionary();
89
48
  }
90
49
  /**
91
- * Create a Dictionary wrapper from an existing native dictionary.
92
- * Used internally when wrapping dictionaries from FFmpeg.
93
- * @internal
94
- */
95
- static fromNative(native) {
96
- const dict = Object.create(Dictionary.prototype);
97
- dict.native = native;
98
- return dict;
99
- }
100
- /**
101
- * Create a Dictionary from a JavaScript object.
50
+ * Create dictionary from JavaScript object.
102
51
  *
103
- * Converts a plain JavaScript object to a Dictionary.
104
- * Useful for converting option objects to FFmpeg format.
52
+ * Convenience method to create a dictionary from a plain object.
105
53
  *
106
54
  * @param obj - Object with string key-value pairs
107
- * @param flags - AV_DICT_* flags for set operations
108
- *
109
- * @returns New Dictionary containing all entries from the object
55
+ * @param flags - Flags for setting entries
56
+ * @returns New dictionary with entries from object
110
57
  *
111
58
  * @example
112
59
  * ```typescript
113
- * import { Dictionary } from 'node-av';
114
- *
115
- * const options = {
116
- * bitrate: '128k',
117
- * preset: 'fast',
118
- * crf: '23'
119
- * };
120
- *
121
- * const dict = Dictionary.fromObject(options);
122
- * // Use with codec or format context
123
- * await codecContext.open2(codec, dict);
124
- * dict.free();
60
+ * const metadata = Dictionary.fromObject({
61
+ * 'title': 'My Song',
62
+ * 'album': 'My Album',
63
+ * 'date': '2024',
64
+ * 'track': '1/10'
65
+ * });
66
+ *
67
+ * // Use for codec options
68
+ * const options = Dictionary.fromObject({
69
+ * 'preset': 'medium',
70
+ * 'crf': '23',
71
+ * 'profile': 'high'
72
+ * });
125
73
  * ```
126
74
  */
127
75
  static fromObject(obj, flags = AVFLAG_NONE) {
@@ -132,123 +80,127 @@ export class Dictionary {
132
80
  return dict;
133
81
  }
134
82
  /**
135
- * Allocate a new dictionary.
83
+ * Create dictionary from native instance.
136
84
  *
137
- * Usually not needed as set() will auto-allocate.
138
- * This is mainly for compatibility - FFmpeg doesn't have explicit av_dict_alloc.
85
+ * @param native - Native dictionary instance
86
+ * @returns Dictionary wrapper
87
+ *
88
+ * @internal
89
+ */
90
+ static fromNative(native) {
91
+ const dict = Object.create(Dictionary.prototype);
92
+ dict.native = native;
93
+ return dict;
94
+ }
95
+ /**
96
+ * Allocate a dictionary.
97
+ *
98
+ * Allocates memory for the dictionary structure.
99
+ * Must be called before using the dictionary.
100
+ *
101
+ * Direct mapping to av_dict_alloc().
102
+ *
103
+ * @throws {Error} If allocation fails (ENOMEM)
139
104
  *
140
105
  * @example
141
106
  * ```typescript
142
107
  * const dict = new Dictionary();
143
- * dict.alloc(); // Explicit allocation (optional)
108
+ * dict.alloc();
109
+ * // Dictionary is now ready for use
144
110
  * ```
111
+ *
112
+ * @see {@link free} To deallocate
145
113
  */
146
114
  alloc() {
147
- return this.native.alloc();
115
+ this.native.alloc();
148
116
  }
149
117
  /**
150
- * Free all the memory allocated for an AVDictionary struct and all keys and values.
118
+ * Free the dictionary.
119
+ *
120
+ * Releases all memory associated with the dictionary.
121
+ * The dictionary becomes invalid after calling this.
151
122
  *
152
- * Direct mapping to av_dict_free()
153
- * After calling this, the dictionary is empty and can be reused.
123
+ * Direct mapping to av_dict_free().
154
124
  *
155
125
  * @example
156
126
  * ```typescript
157
127
  * dict.free();
158
- * // Dictionary is now empty and can be reused
159
- * dict.set('new_key', 'new_value', 0);
128
+ * // Dictionary is now invalid
160
129
  * ```
130
+ *
131
+ * @see {@link alloc} To allocate
132
+ * @see {@link Symbol.dispose} For automatic cleanup
161
133
  */
162
134
  free() {
163
- return this.native.free();
135
+ this.native.free();
164
136
  }
165
137
  /**
166
- * Copy entries from this dictionary to destination.
167
- *
168
- * Copies all entries to the destination dictionary.
169
- * Destination entries can be preserved or overwritten based on flags.
138
+ * Copy entries to another dictionary.
170
139
  *
171
- * Direct mapping to av_dict_copy()
140
+ * Copies all entries from this dictionary to the destination.
172
141
  *
173
- * @param dst - Target dictionary to copy to
174
- * @param flags - AV_DICT_* flags for the copy operation
142
+ * Direct mapping to av_dict_copy().
175
143
  *
144
+ * @param dst - Destination dictionary
145
+ * @param flags - Copy flags
176
146
  * @returns 0 on success, negative AVERROR on error:
177
- * - 0: Success
178
- * - AVERROR(ENOMEM): Memory allocation failure
147
+ * - AVERROR_ENOMEM: Memory allocation failure
179
148
  *
180
149
  * @example
181
150
  * ```typescript
182
- * import { Dictionary, FFmpegError } from 'node-av';
183
- *
184
- * const src = new Dictionary();
185
- * src.set('key1', 'value1');
186
- * src.set('key2', 'value2');
151
+ * import { FFmpegError } from 'node-av';
187
152
  *
188
153
  * const dst = new Dictionary();
154
+ * dst.alloc();
189
155
  * const ret = src.copy(dst);
190
156
  * FFmpegError.throwIfError(ret, 'copy');
191
157
  * ```
192
- *
193
- * @note Common flags:
194
- * - AVFLAG_NONE: Default behavior
195
- * - AV_DICT_DONT_OVERWRITE: Don't overwrite existing entries
196
- * - AV_DICT_MULTIKEY: Allow multiple entries with same key
197
158
  */
198
159
  copy(dst, flags = AVFLAG_NONE) {
199
160
  return this.native.copy(dst.getNative(), flags);
200
161
  }
201
162
  /**
202
- * Set the given entry in the dictionary.
163
+ * Set a dictionary entry.
203
164
  *
204
- * Adds or modifies a key-value pair in the dictionary.
205
- * If key or value are empty, the entry is deleted.
206
- * The dictionary will be auto-allocated on first call if needed.
165
+ * Sets or updates a key-value pair in the dictionary.
207
166
  *
208
- * Direct mapping to av_dict_set()
209
- *
210
- * @param key - Entry key to add/modify
211
- * @param value - Entry value to add/modify
212
- * @param flags - AV_DICT_* flags
167
+ * Direct mapping to av_dict_set().
213
168
  *
169
+ * @param key - Entry key
170
+ * @param value - Entry value
171
+ * @param flags - Set flags (e.g., AV_DICT_DONT_OVERWRITE)
214
172
  * @returns 0 on success, negative AVERROR on error:
215
- * - 0: Success
216
- * - AVERROR(ENOMEM): Memory allocation failure
173
+ * - AVERROR_ENOMEM: Memory allocation failure
217
174
  *
218
175
  * @example
219
176
  * ```typescript
220
- * import { Dictionary, FFmpegError } from 'node-av';
177
+ * import { FFmpegError } from 'node-av';
221
178
  * import { AV_DICT_DONT_OVERWRITE } from 'node-av/constants';
222
179
  *
223
- * const ret1 = dict.set('bitrate', '128k');
224
- * FFmpegError.throwIfError(ret1, 'set bitrate');
225
- *
226
- * const ret2 = dict.set('preset', 'fast', AV_DICT_DONT_OVERWRITE);
227
- * FFmpegError.throwIfError(ret2, 'set preset');
180
+ * // Set or update entry
181
+ * let ret = dict.set('bitrate', '128k');
182
+ * FFmpegError.throwIfError(ret, 'set');
228
183
  *
229
- * // Delete an entry
230
- * dict.set('bitrate', '');
184
+ * // Set only if not exists
185
+ * ret = dict.set('preset', 'fast', AV_DICT_DONT_OVERWRITE);
186
+ * FFmpegError.throwIfError(ret, 'set');
231
187
  * ```
232
188
  *
233
- * @note Common flags:
234
- * - AVFLAG_NONE: Default behavior (replace existing, copy strings)
235
- * - AV_DICT_DONT_OVERWRITE: Don't overwrite existing entries
236
- * - AV_DICT_APPEND: Append to existing value (with comma separator)
237
- * - AV_DICT_MULTIKEY: Allow multiple entries with same key
238
- * - AV_DICT_MATCH_CASE: Case sensitive key matching
189
+ * @see {@link get} To retrieve values
239
190
  */
240
191
  set(key, value, flags = AVFLAG_NONE) {
241
192
  return this.native.set(key, value, flags);
242
193
  }
243
194
  /**
244
- * Get a dictionary entry with matching key.
195
+ * Get a dictionary entry.
245
196
  *
246
- * Direct mapping to av_dict_get()
197
+ * Retrieves the value for a given key.
247
198
  *
248
- * @param key - Key to search for
249
- * @param flags - AV_DICT_* flags for matching
199
+ * Direct mapping to av_dict_get().
250
200
  *
251
- * @returns Entry value or null if not found
201
+ * @param key - Entry key to look up
202
+ * @param flags - Search flags (e.g., AV_DICT_IGNORE_SUFFIX)
203
+ * @returns Entry value, or null if not found
252
204
  *
253
205
  * @example
254
206
  * ```typescript
@@ -257,22 +209,23 @@ export class Dictionary {
257
209
  * console.log(`Bitrate: ${value}`);
258
210
  * }
259
211
  *
260
- * // Case sensitive search
212
+ * // Case-insensitive search
213
+ * import { AV_DICT_MATCH_CASE } from 'node-av/constants';
261
214
  * const title = dict.get('Title', AV_DICT_MATCH_CASE);
262
215
  * ```
263
216
  *
264
- * Common flags:
265
- * - AVFLAG_NONE: Default (case insensitive)
266
- * - AV_DICT_MATCH_CASE: Case sensitive matching
267
- * - AV_DICT_IGNORE_SUFFIX: Match entries starting with key
217
+ * @see {@link set} To set values
218
+ * @see {@link getAll} To get all entries
268
219
  */
269
220
  get(key, flags = AVFLAG_NONE) {
270
221
  return this.native.get(key, flags);
271
222
  }
272
223
  /**
273
- * Get number of entries in dictionary.
224
+ * Count dictionary entries.
274
225
  *
275
- * Direct mapping to av_dict_count()
226
+ * Returns the number of key-value pairs in the dictionary.
227
+ *
228
+ * Direct mapping to av_dict_count().
276
229
  *
277
230
  * @returns Number of entries
278
231
  *
@@ -286,95 +239,92 @@ export class Dictionary {
286
239
  return this.native.count();
287
240
  }
288
241
  /**
289
- * Get all entries as a JavaScript object.
242
+ * Get all dictionary entries.
290
243
  *
291
- * Helper method for easier access from JavaScript.
292
- * Internally iterates through all entries using av_dict_get().
244
+ * Returns all key-value pairs as a JavaScript object.
293
245
  *
294
- * @returns Object with all key-value pairs
246
+ * @returns Object with all entries
295
247
  *
296
248
  * @example
297
249
  * ```typescript
298
- * const allOptions = dict.getAll();
299
- * for (const [key, value] of Object.entries(allOptions)) {
250
+ * const entries = dict.getAll();
251
+ * for (const [key, value] of Object.entries(entries)) {
300
252
  * console.log(`${key}: ${value}`);
301
253
  * }
302
- *
303
- * // Check if dictionary is empty
304
- * if (Object.keys(dict.getAll()).length === 0) {
305
- * console.log('Dictionary is empty');
306
- * }
307
254
  * ```
255
+ *
256
+ * @see {@link get} To get individual entries
308
257
  */
309
258
  getAll() {
310
259
  return this.native.getAll();
311
260
  }
312
261
  /**
313
- * Parse the key/value pairs from a string.
262
+ * Parse entries from a string.
314
263
  *
315
- * Parses a formatted string into key-value pairs.
316
- * Supports both single and multi-character separators.
264
+ * Parses key-value pairs from a formatted string and adds them
265
+ * to the dictionary.
317
266
  *
318
- * Direct mapping to av_dict_parse_string()
319
- *
320
- * @param str - String to parse (e.g., "key1=value1:key2=value2")
321
- * @param keyValSep - String separator between key and value (e.g., '=' or ':=')
322
- * @param pairsSep - String separator between pairs (e.g., ':' or ',' or ';')
323
- * @param flags - AV_DICT_* flags (default: AVFLAG_NONE)
267
+ * Direct mapping to av_dict_parse_string().
324
268
  *
269
+ * @param str - String to parse
270
+ * @param keyValSep - Separator between key and value
271
+ * @param pairsSep - Separator between pairs
272
+ * @param flags - Parse flags
325
273
  * @returns 0 on success, negative AVERROR on error:
326
- * - 0: Success
327
- * - AVERROR(EINVAL): Invalid parameters
328
- * - AVERROR(ENOMEM): Memory allocation failure
274
+ * - AVERROR_EINVAL: Invalid format
275
+ * - AVERROR_ENOMEM: Memory allocation failure
329
276
  *
330
277
  * @example
331
278
  * ```typescript
332
- * import { Dictionary, FFmpegError } from 'node-av';
279
+ * import { FFmpegError } from 'node-av';
333
280
  *
334
- * // Parse codec options with single-char separators
335
- * const ret = dict.parseString('bitrate=128k:preset=fast', '=', ':');
281
+ * // Parse colon-separated pairs
282
+ * let ret = dict.parseString('key1=val1:key2=val2', '=', ':');
336
283
  * FFmpegError.throwIfError(ret, 'parseString');
337
284
  *
338
- * // Parse with multi-char separators
339
- * const ret2 = dict.parseString('title:=My Video;;artist:=Me', ':=', ';;');
340
- * FFmpegError.throwIfError(ret2, 'parseString');
285
+ * // Parse comma-separated pairs
286
+ * ret = dict.parseString('width=1920,height=1080', '=', ',');
287
+ * FFmpegError.throwIfError(ret, 'parseString');
341
288
  * ```
342
289
  *
343
- * @see {@link getString} To convert back to string
290
+ * @see {@link getString} To serialize to string
344
291
  */
345
292
  parseString(str, keyValSep, pairsSep, flags = AVFLAG_NONE) {
346
293
  return this.native.parseString(str, keyValSep, pairsSep, flags);
347
294
  }
348
295
  /**
349
- * Get dictionary as a string.
296
+ * Convert dictionary to string.
350
297
  *
351
- * Direct mapping to av_dict_get_string()
298
+ * Serializes all entries to a formatted string.
352
299
  *
353
- * @param keyValSep - Character to separate key from value
354
- * @param pairsSep - Character to separate pairs
300
+ * Direct mapping to av_dict_get_string().
355
301
  *
356
- * @returns String representation or null on error
302
+ * @param keyValSep - Separator between key and value
303
+ * @param pairsSep - Separator between pairs
304
+ * @returns Formatted string, or null on error
357
305
  *
358
306
  * @example
359
307
  * ```typescript
308
+ * // Serialize to colon-separated format
360
309
  * const str = dict.getString('=', ':');
361
- * console.log(str); // "key1=value1:key2=value2"
310
+ * console.log(str); // "key1=val1:key2=val2"
362
311
  *
363
- * // Export as comma-separated
312
+ * // Serialize to comma-separated format
364
313
  * const csv = dict.getString('=', ',');
365
- * console.log(csv); // "key1=value1,key2=value2"
314
+ * console.log(csv); // "key1=val1,key2=val2"
366
315
  * ```
367
316
  *
368
- * @see parseString() - To parse a string back to dictionary
317
+ * @see {@link parseString} To parse from string
369
318
  */
370
319
  getString(keyValSep, pairsSep) {
371
320
  return this.native.getString(keyValSep, pairsSep);
372
321
  }
373
322
  /**
374
- * Get the native FFmpeg AVDictionary pointer.
323
+ * Get the underlying native Dictionary object.
375
324
  *
376
- * @internal For use by other wrapper classes
377
- * @returns The underlying native dictionary object
325
+ * @returns The native Dictionary binding object
326
+ *
327
+ * @internal
378
328
  */
379
329
  getNative() {
380
330
  return this.native;
@@ -387,17 +337,13 @@ export class Dictionary {
387
337
  *
388
338
  * @example
389
339
  * ```typescript
390
- * import { Dictionary, FFmpegError } from 'node-av';
391
- *
392
340
  * {
393
341
  * using dict = new Dictionary();
394
- * const ret = dict.set('key', 'value', 0);
395
- * FFmpegError.throwIfError(ret, 'set');
396
- * // ... use dictionary
342
+ * dict.alloc();
343
+ * dict.set('key', 'value');
344
+ * // Use dict...
397
345
  * } // Automatically freed when leaving scope
398
346
  * ```
399
- *
400
- * @see {@link free} For manual cleanup
401
347
  */
402
348
  [Symbol.dispose]() {
403
349
  this.native[Symbol.dispose]();
@@ -1 +1 @@
1
- {"version":3,"file":"dictionary.js","sourceRoot":"","sources":["../../src/lib/dictionary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,WAAW,EAAmB,MAAM,gBAAgB,CAAC;AAG9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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