@revizly/node-av 5.2.2-beta.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 (254) hide show
  1. package/BUILD_LINUX.md +61 -0
  2. package/LICENSE.md +22 -0
  3. package/README.md +662 -0
  4. package/build_mac_local.sh +69 -0
  5. package/dist/api/audio-frame-buffer.d.ts +205 -0
  6. package/dist/api/audio-frame-buffer.js +287 -0
  7. package/dist/api/audio-frame-buffer.js.map +1 -0
  8. package/dist/api/bitstream-filter.d.ts +820 -0
  9. package/dist/api/bitstream-filter.js +1242 -0
  10. package/dist/api/bitstream-filter.js.map +1 -0
  11. package/dist/api/constants.d.ts +44 -0
  12. package/dist/api/constants.js +45 -0
  13. package/dist/api/constants.js.map +1 -0
  14. package/dist/api/data/test_av1.ivf +0 -0
  15. package/dist/api/data/test_h264.h264 +0 -0
  16. package/dist/api/data/test_hevc.h265 +0 -0
  17. package/dist/api/data/test_mjpeg.mjpeg +0 -0
  18. package/dist/api/data/test_vp8.ivf +0 -0
  19. package/dist/api/data/test_vp9.ivf +0 -0
  20. package/dist/api/decoder.d.ts +1088 -0
  21. package/dist/api/decoder.js +1775 -0
  22. package/dist/api/decoder.js.map +1 -0
  23. package/dist/api/demuxer.d.ts +1219 -0
  24. package/dist/api/demuxer.js +2081 -0
  25. package/dist/api/demuxer.js.map +1 -0
  26. package/dist/api/device.d.ts +586 -0
  27. package/dist/api/device.js +961 -0
  28. package/dist/api/device.js.map +1 -0
  29. package/dist/api/encoder.d.ts +1132 -0
  30. package/dist/api/encoder.js +1988 -0
  31. package/dist/api/encoder.js.map +1 -0
  32. package/dist/api/filter-complex.d.ts +821 -0
  33. package/dist/api/filter-complex.js +1604 -0
  34. package/dist/api/filter-complex.js.map +1 -0
  35. package/dist/api/filter-presets.d.ts +1286 -0
  36. package/dist/api/filter-presets.js +2152 -0
  37. package/dist/api/filter-presets.js.map +1 -0
  38. package/dist/api/filter.d.ts +1234 -0
  39. package/dist/api/filter.js +1976 -0
  40. package/dist/api/filter.js.map +1 -0
  41. package/dist/api/fmp4-stream.d.ts +426 -0
  42. package/dist/api/fmp4-stream.js +739 -0
  43. package/dist/api/fmp4-stream.js.map +1 -0
  44. package/dist/api/hardware.d.ts +651 -0
  45. package/dist/api/hardware.js +1260 -0
  46. package/dist/api/hardware.js.map +1 -0
  47. package/dist/api/index.d.ts +17 -0
  48. package/dist/api/index.js +32 -0
  49. package/dist/api/index.js.map +1 -0
  50. package/dist/api/io-stream.d.ts +307 -0
  51. package/dist/api/io-stream.js +282 -0
  52. package/dist/api/io-stream.js.map +1 -0
  53. package/dist/api/muxer.d.ts +957 -0
  54. package/dist/api/muxer.js +2002 -0
  55. package/dist/api/muxer.js.map +1 -0
  56. package/dist/api/pipeline.d.ts +607 -0
  57. package/dist/api/pipeline.js +1145 -0
  58. package/dist/api/pipeline.js.map +1 -0
  59. package/dist/api/utilities/async-queue.d.ts +120 -0
  60. package/dist/api/utilities/async-queue.js +211 -0
  61. package/dist/api/utilities/async-queue.js.map +1 -0
  62. package/dist/api/utilities/audio-sample.d.ts +117 -0
  63. package/dist/api/utilities/audio-sample.js +112 -0
  64. package/dist/api/utilities/audio-sample.js.map +1 -0
  65. package/dist/api/utilities/channel-layout.d.ts +76 -0
  66. package/dist/api/utilities/channel-layout.js +80 -0
  67. package/dist/api/utilities/channel-layout.js.map +1 -0
  68. package/dist/api/utilities/electron-shared-texture.d.ts +328 -0
  69. package/dist/api/utilities/electron-shared-texture.js +503 -0
  70. package/dist/api/utilities/electron-shared-texture.js.map +1 -0
  71. package/dist/api/utilities/image.d.ts +207 -0
  72. package/dist/api/utilities/image.js +213 -0
  73. package/dist/api/utilities/image.js.map +1 -0
  74. package/dist/api/utilities/index.d.ts +12 -0
  75. package/dist/api/utilities/index.js +25 -0
  76. package/dist/api/utilities/index.js.map +1 -0
  77. package/dist/api/utilities/media-type.d.ts +49 -0
  78. package/dist/api/utilities/media-type.js +53 -0
  79. package/dist/api/utilities/media-type.js.map +1 -0
  80. package/dist/api/utilities/pixel-format.d.ts +89 -0
  81. package/dist/api/utilities/pixel-format.js +97 -0
  82. package/dist/api/utilities/pixel-format.js.map +1 -0
  83. package/dist/api/utilities/sample-format.d.ts +129 -0
  84. package/dist/api/utilities/sample-format.js +141 -0
  85. package/dist/api/utilities/sample-format.js.map +1 -0
  86. package/dist/api/utilities/scheduler.d.ts +138 -0
  87. package/dist/api/utilities/scheduler.js +98 -0
  88. package/dist/api/utilities/scheduler.js.map +1 -0
  89. package/dist/api/utilities/streaming.d.ts +186 -0
  90. package/dist/api/utilities/streaming.js +309 -0
  91. package/dist/api/utilities/streaming.js.map +1 -0
  92. package/dist/api/utilities/timestamp.d.ts +193 -0
  93. package/dist/api/utilities/timestamp.js +206 -0
  94. package/dist/api/utilities/timestamp.js.map +1 -0
  95. package/dist/api/utilities/whisper-model.d.ts +310 -0
  96. package/dist/api/utilities/whisper-model.js +528 -0
  97. package/dist/api/utilities/whisper-model.js.map +1 -0
  98. package/dist/api/utils.d.ts +19 -0
  99. package/dist/api/utils.js +39 -0
  100. package/dist/api/utils.js.map +1 -0
  101. package/dist/api/whisper.d.ts +324 -0
  102. package/dist/api/whisper.js +362 -0
  103. package/dist/api/whisper.js.map +1 -0
  104. package/dist/constants/channel-layouts.d.ts +53 -0
  105. package/dist/constants/channel-layouts.js +57 -0
  106. package/dist/constants/channel-layouts.js.map +1 -0
  107. package/dist/constants/constants.d.ts +2325 -0
  108. package/dist/constants/constants.js +1887 -0
  109. package/dist/constants/constants.js.map +1 -0
  110. package/dist/constants/decoders.d.ts +633 -0
  111. package/dist/constants/decoders.js +641 -0
  112. package/dist/constants/decoders.js.map +1 -0
  113. package/dist/constants/encoders.d.ts +295 -0
  114. package/dist/constants/encoders.js +308 -0
  115. package/dist/constants/encoders.js.map +1 -0
  116. package/dist/constants/hardware.d.ts +26 -0
  117. package/dist/constants/hardware.js +27 -0
  118. package/dist/constants/hardware.js.map +1 -0
  119. package/dist/constants/index.d.ts +5 -0
  120. package/dist/constants/index.js +6 -0
  121. package/dist/constants/index.js.map +1 -0
  122. package/dist/ffmpeg/index.d.ts +99 -0
  123. package/dist/ffmpeg/index.js +115 -0
  124. package/dist/ffmpeg/index.js.map +1 -0
  125. package/dist/ffmpeg/utils.d.ts +31 -0
  126. package/dist/ffmpeg/utils.js +68 -0
  127. package/dist/ffmpeg/utils.js.map +1 -0
  128. package/dist/ffmpeg/version.d.ts +6 -0
  129. package/dist/ffmpeg/version.js +7 -0
  130. package/dist/ffmpeg/version.js.map +1 -0
  131. package/dist/index.d.ts +4 -0
  132. package/dist/index.js +9 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/lib/audio-fifo.d.ts +399 -0
  135. package/dist/lib/audio-fifo.js +431 -0
  136. package/dist/lib/audio-fifo.js.map +1 -0
  137. package/dist/lib/binding.d.ts +228 -0
  138. package/dist/lib/binding.js +60 -0
  139. package/dist/lib/binding.js.map +1 -0
  140. package/dist/lib/bitstream-filter-context.d.ts +379 -0
  141. package/dist/lib/bitstream-filter-context.js +441 -0
  142. package/dist/lib/bitstream-filter-context.js.map +1 -0
  143. package/dist/lib/bitstream-filter.d.ts +140 -0
  144. package/dist/lib/bitstream-filter.js +154 -0
  145. package/dist/lib/bitstream-filter.js.map +1 -0
  146. package/dist/lib/codec-context.d.ts +1071 -0
  147. package/dist/lib/codec-context.js +1354 -0
  148. package/dist/lib/codec-context.js.map +1 -0
  149. package/dist/lib/codec-parameters.d.ts +616 -0
  150. package/dist/lib/codec-parameters.js +761 -0
  151. package/dist/lib/codec-parameters.js.map +1 -0
  152. package/dist/lib/codec-parser.d.ts +201 -0
  153. package/dist/lib/codec-parser.js +213 -0
  154. package/dist/lib/codec-parser.js.map +1 -0
  155. package/dist/lib/codec.d.ts +586 -0
  156. package/dist/lib/codec.js +713 -0
  157. package/dist/lib/codec.js.map +1 -0
  158. package/dist/lib/device.d.ts +291 -0
  159. package/dist/lib/device.js +324 -0
  160. package/dist/lib/device.js.map +1 -0
  161. package/dist/lib/dictionary.d.ts +333 -0
  162. package/dist/lib/dictionary.js +372 -0
  163. package/dist/lib/dictionary.js.map +1 -0
  164. package/dist/lib/error.d.ts +242 -0
  165. package/dist/lib/error.js +303 -0
  166. package/dist/lib/error.js.map +1 -0
  167. package/dist/lib/fifo.d.ts +416 -0
  168. package/dist/lib/fifo.js +453 -0
  169. package/dist/lib/fifo.js.map +1 -0
  170. package/dist/lib/filter-context.d.ts +712 -0
  171. package/dist/lib/filter-context.js +789 -0
  172. package/dist/lib/filter-context.js.map +1 -0
  173. package/dist/lib/filter-graph-segment.d.ts +160 -0
  174. package/dist/lib/filter-graph-segment.js +171 -0
  175. package/dist/lib/filter-graph-segment.js.map +1 -0
  176. package/dist/lib/filter-graph.d.ts +641 -0
  177. package/dist/lib/filter-graph.js +704 -0
  178. package/dist/lib/filter-graph.js.map +1 -0
  179. package/dist/lib/filter-inout.d.ts +198 -0
  180. package/dist/lib/filter-inout.js +257 -0
  181. package/dist/lib/filter-inout.js.map +1 -0
  182. package/dist/lib/filter.d.ts +243 -0
  183. package/dist/lib/filter.js +272 -0
  184. package/dist/lib/filter.js.map +1 -0
  185. package/dist/lib/format-context.d.ts +1254 -0
  186. package/dist/lib/format-context.js +1379 -0
  187. package/dist/lib/format-context.js.map +1 -0
  188. package/dist/lib/frame-utils.d.ts +116 -0
  189. package/dist/lib/frame-utils.js +98 -0
  190. package/dist/lib/frame-utils.js.map +1 -0
  191. package/dist/lib/frame.d.ts +1222 -0
  192. package/dist/lib/frame.js +1435 -0
  193. package/dist/lib/frame.js.map +1 -0
  194. package/dist/lib/hardware-device-context.d.ts +362 -0
  195. package/dist/lib/hardware-device-context.js +383 -0
  196. package/dist/lib/hardware-device-context.js.map +1 -0
  197. package/dist/lib/hardware-frames-context.d.ts +419 -0
  198. package/dist/lib/hardware-frames-context.js +477 -0
  199. package/dist/lib/hardware-frames-context.js.map +1 -0
  200. package/dist/lib/index.d.ts +35 -0
  201. package/dist/lib/index.js +60 -0
  202. package/dist/lib/index.js.map +1 -0
  203. package/dist/lib/input-format.d.ts +249 -0
  204. package/dist/lib/input-format.js +306 -0
  205. package/dist/lib/input-format.js.map +1 -0
  206. package/dist/lib/io-context.d.ts +696 -0
  207. package/dist/lib/io-context.js +769 -0
  208. package/dist/lib/io-context.js.map +1 -0
  209. package/dist/lib/log.d.ts +174 -0
  210. package/dist/lib/log.js +184 -0
  211. package/dist/lib/log.js.map +1 -0
  212. package/dist/lib/native-types.d.ts +946 -0
  213. package/dist/lib/native-types.js +2 -0
  214. package/dist/lib/native-types.js.map +1 -0
  215. package/dist/lib/option.d.ts +927 -0
  216. package/dist/lib/option.js +1583 -0
  217. package/dist/lib/option.js.map +1 -0
  218. package/dist/lib/output-format.d.ts +180 -0
  219. package/dist/lib/output-format.js +213 -0
  220. package/dist/lib/output-format.js.map +1 -0
  221. package/dist/lib/packet.d.ts +501 -0
  222. package/dist/lib/packet.js +590 -0
  223. package/dist/lib/packet.js.map +1 -0
  224. package/dist/lib/rational.d.ts +251 -0
  225. package/dist/lib/rational.js +278 -0
  226. package/dist/lib/rational.js.map +1 -0
  227. package/dist/lib/software-resample-context.d.ts +552 -0
  228. package/dist/lib/software-resample-context.js +592 -0
  229. package/dist/lib/software-resample-context.js.map +1 -0
  230. package/dist/lib/software-scale-context.d.ts +344 -0
  231. package/dist/lib/software-scale-context.js +366 -0
  232. package/dist/lib/software-scale-context.js.map +1 -0
  233. package/dist/lib/stream.d.ts +379 -0
  234. package/dist/lib/stream.js +526 -0
  235. package/dist/lib/stream.js.map +1 -0
  236. package/dist/lib/sync-queue.d.ts +179 -0
  237. package/dist/lib/sync-queue.js +197 -0
  238. package/dist/lib/sync-queue.js.map +1 -0
  239. package/dist/lib/types.d.ts +34 -0
  240. package/dist/lib/types.js +2 -0
  241. package/dist/lib/types.js.map +1 -0
  242. package/dist/lib/utilities.d.ts +1127 -0
  243. package/dist/lib/utilities.js +1225 -0
  244. package/dist/lib/utilities.js.map +1 -0
  245. package/dist/utils/electron.d.ts +49 -0
  246. package/dist/utils/electron.js +63 -0
  247. package/dist/utils/electron.js.map +1 -0
  248. package/dist/utils/index.d.ts +4 -0
  249. package/dist/utils/index.js +5 -0
  250. package/dist/utils/index.js.map +1 -0
  251. package/install/check.js +121 -0
  252. package/install/ffmpeg.js +66 -0
  253. package/jellyfin-ffmpeg.patch +181 -0
  254. package/package.json +129 -0
