node-av-lgpl 0.0.0 → 7.1.0-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 (311) hide show
  1. package/LICENSE.md +22 -0
  2. package/README.md +711 -0
  3. package/dist/api/audio-frame-buffer.d.ts +636 -0
  4. package/dist/api/audio-frame-buffer.js +1027 -0
  5. package/dist/api/audio-frame-buffer.js.map +1 -0
  6. package/dist/api/bitstream-filter.d.ts +938 -0
  7. package/dist/api/bitstream-filter.js +1427 -0
  8. package/dist/api/bitstream-filter.js.map +1 -0
  9. package/dist/api/constants.d.ts +44 -0
  10. package/dist/api/constants.js +45 -0
  11. package/dist/api/constants.js.map +1 -0
  12. package/dist/api/data/test_av1.ivf +0 -0
  13. package/dist/api/data/test_h264.h264 +0 -0
  14. package/dist/api/data/test_hevc.h265 +0 -0
  15. package/dist/api/data/test_mjpeg.mjpeg +0 -0
  16. package/dist/api/data/test_vp8.ivf +0 -0
  17. package/dist/api/data/test_vp9.ivf +0 -0
  18. package/dist/api/decoder.d.ts +1413 -0
  19. package/dist/api/decoder.js +2367 -0
  20. package/dist/api/decoder.js.map +1 -0
  21. package/dist/api/demuxer.d.ts +1295 -0
  22. package/dist/api/demuxer.js +2344 -0
  23. package/dist/api/demuxer.js.map +1 -0
  24. package/dist/api/device.d.ts +589 -0
  25. package/dist/api/device.js +964 -0
  26. package/dist/api/device.js.map +1 -0
  27. package/dist/api/encoder-pool.d.ts +262 -0
  28. package/dist/api/encoder-pool.js +397 -0
  29. package/dist/api/encoder-pool.js.map +1 -0
  30. package/dist/api/encoder.d.ts +1509 -0
  31. package/dist/api/encoder.js +2619 -0
  32. package/dist/api/encoder.js.map +1 -0
  33. package/dist/api/filter-complex.d.ts +828 -0
  34. package/dist/api/filter-complex.js +1661 -0
  35. package/dist/api/filter-complex.js.map +1 -0
  36. package/dist/api/filter-presets.d.ts +800 -0
  37. package/dist/api/filter-presets.js +1554 -0
  38. package/dist/api/filter-presets.js.map +1 -0
  39. package/dist/api/filter.d.ts +1339 -0
  40. package/dist/api/filter.js +2075 -0
  41. package/dist/api/filter.js.map +1 -0
  42. package/dist/api/fmp4-stream.d.ts +797 -0
  43. package/dist/api/fmp4-stream.js +1428 -0
  44. package/dist/api/fmp4-stream.js.map +1 -0
  45. package/dist/api/hardware.d.ts +677 -0
  46. package/dist/api/hardware.js +1300 -0
  47. package/dist/api/hardware.js.map +1 -0
  48. package/dist/api/index.d.ts +21 -0
  49. package/dist/api/index.js +38 -0
  50. package/dist/api/index.js.map +1 -0
  51. package/dist/api/io-stream.d.ts +308 -0
  52. package/dist/api/io-stream.js +358 -0
  53. package/dist/api/io-stream.js.map +1 -0
  54. package/dist/api/muxer.d.ts +1311 -0
  55. package/dist/api/muxer.js +2672 -0
  56. package/dist/api/muxer.js.map +1 -0
  57. package/dist/api/pipeline.d.ts +801 -0
  58. package/dist/api/pipeline.js +1344 -0
  59. package/dist/api/pipeline.js.map +1 -0
  60. package/dist/api/probe.d.ts +128 -0
  61. package/dist/api/probe.js +227 -0
  62. package/dist/api/probe.js.map +1 -0
  63. package/dist/api/rtp-stream.d.ts +497 -0
  64. package/dist/api/rtp-stream.js +1131 -0
  65. package/dist/api/rtp-stream.js.map +1 -0
  66. package/dist/api/scaler.d.ts +561 -0
  67. package/dist/api/scaler.js +918 -0
  68. package/dist/api/scaler.js.map +1 -0
  69. package/dist/api/types.d.ts +17 -0
  70. package/dist/api/types.js +2 -0
  71. package/dist/api/types.js.map +1 -0
  72. package/dist/api/utilities/async-queue.d.ts +149 -0
  73. package/dist/api/utilities/async-queue.js +254 -0
  74. package/dist/api/utilities/async-queue.js.map +1 -0
  75. package/dist/api/utilities/audio-sample.d.ts +117 -0
  76. package/dist/api/utilities/audio-sample.js +112 -0
  77. package/dist/api/utilities/audio-sample.js.map +1 -0
  78. package/dist/api/utilities/audio-transcode.d.ts +20 -0
  79. package/dist/api/utilities/audio-transcode.js +27 -0
  80. package/dist/api/utilities/audio-transcode.js.map +1 -0
  81. package/dist/api/utilities/channel-layout.d.ts +76 -0
  82. package/dist/api/utilities/channel-layout.js +80 -0
  83. package/dist/api/utilities/channel-layout.js.map +1 -0
  84. package/dist/api/utilities/codec-format.d.ts +87 -0
  85. package/dist/api/utilities/codec-format.js +117 -0
  86. package/dist/api/utilities/codec-format.js.map +1 -0
  87. package/dist/api/utilities/context-options.d.ts +25 -0
  88. package/dist/api/utilities/context-options.js +23 -0
  89. package/dist/api/utilities/context-options.js.map +1 -0
  90. package/dist/api/utilities/electron-shared-texture.d.ts +368 -0
  91. package/dist/api/utilities/electron-shared-texture.js +540 -0
  92. package/dist/api/utilities/electron-shared-texture.js.map +1 -0
  93. package/dist/api/utilities/image.d.ts +207 -0
  94. package/dist/api/utilities/image.js +213 -0
  95. package/dist/api/utilities/image.js.map +1 -0
  96. package/dist/api/utilities/index.d.ts +14 -0
  97. package/dist/api/utilities/index.js +27 -0
  98. package/dist/api/utilities/index.js.map +1 -0
  99. package/dist/api/utilities/live-decoding.d.ts +15 -0
  100. package/dist/api/utilities/live-decoding.js +32 -0
  101. package/dist/api/utilities/live-decoding.js.map +1 -0
  102. package/dist/api/utilities/media-type.d.ts +49 -0
  103. package/dist/api/utilities/media-type.js +53 -0
  104. package/dist/api/utilities/media-type.js.map +1 -0
  105. package/dist/api/utilities/packet-age-watchdog.d.ts +198 -0
  106. package/dist/api/utilities/packet-age-watchdog.js +594 -0
  107. package/dist/api/utilities/packet-age-watchdog.js.map +1 -0
  108. package/dist/api/utilities/pixel-format.d.ts +89 -0
  109. package/dist/api/utilities/pixel-format.js +97 -0
  110. package/dist/api/utilities/pixel-format.js.map +1 -0
  111. package/dist/api/utilities/sample-format.d.ts +129 -0
  112. package/dist/api/utilities/sample-format.js +141 -0
  113. package/dist/api/utilities/sample-format.js.map +1 -0
  114. package/dist/api/utilities/scale-size.d.ts +51 -0
  115. package/dist/api/utilities/scale-size.js +55 -0
  116. package/dist/api/utilities/scale-size.js.map +1 -0
  117. package/dist/api/utilities/scheduler.d.ts +138 -0
  118. package/dist/api/utilities/scheduler.js +98 -0
  119. package/dist/api/utilities/scheduler.js.map +1 -0
  120. package/dist/api/utilities/streaming.d.ts +186 -0
  121. package/dist/api/utilities/streaming.js +309 -0
  122. package/dist/api/utilities/streaming.js.map +1 -0
  123. package/dist/api/utilities/timestamp.d.ts +193 -0
  124. package/dist/api/utilities/timestamp.js +206 -0
  125. package/dist/api/utilities/timestamp.js.map +1 -0
  126. package/dist/api/utilities/video-transcode.d.ts +218 -0
  127. package/dist/api/utilities/video-transcode.js +624 -0
  128. package/dist/api/utilities/video-transcode.js.map +1 -0
  129. package/dist/api/utilities/whisper-model.d.ts +330 -0
  130. package/dist/api/utilities/whisper-model.js +587 -0
  131. package/dist/api/utilities/whisper-model.js.map +1 -0
  132. package/dist/api/utils.d.ts +19 -0
  133. package/dist/api/utils.js +39 -0
  134. package/dist/api/utils.js.map +1 -0
  135. package/dist/api/webrtc-stream.d.ts +294 -0
  136. package/dist/api/webrtc-stream.js +546 -0
  137. package/dist/api/webrtc-stream.js.map +1 -0
  138. package/dist/api/whisper.d.ts +326 -0
  139. package/dist/api/whisper.js +402 -0
  140. package/dist/api/whisper.js.map +1 -0
  141. package/dist/constants/bsf-options.d.ts +364 -0
  142. package/dist/constants/bsf-options.js +7 -0
  143. package/dist/constants/bsf-options.js.map +1 -0
  144. package/dist/constants/channel-layouts.d.ts +53 -0
  145. package/dist/constants/channel-layouts.js +57 -0
  146. package/dist/constants/channel-layouts.js.map +1 -0
  147. package/dist/constants/constants.d.ts +2435 -0
  148. package/dist/constants/constants.js +1989 -0
  149. package/dist/constants/constants.js.map +1 -0
  150. package/dist/constants/decoders.d.ts +651 -0
  151. package/dist/constants/decoders.js +641 -0
  152. package/dist/constants/decoders.js.map +1 -0
  153. package/dist/constants/encoders.d.ts +314 -0
  154. package/dist/constants/encoders.js +309 -0
  155. package/dist/constants/encoders.js.map +1 -0
  156. package/dist/constants/filter-options.d.ts +12099 -0
  157. package/dist/constants/filter-options.js +7 -0
  158. package/dist/constants/filter-options.js.map +1 -0
  159. package/dist/constants/format-options.d.ts +4319 -0
  160. package/dist/constants/format-options.js +7 -0
  161. package/dist/constants/format-options.js.map +1 -0
  162. package/dist/constants/formats.d.ts +18 -0
  163. package/dist/constants/formats.js +7 -0
  164. package/dist/constants/formats.js.map +1 -0
  165. package/dist/constants/hardware.d.ts +26 -0
  166. package/dist/constants/hardware.js +27 -0
  167. package/dist/constants/hardware.js.map +1 -0
  168. package/dist/constants/index.d.ts +10 -0
  169. package/dist/constants/index.js +6 -0
  170. package/dist/constants/index.js.map +1 -0
  171. package/dist/constants/options.d.ts +6217 -0
  172. package/dist/constants/options.js +7 -0
  173. package/dist/constants/options.js.map +1 -0
  174. package/dist/ffmpeg/index.d.ts +101 -0
  175. package/dist/ffmpeg/index.js +161 -0
  176. package/dist/ffmpeg/index.js.map +1 -0
  177. package/dist/ffmpeg/version.d.ts +6 -0
  178. package/dist/ffmpeg/version.js +7 -0
  179. package/dist/ffmpeg/version.js.map +1 -0
  180. package/dist/index.d.ts +4 -0
  181. package/dist/index.js +9 -0
  182. package/dist/index.js.map +1 -0
  183. package/dist/lib/audio-fifo.d.ts +399 -0
  184. package/dist/lib/audio-fifo.js +431 -0
  185. package/dist/lib/audio-fifo.js.map +1 -0
  186. package/dist/lib/binding.d.ts +242 -0
  187. package/dist/lib/binding.js +102 -0
  188. package/dist/lib/binding.js.map +1 -0
  189. package/dist/lib/bitstream-filter-context.d.ts +381 -0
  190. package/dist/lib/bitstream-filter-context.js +443 -0
  191. package/dist/lib/bitstream-filter-context.js.map +1 -0
  192. package/dist/lib/bitstream-filter.d.ts +140 -0
  193. package/dist/lib/bitstream-filter.js +154 -0
  194. package/dist/lib/bitstream-filter.js.map +1 -0
  195. package/dist/lib/codec-context.d.ts +1069 -0
  196. package/dist/lib/codec-context.js +1336 -0
  197. package/dist/lib/codec-context.js.map +1 -0
  198. package/dist/lib/codec-parameters.d.ts +664 -0
  199. package/dist/lib/codec-parameters.js +813 -0
  200. package/dist/lib/codec-parameters.js.map +1 -0
  201. package/dist/lib/codec-parser.d.ts +201 -0
  202. package/dist/lib/codec-parser.js +213 -0
  203. package/dist/lib/codec-parser.js.map +1 -0
  204. package/dist/lib/codec.d.ts +617 -0
  205. package/dist/lib/codec.js +746 -0
  206. package/dist/lib/codec.js.map +1 -0
  207. package/dist/lib/device.d.ts +294 -0
  208. package/dist/lib/device.js +326 -0
  209. package/dist/lib/device.js.map +1 -0
  210. package/dist/lib/dictionary.d.ts +333 -0
  211. package/dist/lib/dictionary.js +372 -0
  212. package/dist/lib/dictionary.js.map +1 -0
  213. package/dist/lib/error.d.ts +311 -0
  214. package/dist/lib/error.js +395 -0
  215. package/dist/lib/error.js.map +1 -0
  216. package/dist/lib/fifo.d.ts +416 -0
  217. package/dist/lib/fifo.js +453 -0
  218. package/dist/lib/fifo.js.map +1 -0
  219. package/dist/lib/filter-context.d.ts +714 -0
  220. package/dist/lib/filter-context.js +783 -0
  221. package/dist/lib/filter-context.js.map +1 -0
  222. package/dist/lib/filter-graph-segment.d.ts +161 -0
  223. package/dist/lib/filter-graph-segment.js +172 -0
  224. package/dist/lib/filter-graph-segment.js.map +1 -0
  225. package/dist/lib/filter-graph.d.ts +641 -0
  226. package/dist/lib/filter-graph.js +704 -0
  227. package/dist/lib/filter-graph.js.map +1 -0
  228. package/dist/lib/filter-inout.d.ts +202 -0
  229. package/dist/lib/filter-inout.js +261 -0
  230. package/dist/lib/filter-inout.js.map +1 -0
  231. package/dist/lib/filter.d.ts +243 -0
  232. package/dist/lib/filter.js +272 -0
  233. package/dist/lib/filter.js.map +1 -0
  234. package/dist/lib/format-context.d.ts +1335 -0
  235. package/dist/lib/format-context.js +1455 -0
  236. package/dist/lib/format-context.js.map +1 -0
  237. package/dist/lib/frame-utils.d.ts +116 -0
  238. package/dist/lib/frame-utils.js +98 -0
  239. package/dist/lib/frame-utils.js.map +1 -0
  240. package/dist/lib/frame.d.ts +1315 -0
  241. package/dist/lib/frame.js +1535 -0
  242. package/dist/lib/frame.js.map +1 -0
  243. package/dist/lib/hardware-device-context.d.ts +362 -0
  244. package/dist/lib/hardware-device-context.js +383 -0
  245. package/dist/lib/hardware-device-context.js.map +1 -0
  246. package/dist/lib/hardware-frames-context.d.ts +418 -0
  247. package/dist/lib/hardware-frames-context.js +471 -0
  248. package/dist/lib/hardware-frames-context.js.map +1 -0
  249. package/dist/lib/index.d.ts +35 -0
  250. package/dist/lib/index.js +60 -0
  251. package/dist/lib/index.js.map +1 -0
  252. package/dist/lib/input-format.d.ts +249 -0
  253. package/dist/lib/input-format.js +306 -0
  254. package/dist/lib/input-format.js.map +1 -0
  255. package/dist/lib/io-context.d.ts +698 -0
  256. package/dist/lib/io-context.js +771 -0
  257. package/dist/lib/io-context.js.map +1 -0
  258. package/dist/lib/log.d.ts +174 -0
  259. package/dist/lib/log.js +184 -0
  260. package/dist/lib/log.js.map +1 -0
  261. package/dist/lib/native-types.d.ts +1024 -0
  262. package/dist/lib/native-types.js +2 -0
  263. package/dist/lib/native-types.js.map +1 -0
  264. package/dist/lib/option.d.ts +953 -0
  265. package/dist/lib/option.js +1607 -0
  266. package/dist/lib/option.js.map +1 -0
  267. package/dist/lib/output-format.d.ts +222 -0
  268. package/dist/lib/output-format.js +259 -0
  269. package/dist/lib/output-format.js.map +1 -0
  270. package/dist/lib/packet.d.ts +521 -0
  271. package/dist/lib/packet.js +613 -0
  272. package/dist/lib/packet.js.map +1 -0
  273. package/dist/lib/rational.d.ts +251 -0
  274. package/dist/lib/rational.js +278 -0
  275. package/dist/lib/rational.js.map +1 -0
  276. package/dist/lib/software-resample-context.d.ts +552 -0
  277. package/dist/lib/software-resample-context.js +592 -0
  278. package/dist/lib/software-resample-context.js.map +1 -0
  279. package/dist/lib/software-scale-context.d.ts +344 -0
  280. package/dist/lib/software-scale-context.js +366 -0
  281. package/dist/lib/software-scale-context.js.map +1 -0
  282. package/dist/lib/stream.d.ts +383 -0
  283. package/dist/lib/stream.js +524 -0
  284. package/dist/lib/stream.js.map +1 -0
  285. package/dist/lib/sync-queue.d.ts +179 -0
  286. package/dist/lib/sync-queue.js +197 -0
  287. package/dist/lib/sync-queue.js.map +1 -0
  288. package/dist/lib/types.d.ts +34 -0
  289. package/dist/lib/types.js +2 -0
  290. package/dist/lib/types.js.map +1 -0
  291. package/dist/lib/utilities.d.ts +1198 -0
  292. package/dist/lib/utilities.js +1302 -0
  293. package/dist/lib/utilities.js.map +1 -0
  294. package/dist/utils/electron.d.ts +49 -0
  295. package/dist/utils/electron.js +63 -0
  296. package/dist/utils/electron.js.map +1 -0
  297. package/dist/utils/index.d.ts +6 -0
  298. package/dist/utils/index.js +7 -0
  299. package/dist/utils/index.js.map +1 -0
  300. package/dist/utils/libc.d.ts +11 -0
  301. package/dist/utils/libc.js +35 -0
  302. package/dist/utils/libc.js.map +1 -0
  303. package/dist/utils/variant.d.ts +26 -0
  304. package/dist/utils/variant.js +31 -0
  305. package/dist/utils/variant.js.map +1 -0
  306. package/dist/webrtc/index.d.ts +4 -0
  307. package/dist/webrtc/index.js +7 -0
  308. package/dist/webrtc/index.js.map +1 -0
  309. package/install/check.js +124 -0
  310. package/install/ffmpeg.js +66 -0
  311. package/package.json +165 -3
