node-av 0.0.1

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 (175) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +22 -0
  3. package/README.md +377 -0
  4. package/binding.gyp +78 -0
  5. package/dist/api/bitstream-filter.d.ts +246 -0
  6. package/dist/api/bitstream-filter.js +369 -0
  7. package/dist/api/bitstream-filter.js.map +1 -0
  8. package/dist/api/decoder.d.ts +257 -0
  9. package/dist/api/decoder.js +424 -0
  10. package/dist/api/decoder.js.map +1 -0
  11. package/dist/api/encoder.d.ts +298 -0
  12. package/dist/api/encoder.js +574 -0
  13. package/dist/api/encoder.js.map +1 -0
  14. package/dist/api/filter.d.ts +457 -0
  15. package/dist/api/filter.js +876 -0
  16. package/dist/api/filter.js.map +1 -0
  17. package/dist/api/hardware.d.ts +318 -0
  18. package/dist/api/hardware.js +558 -0
  19. package/dist/api/hardware.js.map +1 -0
  20. package/dist/api/index.d.ts +12 -0
  21. package/dist/api/index.js +20 -0
  22. package/dist/api/index.js.map +1 -0
  23. package/dist/api/io-stream.d.ts +109 -0
  24. package/dist/api/io-stream.js +124 -0
  25. package/dist/api/io-stream.js.map +1 -0
  26. package/dist/api/media-input.d.ts +295 -0
  27. package/dist/api/media-input.js +456 -0
  28. package/dist/api/media-input.js.map +1 -0
  29. package/dist/api/media-output.d.ts +274 -0
  30. package/dist/api/media-output.js +486 -0
  31. package/dist/api/media-output.js.map +1 -0
  32. package/dist/api/pipeline.d.ts +117 -0
  33. package/dist/api/pipeline.js +836 -0
  34. package/dist/api/pipeline.js.map +1 -0
  35. package/dist/api/types.d.ts +440 -0
  36. package/dist/api/types.js +2 -0
  37. package/dist/api/types.js.map +1 -0
  38. package/dist/api/utilities/audio-sample.d.ts +115 -0
  39. package/dist/api/utilities/audio-sample.js +110 -0
  40. package/dist/api/utilities/audio-sample.js.map +1 -0
  41. package/dist/api/utilities/channel-layout.d.ts +83 -0
  42. package/dist/api/utilities/channel-layout.js +87 -0
  43. package/dist/api/utilities/channel-layout.js.map +1 -0
  44. package/dist/api/utilities/image.d.ts +177 -0
  45. package/dist/api/utilities/image.js +183 -0
  46. package/dist/api/utilities/image.js.map +1 -0
  47. package/dist/api/utilities/index.d.ts +8 -0
  48. package/dist/api/utilities/index.js +17 -0
  49. package/dist/api/utilities/index.js.map +1 -0
  50. package/dist/api/utilities/media-type.d.ts +56 -0
  51. package/dist/api/utilities/media-type.js +60 -0
  52. package/dist/api/utilities/media-type.js.map +1 -0
  53. package/dist/api/utilities/pixel-format.d.ts +94 -0
  54. package/dist/api/utilities/pixel-format.js +102 -0
  55. package/dist/api/utilities/pixel-format.js.map +1 -0
  56. package/dist/api/utilities/sample-format.d.ts +132 -0
  57. package/dist/api/utilities/sample-format.js +144 -0
  58. package/dist/api/utilities/sample-format.js.map +1 -0
  59. package/dist/api/utilities/streaming.d.ts +104 -0
  60. package/dist/api/utilities/streaming.js +137 -0
  61. package/dist/api/utilities/streaming.js.map +1 -0
  62. package/dist/api/utilities/timestamp.d.ts +187 -0
  63. package/dist/api/utilities/timestamp.js +200 -0
  64. package/dist/api/utilities/timestamp.js.map +1 -0
  65. package/dist/api/utils.d.ts +61 -0
  66. package/dist/api/utils.js +330 -0
  67. package/dist/api/utils.js.map +1 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.js +5 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/lib/audio-fifo.d.ts +339 -0
  72. package/dist/lib/audio-fifo.js +365 -0
  73. package/dist/lib/audio-fifo.js.map +1 -0
  74. package/dist/lib/binding.d.ts +192 -0
  75. package/dist/lib/binding.js +70 -0
  76. package/dist/lib/binding.js.map +1 -0
  77. package/dist/lib/bitstream-filter-context.d.ts +345 -0
  78. package/dist/lib/bitstream-filter-context.js +407 -0
  79. package/dist/lib/bitstream-filter-context.js.map +1 -0
  80. package/dist/lib/bitstream-filter.d.ts +124 -0
  81. package/dist/lib/bitstream-filter.js +138 -0
  82. package/dist/lib/bitstream-filter.js.map +1 -0
  83. package/dist/lib/channel-layouts.d.ts +51 -0
  84. package/dist/lib/channel-layouts.js +55 -0
  85. package/dist/lib/channel-layouts.js.map +1 -0
  86. package/dist/lib/codec-context.d.ts +763 -0
  87. package/dist/lib/codec-context.js +974 -0
  88. package/dist/lib/codec-context.js.map +1 -0
  89. package/dist/lib/codec-parameters.d.ts +362 -0
  90. package/dist/lib/codec-parameters.js +460 -0
  91. package/dist/lib/codec-parameters.js.map +1 -0
  92. package/dist/lib/codec-parser.d.ts +185 -0
  93. package/dist/lib/codec-parser.js +193 -0
  94. package/dist/lib/codec-parser.js.map +1 -0
  95. package/dist/lib/codec.d.ts +432 -0
  96. package/dist/lib/codec.js +492 -0
  97. package/dist/lib/codec.js.map +1 -0
  98. package/dist/lib/constants.d.ts +2037 -0
  99. package/dist/lib/constants.js +1659 -0
  100. package/dist/lib/constants.js.map +1 -0
  101. package/dist/lib/dictionary.d.ts +371 -0
  102. package/dist/lib/dictionary.js +406 -0
  103. package/dist/lib/dictionary.js.map +1 -0
  104. package/dist/lib/error.d.ts +216 -0
  105. package/dist/lib/error.js +254 -0
  106. package/dist/lib/error.js.map +1 -0
  107. package/dist/lib/filter-context.d.ts +445 -0
  108. package/dist/lib/filter-context.js +505 -0
  109. package/dist/lib/filter-context.js.map +1 -0
  110. package/dist/lib/filter-graph.d.ts +556 -0
  111. package/dist/lib/filter-graph.js +608 -0
  112. package/dist/lib/filter-graph.js.map +1 -0
  113. package/dist/lib/filter-inout.d.ts +205 -0
  114. package/dist/lib/filter-inout.js +264 -0
  115. package/dist/lib/filter-inout.js.map +1 -0
  116. package/dist/lib/filter.d.ts +231 -0
  117. package/dist/lib/filter.js +260 -0
  118. package/dist/lib/filter.js.map +1 -0
  119. package/dist/lib/format-context.d.ts +798 -0
  120. package/dist/lib/format-context.js +845 -0
  121. package/dist/lib/format-context.js.map +1 -0
  122. package/dist/lib/frame.d.ts +784 -0
  123. package/dist/lib/frame.js +933 -0
  124. package/dist/lib/frame.js.map +1 -0
  125. package/dist/lib/hardware-device-context.d.ts +407 -0
  126. package/dist/lib/hardware-device-context.js +429 -0
  127. package/dist/lib/hardware-device-context.js.map +1 -0
  128. package/dist/lib/hardware-frames-context.d.ts +374 -0
  129. package/dist/lib/hardware-frames-context.js +430 -0
  130. package/dist/lib/hardware-frames-context.js.map +1 -0
  131. package/dist/lib/index.d.ts +31 -0
  132. package/dist/lib/index.js +54 -0
  133. package/dist/lib/index.js.map +1 -0
  134. package/dist/lib/input-format.d.ts +216 -0
  135. package/dist/lib/input-format.js +246 -0
  136. package/dist/lib/input-format.js.map +1 -0
  137. package/dist/lib/io-context.d.ts +495 -0
  138. package/dist/lib/io-context.js +550 -0
  139. package/dist/lib/io-context.js.map +1 -0
  140. package/dist/lib/log.d.ts +201 -0
  141. package/dist/lib/log.js +219 -0
  142. package/dist/lib/log.js.map +1 -0
  143. package/dist/lib/native-types.d.ts +719 -0
  144. package/dist/lib/native-types.js +2 -0
  145. package/dist/lib/native-types.js.map +1 -0
  146. package/dist/lib/option.d.ts +589 -0
  147. package/dist/lib/option.js +853 -0
  148. package/dist/lib/option.js.map +1 -0
  149. package/dist/lib/output-format.d.ts +179 -0
  150. package/dist/lib/output-format.js +205 -0
  151. package/dist/lib/output-format.js.map +1 -0
  152. package/dist/lib/packet.d.ts +487 -0
  153. package/dist/lib/packet.js +558 -0
  154. package/dist/lib/packet.js.map +1 -0
  155. package/dist/lib/rational.d.ts +210 -0
  156. package/dist/lib/rational.js +233 -0
  157. package/dist/lib/rational.js.map +1 -0
  158. package/dist/lib/software-resample-context.d.ts +572 -0
  159. package/dist/lib/software-resample-context.js +610 -0
  160. package/dist/lib/software-resample-context.js.map +1 -0
  161. package/dist/lib/software-scale-context.d.ts +290 -0
  162. package/dist/lib/software-scale-context.js +308 -0
  163. package/dist/lib/software-scale-context.js.map +1 -0
  164. package/dist/lib/stream.d.ts +322 -0
  165. package/dist/lib/stream.js +408 -0
  166. package/dist/lib/stream.js.map +1 -0
  167. package/dist/lib/types.d.ts +59 -0
  168. package/dist/lib/types.js +8 -0
  169. package/dist/lib/types.js.map +1 -0
  170. package/dist/lib/utilities.d.ts +346 -0
  171. package/dist/lib/utilities.js +424 -0
  172. package/dist/lib/utilities.js.map +1 -0
  173. package/install/check.js +113 -0
  174. package/install/ffmpeg.js +163 -0
  175. package/package.json +107 -0
