@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,60 @@
1
+ /**
2
+ * Native bindings loader
3
+ *
4
+ * This module loads the native C++ bindings compiled by node-gyp.
5
+ * All native classes are accessed through this single entry point.
6
+ */
7
+ import { existsSync } from 'node:fs';
8
+ import { createRequire } from 'node:module';
9
+ import { resolve } from 'node:path';
10
+ import { getDirname } from '../utils/electron.js';
11
+ const __dirname = getDirname(import.meta.url);
12
+ /**
13
+ * Load the native binding
14
+ *
15
+ * @returns The loaded native binding interface
16
+ *
17
+ * @internal
18
+ */
19
+ function loadBinding() {
20
+ const require = createRequire(import.meta.url);
21
+ const errors = [];
22
+ // Detect platform
23
+ const platform = process.platform;
24
+ const arch = process.arch;
25
+ const platformArch = `${platform}-${arch}`;
26
+ const loadLocal = process.env.AV_FROM_SOURCE === '1';
27
+ // Local build directory (--build-from-source)
28
+ try {
29
+ const releasePath = resolve(__dirname, '..', '..', 'build', 'Release', 'node-av.node');
30
+ const binaryPath = resolve(__dirname, '..', '..', 'binary', 'node-av.node');
31
+ const rootPath = resolve(__dirname, '..', '..', 'node-av.node');
32
+ const localPath = [releasePath, binaryPath, rootPath];
33
+ for (const path of localPath) {
34
+ if (existsSync(path)) {
35
+ return require(path);
36
+ }
37
+ }
38
+ }
39
+ catch (err) {
40
+ errors.push(new Error(`Local build loading failed: ${err}`));
41
+ }
42
+ if (!loadLocal) {
43
+ try {
44
+ const packageName = `@revizly/node-av-${platformArch}`;
45
+ return require(`${packageName}/node-av.node`);
46
+ }
47
+ catch (err) {
48
+ errors.push(new Error(`Platform package not found or loading failed: ${err}`));
49
+ }
50
+ }
51
+ // All attempts failed
52
+ const errorMessages = errors.map((e) => e.message).join('\n ');
53
+ // prettier-ignore
54
+ throw new Error(`Could not load the node-av native binding for ${platformArch}.\n` +
55
+ `Errors:\n ${errorMessages}\n\n`);
56
+ }
57
+ // Load the native binding with fallback logic
58
+ const bindings = loadBinding();
59
+ export { bindings };
60
+ //# sourceMappingURL=binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding.js","sourceRoot":"","sources":["../../src/lib/binding.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAiDlD,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAoS9C;;;;;;GAMG;AACH,SAAS,WAAW;IAClB,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAY,EAAE,CAAC;IAE3B,kBAAkB;IAClB,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1B,MAAM,YAAY,GAAG,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC;IAC3C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,GAAG,CAAC;IAErD,8CAA8C;IAC9C,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;QACvF,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;QAC5E,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QAChE,MAAM,SAAS,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;QACtD,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC7B,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,+BAA+B,GAAG,EAAE,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,oBAAoB,YAAY,EAAE,CAAC;YACvD,OAAO,OAAO,CAAC,GAAG,WAAW,eAAe,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,iDAAiD,GAAG,EAAE,CAAC,CAAC,CAAC;QACjF,CAAC;IACH,CAAC;IAED,sBAAsB;IACtB,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChE,kBAAkB;IAClB,MAAM,IAAI,KAAK,CACb,iDAAiD,YAAY,KAAK;QAClE,cAAc,aAAa,MAAM,CAClC,CAAC;AACJ,CAAC;AAED,8CAA8C;AAC9C,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,379 @@
1
+ import { BitStreamFilter } from './bitstream-filter.js';
2
+ import { CodecParameters } from './codec-parameters.js';
3
+ import { OptionMember } from './option.js';
4
+ import { Rational } from './rational.js';
5
+ import type { NativeBitStreamFilterContext, NativeWrapper } from './native-types.js';
6
+ import type { Packet } from './packet.js';
7
+ /**
8
+ * Bitstream filter context for processing compressed video/audio streams.
9
+ *
10
+ * Applies bitstream filters to modify or analyze compressed packets without
11
+ * full decoding/encoding. Common uses include format conversion (e.g., H.264 MP4 to Annex B),
12
+ * metadata extraction, parameter set manipulation, and packet splitting/merging.
13
+ * Essential for stream compatibility between different containers and decoders.
14
+ *
15
+ * Direct mapping to FFmpeg's AVBSFContext.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { BitStreamFilterContext, BitStreamFilter, Packet, FFmpegError } from 'node-av';
20
+ *
21
+ * // Create and initialize H.264 stream format converter
22
+ * const ctx = new BitStreamFilterContext();
23
+ * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
24
+ * if (!filter) {
25
+ * throw new Error('H.264 filter not available');
26
+ * }
27
+ *
28
+ * let ret = ctx.alloc(filter);
29
+ * FFmpegError.throwIfError(ret, 'alloc');
30
+ *
31
+ * ret = ctx.init();
32
+ * FFmpegError.throwIfError(ret, 'init');
33
+ *
34
+ * // Process packets
35
+ * const inputPacket = new Packet();
36
+ * const outputPacket = new Packet();
37
+ *
38
+ * ret = await ctx.sendPacket(inputPacket);
39
+ * FFmpegError.throwIfError(ret, 'sendPacket');
40
+ *
41
+ * ret = await ctx.receivePacket(outputPacket);
42
+ * if (ret >= 0) {
43
+ * // Process filtered packet
44
+ * }
45
+ *
46
+ * // Cleanup
47
+ * ctx.free();
48
+ * ```
49
+ *
50
+ * @see {@link BitStreamFilter} For available filter types
51
+ * @see {@link Packet} For packet manipulation
52
+ */
53
+ export declare class BitStreamFilterContext extends OptionMember<NativeBitStreamFilterContext> implements Disposable, NativeWrapper<NativeBitStreamFilterContext> {
54
+ private _filter?;
55
+ constructor();
56
+ /**
57
+ * Check if the context has been initialized.
58
+ *
59
+ * Returns true if init() has been successfully called.
60
+ * The context must be initialized before sending/receiving packets.
61
+ */
62
+ get isInitialized(): boolean;
63
+ /**
64
+ * Input codec parameters.
65
+ *
66
+ * Parameters describing the input stream format.
67
+ * These are automatically configured from the input packets in most cases.
68
+ *
69
+ * Direct mapping to AVBSFContext->par_in.
70
+ */
71
+ get inputCodecParameters(): CodecParameters | null;
72
+ /**
73
+ * Output codec parameters.
74
+ *
75
+ * Parameters describing the output stream format after filtering.
76
+ * These reflect any changes made by the bitstream filter.
77
+ *
78
+ * Direct mapping to AVBSFContext->par_out.
79
+ */
80
+ get outputCodecParameters(): CodecParameters | null;
81
+ /**
82
+ * Input time base.
83
+ *
84
+ * Time base of the input packets (timestamps per second).
85
+ * Must be set before init() for proper timestamp handling.
86
+ *
87
+ * Direct mapping to AVBSFContext->time_base_in.
88
+ */
89
+ get inputTimeBase(): Rational;
90
+ set inputTimeBase(value: Rational);
91
+ /**
92
+ * Output time base.
93
+ *
94
+ * Time base of the output packets after filtering.
95
+ * May differ from input if the filter modifies timing.
96
+ *
97
+ * Direct mapping to AVBSFContext->time_base_out.
98
+ */
99
+ get outputTimeBase(): Rational | null;
100
+ /**
101
+ * The bitstream filter being used.
102
+ *
103
+ * Reference to the filter descriptor allocated to this context.
104
+ *
105
+ * Direct mapping to AVBSFContext->filter.
106
+ */
107
+ get filter(): BitStreamFilter | null;
108
+ /**
109
+ * Allocate a bitstream filter context.
110
+ *
111
+ * Allocates and configures the context for the specified filter.
112
+ * Must be called before init().
113
+ *
114
+ * Direct mapping to av_bsf_alloc().
115
+ *
116
+ * @param filter - The bitstream filter to use
117
+ *
118
+ * @returns 0 on success, negative AVERROR on error:
119
+ * - AVERROR_ENOMEM: Memory allocation failure
120
+ * - AVERROR_EINVAL: Invalid filter
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * import { FFmpegError } from 'node-av';
125
+ *
126
+ * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
127
+ * if (!filter) {
128
+ * throw new Error('Filter not found');
129
+ * }
130
+ *
131
+ * const ret = ctx.alloc(filter);
132
+ * FFmpegError.throwIfError(ret, 'alloc');
133
+ * ```
134
+ *
135
+ * @see {@link init} To initialize after allocation
136
+ * @see {@link BitStreamFilter.getByName} To get filter by name
137
+ */
138
+ alloc(filter: BitStreamFilter): number;
139
+ /**
140
+ * Initialize the bitstream filter context.
141
+ *
142
+ * Initializes the filter with the configured parameters.
143
+ * Must be called after alloc() and before processing packets.
144
+ *
145
+ * Direct mapping to av_bsf_init().
146
+ *
147
+ * @returns 0 on success, negative AVERROR on error:
148
+ * - AVERROR_EINVAL: Invalid parameters
149
+ * - AVERROR_ENOMEM: Memory allocation failure
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * import { FFmpegError } from 'node-av';
154
+ *
155
+ * // Allocate and initialize
156
+ * const ret1 = ctx.alloc(filter);
157
+ * FFmpegError.throwIfError(ret1, 'alloc');
158
+ *
159
+ * // Set parameters if needed
160
+ * ctx.inputTimeBase = new Rational(1, 25);
161
+ *
162
+ * const ret2 = ctx.init();
163
+ * FFmpegError.throwIfError(ret2, 'init');
164
+ * ```
165
+ *
166
+ * @see {@link alloc} Must be called first
167
+ * @see {@link isInitialized} To check initialization status
168
+ */
169
+ init(): number;
170
+ /**
171
+ * Free the bitstream filter context.
172
+ *
173
+ * Releases all resources associated with the context.
174
+ * The context becomes invalid after calling this.
175
+ *
176
+ * Direct mapping to av_bsf_free().
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * ctx.free();
181
+ * // Context is now invalid
182
+ * ```
183
+ *
184
+ * @see {@link Symbol.dispose} For automatic cleanup
185
+ * @see {@link alloc} To allocate
186
+ */
187
+ free(): void;
188
+ /**
189
+ * Flush the bitstream filter.
190
+ *
191
+ * Resets the internal state and discards any buffered data.
192
+ * Useful when seeking or switching streams.
193
+ *
194
+ * Direct mapping to av_bsf_flush().
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * // Flush when seeking
199
+ * ctx.flush();
200
+ * // Now ready to process packets from new position
201
+ * ```
202
+ */
203
+ flush(): void;
204
+ /**
205
+ * Send a packet to the bitstream filter.
206
+ *
207
+ * Submits a packet for filtering. The filter may buffer the packet
208
+ * internally and require multiple calls to receivePacket() to retrieve
209
+ * all output. Send null to signal end of stream.
210
+ *
211
+ * Direct mapping to av_bsf_send_packet().
212
+ *
213
+ * @param packet - Packet to filter, or null to signal EOF
214
+ *
215
+ * @returns 0 on success, negative AVERROR on error:
216
+ * - AVERROR_EAGAIN: Filter needs output to be consumed first
217
+ * - AVERROR_EOF: Filter has been flushed
218
+ * - AVERROR_EINVAL: Invalid parameters
219
+ * - AVERROR_ENOMEM: Memory allocation failure
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * import { FFmpegError } from 'node-av';
224
+ * import { AVERROR_EAGAIN } from 'node-av';
225
+ *
226
+ * const ret = await ctx.sendPacket(inputPacket);
227
+ * if (ret === AVERROR_EAGAIN) {
228
+ * // Need to receive packets first
229
+ * const ret2 = await ctx.receivePacket(outputPacket);
230
+ * FFmpegError.throwIfError(ret2, 'receivePacket');
231
+ * } else {
232
+ * FFmpegError.throwIfError(ret, 'sendPacket');
233
+ * }
234
+ *
235
+ * // Send EOF
236
+ * await ctx.sendPacket(null);
237
+ * ```
238
+ *
239
+ * @see {@link receivePacket} To retrieve filtered packets
240
+ */
241
+ sendPacket(packet: Packet | null): Promise<number>;
242
+ /**
243
+ * Send a packet to the bitstream filter synchronously.
244
+ * Synchronous version of sendPacket.
245
+ *
246
+ * Submits a packet for filtering. The filter may buffer packets
247
+ * internally and produce output with different timing.
248
+ *
249
+ * Direct mapping to av_bsf_send_packet().
250
+ *
251
+ * @param packet - Packet to filter (null to drain)
252
+ *
253
+ * @returns 0 on success, negative AVERROR on error:
254
+ * - AVERROR_EAGAIN: Need to receive packets first
255
+ * - AVERROR_EOF: Filter has been flushed
256
+ * - AVERROR_EINVAL: Invalid state
257
+ * - AVERROR(ENOMEM): Memory allocation failure
258
+ *
259
+ * @example
260
+ * ```typescript
261
+ * import { FFmpegError } from 'node-av';
262
+ * import { AVERROR_EAGAIN } from 'node-av/constants';
263
+ *
264
+ * // Send packet to filter
265
+ * const ret = ctx.sendPacketSync(inputPacket);
266
+ * if (ret === AVERROR_EAGAIN) {
267
+ * // Need to receive output first
268
+ * const outputPacket = new Packet();
269
+ * ctx.receivePacketSync(outputPacket);
270
+ * } else {
271
+ * FFmpegError.throwIfError(ret, 'sendPacketSync');
272
+ * }
273
+ *
274
+ * // Drain filter
275
+ * ctx.sendPacketSync(null);
276
+ * ```
277
+ *
278
+ * @see {@link sendPacket} For async version
279
+ */
280
+ sendPacketSync(packet: Packet | null): number;
281
+ /**
282
+ * Receive a filtered packet from the bitstream filter.
283
+ *
284
+ * Retrieves a packet that has been processed by the filter.
285
+ * May need to be called multiple times after each sendPacket().
286
+ *
287
+ * Direct mapping to av_bsf_receive_packet().
288
+ *
289
+ * @param packet - Packet to receive filtered data into
290
+ *
291
+ * @returns 0 on success, negative AVERROR on error:
292
+ * - AVERROR_EAGAIN: Need more input
293
+ * - AVERROR_EOF: No more packets available
294
+ * - AVERROR_EINVAL: Invalid parameters
295
+ *
296
+ * @example
297
+ * ```typescript
298
+ * import { FFmpegError } from 'node-av';
299
+ * import { AVERROR_EAGAIN, AVERROR_EOF } from 'node-av';
300
+ *
301
+ * // Receive all available packets
302
+ * while (true) {
303
+ * const ret = await ctx.receivePacket(outputPacket);
304
+ * if (ret === AVERROR_EAGAIN || ret === AVERROR_EOF) {
305
+ * break;
306
+ * }
307
+ * FFmpegError.throwIfError(ret, 'receivePacket');
308
+ *
309
+ * // Process filtered packet
310
+ * console.log(`Filtered packet size: ${outputPacket.size}`);
311
+ * }
312
+ * ```
313
+ *
314
+ * @see {@link sendPacket} To submit packets for filtering
315
+ */
316
+ receivePacket(packet: Packet): Promise<number>;
317
+ /**
318
+ * Receive a filtered packet from the bitstream filter synchronously.
319
+ * Synchronous version of receivePacket.
320
+ *
321
+ * Retrieves a packet that has been processed by the filter.
322
+ * May need to be called multiple times after each sendPacketSync().
323
+ *
324
+ * Direct mapping to av_bsf_receive_packet().
325
+ *
326
+ * @param packet - Packet to receive filtered data into
327
+ *
328
+ * @returns 0 on success, negative AVERROR on error:
329
+ * - AVERROR_EAGAIN: Need more input
330
+ * - AVERROR_EOF: No more packets available
331
+ *
332
+ * @example
333
+ * ```typescript
334
+ * import { FFmpegError } from 'node-av';
335
+ * import { AVERROR_EAGAIN, AVERROR_EOF } from 'node-av/constants';
336
+ *
337
+ * // Receive filtered packets
338
+ * const outputPacket = new Packet();
339
+ * let ret;
340
+ * while ((ret = ctx.receivePacketSync(outputPacket)) >= 0) {
341
+ * // Process filtered packet
342
+ * console.log(`Filtered packet size: ${outputPacket.size}`);
343
+ * outputPacket.unref();
344
+ * }
345
+ *
346
+ * if (ret !== AVERROR_EAGAIN && ret !== AVERROR_EOF) {
347
+ * FFmpegError.throwIfError(ret, 'receivePacketSync');
348
+ * }
349
+ * ```
350
+ *
351
+ * @see {@link receivePacket} For async version
352
+ */
353
+ receivePacketSync(packet: Packet): number;
354
+ /**
355
+ * Get the underlying native BitStreamFilterContext object.
356
+ *
357
+ * @returns The native BitStreamFilterContext binding object
358
+ *
359
+ * @internal
360
+ */
361
+ getNative(): NativeBitStreamFilterContext;
362
+ /**
363
+ * Dispose of the bitstream filter context.
364
+ *
365
+ * Implements the Disposable interface for automatic cleanup.
366
+ * Equivalent to calling free().
367
+ *
368
+ * @example
369
+ * ```typescript
370
+ * {
371
+ * using ctx = new BitStreamFilterContext();
372
+ * ctx.alloc(filter);
373
+ * ctx.init();
374
+ * // Use context...
375
+ * } // Automatically freed when leaving scope
376
+ * ```
377
+ */
378
+ [Symbol.dispose](): void;
379
+ }