node-av 6.2.0-beta.9 → 7.0.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 (116) hide show
  1. package/README.md +7 -19
  2. package/dist/api/audio-frame-buffer.d.ts +378 -19
  3. package/dist/api/audio-frame-buffer.js +715 -101
  4. package/dist/api/audio-frame-buffer.js.map +1 -1
  5. package/dist/api/data/test_av1.ivf +0 -0
  6. package/dist/api/data/test_hevc.h265 +0 -0
  7. package/dist/api/data/test_vp9.ivf +0 -0
  8. package/dist/api/decoder.d.ts +117 -2
  9. package/dist/api/decoder.js +290 -23
  10. package/dist/api/decoder.js.map +1 -1
  11. package/dist/api/demuxer.d.ts +19 -3
  12. package/dist/api/demuxer.js +95 -29
  13. package/dist/api/demuxer.js.map +1 -1
  14. package/dist/api/encoder-pool.js +9 -1
  15. package/dist/api/encoder-pool.js.map +1 -1
  16. package/dist/api/encoder.d.ts +100 -6
  17. package/dist/api/encoder.js +249 -108
  18. package/dist/api/encoder.js.map +1 -1
  19. package/dist/api/filter-presets.d.ts +25 -1
  20. package/dist/api/filter-presets.js +67 -5
  21. package/dist/api/filter-presets.js.map +1 -1
  22. package/dist/api/filter.d.ts +62 -3
  23. package/dist/api/filter.js +118 -36
  24. package/dist/api/filter.js.map +1 -1
  25. package/dist/api/fmp4-stream.d.ts +179 -15
  26. package/dist/api/fmp4-stream.js +341 -120
  27. package/dist/api/fmp4-stream.js.map +1 -1
  28. package/dist/api/hardware.d.ts +2 -0
  29. package/dist/api/hardware.js +33 -10
  30. package/dist/api/hardware.js.map +1 -1
  31. package/dist/api/index.d.ts +2 -2
  32. package/dist/api/index.js.map +1 -1
  33. package/dist/api/io-stream.d.ts +3 -2
  34. package/dist/api/io-stream.js +23 -7
  35. package/dist/api/io-stream.js.map +1 -1
  36. package/dist/api/muxer.d.ts +276 -7
  37. package/dist/api/muxer.js +649 -116
  38. package/dist/api/muxer.js.map +1 -1
  39. package/dist/api/pipeline.d.ts +22 -0
  40. package/dist/api/pipeline.js +53 -0
  41. package/dist/api/pipeline.js.map +1 -1
  42. package/dist/api/rtp-stream.d.ts +54 -33
  43. package/dist/api/rtp-stream.js +232 -153
  44. package/dist/api/rtp-stream.js.map +1 -1
  45. package/dist/api/scaler.d.ts +39 -6
  46. package/dist/api/scaler.js +72 -18
  47. package/dist/api/scaler.js.map +1 -1
  48. package/dist/api/utilities/live-decoding.d.ts +15 -0
  49. package/dist/api/utilities/live-decoding.js +32 -0
  50. package/dist/api/utilities/live-decoding.js.map +1 -0
  51. package/dist/api/utilities/packet-age-watchdog.d.ts +198 -0
  52. package/dist/api/utilities/packet-age-watchdog.js +594 -0
  53. package/dist/api/utilities/packet-age-watchdog.js.map +1 -0
  54. package/dist/api/utilities/scale-size.d.ts +51 -0
  55. package/dist/api/utilities/scale-size.js +55 -0
  56. package/dist/api/utilities/scale-size.js.map +1 -0
  57. package/dist/api/utilities/video-transcode.d.ts +218 -0
  58. package/dist/api/utilities/video-transcode.js +624 -0
  59. package/dist/api/utilities/video-transcode.js.map +1 -0
  60. package/dist/constants/bsf-options.d.ts +32 -8
  61. package/dist/constants/constants.d.ts +36 -114
  62. package/dist/constants/constants.js +32 -95
  63. package/dist/constants/constants.js.map +1 -1
  64. package/dist/constants/decoders.d.ts +74 -74
  65. package/dist/constants/decoders.js +79 -77
  66. package/dist/constants/decoders.js.map +1 -1
  67. package/dist/constants/encoders.d.ts +20 -21
  68. package/dist/constants/encoders.js +25 -24
  69. package/dist/constants/encoders.js.map +1 -1
  70. package/dist/constants/filter-options.d.ts +1378 -194
  71. package/dist/constants/format-options.d.ts +1342 -83
  72. package/dist/constants/formats.d.ts +2 -2
  73. package/dist/constants/options.d.ts +2261 -125
  74. package/dist/ffmpeg/utils.js +7 -4
  75. package/dist/ffmpeg/utils.js.map +1 -1
  76. package/dist/ffmpeg/version.d.ts +1 -1
  77. package/dist/ffmpeg/version.js +1 -1
  78. package/dist/ffmpeg/version.js.map +1 -1
  79. package/dist/lib/binding.d.ts +10 -1
  80. package/dist/lib/binding.js +25 -16
  81. package/dist/lib/binding.js.map +1 -1
  82. package/dist/lib/bitstream-filter-context.d.ts +2 -0
  83. package/dist/lib/bitstream-filter-context.js +2 -0
  84. package/dist/lib/bitstream-filter-context.js.map +1 -1
  85. package/dist/lib/filter-context.d.ts +3 -0
  86. package/dist/lib/filter-context.js +3 -0
  87. package/dist/lib/filter-context.js.map +1 -1
  88. package/dist/lib/filter-graph-segment.d.ts +3 -2
  89. package/dist/lib/filter-graph-segment.js +3 -2
  90. package/dist/lib/filter-graph-segment.js.map +1 -1
  91. package/dist/lib/filter-graph.d.ts +4 -4
  92. package/dist/lib/filter-graph.js +4 -4
  93. package/dist/lib/filter-inout.d.ts +4 -0
  94. package/dist/lib/filter-inout.js +4 -0
  95. package/dist/lib/filter-inout.js.map +1 -1
  96. package/dist/lib/format-context.d.ts +27 -3
  97. package/dist/lib/format-context.js +30 -6
  98. package/dist/lib/format-context.js.map +1 -1
  99. package/dist/lib/frame.d.ts +6 -2
  100. package/dist/lib/frame.js +11 -3
  101. package/dist/lib/frame.js.map +1 -1
  102. package/dist/lib/io-context.d.ts +4 -2
  103. package/dist/lib/io-context.js +4 -2
  104. package/dist/lib/io-context.js.map +1 -1
  105. package/dist/lib/native-types.d.ts +7 -3
  106. package/dist/lib/output-format.d.ts +42 -0
  107. package/dist/lib/output-format.js +46 -0
  108. package/dist/lib/output-format.js.map +1 -1
  109. package/dist/lib/stream.d.ts +5 -0
  110. package/dist/lib/stream.js +5 -0
  111. package/dist/lib/stream.js.map +1 -1
  112. package/dist/lib/utilities.d.ts +26 -0
  113. package/dist/lib/utilities.js +28 -0
  114. package/dist/lib/utilities.js.map +1 -1
  115. package/install/check.js +14 -16
  116. package/package.json +28 -44