@@ -0,0 +1,1335 @@
1
+ import { Codec } from './codec.js';
2
+ import { Dictionary } from './dictionary.js';
3
+ import { InputFormat } from './input-format.js';
4
+ import { OptionMember } from './option.js';
5
+ import { OutputFormat } from './output-format.js';
6
+ import { Stream } from './stream.js';
7
+ import type { AVCodecID, AVFormatFlag, AVMediaType, AVSeekFlag } from '../constants/constants.js';
8
+ import type { IOContext } from './io-context.js';
9
+ import type { NativeFormatContext, NativeWrapper } from './native-types.js';
10
+ import type { Packet } from './packet.js';
11
+ /**
12
+ * RTSP stream information interface
13
+ */
14
+ export interface RTSPStreamInfo {
15
+ streamIndex: number;
16
+ controlUrl: string;
17
+ transport: 'tcp' | 'udp' | 'udp_multicast' | 'unknown';
18
+ payloadType: number;
19
+ codecId: AVCodecID;
20
+ mediaType: 'video' | 'audio' | 'data' | 'subtitle' | 'unknown';
21
+ mimeType: string;
22
+ sampleRate?: number;
23
+ channels?: number;
24
+ direction: 'sendonly' | 'recvonly' | 'sendrecv' | 'inactive';
25
+ fmtp?: string;
26
+ }
27
+ /**
28
+ * Container format context for reading/writing multimedia files.
29
+ *
30
+ * Central structure for demuxing (reading) and muxing (writing) media files.
31
+ * Manages streams, packets, metadata, and format-specific operations.
32
+ * Supports both file-based and custom I/O through IOContext.
33
+ * Essential for all file-based media operations.
34
+ *
35
+ * Direct mapping to FFmpeg's AVFormatContext.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * import { FormatContext, FFmpegError } from 'node-av';
40
+ * import { AVMEDIA_TYPE_VIDEO } from 'node-av/constants';
41
+ *
42
+ * // Open input file
43
+ * const ctx = new FormatContext();
44
+ * let ret = await ctx.openInput('input.mp4');
45
+ * FFmpegError.throwIfError(ret, 'openInput');
46
+ *
47
+ * ret = await ctx.findStreamInfo();
48
+ * FFmpegError.throwIfError(ret, 'findStreamInfo');
49
+ *
50
+ * // Find video stream
51
+ * const videoIndex = ctx.findBestStream(AVMEDIA_TYPE_VIDEO);
52
+ * if (videoIndex < 0) {
53
+ * throw new Error('No video stream found');
54
+ * }
55
+ *
56
+ * // Read packets
57
+ * const packet = new Packet();
58
+ * packet.alloc();
59
+ * while ((ret = await ctx.readFrame(packet)) >= 0) {
60
+ * if (packet.streamIndex === videoIndex) {
61
+ * // Process video packet
62
+ * }
63
+ * packet.unref();
64
+ * }
65
+ *
66
+ * // Cleanup
67
+ * await ctx.closeInput();
68
+ * ```
69
+ *
70
+ * @see [AVFormatContext](https://ffmpeg.org/doxygen/trunk/structAVFormatContext.html) - FFmpeg Doxygen
71
+ * @see {@link InputFormat} For supported input formats
72
+ * @see {@link OutputFormat} For supported output formats
73
+ * @see {@link Stream} For stream management
74
+ */
75
+ export declare class FormatContext extends OptionMember<NativeFormatContext> implements AsyncDisposable, NativeWrapper<NativeFormatContext> {
76
+ private _ioContext;
77
+ constructor();
78
+ /**
79
+ * URL or filename of the media.
80
+ *
81
+ * For input: the opened file path.
82
+ * For output: the target file path.
83
+ *
84
+ * Direct mapping to AVFormatContext->url.
85
+ */
86
+ get url(): string | null;
87
+ set url(value: string | null);
88
+ /**
89
+ * Start time of the stream.
90
+ *
91
+ * Position of the first frame in microseconds.
92
+ * AV_NOPTS_VALUE if unknown.
93
+ *
94
+ * Direct mapping to AVFormatContext->start_time.
95
+ */
96
+ get startTime(): bigint;
97
+ /**
98
+ * Duration of the stream.
99
+ *
100
+ * Total stream duration in microseconds.
101
+ * AV_NOPTS_VALUE if unknown.
102
+ *
103
+ * Direct mapping to AVFormatContext->duration.
104
+ */
105
+ get duration(): bigint;
106
+ /**
107
+ * Total stream bitrate.
108
+ *
109
+ * Bitrate in bits per second.
110
+ * 0 if unknown.
111
+ *
112
+ * Direct mapping to AVFormatContext->bit_rate.
113
+ */
114
+ get bitRate(): bigint;
115
+ /**
116
+ * Format-specific flags.
117
+ *
118
+ * Combination of AVFMT_FLAG_* values controlling
119
+ * format behavior (e.g., AVFMT_FLAG_GENPTS).
120
+ *
121
+ * Direct mapping to AVFormatContext->flags.
122
+ */
123
+ get flags(): AVFormatFlag;
124
+ set flags(value: AVFormatFlag);
125
+ /**
126
+ * Maximum bytes to probe for format detection.
127
+ *
128
+ * Larger values improve format detection accuracy
129
+ * but increase startup time.
130
+ *
131
+ * Direct mapping to AVFormatContext->probesize.
132
+ */
133
+ get probesize(): bigint;
134
+ set probesize(value: bigint);
135
+ /**
136
+ * Maximum duration to analyze streams.
137
+ *
138
+ * Time in microseconds to spend analyzing streams.
139
+ * Larger values improve stream detection accuracy.
140
+ *
141
+ * Direct mapping to AVFormatContext->max_analyze_duration.
142
+ */
143
+ get maxAnalyzeDuration(): bigint;
144
+ set maxAnalyzeDuration(value: bigint);
145
+ /**
146
+ * Maximum buffering duration for interleaving.
147
+ *
148
+ * Specifies the maximum difference between the timestamps of the
149
+ * first and the last packet in the muxing queue, above which libavformat
150
+ * will output a packet regardless of whether it has queued a packet for all
151
+ * the streams.
152
+ *
153
+ * Set to 0 for unlimited buffering
154
+ *
155
+ * Default: 10000000 (10 seconds in microseconds)
156
+ *
157
+ * Muxing only, set before avformat_write_header().
158
+ *
159
+ * Direct mapping to AVFormatContext->max_interleave_delta.
160
+ */
161
+ get maxInterleaveDelta(): bigint;
162
+ set maxInterleaveDelta(value: bigint);
163
+ /**
164
+ * Container metadata.
165
+ *
166
+ * Key-value pairs of metadata (title, author, etc.).
167
+ *
168
+ * Returns a copy of AVFormatContext->metadata - mutating the returned
169
+ * Dictionary does not affect the context. Assign it back to apply changes.
170
+ */
171
+ get metadata(): Dictionary | null;
172
+ set metadata(value: Dictionary | null);
173
+ /**
174
+ * Input format descriptor.
175
+ *
176
+ * Format used for demuxing. Null for output contexts.
177
+ *
178
+ * Direct mapping to AVFormatContext->iformat.
179
+ */
180
+ get iformat(): InputFormat | null;
181
+ /**
182
+ * Output format descriptor.
183
+ *
184
+ * Format used for muxing. Null for input contexts.
185
+ *
186
+ * Direct mapping to AVFormatContext->oformat.
187
+ */
188
+ get oformat(): OutputFormat | null;
189
+ set oformat(value: OutputFormat | null);
190
+ /**
191
+ * Custom I/O context.
192
+ *
193
+ * For custom I/O operations instead of file I/O.
194
+ * Assigning a callback-backed context also sets AVFMT_FLAG_CUSTOM_IO so libavformat never closes it.
195
+ * A context opened with open2() is closed once, by whichever comes first: its closep(), which
196
+ * also clears this pb like `avio_closep(&ctx->pb)` in C, or closing or freeing this output context.
197
+ * An IOContext can be the pb of one FormatContext at a time.
198
+ *
199
+ * Direct mapping to AVFormatContext->pb.
200
+ */
201
+ get pb(): IOContext | null;
202
+ set pb(value: IOContext | null);
203
+ /**
204
+ * Number of streams in the container.
205
+ *
206
+ * Direct mapping to AVFormatContext->nb_streams.
207
+ */
208
+ get nbStreams(): number;
209
+ /**
210
+ * Array of streams in the container.
211
+ *
212
+ * All audio, video, subtitle, and data streams.
213
+ *
214
+ * Direct mapping to AVFormatContext->streams.
215
+ */
216
+ get streams(): Stream[];
217
+ /**
218
+ * Strictness level for standards compliance.
219
+ *
220
+ * FF_COMPLIANCE_* value controlling how strictly
221
+ * to follow specifications.
222
+ *
223
+ * Direct mapping to AVFormatContext->strict_std_compliance.
224
+ */
225
+ get strictStdCompliance(): number;
226
+ set strictStdCompliance(value: number);
227
+ /**
228
+ * Maximum number of streams.
229
+ *
230
+ * Limit on stream count for security/resource reasons.
231
+ *
232
+ * Direct mapping to AVFormatContext->max_streams.
233
+ */
234
+ get maxStreams(): number;
235
+ set maxStreams(value: number);
236
+ /**
237
+ * Number of programs.
238
+ *
239
+ * For containers with multiple programs (e.g., MPEG-TS).
240
+ *
241
+ * Direct mapping to AVFormatContext->nb_programs.
242
+ */
243
+ get nbPrograms(): number;
244
+ /**
245
+ * Number of bytes read/written through I/O context.
246
+ *
247
+ * Direct mapping to avio_tell(AVFormatContext->pb).
248
+ */
249
+ get pbBytes(): bigint;
250
+ /**
251
+ * Format probe score.
252
+ *
253
+ * Confidence score from format detection (0-100).
254
+ * Higher values indicate more confident detection.
255
+ *
256
+ * Direct mapping to AVFormatContext->probe_score.
257
+ */
258
+ get probeScore(): number;
259
+ /**
260
+ * Allocate a format context.
261
+ *
262
+ * Allocates the context structure. Usually not needed
263
+ * as openInput/allocOutputContext2 handle this.
264
+ *
265
+ * Direct mapping to avformat_alloc_context().
266
+ *
267
+ * @example
268
+ * ```typescript
269
+ * const ctx = new FormatContext();
270
+ * ctx.allocContext();
271
+ * // Context is now allocated
272
+ * ```
273
+ */
274
+ allocContext(): void;
275
+ /**
276
+ * Allocate an output format context.
277
+ *
278
+ * Allocates and configures context for writing.
279
+ * Format is determined by parameters in priority order.
280
+ *
281
+ * Direct mapping to avformat_alloc_output_context2().
282
+ *
283
+ * @param oformat - Specific output format to use
284
+ *
285
+ * @param formatName - Format name (e.g., 'mp4', 'mkv')
286
+ *
287
+ * @param filename - Filename to guess format from extension
288
+ *
289
+ * @returns 0 on success, negative AVERROR on error:
290
+ * - AVERROR_ENOMEM: Memory allocation failure
291
+ * - AVERROR_EINVAL: Invalid parameters
292
+ *
293
+ * @example
294
+ * ```typescript
295
+ * import { FFmpegError } from 'node-av';
296
+ *
297
+ * const ctx = new FormatContext();
298
+ * const ret = ctx.allocOutputContext2(null, 'mp4', 'output.mp4');
299
+ * FFmpegError.throwIfError(ret, 'allocOutputContext2');
300
+ * ```
301
+ *
302
+ * @see {@link openOutput} To open output file
303
+ * @see {@link writeHeader} To write file header
304
+ */
305
+ allocOutputContext2(oformat: OutputFormat | null, formatName: string | null, filename: string | null): number;
306
+ /**
307
+ * Free the format context.
308
+ *
309
+ * Releases all resources. The context becomes invalid.
310
+ *
311
+ * Direct mapping to avformat_free_context().
312
+ *
313
+ * @example
314
+ * ```typescript
315
+ * ctx.freeContext();
316
+ * // Context is now invalid
317
+ * ```
318
+ *
319
+ * @see {@link Symbol.asyncDispose} For automatic cleanup
320
+ */
321
+ freeContext(): void;
322
+ /**
323
+ * Open output file for writing.
324
+ *
325
+ * Opens the output file specified in url.
326
+ * Must call allocOutputContext2 first.
327
+ *
328
+ * Direct mapping to avio_open2().
329
+ *
330
+ * @returns 0 on success, negative AVERROR on error:
331
+ * - AVERROR_ENOENT: File not found
332
+ * - AVERROR_EACCES: Permission denied
333
+ * - AVERROR_EIO: I/O error
334
+ *
335
+ * @example
336
+ * ```typescript
337
+ * import { FFmpegError } from 'node-av';
338
+ *
339
+ * const ret = await ctx.openOutput();
340
+ * FFmpegError.throwIfError(ret, 'openOutput');
341
+ * ```
342
+ *
343
+ * @see {@link allocOutputContext2} Must be called first
344
+ * @see {@link closeOutput} To close output
345
+ */
346
+ openOutput(): Promise<number>;
347
+ /**
348
+ * Open output file synchronously.
349
+ * Synchronous version of openOutput.
350
+ *
351
+ * Opens output file for writing.
352
+ * I/O context must be set before calling.
353
+ *
354
+ * Direct mapping to avio_open2().
355
+ *
356
+ * @returns 0 on success, negative AVERROR on error:
357
+ * - AVERROR(EIO): I/O error
358
+ * - AVERROR(ENOMEM): Memory allocation failure
359
+ *
360
+ * @example
361
+ * ```typescript
362
+ * import { FFmpegError } from 'node-av';
363
+ *
364
+ * const ret = ctx.openOutputSync();
365
+ * FFmpegError.throwIfError(ret, 'openOutputSync');
366
+ * ```
367
+ *
368
+ * @see {@link openOutput} For async version
369
+ */
370
+ openOutputSync(): number;
371
+ /**
372
+ * Close output file.
373
+ *
374
+ * Closes the output file and releases I/O resources.
375
+ *
376
+ * Direct mapping to avio_closep().
377
+ *
378
+ * @returns Promise that resolves when closed
379
+ *
380
+ * @example
381
+ * ```typescript
382
+ * await ctx.closeOutput();
383
+ * // Output file closed
384
+ * ```
385
+ *
386
+ * @see {@link openOutput} To open output
387
+ */
388
+ closeOutput(): Promise<void>;
389
+ /**
390
+ * Close output file synchronously.
391
+ * Synchronous version of closeOutput.
392
+ *
393
+ * Closes the output file and releases I/O resources.
394
+ *
395
+ * Direct mapping to avio_closep().
396
+ *
397
+ * @example
398
+ * ```typescript
399
+ * ctx.closeOutputSync();
400
+ * // Output file closed
401
+ * ```
402
+ *
403
+ * @see {@link closeOutput} For async version
404
+ */
405
+ closeOutputSync(): void;
406
+ /**
407
+ * Open input file for reading.
408
+ *
409
+ * Opens and probes the input file, detecting format automatically
410
+ * unless specified.
411
+ *
412
+ * Direct mapping to avformat_open_input().
413
+ *
414
+ * @param url - URL or file path to open
415
+ *
416
+ * @param fmt - Force specific input format (null for auto-detect)
417
+ *
418
+ * @param options - Format-specific options
419
+ *
420
+ * @returns 0 on success, negative AVERROR on error:
421
+ * - AVERROR_ENOENT: File not found
422
+ * - AVERROR_INVALIDDATA: Invalid file format
423
+ * - AVERROR_EIO: I/O error
424
+ *
425
+ * @example
426
+ * ```typescript
427
+ * import { FFmpegError } from 'node-av';
428
+ *
429
+ * const ret = await ctx.openInput('input.mp4');
430
+ * FFmpegError.throwIfError(ret, 'openInput');
431
+ * ```
432
+ *
433
+ * @see {@link findStreamInfo} To analyze streams after opening
434
+ * @see {@link closeInput} To close input
435
+ */
436
+ openInput(url: string, fmt?: InputFormat | null, options?: Dictionary | null): Promise<number>;
437
+ /**
438
+ * Open an input file or URL synchronously.
439
+ * Synchronous version of openInput.
440
+ *
441
+ * Opens a media file or stream for reading.
442
+ * The format is auto-detected if not specified.
443
+ *
444
+ * Direct mapping to avformat_open_input().
445
+ *
446
+ * @param url - File path or URL to open
447
+ *
448
+ * @param fmt - Force specific format (null for auto-detect)
449
+ *
450
+ * @param options - Format-specific options
451
+ *
452
+ * @returns 0 on success, negative AVERROR on error:
453
+ * - AVERROR_EINVAL: Invalid arguments
454
+ * - AVERROR(EIO): I/O error
455
+ * - AVERROR(ENOMEM): Memory allocation failure
456
+ *
457
+ * @example
458
+ * ```typescript
459
+ * import { FFmpegError } from 'node-av';
460
+ *
461
+ * const ret = ctx.openInputSync('input.mp4');
462
+ * FFmpegError.throwIfError(ret, 'openInputSync');
463
+ * ```
464
+ *
465
+ * @see {@link openInput} For async version
466
+ */
467
+ openInputSync(url: string, fmt?: InputFormat | null, options?: Dictionary | null): number;
468
+ /**
469
+ * Close an input format context.
470
+ *
471
+ * Closes input file and releases resources.
472
+ * A pb with JS callbacks stops serving this input: a read, seek or open
473
+ * still waiting for one of its callbacks fails with AVERROR_EXIT, and its
474
+ * callbacks are not called again, so a stalled source cannot block the close.
475
+ *
476
+ * Direct mapping to avformat_close_input().
477
+ *
478
+ * @param detachPb - Forget a caller-owned pb (custom IOContext) once the
479
+ * reader thread has stopped, so it is not closed with the input. Setting
480
+ * `pb = null` yourself throws while an async reader is active.
481
+ *
482
+ * @returns Promise that resolves when closed
483
+ *
484
+ * @example
485
+ * ```typescript
486
+ * await ctx.closeInput();
487
+ * // Input closed and context freed
488
+ * ```
489
+ *
490
+ * @see {@link openInput} To open input
491
+ */
492
+ closeInput(detachPb?: boolean): Promise<void>;
493
+ /**
494
+ * Close an input format context synchronously.
495
+ * Synchronous version of closeInput.
496
+ *
497
+ * Closes input file and releases resources.
498
+ * A pb with JS callbacks stops serving this input (see closeInput).
499
+ *
500
+ * Direct mapping to avformat_close_input().
501
+ *
502
+ * @example
503
+ * ```typescript
504
+ * ctx.closeInputSync();
505
+ * // Input closed and context freed
506
+ * ```
507
+ *
508
+ * @see {@link closeInput} For async version
509
+ *
510
+ * @param detachPb - Forget a caller-owned pb once the reader stopped (see closeInput)
511
+ */
512
+ closeInputSync(detachPb?: boolean): void;
513
+ /**
514
+ * Analyze streams to get stream info.
515
+ *
516
+ * Reads packet headers to fill in stream information.
517
+ * Should be called after openInput for accurate stream data.
518
+ *
519
+ * Direct mapping to avformat_find_stream_info().
520
+ *
521
+ * @param options - Per-stream options array
522
+ *
523
+ * @returns >=0 on success, negative AVERROR on error:
524
+ * - AVERROR_EOF: End of file reached
525
+ * - AVERROR_ENOMEM: Memory allocation failure
526
+ *
527
+ * @example
528
+ * ```typescript
529
+ * import { FFmpegError } from 'node-av';
530
+ *
531
+ * const ret = await ctx.findStreamInfo();
532
+ * FFmpegError.throwIfError(ret, 'findStreamInfo');
533
+ * console.log(`Found ${ctx.nbStreams} streams`);
534
+ * ```
535
+ *
536
+ * @see {@link findStreamInfoSync} For synchronous version
537
+ * @see {@link openInput} Must be called first
538
+ */
539
+ findStreamInfo(options?: Dictionary[] | null): Promise<number>;
540
+ /**
541
+ * Analyze streams to get stream info synchronously.
542
+ * Synchronous version of findStreamInfo.
543
+ *
544
+ * Reads packet headers to fill in stream information.
545
+ * Should be called after openInputSync for accurate stream data.
546
+ *
547
+ * Direct mapping to avformat_find_stream_info().
548
+ *
549
+ * @param options - Per-stream options array
550
+ *
551
+ * @returns >=0 on success, negative AVERROR on error:
552
+ * - AVERROR_EOF: End of file reached
553
+ * - AVERROR_ENOMEM: Memory allocation failure
554
+ *
555
+ * @example
556
+ * ```typescript
557
+ * import { FFmpegError } from 'node-av';
558
+ *
559
+ * const ret = ctx.findStreamInfoSync();
560
+ * FFmpegError.throwIfError(ret, 'findStreamInfoSync');
561
+ * console.log(`Found ${ctx.nbStreams} streams`);
562
+ * ```
563
+ *
564
+ * @see {@link findStreamInfo} For async version
565
+ */
566
+ findStreamInfoSync(options?: Dictionary[] | null): number;
567
+ /**
568
+ * Read next packet from the input.
569
+ *
570
+ * Reads and returns the next packet in the stream.
571
+ * Packet must be unreferenced after use.
572
+ *
573
+ * Direct mapping to av_read_frame().
574
+ *
575
+ * @param pkt - Packet to read into
576
+ *
577
+ * @returns 0 on success, negative AVERROR on error:
578
+ * - AVERROR_EOF: End of file
579
+ * - AVERROR_EXIT: Aborted by interrupt() or closeInput()
580
+ *
581
+ * The first call starts the context's own reader thread, which is the only
582
+ * thread touching the input from then on: it blocks in av_read_frame(),
583
+ * retries EAGAIN itself and hands packets over through a bounded queue, so
584
+ * a waiting read never occupies a libuv threadpool thread. seekFrame(),
585
+ * seekFile(), sendRTSPPacket() and findStreamInfo() run on that thread
586
+ * between two reads; the sync variants throw while it is active.
587
+ *
588
+ * @example
589
+ * ```typescript
590
+ * import { FFmpegError } from 'node-av';
591
+ * import { AVERROR_EOF } from 'node-av';
592
+ *
593
+ * const packet = new Packet();
594
+ * packet.alloc();
595
+ *
596
+ * let ret;
597
+ * while ((ret = await ctx.readFrame(packet)) >= 0) {
598
+ * // Process packet
599
+ * console.log(`Stream ${packet.streamIndex}, PTS: ${packet.pts}`);
600
+ * packet.unref();
601
+ * }
602
+ *
603
+ * if (ret !== AVERROR_EOF) {
604
+ * FFmpegError.throwIfError(ret, 'readFrame');
605
+ * }
606
+ * ```
607
+ *
608
+ * @see {@link seekFrame} To seek before reading
609
+ */
610
+ readFrame(pkt: Packet): Promise<number>;
611
+ /**
612
+ * Read next packet from the input synchronously.
613
+ * Synchronous version of readFrame.
614
+ *
615
+ * Reads and returns the next packet in the stream.
616
+ * Packet must be unreferenced after use.
617
+ *
618
+ * Direct mapping to av_read_frame().
619
+ *
620
+ * @param pkt - Packet to read into
621
+ *
622
+ * @returns 0 on success, negative AVERROR on error:
623
+ * - AVERROR_EOF: End of file
624
+ * - AVERROR_EAGAIN: Temporarily unavailable
625
+ *
626
+ * @example
627
+ * ```typescript
628
+ * import { FFmpegError } from 'node-av';
629
+ * import { AVERROR_EOF } from 'node-av';
630
+ *
631
+ * const packet = new Packet();
632
+ * packet.alloc();
633
+ *
634
+ * let ret;
635
+ * while ((ret = ctx.readFrameSync(packet)) >= 0) {
636
+ * // Process packet
637
+ * console.log(`Stream ${packet.streamIndex}, PTS: ${packet.pts}`);
638
+ * packet.unref();
639
+ * }
640
+ *
641
+ * if (ret !== AVERROR_EOF) {
642
+ * FFmpegError.throwIfError(ret, 'readFrameSync');
643
+ * }
644
+ * ```
645
+ *
646
+ * @see {@link readFrame} For async version
647
+ */
648
+ readFrameSync(pkt: Packet): number;
649
+ /**
650
+ * Seek to timestamp in stream.
651
+ *
652
+ * Seeks to the keyframe at or before the given timestamp.
653
+ *
654
+ * Direct mapping to av_seek_frame().
655
+ *
656
+ * @param streamIndex - Stream to seek in (-1 for default)
657
+ *
658
+ * @param timestamp - Target timestamp in stream time base
659
+ *
660
+ * @param flags - Seek flags (AVSEEK_FLAG_*)
661
+ *
662
+ * @returns >=0 on success, negative AVERROR on error:
663
+ * - AVERROR_EINVAL: Invalid parameters
664
+ * - AVERROR_EOF: Seek beyond file
665
+ *
666
+ * @example
667
+ * ```typescript
668
+ * import { FFmpegError } from 'node-av';
669
+ * import { AVSEEK_FLAG_BACKWARD } from 'node-av/constants';
670
+ *
671
+ * // Seek to 10 seconds (assuming 1/1000 time base)
672
+ * const ret = await ctx.seekFrame(videoStreamIndex, 10000n, AVSEEK_FLAG_BACKWARD);
673
+ * FFmpegError.throwIfError(ret, 'seekFrame');
674
+ * ```
675
+ *
676
+ * @see {@link seekFile} For more precise seeking
677
+ */
678
+ seekFrame(streamIndex: number, timestamp: bigint, flags?: AVSeekFlag): Promise<number>;
679
+ /**
680
+ * Seek to timestamp in stream synchronously.
681
+ * Synchronous version of seekFrame.
682
+ *
683
+ * Seeks to closest keyframe at or before timestamp.
684
+ * Timestamp is in stream timebase units.
685
+ *
686
+ * Direct mapping to av_seek_frame().
687
+ *
688
+ * @param streamIndex - Stream to seek in (-1 for default)
689
+ *
690
+ * @param timestamp - Target timestamp in stream timebase
691
+ *
692
+ * @param flags - Seek flags (AVSEEK_FLAG_*)
693
+ *
694
+ * @returns >=0 on success, negative AVERROR on error:
695
+ * - AVERROR_EINVAL: Invalid arguments
696
+ * - AVERROR(EIO): I/O error
697
+ *
698
+ * @example
699
+ * ```typescript
700
+ * import { FFmpegError } from 'node-av';
701
+ * import { AVSEEK_FLAG_BACKWARD } from 'node-av/constants';
702
+ *
703
+ * // Seek to 10 seconds
704
+ * const timestamp = 10n * 1000000n; // Assuming microsecond timebase
705
+ * const ret = ctx.seekFrameSync(-1, timestamp, AVSEEK_FLAG_BACKWARD);
706
+ * FFmpegError.throwIfError(ret, 'seekFrameSync');
707
+ * ```
708
+ *
709
+ * @see {@link seekFrame} For async version
710
+ */
711
+ seekFrameSync(streamIndex: number, timestamp: bigint, flags?: AVSeekFlag): number;
712
+ /**
713
+ * Seek to timestamp with bounds.
714
+ *
715
+ * More precise seeking with min/max timestamp bounds.
716
+ *
717
+ * Direct mapping to avformat_seek_file().
718
+ *
719
+ * @param streamIndex - Stream to seek in (-1 for default)
720
+ *
721
+ * @param minTs - Minimum acceptable timestamp
722
+ *
723
+ * @param ts - Target timestamp
724
+ *
725
+ * @param maxTs - Maximum acceptable timestamp
726
+ *
727
+ * @param flags - Seek flags
728
+ *
729
+ * @returns >=0 on success, negative AVERROR on error
730
+ *
731
+ * @example
732
+ * ```typescript
733
+ * import { FFmpegError } from 'node-av';
734
+ *
735
+ * // Seek to 10s with 0.5s tolerance
736
+ * const target = 10000n;
737
+ * const ret = await ctx.seekFile(
738
+ * -1,
739
+ * target - 500n,
740
+ * target,
741
+ * target + 500n
742
+ * );
743
+ * FFmpegError.throwIfError(ret, 'seekFile');
744
+ * ```
745
+ *
746
+ * @see {@link seekFileSync} For synchronous version
747
+ * @see {@link seekFrame} For simpler seeking
748
+ */
749
+ seekFile(streamIndex: number, minTs: bigint, ts: bigint, maxTs: bigint, flags?: AVSeekFlag): Promise<number>;
750
+ /**
751
+ * Seek to timestamp with bounds synchronously.
752
+ * Synchronous version of seekFile.
753
+ *
754
+ * More precise seeking with min/max timestamp bounds.
755
+ *
756
+ * Direct mapping to avformat_seek_file().
757
+ *
758
+ * @param streamIndex - Stream to seek in (-1 for default)
759
+ *
760
+ * @param minTs - Minimum acceptable timestamp
761
+ *
762
+ * @param ts - Target timestamp
763
+ *
764
+ * @param maxTs - Maximum acceptable timestamp
765
+ *
766
+ * @param flags - Seek flags
767
+ *
768
+ * @returns >=0 on success, negative AVERROR on error
769
+ *
770
+ * @example
771
+ * ```typescript
772
+ * import { FFmpegError } from 'node-av';
773
+ *
774
+ * // Seek to 10s with 0.5s tolerance
775
+ * const target = 10000n;
776
+ * const ret = ctx.seekFileSync(
777
+ * -1,
778
+ * target - 500n,
779
+ * target,
780
+ * target + 500n
781
+ * );
782
+ * FFmpegError.throwIfError(ret, 'seekFileSync');
783
+ * ```
784
+ *
785
+ * @see {@link seekFile} For async version
786
+ * @see {@link seekFrameSync} For simpler seeking
787
+ */
788
+ seekFileSync(streamIndex: number, minTs: bigint, ts: bigint, maxTs: bigint, flags?: AVSeekFlag): number;
789
+ /**
790
+ * Write file header.
791
+ *
792
+ * Writes the file header and initializes output.
793
+ * Must be called before writing packets.
794
+ *
795
+ * Direct mapping to avformat_write_header().
796
+ *
797
+ * @param options - Muxer-specific options
798
+ *
799
+ * @returns 0 on success, negative AVERROR on error:
800
+ * - AVERROR_EINVAL: Invalid parameters
801
+ * - AVERROR_EIO: I/O error
802
+ *
803
+ * @example
804
+ * ```typescript
805
+ * import { FFmpegError } from 'node-av';
806
+ *
807
+ * const ret = await ctx.writeHeader();
808
+ * FFmpegError.throwIfError(ret, 'writeHeader');
809
+ * // Now ready to write packets
810
+ * ```
811
+ *
812
+ * @see {@link writeTrailer} To finalize file
813
+ * @see {@link writeFrame} To write packets
814
+ */
815
+ writeHeader(options?: Dictionary | null): Promise<number>;
816
+ /**
817
+ * Write file header synchronously.
818
+ * Synchronous version of writeHeader.
819
+ *
820
+ * Writes format header to output file.
821
+ * Must be called before writing packets.
822
+ *
823
+ * Direct mapping to avformat_write_header().
824
+ *
825
+ * @param options - Muxer-specific options
826
+ *
827
+ * @returns 0 on success, negative AVERROR on error:
828
+ * - AVERROR_EINVAL: Invalid parameters
829
+ *
830
+ * @example
831
+ * ```typescript
832
+ * import { FFmpegError } from 'node-av';
833
+ *
834
+ * const ret = ctx.writeHeaderSync();
835
+ * FFmpegError.throwIfError(ret, 'writeHeaderSync');
836
+ * ```
837
+ *
838
+ * @see {@link writeHeader} For async version
839
+ */
840
+ writeHeaderSync(options?: Dictionary | null): number;
841
+ /**
842
+ * Write packet to output.
843
+ *
844
+ * Writes a packet directly without interleaving.
845
+ * Caller must handle correct interleaving.
846
+ *
847
+ * Direct mapping to av_write_frame().
848
+ *
849
+ * @param pkt - Packet to write (null to flush)
850
+ *
851
+ * @returns 0 on success, negative AVERROR on error:
852
+ * - AVERROR_EINVAL: Invalid packet
853
+ * - AVERROR_EIO: I/O error
854
+ *
855
+ * @example
856
+ * ```typescript
857
+ * import { FFmpegError } from 'node-av';
858
+ *
859
+ * const ret = await ctx.writeFrame(packet);
860
+ * FFmpegError.throwIfError(ret, 'writeFrame');
861
+ * ```
862
+ *
863
+ * @see {@link interleavedWriteFrame} For automatic interleaving
864
+ */
865
+ writeFrame(pkt: Packet | null): Promise<number>;
866
+ /**
867
+ * Write packet to output synchronously.
868
+ * Synchronous version of writeFrame.
869
+ *
870
+ * Writes a packet directly without interleaving.
871
+ * Caller must handle correct interleaving.
872
+ *
873
+ * Direct mapping to av_write_frame().
874
+ *
875
+ * @param pkt - Packet to write (null to flush)
876
+ *
877
+ * @returns 0 on success, negative AVERROR on error
878
+ *
879
+ * @example
880
+ * ```typescript
881
+ * import { FFmpegError } from 'node-av';
882
+ *
883
+ * const ret = ctx.writeFrameSync(packet);
884
+ * FFmpegError.throwIfError(ret, 'writeFrameSync');
885
+ * ```
886
+ *
887
+ * @see {@link writeFrame} For async version
888
+ */
889
+ writeFrameSync(pkt: Packet | null): number;
890
+ /**
891
+ * Write packet with automatic interleaving.
892
+ *
893
+ * Writes packet with proper interleaving for muxing.
894
+ * Preferred method for writing packets.
895
+ *
896
+ * Direct mapping to av_interleaved_write_frame().
897
+ *
898
+ * @param pkt - Packet to write (null to flush)
899
+ *
900
+ * @returns 0 on success, negative AVERROR on error:
901
+ * - AVERROR_EINVAL: Invalid packet
902
+ * - AVERROR_EIO: I/O error
903
+ *
904
+ * @example
905
+ * ```typescript
906
+ * import { FFmpegError } from 'node-av';
907
+ *
908
+ * // Write with proper interleaving
909
+ * const ret = await ctx.interleavedWriteFrame(packet);
910
+ * FFmpegError.throwIfError(ret, 'interleavedWriteFrame');
911
+ *
912
+ * // Flush buffered packets
913
+ * await ctx.interleavedWriteFrame(null);
914
+ * ```
915
+ *
916
+ * @see {@link writeFrame} For direct writing
917
+ */
918
+ interleavedWriteFrame(pkt: Packet | null): Promise<number>;
919
+ /**
920
+ * Write packet with automatic interleaving synchronously.
921
+ * Synchronous version of interleavedWriteFrame.
922
+ *
923
+ * Writes packet with proper interleaving for muxing.
924
+ * Preferred method for writing packets.
925
+ *
926
+ * Direct mapping to av_interleaved_write_frame().
927
+ *
928
+ * @param pkt - Packet to write (null to flush)
929
+ *
930
+ * @returns 0 on success, negative AVERROR on error:
931
+ * - AVERROR_EINVAL: Invalid parameters
932
+ * - AVERROR(EIO): I/O error
933
+ *
934
+ * @example
935
+ * ```typescript
936
+ * import { FFmpegError } from 'node-av';
937
+ *
938
+ * // Write packet
939
+ * const ret = ctx.interleavedWriteFrameSync(packet);
940
+ * FFmpegError.throwIfError(ret, 'interleavedWriteFrameSync');
941
+ *
942
+ * // Flush interleaved packets
943
+ * ctx.interleavedWriteFrameSync(null);
944
+ * ```
945
+ *
946
+ * @see {@link interleavedWriteFrame} For async version
947
+ */
948
+ interleavedWriteFrameSync(pkt: Packet | null): number;
949
+ /**
950
+ * Write file trailer.
951
+ *
952
+ * Finalizes the output file, writing index and metadata.
953
+ * Must be called to properly close output files.
954
+ *
955
+ * Direct mapping to av_write_trailer().
956
+ *
957
+ * @returns 0 on success, negative AVERROR on error:
958
+ * - AVERROR_EIO: I/O error
959
+ *
960
+ * @example
961
+ * ```typescript
962
+ * import { FFmpegError } from 'node-av';
963
+ *
964
+ * const ret = await ctx.writeTrailer();
965
+ * FFmpegError.throwIfError(ret, 'writeTrailer');
966
+ * // File is now finalized
967
+ * ```
968
+ *
969
+ * @see {@link writeHeader} Must be called first
970
+ */
971
+ writeTrailer(): Promise<number>;
972
+ /**
973
+ * Write file trailer synchronously.
974
+ * Synchronous version of writeTrailer.
975
+ *
976
+ * Finalizes the output file, writing index and metadata.
977
+ * Must be called to properly close output files.
978
+ *
979
+ * Direct mapping to av_write_trailer().
980
+ *
981
+ * @returns 0 on success, negative AVERROR on error
982
+ *
983
+ * @example
984
+ * ```typescript
985
+ * import { FFmpegError } from 'node-av';
986
+ *
987
+ * const ret = ctx.writeTrailerSync();
988
+ * FFmpegError.throwIfError(ret, 'writeTrailerSync');
989
+ * // File is now finalized
990
+ * ```
991
+ *
992
+ * @see {@link writeTrailer} For async version
993
+ */
994
+ writeTrailerSync(): number;
995
+ /**
996
+ * Flush buffered data.
997
+ *
998
+ * Flushes any buffered packets in muxers.
999
+ *
1000
+ * Direct mapping to avio_flush().
1001
+ *
1002
+ * @example
1003
+ * ```typescript
1004
+ * await ctx.flush();
1005
+ * // Buffered data written to output
1006
+ * ```
1007
+ */
1008
+ flush(): Promise<void>;
1009
+ /**
1010
+ * Flush buffered data synchronously.
1011
+ * Synchronous version of flush.
1012
+ *
1013
+ * Flushes any buffered packets in muxers.
1014
+ *
1015
+ * Direct mapping to avio_flush().
1016
+ *
1017
+ * @example
1018
+ * ```typescript
1019
+ * ctx.flushSync();
1020
+ * // Buffered data written to output
1021
+ * ```
1022
+ *
1023
+ * @see {@link flush} For async version
1024
+ */
1025
+ flushSync(): void;
1026
+ /**
1027
+ * Print format information.
1028
+ *
1029
+ * Dumps human-readable format info to stderr.
1030
+ * Useful for debugging.
1031
+ *
1032
+ * Direct mapping to av_dump_format().
1033
+ *
1034
+ * @param index - Stream index to highlight (-1 for none)
1035
+ *
1036
+ * @param url - URL to display
1037
+ *
1038
+ * @param isOutput - True for output format, false for input
1039
+ *
1040
+ * @example
1041
+ * ```typescript
1042
+ * // Dump input format info
1043
+ * ctx.dumpFormat(0, 'input.mp4', false);
1044
+ *
1045
+ * // Dump output format info
1046
+ * ctx.dumpFormat(0, 'output.mp4', true);
1047
+ * ```
1048
+ */
1049
+ dumpFormat(index: number, url: string, isOutput: boolean): void;
1050
+ /**
1051
+ * Find the best stream of a given type.
1052
+ *
1053
+ * Selects the most suitable stream (e.g., default audio/video).
1054
+ *
1055
+ * Direct mapping to av_find_best_stream().
1056
+ *
1057
+ * @param type - Media type to find (AVMEDIA_TYPE_*)
1058
+ *
1059
+ * @param wantedStreamNb - Preferred stream index (-1 for auto)
1060
+ *
1061
+ * @param relatedStream - Related stream for audio/video sync (-1 for none)
1062
+ *
1063
+ * @returns Stream index, or negative AVERROR if not found
1064
+ *
1065
+ * @example
1066
+ * ```typescript
1067
+ * import { AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO } from 'node-av/constants';
1068
+ *
1069
+ * const videoIndex = ctx.findBestStream(AVMEDIA_TYPE_VIDEO);
1070
+ * if (videoIndex >= 0) {
1071
+ * console.log(`Best video stream: ${videoIndex}`);
1072
+ * }
1073
+ *
1074
+ * const audioIndex = ctx.findBestStream(AVMEDIA_TYPE_AUDIO);
1075
+ * if (audioIndex >= 0) {
1076
+ * console.log(`Best audio stream: ${audioIndex}`);
1077
+ * }
1078
+ * ```
1079
+ */
1080
+ findBestStream(type: AVMediaType, wantedStreamNb?: number, relatedStream?: number): number;
1081
+ /**
1082
+ * Find the best stream and its decoder.
1083
+ *
1084
+ * @param type - Media type to find
1085
+ *
1086
+ * @param wantedStreamNb - Preferred stream index
1087
+ *
1088
+ * @param relatedStream - Related stream index
1089
+ *
1090
+ * @param wantDecoder - True to also find decoder
1091
+ *
1092
+ * @param flags - Reserved flags
1093
+ *
1094
+ * @returns Object with stream index and decoder
1095
+ */
1096
+ findBestStream(type: AVMediaType, wantedStreamNb: number, relatedStream: number, wantDecoder: true, flags?: number): {
1097
+ streamIndex: number;
1098
+ decoder: Codec | null;
1099
+ };
1100
+ /**
1101
+ * Add a new stream to output context.
1102
+ *
1103
+ * Creates a new stream for writing.
1104
+ *
1105
+ * Direct mapping to avformat_new_stream().
1106
+ *
1107
+ * @param c - Codec for the stream (optional)
1108
+ *
1109
+ * @returns New stream instance
1110
+ *
1111
+ * @example
1112
+ * ```typescript
1113
+ * import { Codec } from 'node-av';
1114
+ * import { AV_CODEC_ID_H264 } from 'node-av/constants';
1115
+ *
1116
+ * const codec = Codec.findEncoder(AV_CODEC_ID_H264);
1117
+ * const stream = ctx.newStream(codec);
1118
+ * stream.id = ctx.nbStreams - 1;
1119
+ * ```
1120
+ *
1121
+ * @see {@link Stream} For stream configuration
1122
+ */
1123
+ newStream(c?: Codec | null): Stream;
1124
+ /**
1125
+ * Set format flags.
1126
+ *
1127
+ * Sets one or more flags using bitwise OR. Allows setting multiple flags
1128
+ * without manually performing bitwise operations.
1129
+ *
1130
+ * @param flags - One or more flag values to set
1131
+ *
1132
+ * @example
1133
+ * ```typescript
1134
+ * import { AVFMT_FLAG_GENPTS, AVFMT_FLAG_IGNIDX } from 'node-av/constants';
1135
+ *
1136
+ * // Set multiple flags at once
1137
+ * formatContext.setFlags(AVFMT_FLAG_GENPTS, AVFMT_FLAG_IGNIDX);
1138
+ * ```
1139
+ *
1140
+ * @see {@link clearFlags} To unset flags
1141
+ * @see {@link hasFlags} To check flags
1142
+ * @see {@link flags} For direct flag access
1143
+ */
1144
+ setFlags(...flags: AVFormatFlag[]): void;
1145
+ /**
1146
+ * Clear format flags.
1147
+ *
1148
+ * Clears one or more flags using bitwise AND NOT. Allows clearing multiple
1149
+ * flags without manually performing bitwise operations.
1150
+ *
1151
+ * @param flags - One or more flag values to clear
1152
+ *
1153
+ * @example
1154
+ * ```typescript
1155
+ * import { AVFMT_FLAG_IGNIDX } from 'node-av/constants';
1156
+ *
1157
+ * // Clear specific flag
1158
+ * formatContext.clearFlags(AVFMT_FLAG_IGNIDX);
1159
+ * ```
1160
+ *
1161
+ * @see {@link setFlags} To set flags
1162
+ * @see {@link hasFlags} To check flags
1163
+ * @see {@link flags} For direct flag access
1164
+ */
1165
+ clearFlags(...flags: AVFormatFlag[]): void;
1166
+ /**
1167
+ * Check if format context has specific flags.
1168
+ *
1169
+ * Tests whether all specified flags are set using bitwise AND.
1170
+ *
1171
+ * @param flags - One or more flag values to check
1172
+ *
1173
+ * @returns true if all specified flags are set, false otherwise
1174
+ *
1175
+ * @example
1176
+ * ```typescript
1177
+ * import { AVFMT_FLAG_GENPTS } from 'node-av/constants';
1178
+ *
1179
+ * if (formatContext.hasFlags(AVFMT_FLAG_GENPTS)) {
1180
+ * console.log('GENPTS flag is set');
1181
+ * }
1182
+ * ```
1183
+ *
1184
+ * @see {@link setFlags} To set flags
1185
+ * @see {@link clearFlags} To unset flags
1186
+ * @see {@link flags} For direct flag access
1187
+ */
1188
+ hasFlags(...flags: AVFormatFlag[]): boolean;
1189
+ /**
1190
+ * Get RTSP stream information.
1191
+ *
1192
+ * Returns information about all RTSP streams including codec details.
1193
+ * Only works with RTSP input contexts.
1194
+ *
1195
+ * @returns Array of stream information objects with codec details, or null if not RTSP
1196
+ *
1197
+ * @example
1198
+ * ```typescript
1199
+ * const ctx = new FormatContext();
1200
+ * await ctx.openInput('rtsp://camera/stream?backchannel=1');
1201
+ *
1202
+ * const rtspStreams = ctx.getRTSPStreamInfo();
1203
+ * if (rtspStreams) {
1204
+ * // Find sendonly stream (backchannel)
1205
+ * const backchannel = rtspStreams.find(s => s.direction === 'sendonly');
1206
+ * if (backchannel) {
1207
+ * console.log(`Transport: ${backchannel.transport}`);
1208
+ * console.log(`Codec ID: ${backchannel.codecId}`);
1209
+ * console.log(`MIME Type: ${backchannel.mimeType}`);
1210
+ * console.log(`Payload Type: ${backchannel.payloadType}`);
1211
+ * if (backchannel.sampleRate) {
1212
+ * console.log(`Audio: ${backchannel.sampleRate}Hz, ${backchannel.channels} channels`);
1213
+ * }
1214
+ * }
1215
+ * }
1216
+ * ```
1217
+ */
1218
+ getRTSPStreamInfo(): RTSPStreamInfo[] | null;
1219
+ /**
1220
+ * Interrupt any in-progress blocking I/O operation.
1221
+ *
1222
+ * Signals the interrupt callback so a blocking call (e.g. av_read_frame() on a
1223
+ * quiet RTSP socket) returns immediately instead of waiting for data. The
1224
+ * context is not freed and remains valid - this only aborts the pending
1225
+ * operation, so a reader can drain and shut down before closing the input.
1226
+ * An input pb with JS callbacks stops serving the input as on close: a call
1227
+ * waiting for one of its callbacks fails with AVERROR_EXIT, and its callbacks
1228
+ * are not called again.
1229
+ *
1230
+ * @example
1231
+ * ```typescript
1232
+ * ctx.interrupt(); // unblock a stalled readFrame()
1233
+ * ```
1234
+ *
1235
+ * @see {@link closeInput} To close and free the input
1236
+ */
1237
+ interrupt(): void;
1238
+ /**
1239
+ * Send RTP packet to RTSP stream (supports both TCP and UDP)
1240
+ *
1241
+ * Automatically handles transport-specific packet formatting:
1242
+ * - TCP: Sends with interleaved header ($channelId + length + RTP)
1243
+ * - UDP: Sends raw RTP packet directly to UDP socket
1244
+ *
1245
+ * Used for backchannel/talkback audio streaming.
1246
+ * Only works with RTSP input contexts.
1247
+ *
1248
+ * @param streamIndex - RTSP stream index
1249
+ *
1250
+ * @param rtpData - Raw RTP packet data (12-byte header + payload)
1251
+ *
1252
+ * @returns Promise resolving to number of bytes written on success, negative AVERROR on failure
1253
+ *
1254
+ * @example
1255
+ * ```typescript
1256
+ * // Get backchannel stream info
1257
+ * const streams = ctx.getRTSPStreamInfo();
1258
+ * const backchannel = streams.find(s => s.direction === 'sendonly');
1259
+ *
1260
+ * if (backchannel) {
1261
+ * // Send to camera (works with both TCP and UDP)
1262
+ * const ret = await ctx.sendRTSPPacket(backchannel.streamIndex, rtpPacket);
1263
+ * if (ret < 0) {
1264
+ * throw new Error(`Failed to send: ${ret}`);
1265
+ * }
1266
+ * }
1267
+ * ```
1268
+ *
1269
+ * @see {@link sendRTSPPacketSync} For synchronous version
1270
+ * @see {@link getRTSPStreamInfo} For getting stream info and transport type
1271
+ */
1272
+ sendRTSPPacket(streamIndex: number, rtpData: Buffer): Promise<number>;
1273
+ /**
1274
+ * Send RTP packet to RTSP stream (supports both TCP and UDP) synchronously.
1275
+ * Synchronous version of sendRTSPPacket.
1276
+ *
1277
+ * Automatically handles transport-specific packet formatting:
1278
+ * - TCP: Sends with interleaved header ($channelId + length + RTP)
1279
+ * - UDP: Sends raw RTP packet directly to UDP socket
1280
+ *
1281
+ * Used for backchannel/talkback audio streaming.
1282
+ * Only works with RTSP input contexts.
1283
+ *
1284
+ * @param streamIndex - RTSP stream index
1285
+ *
1286
+ * @param rtpData - Raw RTP packet data (12-byte header + payload)
1287
+ *
1288
+ * @returns Number of bytes written on success, negative AVERROR on failure
1289
+ *
1290
+ * @example
1291
+ * ```typescript
1292
+ * // Get backchannel stream info
1293
+ * const streams = ctx.getRTSPStreamInfo();
1294
+ * const backchannel = streams.find(s => s.direction === 'sendonly');
1295
+ *
1296
+ * if (backchannel) {
1297
+ * // Send to camera (works with both TCP and UDP)
1298
+ * const ret = ctx.sendRTSPPacketSync(backchannel.streamIndex, rtpPacket);
1299
+ * if (ret < 0) {
1300
+ * throw new Error(`Failed to send: ${ret}`);
1301
+ * }
1302
+ * }
1303
+ * ```
1304
+ *
1305
+ * @see {@link sendRTSPPacket} For asynchronous version
1306
+ * @see {@link getRTSPStreamInfo} For getting stream info and transport type
1307
+ */
1308
+ sendRTSPPacketSync(streamIndex: number, rtpData: Buffer): number;
1309
+ /**
1310
+ * Get the underlying native FormatContext object.
1311
+ *
1312
+ * @returns The native FormatContext binding object
1313
+ *
1314
+ * @internal
1315
+ */
1316
+ getNative(): NativeFormatContext;
1317
+ /**
1318
+ * Dispose of the format context.
1319
+ *
1320
+ * Implements the AsyncDisposable interface for automatic cleanup.
1321
+ * Closes input/output and frees resources.
1322
+ *
1323
+ * @returns Promise that resolves when disposed
1324
+ *
1325
+ * @example
1326
+ * ```typescript
1327
+ * {
1328
+ * await using ctx = new FormatContext();
1329
+ * await ctx.openInput('input.mp4');
1330
+ * // Use context...
1331
+ * } // Automatically closed and freed
1332
+ * ```
1333
+ */
1334
+ [Symbol.asyncDispose](): Promise<void>;
1335
+ }