@@ -0,0 +1,696 @@
1
+ import { OptionMember } from './option.js';
2
+ import type { AVIOFlag, AVSeekWhence } from '../constants/constants.js';
3
+ import type { NativeIOContext, NativeWrapper } from './native-types.js';
4
+ /**
5
+ * I/O context for custom input/output operations.
6
+ *
7
+ * Provides an abstraction layer for all I/O operations in FFmpeg.
8
+ * Enables reading from and writing to various sources including files,
9
+ * network streams, memory buffers, and custom callbacks. Essential for
10
+ * implementing custom protocols or handling non-standard I/O scenarios.
11
+ *
12
+ * Direct mapping to FFmpeg's AVIOContext.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { IOContext, FFmpegError } from 'node-av';
17
+ * import { AVIO_FLAG_READ, AVIO_FLAG_WRITE, AVSEEK_SET } from 'node-av/constants';
18
+ *
19
+ * // Open file for reading
20
+ * const io = new IOContext();
21
+ * const ret = await io.open2('input.mp4', AVIO_FLAG_READ);
22
+ * FFmpegError.throwIfError(ret, 'open2');
23
+ *
24
+ * // Read data
25
+ * const data = await io.read(4096);
26
+ * if (data instanceof Buffer) {
27
+ * console.log(`Read ${data.length} bytes`);
28
+ * }
29
+ *
30
+ * // Seek to position
31
+ * const pos = await io.seek(1024n, AVSEEK_SET);
32
+ * console.log(`Seeked to position ${pos}`);
33
+ *
34
+ * // Get file size
35
+ * const fileSize = await io.size();
36
+ * console.log(`File size: ${fileSize}`);
37
+ *
38
+ * // Close when done
39
+ * await io.closep();
40
+ *
41
+ * // Custom I/O with callbacks
42
+ * const customIO = new IOContext();
43
+ * let position = 0n;
44
+ * const buffer = Buffer.from('Hello World');
45
+ *
46
+ * customIO.allocContextWithCallbacks(
47
+ * 4096, // Buffer size
48
+ * 0, // Read mode
49
+ * (size) => {
50
+ * // Read callback
51
+ * const end = Number(position) + size;
52
+ * const chunk = buffer.subarray(Number(position), end);
53
+ * position = BigInt(end);
54
+ * return chunk;
55
+ * },
56
+ * null, // No write callback for read mode
57
+ * (offset, whence) => {
58
+ * // Seek callback
59
+ * if (whence === AVSEEK_SET) position = offset;
60
+ * else if (whence === AVSEEK_CUR) position += offset;
61
+ * else if (whence === AVSEEK_END) position = BigInt(buffer.length) + offset;
62
+ * return position;
63
+ * }
64
+ * );
65
+ * ```
66
+ *
67
+ * @see [AVIOContext](https://ffmpeg.org/doxygen/trunk/structAVIOContext.html) - FFmpeg Doxygen
68
+ * @see {@link FormatContext} For using with demuxing/muxing
69
+ */
70
+ export declare class IOContext extends OptionMember<NativeIOContext> implements Disposable, AsyncDisposable, NativeWrapper<NativeIOContext> {
71
+ constructor();
72
+ /**
73
+ * Find input format by short name.
74
+ *
75
+ * Creates an IOContext instance from a native binding object.
76
+ * Used internally for wrapping native I/O contexts.
77
+ *
78
+ * @param native - Native IOContext binding object
79
+ *
80
+ * @returns Wrapped IOContext instance
81
+ *
82
+ * @internal
83
+ */
84
+ static fromNative(native: NativeIOContext): IOContext;
85
+ /**
86
+ * End of file indicator.
87
+ *
88
+ * True if end of file has been reached during reading.
89
+ *
90
+ * Direct mapping to AVIOContext->eof_reached.
91
+ */
92
+ get eof(): boolean;
93
+ /**
94
+ * Error code.
95
+ *
96
+ * Contains the last error that occurred, or 0 if no error.
97
+ *
98
+ * Direct mapping to AVIOContext->error.
99
+ */
100
+ get error(): number;
101
+ /**
102
+ * Seekability indicator.
103
+ *
104
+ * Non-zero if the underlying resource supports seeking.
105
+ * Some protocols like pipes or network streams may not be seekable.
106
+ *
107
+ * Direct mapping to AVIOContext->seekable.
108
+ */
109
+ get seekable(): number;
110
+ /**
111
+ * Maximum packet size.
112
+ *
113
+ * Used to limit packet sizes in network protocols.
114
+ * 0 means no limit.
115
+ *
116
+ * Direct mapping to AVIOContext->max_packet_size.
117
+ */
118
+ get maxPacketSize(): number;
119
+ set maxPacketSize(value: number);
120
+ /**
121
+ * Direct mode flag.
122
+ *
123
+ * If set, the I/O context will attempt to avoid buffering.
124
+ *
125
+ * Direct mapping to AVIOContext->direct.
126
+ */
127
+ get direct(): number;
128
+ set direct(value: number);
129
+ /**
130
+ * Current position.
131
+ *
132
+ * Current byte position in the stream.
133
+ *
134
+ * Direct mapping to AVIOContext->pos.
135
+ */
136
+ get pos(): bigint;
137
+ /**
138
+ * Internal buffer size.
139
+ *
140
+ * Size of the internal buffer used for I/O operations.
141
+ *
142
+ * Direct mapping to AVIOContext->buffer_size.
143
+ */
144
+ get bufferSize(): number;
145
+ /**
146
+ * Write flag.
147
+ *
148
+ * True if opened for writing, false for reading.
149
+ *
150
+ * Direct mapping to AVIOContext->write_flag.
151
+ */
152
+ get writeFlag(): boolean;
153
+ /**
154
+ * Allocate I/O context with buffer.
155
+ *
156
+ * Allocates a basic I/O context with an internal buffer.
157
+ * For custom I/O, use allocContextWithCallbacks instead.
158
+ *
159
+ * Direct mapping to avio_alloc_context() without callbacks.
160
+ *
161
+ * @param bufferSize - Size of internal buffer
162
+ *
163
+ * @param writeFlag - 1 for write, 0 for read
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * const io = new IOContext();
168
+ * io.allocContext(4096, 0); // 4KB buffer for reading
169
+ * ```
170
+ *
171
+ * @see {@link allocContextWithCallbacks} For custom I/O
172
+ */
173
+ allocContext(bufferSize: number, writeFlag: number): void;
174
+ /**
175
+ * Allocate I/O context with custom callbacks.
176
+ *
177
+ * Creates an I/O context with custom read, write, and seek callbacks.
178
+ * Enables implementing custom protocols or data sources.
179
+ *
180
+ * NOTE: When using JavaScript callbacks, synchronous operations
181
+ * (e.g., readSync, seekSync) cannot be used on this context.
182
+ * This is because JavaScript callbacks require the event loop to be available,
183
+ * which is blocked during synchronous operations. Always use async methods
184
+ * (read, seek) when working with custom callbacks.
185
+ *
186
+ * Direct mapping to avio_alloc_context() with callbacks.
187
+ *
188
+ * @param bufferSize - Size of internal buffer
189
+ *
190
+ * @param writeFlag - 1 for write mode, 0 for read mode
191
+ *
192
+ * @param readCallback - Function to read data (null for write-only)
193
+ *
194
+ * @param writeCallback - Function to write data (null for read-only)
195
+ *
196
+ * @param seekCallback - Function to seek in stream (optional)
197
+ *
198
+ * @example
199
+ * ```typescript
200
+ * import { AVSEEK_SET, AVSEEK_CUR, AVSEEK_END, AVSEEK_SIZE } from 'node-av/constants';
201
+ *
202
+ * const data = Buffer.from('Custom data source');
203
+ * let position = 0;
204
+ *
205
+ * io.allocContextWithCallbacks(
206
+ * 4096,
207
+ * 0, // Read mode
208
+ * (size) => {
209
+ * // Read callback
210
+ * if (position >= data.length) return -541; // EOF
211
+ * const chunk = data.subarray(position, position + size);
212
+ * position += chunk.length;
213
+ * return chunk;
214
+ * },
215
+ * null,
216
+ * (offset, whence) => {
217
+ * // Seek callback
218
+ * if (whence === AVSEEK_SIZE) return BigInt(data.length);
219
+ * if (whence === AVSEEK_SET) position = Number(offset);
220
+ * else if (whence === AVSEEK_CUR) position += Number(offset);
221
+ * else if (whence === AVSEEK_END) position = data.length + Number(offset);
222
+ * return BigInt(position);
223
+ * }
224
+ * );
225
+ * ```
226
+ *
227
+ * @see {@link allocContext} For simple allocation
228
+ */
229
+ allocContextWithCallbacks(bufferSize: number, writeFlag: 0 | 1, readCallback?: ((size: number) => Buffer | null | number | Promise<Buffer | null | number>) | null, writeCallback?: ((buffer: Buffer) => number | void | Promise<number | void>) | null, seekCallback?: ((offset: bigint, whence: AVSeekWhence) => bigint | number | Promise<bigint | number>) | null): void;
230
+ /**
231
+ * Free I/O context.
232
+ *
233
+ * Releases the I/O context and its resources.
234
+ * The context becomes invalid after calling this.
235
+ *
236
+ * Direct mapping to avio_context_free().
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * io.freeContext();
241
+ * // Context is now invalid
242
+ * ```
243
+ */
244
+ freeContext(): void;
245
+ /**
246
+ * Open resource for I/O.
247
+ *
248
+ * Opens a URL or file for reading or writing.
249
+ * Automatically selects the appropriate protocol handler.
250
+ *
251
+ * Direct mapping to avio_open2().
252
+ *
253
+ * @param url - URL or file path to open
254
+ *
255
+ * @param flags - Open flags (AVIO_FLAG_READ, AVIO_FLAG_WRITE, etc.)
256
+ *
257
+ * @returns 0 on success, negative AVERROR on error:
258
+ * - AVERROR_ENOENT: File not found
259
+ * - AVERROR_EACCES: Permission denied
260
+ * - AVERROR_ENOMEM: Memory allocation failure
261
+ *
262
+ * @example
263
+ * ```typescript
264
+ * import { FFmpegError } from 'node-av';
265
+ * import { AVIO_FLAG_READ, AVIO_FLAG_WRITE } from 'node-av/constants';
266
+ *
267
+ * // Open for reading
268
+ * const ret = await io.open2('input.mp4', AVIO_FLAG_READ);
269
+ * FFmpegError.throwIfError(ret, 'open2');
270
+ *
271
+ * // Open for writing
272
+ * const ret2 = await io.open2('output.mp4', AVIO_FLAG_WRITE);
273
+ * FFmpegError.throwIfError(ret2, 'open2');
274
+ * ```
275
+ *
276
+ * @see {@link closep} To close after use
277
+ */
278
+ open2(url: string, flags?: AVIOFlag): Promise<number>;
279
+ /**
280
+ * Open resource for I/O synchronously.
281
+ * Synchronous version of open2.
282
+ *
283
+ * Opens a URL or file for reading or writing.
284
+ * Automatically selects the appropriate protocol handler.
285
+ *
286
+ * Direct mapping to avio_open2().
287
+ *
288
+ * @param url - URL or file path to open
289
+ *
290
+ * @param flags - Open flags (AVIO_FLAG_READ, AVIO_FLAG_WRITE, etc.)
291
+ *
292
+ * @returns 0 on success, negative AVERROR on error:
293
+ * - AVERROR_ENOENT: File not found
294
+ * - AVERROR_EACCES: Permission denied
295
+ * - AVERROR_ENOMEM: Memory allocation failure
296
+ *
297
+ * @example
298
+ * ```typescript
299
+ * import { FFmpegError } from 'node-av';
300
+ * import { AVIO_FLAG_READ, AVIO_FLAG_WRITE } from 'node-av/constants';
301
+ *
302
+ * // Open for reading
303
+ * const ret = io.open2Sync('input.mp4', AVIO_FLAG_READ);
304
+ * FFmpegError.throwIfError(ret, 'open2');
305
+ *
306
+ * // Open for writing
307
+ * const ret2 = io.open2Sync('output.mp4', AVIO_FLAG_WRITE);
308
+ * FFmpegError.throwIfError(ret2, 'open2');
309
+ * ```
310
+ *
311
+ * @see {@link open2} For async version
312
+ */
313
+ open2Sync(url: string, flags?: AVIOFlag): number;
314
+ /**
315
+ * Close I/O context.
316
+ *
317
+ * Closes the I/O context and releases associated resources.
318
+ * Flushes any buffered data before closing.
319
+ *
320
+ * Direct mapping to avio_closep().
321
+ *
322
+ * @returns 0 on success, negative AVERROR on error
323
+ *
324
+ * @example
325
+ * ```typescript
326
+ * const ret = await io.closep();
327
+ * if (ret < 0) {
328
+ * console.error('Error closing I/O context');
329
+ * }
330
+ * ```
331
+ *
332
+ * @see {@link open2} To open resources
333
+ */
334
+ closep(): Promise<number>;
335
+ /**
336
+ * Close I/O context synchronously.
337
+ * Synchronous version of closep.
338
+ *
339
+ * Closes the I/O context and frees resources.
340
+ * Sets internal pointer to NULL.
341
+ *
342
+ * Direct mapping to avio_closep().
343
+ *
344
+ * @returns 0 on success, negative AVERROR on error
345
+ *
346
+ * @example
347
+ * ```typescript
348
+ * const ret = io.closepSync();
349
+ * if (ret < 0) {
350
+ * console.error(`Failed to close: ${ret}`);
351
+ * }
352
+ * ```
353
+ *
354
+ * @see {@link closep} For async version
355
+ */
356
+ closepSync(): number;
357
+ /**
358
+ * Read data from I/O context.
359
+ *
360
+ * Reads up to the specified number of bytes from the stream.
361
+ *
362
+ * Direct mapping to avio_read().
363
+ *
364
+ * @param size - Maximum number of bytes to read
365
+ *
366
+ * @returns Buffer with data, or error code if negative:
367
+ * - AVERROR_EOF: End of file reached
368
+ * - AVERROR_EIO: I/O error
369
+ *
370
+ * @example
371
+ * ```typescript
372
+ * const data = await io.read(4096);
373
+ * if (data instanceof Buffer) {
374
+ * console.log(`Read ${data.length} bytes`);
375
+ * } else {
376
+ * console.error(`Read error: ${data}`);
377
+ * }
378
+ * ```
379
+ *
380
+ * @see {@link write} For writing data
381
+ */
382
+ read(size: number): Promise<Buffer | number>;
383
+ /**
384
+ * Read data from I/O context synchronously.
385
+ * Synchronous version of read.
386
+ *
387
+ * Reads up to the specified number of bytes from the stream.
388
+ *
389
+ * Direct mapping to avio_read().
390
+ *
391
+ * @param size - Number of bytes to read
392
+ *
393
+ * @returns Buffer with data, or negative AVERROR on error
394
+ *
395
+ * @example
396
+ * ```typescript
397
+ * const result = io.readSync(4096);
398
+ * if (Buffer.isBuffer(result)) {
399
+ * console.log(`Read ${result.length} bytes`);
400
+ * } else {
401
+ * console.log(`Read error: ${result}`);
402
+ * }
403
+ * ```
404
+ *
405
+ * @see {@link read} For async version
406
+ */
407
+ readSync(size: number): Buffer | number;
408
+ /**
409
+ * Write data to I/O context.
410
+ *
411
+ * Writes buffer data to the stream.
412
+ *
413
+ * Direct mapping to avio_write().
414
+ *
415
+ * @param buffer - Data to write
416
+ *
417
+ * @example
418
+ * ```typescript
419
+ * const data = Buffer.from('Hello World');
420
+ * await io.write(data);
421
+ * ```
422
+ *
423
+ * @see {@link read} For reading data
424
+ * @see {@link flush} To flush buffers
425
+ */
426
+ write(buffer: Buffer): Promise<void>;
427
+ /**
428
+ * Write data to I/O context synchronously.
429
+ * Synchronous version of write.
430
+ *
431
+ * Writes buffer data to the stream.
432
+ *
433
+ * Direct mapping to avio_write().
434
+ *
435
+ * @param buffer - Data to write
436
+ *
437
+ * @example
438
+ * ```typescript
439
+ * const data = Buffer.from('Hello, World!');
440
+ * io.writeSync(data);
441
+ * ```
442
+ *
443
+ * @see {@link write} For async version
444
+ */
445
+ writeSync(buffer: Buffer): void;
446
+ /**
447
+ * Seek to position in stream.
448
+ *
449
+ * Changes the current position in the stream.
450
+ * Not all streams support seeking.
451
+ *
452
+ * Direct mapping to avio_seek().
453
+ *
454
+ * @param offset - Byte offset to seek to
455
+ *
456
+ * @param whence - Seek origin (AVSEEK_SET, AVSEEK_CUR, AVSEEK_END)
457
+ *
458
+ * @returns New position, or negative AVERROR on error:
459
+ * - AVERROR_EINVAL: Invalid arguments
460
+ * - AVERROR_ENOSYS: Seeking not supported
461
+ *
462
+ * @example
463
+ * ```typescript
464
+ * import { AVSEEK_SET, AVSEEK_CUR, AVSEEK_END } from 'node-av/constants';
465
+ *
466
+ * // Seek to absolute position
467
+ * const pos1 = await io.seek(1024n, AVSEEK_SET);
468
+ *
469
+ * // Seek relative to current position
470
+ * const pos2 = await io.seek(512n, AVSEEK_CUR);
471
+ *
472
+ * // Seek relative to end
473
+ * const pos3 = await io.seek(-1024n, AVSEEK_END);
474
+ * ```
475
+ *
476
+ * @see {@link tell} To get current position
477
+ * @see {@link skip} For relative seeking
478
+ */
479
+ seek(offset: bigint, whence: AVSeekWhence): Promise<bigint>;
480
+ /**
481
+ * Seek to position in stream synchronously.
482
+ * Synchronous version of seek.
483
+ *
484
+ * Changes the current position in the stream.
485
+ * Not all streams support seeking.
486
+ *
487
+ * Direct mapping to avio_seek().
488
+ *
489
+ * @param offset - Byte offset to seek to
490
+ *
491
+ * @param whence - Seek origin (AVSEEK_SET, AVSEEK_CUR, AVSEEK_END)
492
+ *
493
+ * @returns New position, or negative AVERROR on error:
494
+ * - AVERROR_EINVAL: Invalid arguments
495
+ * - AVERROR_ENOSYS: Seeking not supported
496
+ *
497
+ * @example
498
+ * ```typescript
499
+ * import { AVSEEK_SET, AVSEEK_CUR, AVSEEK_END } from 'node-av/constants';
500
+ *
501
+ * // Seek to absolute position
502
+ * const pos1 = io.seekSync(1024n, AVSEEK_SET);
503
+ *
504
+ * // Seek relative to current position
505
+ * const pos2 = io.seekSync(512n, AVSEEK_CUR);
506
+ *
507
+ * // Seek relative to end
508
+ * const pos3 = io.seekSync(-1024n, AVSEEK_END);
509
+ * ```
510
+ *
511
+ * @see {@link seek} For async version
512
+ */
513
+ seekSync(offset: bigint, whence: AVSeekWhence): bigint;
514
+ /**
515
+ * Get stream size.
516
+ *
517
+ * Returns the total size of the stream in bytes.
518
+ * Not all streams have a known size.
519
+ *
520
+ * Direct mapping to avio_size().
521
+ *
522
+ * @returns Size in bytes, or negative AVERROR if unknown:
523
+ * - AVERROR_ENOSYS: Size not available
524
+ *
525
+ * @example
526
+ * ```typescript
527
+ * const size = await io.size();
528
+ * if (size >= 0n) {
529
+ * console.log(`Stream size: ${size} bytes`);
530
+ * } else {
531
+ * console.log('Stream size unknown');
532
+ * }
533
+ * ```
534
+ */
535
+ size(): Promise<bigint>;
536
+ /**
537
+ * Get stream size synchronously.
538
+ * Synchronous version of size.
539
+ *
540
+ * Returns the total size of the stream in bytes.
541
+ * Not all streams have a known size.
542
+ *
543
+ * Direct mapping to avio_size().
544
+ *
545
+ * @returns Size in bytes, or negative AVERROR if unknown:
546
+ * - AVERROR_ENOSYS: Size not available
547
+ *
548
+ * @example
549
+ * ```typescript
550
+ * const size = io.sizeSync();
551
+ * if (size >= 0n) {
552
+ * console.log(`Stream size: ${size} bytes`);
553
+ * } else {
554
+ * console.log('Stream size unknown');
555
+ * }
556
+ * ```
557
+ *
558
+ * @see {@link size} For async version
559
+ */
560
+ sizeSync(): bigint;
561
+ /**
562
+ * Flush buffered data.
563
+ *
564
+ * Forces any buffered data to be written to the underlying resource.
565
+ *
566
+ * Direct mapping to avio_flush().
567
+ *
568
+ * @example
569
+ * ```typescript
570
+ * await io.write(data);
571
+ * await io.flush(); // Ensure data is written
572
+ * ```
573
+ *
574
+ * @see {@link write} For writing data
575
+ */
576
+ flush(): Promise<void>;
577
+ /**
578
+ * Flush buffered data synchronously.
579
+ * Synchronous version of flush.
580
+ *
581
+ * Forces any buffered data to be written to the underlying resource.
582
+ *
583
+ * Direct mapping to avio_flush().
584
+ *
585
+ * @example
586
+ * ```typescript
587
+ * io.writeSync(data);
588
+ * io.flushSync(); // Ensure data is written
589
+ * ```
590
+ *
591
+ * @see {@link flush} For async version
592
+ */
593
+ flushSync(): void;
594
+ /**
595
+ * Skip bytes in stream.
596
+ *
597
+ * Advances the position by the specified offset.
598
+ * More efficient than reading and discarding data.
599
+ *
600
+ * Direct mapping to avio_skip().
601
+ *
602
+ * @param offset - Number of bytes to skip
603
+ *
604
+ * @returns New position after skipping
605
+ *
606
+ * @example
607
+ * ```typescript
608
+ * // Skip 1024 bytes forward
609
+ * const newPos = await io.skip(1024n);
610
+ * console.log(`New position: ${newPos}`);
611
+ * ```
612
+ *
613
+ * @see {@link seek} For absolute positioning
614
+ */
615
+ skip(offset: bigint): Promise<bigint>;
616
+ /**
617
+ * Skip bytes in stream synchronously.
618
+ * Synchronous version of skip.
619
+ *
620
+ * Advances the position by the specified offset.
621
+ * More efficient than reading and discarding data.
622
+ *
623
+ * Direct mapping to avio_skip().
624
+ *
625
+ * @param offset - Number of bytes to skip
626
+ *
627
+ * @returns New position after skipping
628
+ *
629
+ * @example
630
+ * ```typescript
631
+ * // Skip 1024 bytes forward
632
+ * const newPos = io.skipSync(1024n);
633
+ * console.log(`New position: ${newPos}`);
634
+ * ```
635
+ *
636
+ * @see {@link skip} For async version
637
+ */
638
+ skipSync(offset: bigint): bigint;
639
+ /**
640
+ * Get current position.
641
+ *
642
+ * Returns the current byte position in the stream.
643
+ *
644
+ * Direct mapping to avio_tell().
645
+ *
646
+ * @returns Current position in bytes
647
+ *
648
+ * @example
649
+ * ```typescript
650
+ * const position = io.tell();
651
+ * console.log(`Current position: ${position}`);
652
+ * ```
653
+ *
654
+ * @see {@link seek} To change position
655
+ */
656
+ tell(): bigint;
657
+ /**
658
+ * Get the underlying native IOContext object.
659
+ *
660
+ * @returns The native IOContext binding object
661
+ *
662
+ * @internal
663
+ */
664
+ getNative(): NativeIOContext;
665
+ /**
666
+ * Dispose of the I/O context synchronously.
667
+ *
668
+ * Implements the Disposable interface for automatic cleanup.
669
+ * Closes the context and releases resources.
670
+ *
671
+ * @example
672
+ * ```typescript
673
+ * {
674
+ * using io = IOStream.create(buffer);
675
+ * // Use io...
676
+ * } // Automatically freed when leaving scope
677
+ * ```
678
+ */
679
+ [Symbol.dispose](): void;
680
+ /**
681
+ * Dispose of the I/O context asynchronously.
682
+ *
683
+ * Implements the AsyncDisposable interface for automatic cleanup.
684
+ * Closes the context and releases resources.
685
+ *
686
+ * @example
687
+ * ```typescript
688
+ * {
689
+ * await using io = new IOContext();
690
+ * await io.open2('input.mp4');
691
+ * // Use io...
692
+ * } // Automatically closed when leaving scope
693
+ * ```
694
+ */
695
+ [Symbol.asyncDispose](): Promise<void>;
696
+ }