@@ -0,0 +1,198 @@
1
+ /**
2
+ * Bounds how long an fMP4 muxer may hold a packet before emitting it in a fragment.
3
+ *
4
+ * Remembers when each packet reached the muxer, per output stream and in order, and
5
+ * forgets packets as the fragments carrying them are written. When the oldest pending
6
+ * packet of any stream is older than the limit, the next packet write fails with a
7
+ * descriptive error. The age does not depend on packet timestamps, so it also bounds
8
+ * retention caused by missing, constant or runaway timestamps. It counts the time
9
+ * while packets arrive: a pause of the whole input counts at most 2 s, so a source
10
+ * that goes quiet and resumes is not mistaken for a stalled muxer.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const watchdog = new PacketAgeWatchdog(60, (index) => `stream ${index}`);
15
+ * const output = await Muxer.open(
16
+ * {
17
+ * write: (chunk) => {
18
+ * watchdog.consumeChunk(chunk);
19
+ * return chunk.length;
20
+ * },
21
+ * },
22
+ * { format: 'mp4', options: { movflags: '+frag_keyframe+empty_moov' } },
23
+ * );
24
+ * output.setPacketObserver(watchdog);
25
+ * ```
26
+ *
27
+ * @see {@link Muxer.setPacketObserver} For registering it with a muxer
28
+ *
29
+ * @internal
30
+ */
31
+ export declare class PacketAgeWatchdog {
32
+ private readonly limitMs;
33
+ private readonly limitSeconds;
34
+ private readonly describeStream;
35
+ private queues;
36
+ private clock;
37
+ private lastArrival;
38
+ private header;
39
+ private headerFill;
40
+ private skipRemaining;
41
+ private partialBox;
42
+ private partialFill;
43
+ private blind;
44
+ /**
45
+ * @param limitSeconds - Maximum age of a pending packet in seconds (> 0)
46
+ *
47
+ * @param describeStream - Label for an output stream in the error message (e.g. its media type)
48
+ *
49
+ * @internal
50
+ */
51
+ constructor(limitSeconds: number, describeStream: (streamIndex: number) => string);
52
+ /**
53
+ * Number of packets of a stream that have not been emitted in a fragment yet.
54
+ *
55
+ * @param streamIndex - Output stream index
56
+ *
57
+ * @returns Pending packet count
58
+ *
59
+ * @internal
60
+ */
61
+ pendingPackets(streamIndex: number): number;
62
+ /**
63
+ * Age of the oldest pending packet of a stream, as the next packet would see it.
64
+ *
65
+ * @param streamIndex - Output stream index
66
+ *
67
+ * @param now - Current time in ms (performance.now() clock)
68
+ *
69
+ * @returns Age in ms of input time, or 0 when nothing is pending
70
+ *
71
+ * @internal
72
+ */
73
+ pendingAge(streamIndex: number, now?: number): number;
74
+ /**
75
+ * Record a packet the muxer accepted.
76
+ *
77
+ * Checks every stream first, so a stream that is held back is caught by the
78
+ * packets of the streams that still flow.
79
+ *
80
+ * @param streamIndex - Output stream index
81
+ *
82
+ * @throws {Error} If a pending packet of any stream is older than the limit
83
+ *
84
+ * @internal
85
+ */
86
+ onPacket(streamIndex: number): void;
87
+ /**
88
+ * Forget a packet of a stream that the muxer accepted but dropped.
89
+ *
90
+ * @param streamIndex - Output stream index
91
+ *
92
+ * @internal
93
+ */
94
+ onPacketRejected(streamIndex: number): void;
95
+ /**
96
+ * Stop judging packet ages for the rest of the session.
97
+ *
98
+ * For a caller that frames the output itself and lost the box boundaries:
99
+ * emitted samples can no longer be counted, and pending packets would
100
+ * otherwise look stalled. Drops what it has recorded and records nothing
101
+ * more, so a blind session holds no state.
102
+ *
103
+ * @internal
104
+ */
105
+ onFramingLost(): void;
106
+ /**
107
+ * Account for one complete top-level box of the muxer output.
108
+ *
109
+ * Only `moof` (fragment samples) and `moov` (samples of a first fragment
110
+ * written without `empty_moov`) matter; other boxes are ignored.
111
+ *
112
+ * @param box - The whole box including its header
113
+ *
114
+ * @internal
115
+ */
116
+ consumeBox(box: Buffer): void;
117
+ /**
118
+ * Account for a raw chunk of the muxer output.
119
+ *
120
+ * Frames top-level boxes across chunk boundaries without buffering media
121
+ * data: only `moof`/`moov` boxes are collected, everything else is skipped.
122
+ * If the framing breaks (a size the muxer never writes), the watchdog stops
123
+ * judging ages for the rest of the session instead of guessing.
124
+ *
125
+ * @param chunk - Output chunk in stream order
126
+ *
127
+ * @internal
128
+ */
129
+ consumeChunk(chunk: Buffer): void;
130
+ /**
131
+ * Drain the samples of every track fragment in a moof.
132
+ *
133
+ * @param buf - Buffer holding the moof
134
+ *
135
+ * @param start - Offset of the moof payload
136
+ *
137
+ * @param end - End offset of the moof
138
+ *
139
+ * @internal
140
+ */
141
+ private drainFragment;
142
+ /**
143
+ * Drain the samples of one traf: its tfhd names the track, each trun counts samples.
144
+ *
145
+ * movenc writes several truns per traf when the sample data is not contiguous.
146
+ *
147
+ * @param buf - Buffer holding the traf
148
+ *
149
+ * @param start - Offset of the traf payload
150
+ *
151
+ * @param end - End offset of the traf
152
+ *
153
+ * @internal
154
+ */
155
+ private drainTrackFragment;
156
+ /**
157
+ * Drain samples a moov carries in its sample tables.
158
+ *
159
+ * With `empty_moov` the tables are empty. Without it movenc writes the first
160
+ * fragment's samples into the moov instead of a moof.
161
+ *
162
+ * @param buf - Buffer holding the moov
163
+ *
164
+ * @param start - Offset of the moov payload
165
+ *
166
+ * @param end - End offset of the moov
167
+ *
168
+ * @internal
169
+ */
170
+ private drainInitSegment;
171
+ /**
172
+ * Remove emitted samples from the queue of the stream behind a track.
173
+ *
174
+ * movenc numbers the tracks of the muxer's streams stream index + 1; tracks
175
+ * it adds itself (chapters, timecode) have no queue and are ignored.
176
+ *
177
+ * @param trackId - mp4 track_ID
178
+ *
179
+ * @param samples - Number of emitted samples
180
+ *
181
+ * @internal
182
+ */
183
+ private drain;
184
+ /**
185
+ * Build the error for a stream whose oldest pending packet is too old.
186
+ *
187
+ * @param streamIndex - Output stream index
188
+ *
189
+ * @param ageMs - Age of its oldest pending packet in ms
190
+ *
191
+ * @param pending - Number of its pending packets
192
+ *
193
+ * @returns Error describing the stalled stream
194
+ *
195
+ * @internal
196
+ */
197
+ private violation;
198
+ }