@@ -0,0 +1,495 @@
1
+ import { OptionMember } from './option.js';
2
+ import type { AVIOFlag, AVSeekWhence } from './constants.js';
3
+ import type { NativeIOContext, NativeWrapper } from './native-types.js';
4
+ /**
5
+ * I/O context for custom input/output operations.
6
+ *
7
+ * Provides buffered I/O and protocol handling for reading/writing data
8
+ * from/to files, network streams, memory buffers, or custom sources.
9
+ * Can be used with FormatContext for custom I/O or standalone for direct I/O operations.
10
+ *
11
+ * Direct mapping to FFmpeg's AVIOContext.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { IOContext, FFmpegError } from 'node-av';
16
+ * import { AVIO_FLAG_READ, AVSEEK_SET } from 'node-av/constants';
17
+ *
18
+ * // Open a file for reading
19
+ * const io = new IOContext();
20
+ * const ret = await io.open2('input.mp4', AVIO_FLAG_READ);
21
+ * FFmpegError.throwIfError(ret, 'open2');
22
+ *
23
+ * // Read data
24
+ * const buffer = await io.read(4096);
25
+ *
26
+ * // Seek to position
27
+ * const seekRet = await io.seek(1024n, AVSEEK_SET);
28
+ * FFmpegError.throwIfError(seekRet < 0 ? -1 : 0, 'seek');
29
+ *
30
+ * // Get file size
31
+ * const size = await io.size();
32
+ *
33
+ * // Clean up
34
+ * await io.closep();
35
+ * ```
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // Custom I/O with callbacks
40
+ * const io = new IOContext();
41
+ * io.allocContextWithCallbacks(
42
+ * 4096, // buffer size
43
+ * 0, // read mode
44
+ * (size) => { // custom read function
45
+ * return myBuffer.slice(pos, pos + size);
46
+ * },
47
+ * null, // no write
48
+ * (offset, whence) => { // custom seek function
49
+ * return BigInt(calculateNewPosition(offset, whence));
50
+ * }
51
+ * );
52
+ *
53
+ * // Use with FormatContext
54
+ * const ctx = new FormatContext();
55
+ * ctx.allocOutputContext2(null, 'mp4', null);
56
+ * ctx.pb = io;
57
+ * const openRet = await ctx.openInput(null, null, null);
58
+ * FFmpegError.throwIfError(openRet, 'openInput');
59
+ * ```
60
+ *
61
+ * @see {@link FormatContext} For using custom I/O with containers
62
+ */
63
+ export declare class IOContext extends OptionMember<NativeIOContext> implements AsyncDisposable, NativeWrapper<NativeIOContext> {
64
+ /**
65
+ * Create a new I/O context instance.
66
+ *
67
+ * The context is uninitialized - you must call allocContext() or open2() before use.
68
+ * No FFmpeg resources are allocated until initialization.
69
+ *
70
+ * Direct wrapper around AVIOContext allocation.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * import { IOContext, FFmpegError, AVIO_FLAG_READ } from 'node-av';
75
+ *
76
+ * const io = new IOContext();
77
+ * const ret = await io.open2('file.mp4', AVIO_FLAG_READ);
78
+ * FFmpegError.throwIfError(ret, 'open2');
79
+ * // I/O context is now ready for use
80
+ * ```
81
+ */
82
+ constructor();
83
+ /**
84
+ * Create an IOContext wrapper from a native IOContext.
85
+ *
86
+ * Used internally when getting IOContext from other objects.
87
+ * @internal
88
+ *
89
+ * @param native - Native IOContext to wrap
90
+ * @returns Wrapped IOContext instance
91
+ */
92
+ static fromNative(native: NativeIOContext): IOContext;
93
+ /**
94
+ * Check if end of file reached.
95
+ *
96
+ * Direct mapping to avio_feof()
97
+ *
98
+ * @readonly
99
+ */
100
+ get eof(): boolean;
101
+ /**
102
+ * Error code if any.
103
+ *
104
+ * Direct mapping to AVIOContext->error
105
+ *
106
+ * @readonly
107
+ */
108
+ get error(): number;
109
+ /**
110
+ * Whether seeking is possible.
111
+ *
112
+ * Direct mapping to AVIOContext->seekable
113
+ *
114
+ * Bitmask of AVIO_SEEKABLE_* flags.
115
+ * @readonly
116
+ */
117
+ get seekable(): number;
118
+ /**
119
+ * Maximum packet size.
120
+ *
121
+ * Direct mapping to AVIOContext->max_packet_size
122
+ *
123
+ * If non-zero, indicates the maximum packet size.
124
+ */
125
+ get maxPacketSize(): number;
126
+ set maxPacketSize(value: number);
127
+ /**
128
+ * Whether direct mode is enabled.
129
+ *
130
+ * Direct mapping to AVIOContext->direct
131
+ *
132
+ * avio_read and avio_write should if possible be satisfied directly
133
+ * instead of going through a buffer, and avio_seek will always call
134
+ * the underlying seek function directly.
135
+ */
136
+ get direct(): number;
137
+ set direct(value: number);
138
+ /**
139
+ * Get current position in the file.
140
+ *
141
+ * Direct mapping to AVIOContext->pos
142
+ *
143
+ * @readonly
144
+ */
145
+ get pos(): bigint;
146
+ /**
147
+ * Get buffer size.
148
+ *
149
+ * Direct mapping to AVIOContext->buffer_size
150
+ *
151
+ * @readonly
152
+ */
153
+ get bufferSize(): number;
154
+ /**
155
+ * Check if opened for writing.
156
+ *
157
+ * Direct mapping to AVIOContext->write_flag
158
+ *
159
+ * @readonly
160
+ */
161
+ get writeFlag(): boolean;
162
+ /**
163
+ * Create and initialize a buffered I/O context.
164
+ *
165
+ * Allocates an I/O context with an internal buffer for efficient I/O operations.
166
+ * For file I/O, use open2() instead which handles allocation automatically.
167
+ *
168
+ * Direct mapping to avio_alloc_context()
169
+ *
170
+ * @param bufferSize - Size of the internal buffer in bytes
171
+ * @param writeFlag - 1 for writing, 0 for reading
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * import { IOContext } from 'node-av';
176
+ *
177
+ * const io = new IOContext();
178
+ * io.allocContext(4096, 0); // 4KB buffer for reading
179
+ *
180
+ * // For writing
181
+ * const writeIO = new IOContext();
182
+ * writeIO.allocContext(8192, 1); // 8KB buffer for writing
183
+ * ```
184
+ *
185
+ * @see {@link allocContextWithCallbacks} For custom I/O callbacks
186
+ * @see {@link open2} For file I/O
187
+ */
188
+ allocContext(bufferSize: number, writeFlag: number): void;
189
+ /**
190
+ * Allocate an AVIOContext with custom callbacks.
191
+ *
192
+ * Creates a custom I/O context with JavaScript callbacks for read, write, and seek operations.
193
+ *
194
+ * IMPORTANT: Callbacks must be synchronous! They are called from FFmpeg's thread and must
195
+ * return immediately. If you need async operations, buffer the data in JavaScript first.
196
+ *
197
+ * Direct mapping to avio_alloc_context() with custom callbacks
198
+ *
199
+ * @param bufferSize - Size of the buffer in bytes
200
+ * @param writeFlag - 0 for read, 1 for write
201
+ * @param readCallback - Synchronous callback for reading data. Returns Buffer, null for EOF, or negative error code
202
+ * @param writeCallback - Synchronous callback for writing data. Returns bytes written or negative error code
203
+ * @param seekCallback - Synchronous callback for seeking. Returns new position or negative error code
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * import { IOContext, AVSEEK_SET, AVSEEK_CUR, AVSEEK_END } from 'node-av';
208
+ *
209
+ * const io = new IOContext();
210
+ * let position = 0;
211
+ * const buffer = Buffer.from('example data');
212
+ *
213
+ * io.allocContextWithCallbacks(
214
+ * 4096,
215
+ * 0,
216
+ * (size) => {
217
+ * // Read up to 'size' bytes - MUST BE SYNCHRONOUS
218
+ * return buffer.slice(position, position + size);
219
+ * },
220
+ * null,
221
+ * (offset, whence) => {
222
+ * // Seek to position - MUST BE SYNCHRONOUS
223
+ * if (whence === AVSEEK_SET) position = Number(offset);
224
+ * else if (whence === AVSEEK_CUR) position += Number(offset);
225
+ * else if (whence === AVSEEK_END) position = buffer.length + Number(offset);
226
+ * return BigInt(position);
227
+ * }
228
+ * );
229
+ * ```
230
+ *
231
+ * @see {@link allocContext} For simple buffer allocation
232
+ */
233
+ allocContextWithCallbacks(bufferSize: number, writeFlag: 0 | 1, readCallback?: ((size: number) => Buffer | null | number) | null, writeCallback?: ((buffer: Buffer) => number | void) | null, seekCallback?: ((offset: bigint, whence: number) => bigint | number) | null): void;
234
+ /**
235
+ * Free the AVIOContext.
236
+ *
237
+ * Direct mapping to avio_context_free()
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * import { IOContext } from 'node-av';
242
+ *
243
+ * io.freeContext();
244
+ * // io is now invalid and should not be used
245
+ * ```
246
+ */
247
+ freeContext(): void;
248
+ /**
249
+ * Open a resource for reading or writing.
250
+ *
251
+ * Opens a URL using the appropriate protocol handler (file, http, etc.).
252
+ * Automatically allocates and initializes the I/O context.
253
+ *
254
+ * Direct mapping to avio_open2()
255
+ *
256
+ * @param url - URL to open (file://, http://, https://, etc.)
257
+ * @param flags - I/O flags (AVIO_FLAG_READ, AVIO_FLAG_WRITE, etc.)
258
+ *
259
+ * @returns 0 on success, negative AVERROR on error:
260
+ * - 0: Success
261
+ * - AVERROR(ENOENT): File not found
262
+ * - AVERROR(EACCES): Permission denied
263
+ * - AVERROR(EIO): I/O error
264
+ * - AVERROR(ENOMEM): Memory allocation failure
265
+ * - <0: Other protocol-specific errors
266
+ *
267
+ * @example
268
+ * ```typescript
269
+ * import { IOContext, FFmpegError } from 'node-av';
270
+ * import { AVIO_FLAG_READ, AVIO_FLAG_WRITE } from 'node-av/constants';
271
+ *
272
+ * // Open file for reading
273
+ * const io = new IOContext();
274
+ * const ret = await io.open2('input.mp4', AVIO_FLAG_READ);
275
+ * FFmpegError.throwIfError(ret, 'open2');
276
+ *
277
+ * // Open file for writing
278
+ * const writeIO = new IOContext();
279
+ * const writeRet = await writeIO.open2('output.mp4', AVIO_FLAG_WRITE);
280
+ * FFmpegError.throwIfError(writeRet, 'open2');
281
+ *
282
+ * // Open network stream
283
+ * const streamIO = new IOContext();
284
+ * const streamRet = await streamIO.open2('http://example.com/stream.m3u8', AVIO_FLAG_READ);
285
+ * FFmpegError.throwIfError(streamRet, 'open2');
286
+ * ```
287
+ *
288
+ * @see {@link closep} To close and free resources
289
+ */
290
+ open2(url: string, flags?: AVIOFlag): Promise<number>;
291
+ /**
292
+ * Close the resource and free the AVIOContext.
293
+ *
294
+ * Direct mapping to avio_closep()
295
+ *
296
+ * @returns 0 on success, negative AVERROR on error:
297
+ * - 0: Success
298
+ * - AVERROR(EIO): I/O error during close
299
+ * - <0: Other errors
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * import { FFmpegError } from 'node-av';
304
+ *
305
+ * const ret = await io.closep();
306
+ * FFmpegError.throwIfError(ret, 'closep');
307
+ * // I/O context is now closed and freed
308
+ * ```
309
+ */
310
+ closep(): Promise<number>;
311
+ /**
312
+ * Read size bytes from AVIOContext.
313
+ *
314
+ * Direct mapping to avio_read()
315
+ *
316
+ * @param size - Number of bytes to read
317
+ *
318
+ * @returns Buffer with data or error code if negative:
319
+ * - Buffer: Successfully read data
320
+ * - AVERROR_EOF: End of file reached
321
+ * - AVERROR(EIO): I/O error
322
+ * - <0: Other errors
323
+ *
324
+ * @example
325
+ * ```typescript
326
+ * import { FFmpegError, AVERROR_EOF } from 'node-av';
327
+ *
328
+ * const data = await io.read(1024);
329
+ * if (typeof data === 'number' && data < 0) {
330
+ * if (data === AVERROR_EOF) {
331
+ * console.log('End of file');
332
+ * } else {
333
+ * FFmpegError.throwIfError(data, 'read');
334
+ * }
335
+ * } else {
336
+ * // Process buffer
337
+ * console.log(`Read ${data.length} bytes`);
338
+ * }
339
+ * ```
340
+ */
341
+ read(size: number): Promise<Buffer | number>;
342
+ /**
343
+ * Write buffer to AVIOContext.
344
+ *
345
+ * Direct mapping to avio_write()
346
+ *
347
+ * @param buffer - Buffer to write
348
+ *
349
+ * @example
350
+ * ```typescript
351
+ * import { IOContext } from 'node-av';
352
+ *
353
+ * const data = Buffer.from('Hello, World!');
354
+ * await io.write(data);
355
+ * // Data written successfully
356
+ * ```
357
+ *
358
+ * @throws {Error} If write fails
359
+ */
360
+ write(buffer: Buffer): Promise<void>;
361
+ /**
362
+ * Seek to a given offset.
363
+ *
364
+ * Direct mapping to avio_seek()
365
+ *
366
+ * @param offset - Offset to seek to
367
+ * @param whence - AVSEEK_SET (0), AVSEEK_CUR (1), AVSEEK_END (2), or AVSEEK_SIZE (0x10000)
368
+ *
369
+ * @returns New position or negative AVERROR:
370
+ * - >=0: New position in bytes
371
+ * - AVERROR(EINVAL): Invalid whence value
372
+ * - AVERROR(ESPIPE): Seek not supported
373
+ * - <0: Other errors
374
+ *
375
+ * @example
376
+ * ```typescript
377
+ * import { FFmpegError, AVSEEK_SET, AVSEEK_END, AVSEEK_SIZE } from 'node-av';
378
+ *
379
+ * // Seek to beginning
380
+ * const pos = await io.seek(0n, AVSEEK_SET);
381
+ * FFmpegError.throwIfError(pos < 0n ? Number(pos) : 0, 'seek');
382
+ *
383
+ * // Seek to end
384
+ * const endPos = await io.seek(0n, AVSEEK_END);
385
+ * FFmpegError.throwIfError(endPos < 0n ? Number(endPos) : 0, 'seek');
386
+ *
387
+ * // Get file size without changing position
388
+ * const size = await io.seek(0n, AVSEEK_SIZE);
389
+ * console.log(`File size: ${size} bytes`);
390
+ * ```
391
+ */
392
+ seek(offset: bigint, whence: AVSeekWhence): Promise<bigint>;
393
+ /**
394
+ * Get the file size.
395
+ *
396
+ * Direct mapping to avio_size()
397
+ *
398
+ * @returns File size or negative AVERROR:
399
+ * - >=0: File size in bytes
400
+ * - AVERROR(ENOSYS): Operation not supported
401
+ * - <0: Other errors
402
+ *
403
+ * @example
404
+ * ```typescript
405
+ * import { FFmpegError } from 'node-av';
406
+ *
407
+ * const size = await io.size();
408
+ * if (size < 0n) {
409
+ * // Handle unsupported or error
410
+ * console.error('Cannot determine file size');
411
+ * } else {
412
+ * console.log(`File size: ${size} bytes`);
413
+ * }
414
+ * ```
415
+ */
416
+ size(): Promise<bigint>;
417
+ /**
418
+ * Force flushing of buffered data.
419
+ *
420
+ * Direct mapping to avio_flush()
421
+ *
422
+ * @example
423
+ * ```typescript
424
+ * import { IOContext } from 'node-av';
425
+ *
426
+ * await io.flush();
427
+ * // All buffered data has been written
428
+ * ```
429
+ */
430
+ flush(): Promise<void>;
431
+ /**
432
+ * Skip given number of bytes forward.
433
+ *
434
+ * Direct mapping to avio_skip()
435
+ *
436
+ * @param offset - Number of bytes to skip
437
+ *
438
+ * @returns New position or negative AVERROR:
439
+ * - >=0: New position in bytes
440
+ * - AVERROR_EOF: End of file reached
441
+ * - <0: Other errors
442
+ *
443
+ * @example
444
+ * ```typescript
445
+ * import { FFmpegError } from 'node-av';
446
+ *
447
+ * // Skip 1024 bytes
448
+ * const newPos = await io.skip(1024n);
449
+ * FFmpegError.throwIfError(newPos < 0n ? Number(newPos) : 0, 'skip');
450
+ * console.log(`New position: ${newPos}`);
451
+ * ```
452
+ */
453
+ skip(offset: bigint): Promise<bigint>;
454
+ /**
455
+ * Get the current position.
456
+ *
457
+ * Direct mapping to avio_tell()
458
+ *
459
+ * @returns Current position in bytes
460
+ *
461
+ * @example
462
+ * ```typescript
463
+ * import { IOContext } from 'node-av';
464
+ *
465
+ * const position = io.tell();
466
+ * console.log(`Current position: ${position} bytes`);
467
+ * ```
468
+ */
469
+ tell(): bigint;
470
+ /**
471
+ * Get the native FFmpeg AVIOContext pointer.
472
+ *
473
+ * @internal For use by other wrapper classes
474
+ * @returns The underlying native I/O context object
475
+ */
476
+ getNative(): NativeIOContext;
477
+ /**
478
+ * Dispose of the I/O context.
479
+ *
480
+ * Implements the AsyncDisposable interface for automatic cleanup.
481
+ * Equivalent to calling closep().
482
+ *
483
+ * @example
484
+ * ```typescript
485
+ * import { IOContext, AVIO_FLAG_READ } from 'node-av';
486
+ *
487
+ * {
488
+ * await using io = new IOContext();
489
+ * await io.open2('file.mp4', AVIO_FLAG_READ);
490
+ * // ... use I/O context
491
+ * } // Automatically closed when leaving scope
492
+ * ```
493
+ */
494
+ [Symbol.asyncDispose](): Promise<void>;
495
+ }