@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.
- package/BUILD_LINUX.md +61 -0
- package/LICENSE.md +22 -0
- package/README.md +662 -0
- package/build_mac_local.sh +69 -0
- package/dist/api/audio-frame-buffer.d.ts +205 -0
- package/dist/api/audio-frame-buffer.js +287 -0
- package/dist/api/audio-frame-buffer.js.map +1 -0
- package/dist/api/bitstream-filter.d.ts +820 -0
- package/dist/api/bitstream-filter.js +1242 -0
- package/dist/api/bitstream-filter.js.map +1 -0
- package/dist/api/constants.d.ts +44 -0
- package/dist/api/constants.js +45 -0
- package/dist/api/constants.js.map +1 -0
- package/dist/api/data/test_av1.ivf +0 -0
- package/dist/api/data/test_h264.h264 +0 -0
- package/dist/api/data/test_hevc.h265 +0 -0
- package/dist/api/data/test_mjpeg.mjpeg +0 -0
- package/dist/api/data/test_vp8.ivf +0 -0
- package/dist/api/data/test_vp9.ivf +0 -0
- package/dist/api/decoder.d.ts +1088 -0
- package/dist/api/decoder.js +1775 -0
- package/dist/api/decoder.js.map +1 -0
- package/dist/api/demuxer.d.ts +1219 -0
- package/dist/api/demuxer.js +2081 -0
- package/dist/api/demuxer.js.map +1 -0
- package/dist/api/device.d.ts +586 -0
- package/dist/api/device.js +961 -0
- package/dist/api/device.js.map +1 -0
- package/dist/api/encoder.d.ts +1132 -0
- package/dist/api/encoder.js +1988 -0
- package/dist/api/encoder.js.map +1 -0
- package/dist/api/filter-complex.d.ts +821 -0
- package/dist/api/filter-complex.js +1604 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +1286 -0
- package/dist/api/filter-presets.js +2152 -0
- package/dist/api/filter-presets.js.map +1 -0
- package/dist/api/filter.d.ts +1234 -0
- package/dist/api/filter.js +1976 -0
- package/dist/api/filter.js.map +1 -0
- package/dist/api/fmp4-stream.d.ts +426 -0
- package/dist/api/fmp4-stream.js +739 -0
- package/dist/api/fmp4-stream.js.map +1 -0
- package/dist/api/hardware.d.ts +651 -0
- package/dist/api/hardware.js +1260 -0
- package/dist/api/hardware.js.map +1 -0
- package/dist/api/index.d.ts +17 -0
- package/dist/api/index.js +32 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/io-stream.d.ts +307 -0
- package/dist/api/io-stream.js +282 -0
- package/dist/api/io-stream.js.map +1 -0
- package/dist/api/muxer.d.ts +957 -0
- package/dist/api/muxer.js +2002 -0
- package/dist/api/muxer.js.map +1 -0
- package/dist/api/pipeline.d.ts +607 -0
- package/dist/api/pipeline.js +1145 -0
- package/dist/api/pipeline.js.map +1 -0
- package/dist/api/utilities/async-queue.d.ts +120 -0
- package/dist/api/utilities/async-queue.js +211 -0
- package/dist/api/utilities/async-queue.js.map +1 -0
- package/dist/api/utilities/audio-sample.d.ts +117 -0
- package/dist/api/utilities/audio-sample.js +112 -0
- package/dist/api/utilities/audio-sample.js.map +1 -0
- package/dist/api/utilities/channel-layout.d.ts +76 -0
- package/dist/api/utilities/channel-layout.js +80 -0
- package/dist/api/utilities/channel-layout.js.map +1 -0
- package/dist/api/utilities/electron-shared-texture.d.ts +328 -0
- package/dist/api/utilities/electron-shared-texture.js +503 -0
- package/dist/api/utilities/electron-shared-texture.js.map +1 -0
- package/dist/api/utilities/image.d.ts +207 -0
- package/dist/api/utilities/image.js +213 -0
- package/dist/api/utilities/image.js.map +1 -0
- package/dist/api/utilities/index.d.ts +12 -0
- package/dist/api/utilities/index.js +25 -0
- package/dist/api/utilities/index.js.map +1 -0
- package/dist/api/utilities/media-type.d.ts +49 -0
- package/dist/api/utilities/media-type.js +53 -0
- package/dist/api/utilities/media-type.js.map +1 -0
- package/dist/api/utilities/pixel-format.d.ts +89 -0
- package/dist/api/utilities/pixel-format.js +97 -0
- package/dist/api/utilities/pixel-format.js.map +1 -0
- package/dist/api/utilities/sample-format.d.ts +129 -0
- package/dist/api/utilities/sample-format.js +141 -0
- package/dist/api/utilities/sample-format.js.map +1 -0
- package/dist/api/utilities/scheduler.d.ts +138 -0
- package/dist/api/utilities/scheduler.js +98 -0
- package/dist/api/utilities/scheduler.js.map +1 -0
- package/dist/api/utilities/streaming.d.ts +186 -0
- package/dist/api/utilities/streaming.js +309 -0
- package/dist/api/utilities/streaming.js.map +1 -0
- package/dist/api/utilities/timestamp.d.ts +193 -0
- package/dist/api/utilities/timestamp.js +206 -0
- package/dist/api/utilities/timestamp.js.map +1 -0
- package/dist/api/utilities/whisper-model.d.ts +310 -0
- package/dist/api/utilities/whisper-model.js +528 -0
- package/dist/api/utilities/whisper-model.js.map +1 -0
- package/dist/api/utils.d.ts +19 -0
- package/dist/api/utils.js +39 -0
- package/dist/api/utils.js.map +1 -0
- package/dist/api/whisper.d.ts +324 -0
- package/dist/api/whisper.js +362 -0
- package/dist/api/whisper.js.map +1 -0
- package/dist/constants/channel-layouts.d.ts +53 -0
- package/dist/constants/channel-layouts.js +57 -0
- package/dist/constants/channel-layouts.js.map +1 -0
- package/dist/constants/constants.d.ts +2325 -0
- package/dist/constants/constants.js +1887 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/constants/decoders.d.ts +633 -0
- package/dist/constants/decoders.js +641 -0
- package/dist/constants/decoders.js.map +1 -0
- package/dist/constants/encoders.d.ts +295 -0
- package/dist/constants/encoders.js +308 -0
- package/dist/constants/encoders.js.map +1 -0
- package/dist/constants/hardware.d.ts +26 -0
- package/dist/constants/hardware.js +27 -0
- package/dist/constants/hardware.js.map +1 -0
- package/dist/constants/index.d.ts +5 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/ffmpeg/index.d.ts +99 -0
- package/dist/ffmpeg/index.js +115 -0
- package/dist/ffmpeg/index.js.map +1 -0
- package/dist/ffmpeg/utils.d.ts +31 -0
- package/dist/ffmpeg/utils.js +68 -0
- package/dist/ffmpeg/utils.js.map +1 -0
- package/dist/ffmpeg/version.d.ts +6 -0
- package/dist/ffmpeg/version.js +7 -0
- package/dist/ffmpeg/version.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/audio-fifo.d.ts +399 -0
- package/dist/lib/audio-fifo.js +431 -0
- package/dist/lib/audio-fifo.js.map +1 -0
- package/dist/lib/binding.d.ts +228 -0
- package/dist/lib/binding.js +60 -0
- package/dist/lib/binding.js.map +1 -0
- package/dist/lib/bitstream-filter-context.d.ts +379 -0
- package/dist/lib/bitstream-filter-context.js +441 -0
- package/dist/lib/bitstream-filter-context.js.map +1 -0
- package/dist/lib/bitstream-filter.d.ts +140 -0
- package/dist/lib/bitstream-filter.js +154 -0
- package/dist/lib/bitstream-filter.js.map +1 -0
- package/dist/lib/codec-context.d.ts +1071 -0
- package/dist/lib/codec-context.js +1354 -0
- package/dist/lib/codec-context.js.map +1 -0
- package/dist/lib/codec-parameters.d.ts +616 -0
- package/dist/lib/codec-parameters.js +761 -0
- package/dist/lib/codec-parameters.js.map +1 -0
- package/dist/lib/codec-parser.d.ts +201 -0
- package/dist/lib/codec-parser.js +213 -0
- package/dist/lib/codec-parser.js.map +1 -0
- package/dist/lib/codec.d.ts +586 -0
- package/dist/lib/codec.js +713 -0
- package/dist/lib/codec.js.map +1 -0
- package/dist/lib/device.d.ts +291 -0
- package/dist/lib/device.js +324 -0
- package/dist/lib/device.js.map +1 -0
- package/dist/lib/dictionary.d.ts +333 -0
- package/dist/lib/dictionary.js +372 -0
- package/dist/lib/dictionary.js.map +1 -0
- package/dist/lib/error.d.ts +242 -0
- package/dist/lib/error.js +303 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/fifo.d.ts +416 -0
- package/dist/lib/fifo.js +453 -0
- package/dist/lib/fifo.js.map +1 -0
- package/dist/lib/filter-context.d.ts +712 -0
- package/dist/lib/filter-context.js +789 -0
- package/dist/lib/filter-context.js.map +1 -0
- package/dist/lib/filter-graph-segment.d.ts +160 -0
- package/dist/lib/filter-graph-segment.js +171 -0
- package/dist/lib/filter-graph-segment.js.map +1 -0
- package/dist/lib/filter-graph.d.ts +641 -0
- package/dist/lib/filter-graph.js +704 -0
- package/dist/lib/filter-graph.js.map +1 -0
- package/dist/lib/filter-inout.d.ts +198 -0
- package/dist/lib/filter-inout.js +257 -0
- package/dist/lib/filter-inout.js.map +1 -0
- package/dist/lib/filter.d.ts +243 -0
- package/dist/lib/filter.js +272 -0
- package/dist/lib/filter.js.map +1 -0
- package/dist/lib/format-context.d.ts +1254 -0
- package/dist/lib/format-context.js +1379 -0
- package/dist/lib/format-context.js.map +1 -0
- package/dist/lib/frame-utils.d.ts +116 -0
- package/dist/lib/frame-utils.js +98 -0
- package/dist/lib/frame-utils.js.map +1 -0
- package/dist/lib/frame.d.ts +1222 -0
- package/dist/lib/frame.js +1435 -0
- package/dist/lib/frame.js.map +1 -0
- package/dist/lib/hardware-device-context.d.ts +362 -0
- package/dist/lib/hardware-device-context.js +383 -0
- package/dist/lib/hardware-device-context.js.map +1 -0
- package/dist/lib/hardware-frames-context.d.ts +419 -0
- package/dist/lib/hardware-frames-context.js +477 -0
- package/dist/lib/hardware-frames-context.js.map +1 -0
- package/dist/lib/index.d.ts +35 -0
- package/dist/lib/index.js +60 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/input-format.d.ts +249 -0
- package/dist/lib/input-format.js +306 -0
- package/dist/lib/input-format.js.map +1 -0
- package/dist/lib/io-context.d.ts +696 -0
- package/dist/lib/io-context.js +769 -0
- package/dist/lib/io-context.js.map +1 -0
- package/dist/lib/log.d.ts +174 -0
- package/dist/lib/log.js +184 -0
- package/dist/lib/log.js.map +1 -0
- package/dist/lib/native-types.d.ts +946 -0
- package/dist/lib/native-types.js +2 -0
- package/dist/lib/native-types.js.map +1 -0
- package/dist/lib/option.d.ts +927 -0
- package/dist/lib/option.js +1583 -0
- package/dist/lib/option.js.map +1 -0
- package/dist/lib/output-format.d.ts +180 -0
- package/dist/lib/output-format.js +213 -0
- package/dist/lib/output-format.js.map +1 -0
- package/dist/lib/packet.d.ts +501 -0
- package/dist/lib/packet.js +590 -0
- package/dist/lib/packet.js.map +1 -0
- package/dist/lib/rational.d.ts +251 -0
- package/dist/lib/rational.js +278 -0
- package/dist/lib/rational.js.map +1 -0
- package/dist/lib/software-resample-context.d.ts +552 -0
- package/dist/lib/software-resample-context.js +592 -0
- package/dist/lib/software-resample-context.js.map +1 -0
- package/dist/lib/software-scale-context.d.ts +344 -0
- package/dist/lib/software-scale-context.js +366 -0
- package/dist/lib/software-scale-context.js.map +1 -0
- package/dist/lib/stream.d.ts +379 -0
- package/dist/lib/stream.js +526 -0
- package/dist/lib/stream.js.map +1 -0
- package/dist/lib/sync-queue.d.ts +179 -0
- package/dist/lib/sync-queue.js +197 -0
- package/dist/lib/sync-queue.js.map +1 -0
- package/dist/lib/types.d.ts +34 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utilities.d.ts +1127 -0
- package/dist/lib/utilities.js +1225 -0
- package/dist/lib/utilities.js.map +1 -0
- package/dist/utils/electron.d.ts +49 -0
- package/dist/utils/electron.js +63 -0
- package/dist/utils/electron.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/install/check.js +121 -0
- package/install/ffmpeg.js +66 -0
- package/jellyfin-ffmpeg.patch +181 -0
- package/package.json +129 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { bindings } from '../../lib/binding.js';
|
|
2
|
+
/**
|
|
3
|
+
* Timestamp and time base utilities.
|
|
4
|
+
*
|
|
5
|
+
* Provides static methods for converting, rescaling, and comparing timestamps.
|
|
6
|
+
* These utilities are essential for working with different time bases in
|
|
7
|
+
* multimedia streams.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { TimestampUtils } from 'node-av';
|
|
12
|
+
* import { AV_ROUND_NEAR_INF } from 'node-av/constants';
|
|
13
|
+
*
|
|
14
|
+
* // Convert timestamp to string representations
|
|
15
|
+
* const pts = 450000n;
|
|
16
|
+
* console.log(TimestampUtils.toString(pts)); // "450000"
|
|
17
|
+
*
|
|
18
|
+
* const timebase = { num: 1, den: 90000 };
|
|
19
|
+
* console.log(TimestampUtils.toTimeString(pts, timebase)); // "5.000000"
|
|
20
|
+
*
|
|
21
|
+
* // Rescale between time bases
|
|
22
|
+
* const srcTb = { num: 1, den: 90000 };
|
|
23
|
+
* const dstTb = { num: 1, den: 1000 };
|
|
24
|
+
* const rescaled = TimestampUtils.rescale(pts, srcTb, dstTb);
|
|
25
|
+
* console.log(rescaled); // 5000n
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export class TimestampUtils {
|
|
29
|
+
// Private constructor to prevent instantiation
|
|
30
|
+
constructor() { }
|
|
31
|
+
/**
|
|
32
|
+
* Convert timestamp to string.
|
|
33
|
+
*
|
|
34
|
+
* Converts a timestamp value to its string representation.
|
|
35
|
+
* Handles special values like AV_NOPTS_VALUE.
|
|
36
|
+
* Direct mapping to av_ts2str()
|
|
37
|
+
*
|
|
38
|
+
* @param ts - Timestamp value (bigint or number), or null
|
|
39
|
+
*
|
|
40
|
+
* @returns String representation
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* import { TimestampUtils } from 'node-av';
|
|
45
|
+
* import { AV_NOPTS_VALUE } from 'node-av/constants';
|
|
46
|
+
*
|
|
47
|
+
* console.log(TimestampUtils.toString(12345n)); // "12345"
|
|
48
|
+
* console.log(TimestampUtils.toString(AV_NOPTS_VALUE)); // "NOPTS"
|
|
49
|
+
* console.log(TimestampUtils.toString(null)); // "NOPTS"
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
static toString(ts) {
|
|
53
|
+
return bindings.avTs2Str(ts);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Convert timestamp to time string.
|
|
57
|
+
*
|
|
58
|
+
* Converts a timestamp to a time string in seconds using the provided time base.
|
|
59
|
+
* Direct mapping to av_ts2timestr()
|
|
60
|
+
*
|
|
61
|
+
* @param ts - Timestamp value
|
|
62
|
+
*
|
|
63
|
+
* @param timeBase - Time base for conversion
|
|
64
|
+
*
|
|
65
|
+
* @returns Time string in seconds with decimal places
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* import { TimestampUtils } from 'node-av';
|
|
70
|
+
*
|
|
71
|
+
* const pts = 450000n;
|
|
72
|
+
* const timebase = { num: 1, den: 90000 }; // 90kHz
|
|
73
|
+
*
|
|
74
|
+
* console.log(TimestampUtils.toTimeString(pts, timebase)); // "5.000000"
|
|
75
|
+
* console.log(TimestampUtils.toTimeString(90000n, timebase)); // "1.000000"
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
static toTimeString(ts, timeBase) {
|
|
79
|
+
return bindings.avTs2TimeStr(ts, timeBase);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Compare timestamps from different time bases.
|
|
83
|
+
*
|
|
84
|
+
* Compares two timestamps that may have different time bases.
|
|
85
|
+
* Direct mapping to av_compare_ts()
|
|
86
|
+
*
|
|
87
|
+
* @param tsA - First timestamp
|
|
88
|
+
*
|
|
89
|
+
* @param tbA - Time base of first timestamp
|
|
90
|
+
*
|
|
91
|
+
* @param tsB - Second timestamp
|
|
92
|
+
*
|
|
93
|
+
* @param tbB - Time base of second timestamp
|
|
94
|
+
*
|
|
95
|
+
* @returns -1 if tsA < tsB, 0 if equal, 1 if tsA > tsB
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* import { TimestampUtils } from 'node-av';
|
|
100
|
+
*
|
|
101
|
+
* // Compare timestamps from different time bases
|
|
102
|
+
* const pts1 = 90000n;
|
|
103
|
+
* const tb1 = { num: 1, den: 90000 }; // 1 second in 90kHz
|
|
104
|
+
*
|
|
105
|
+
* const pts2 = 1000n;
|
|
106
|
+
* const tb2 = { num: 1, den: 1000 }; // 1 second in 1kHz
|
|
107
|
+
*
|
|
108
|
+
* const result = TimestampUtils.compare(pts1, tb1, pts2, tb2);
|
|
109
|
+
* console.log(result); // 0 (equal - both represent 1 second)
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
static compare(tsA, tbA, tsB, tbB) {
|
|
113
|
+
return bindings.avCompareTs(tsA, tbA, tsB, tbB);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Rescale timestamp from one time base to another.
|
|
117
|
+
*
|
|
118
|
+
* Converts a timestamp from source time base to destination time base.
|
|
119
|
+
* Uses AV_ROUND_NEAR_INF rounding.
|
|
120
|
+
* Direct mapping to av_rescale_q()
|
|
121
|
+
*
|
|
122
|
+
* @param a - Timestamp to rescale
|
|
123
|
+
*
|
|
124
|
+
* @param bq - Source time base
|
|
125
|
+
*
|
|
126
|
+
* @param cq - Destination time base
|
|
127
|
+
*
|
|
128
|
+
* @returns Rescaled timestamp
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* import { TimestampUtils } from 'node-av';
|
|
133
|
+
*
|
|
134
|
+
* // Convert from 90kHz to milliseconds
|
|
135
|
+
* const pts = 450000n;
|
|
136
|
+
* const srcTb = { num: 1, den: 90000 };
|
|
137
|
+
* const dstTb = { num: 1, den: 1000 };
|
|
138
|
+
*
|
|
139
|
+
* const rescaled = TimestampUtils.rescale(pts, srcTb, dstTb);
|
|
140
|
+
* console.log(rescaled); // 5000n (5000 milliseconds = 5 seconds)
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
static rescale(a, bq, cq) {
|
|
144
|
+
return bindings.avRescaleQ(a, bq, cq);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Rescale with specified rounding.
|
|
148
|
+
*
|
|
149
|
+
* Rescales a value with explicit rounding mode.
|
|
150
|
+
* More general than rescale() as it doesn't use time bases.
|
|
151
|
+
* Direct mapping to av_rescale_rnd()
|
|
152
|
+
*
|
|
153
|
+
* @param a - Value to rescale
|
|
154
|
+
*
|
|
155
|
+
* @param b - Multiplier
|
|
156
|
+
*
|
|
157
|
+
* @param c - Divisor
|
|
158
|
+
*
|
|
159
|
+
* @param rnd - Rounding mode
|
|
160
|
+
*
|
|
161
|
+
* @returns Rescaled value: a * b / c
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* import { TimestampUtils } from 'node-av';
|
|
166
|
+
* import { AV_ROUND_UP, AV_ROUND_DOWN } from 'node-av/constants';
|
|
167
|
+
*
|
|
168
|
+
* // Scale with different rounding modes
|
|
169
|
+
* const value = 100n;
|
|
170
|
+
* const mul = 3n;
|
|
171
|
+
* const div = 7n;
|
|
172
|
+
*
|
|
173
|
+
* const roundUp = TimestampUtils.rescaleRounded(value, mul, div, AV_ROUND_UP);
|
|
174
|
+
* const roundDown = TimestampUtils.rescaleRounded(value, mul, div, AV_ROUND_DOWN);
|
|
175
|
+
*
|
|
176
|
+
* console.log(roundUp); // 43n (rounds up)
|
|
177
|
+
* console.log(roundDown); // 42n (rounds down)
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
static rescaleRounded(a, b, c, rnd) {
|
|
181
|
+
return bindings.avRescaleRnd(a, b, c, rnd);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Sleep for specified microseconds.
|
|
185
|
+
*
|
|
186
|
+
* Sleeps for the specified number of microseconds.
|
|
187
|
+
* Direct mapping to av_usleep()
|
|
188
|
+
*
|
|
189
|
+
* @param usec - Microseconds to sleep
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* import { TimestampUtils } from 'node-av';
|
|
194
|
+
*
|
|
195
|
+
* // Sleep for 100 milliseconds
|
|
196
|
+
* TimestampUtils.sleep(100000);
|
|
197
|
+
*
|
|
198
|
+
* // Sleep for 1 second
|
|
199
|
+
* TimestampUtils.sleep(1000000);
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
static sleep(usec) {
|
|
203
|
+
bindings.avUsleep(usec);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=timestamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamp.js","sourceRoot":"","sources":["../../../src/api/utilities/timestamp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKhD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,cAAc;IACzB,+CAA+C;IAC/C,gBAAuB,CAAC;IAExB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,QAAQ,CAAC,EAA0B;QACxC,OAAO,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,MAAM,CAAC,YAAY,CAAC,EAA0B,EAAE,QAAmB;QACjE,OAAO,QAAQ,CAAC,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,MAAM,CAAC,OAAO,CAAC,GAA2B,EAAE,GAAc,EAAE,GAA2B,EAAE,GAAc;QACrG,OAAO,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,OAAO,CAAC,CAAyB,EAAE,EAAa,EAAE,EAAa;QACpE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,MAAM,CAAC,cAAc,CAAC,CAAkB,EAAE,CAAkB,EAAE,CAAkB,EAAE,GAAe;QAC/F,OAAO,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,KAAK,CAAC,IAAY;QACvB,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model type for Whisper downloads
|
|
3
|
+
*/
|
|
4
|
+
export type WhisperModelType = 'ggml' | 'vad';
|
|
5
|
+
/**
|
|
6
|
+
* Options for downloading a Whisper model
|
|
7
|
+
*/
|
|
8
|
+
export interface DownloadOptions {
|
|
9
|
+
model: WhisperModelName | WhisperVADModelName;
|
|
10
|
+
outputPath?: string;
|
|
11
|
+
type?: WhisperModelType;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Standard GGML Whisper models
|
|
15
|
+
*/
|
|
16
|
+
export declare const WHISPER_MODELS: readonly ["tiny", "tiny.en", "tiny-q5_1", "tiny.en-q5_1", "tiny-q8_0", "base", "base.en", "base-q5_1", "base.en-q5_1", "base-q8_0", "small", "small.en", "small.en-tdrz", "small-q5_1", "small.en-q5_1", "small-q8_0", "medium", "medium.en", "medium-q5_0", "medium.en-q5_0", "medium-q8_0", "large-v1", "large-v2", "large-v2-q5_0", "large-v2-q8_0", "large-v3", "large-v3-q5_0", "large-v3-turbo", "large-v3-turbo-q5_0", "large-v3-turbo-q8_0"];
|
|
17
|
+
/**
|
|
18
|
+
* Whisper VAD (Voice Activity Detection) models
|
|
19
|
+
*/
|
|
20
|
+
export declare const WHISPER_VAD_MODELS: readonly ["silero-v5.1.2", "silero-v6.2.0"];
|
|
21
|
+
export type WhisperModelName = (typeof WHISPER_MODELS)[number];
|
|
22
|
+
export type WhisperVADModelName = (typeof WHISPER_VAD_MODELS)[number];
|
|
23
|
+
/**
|
|
24
|
+
* Whisper.cpp model downloader utilities.
|
|
25
|
+
*
|
|
26
|
+
* Provides static methods for downloading GGML and VAD models from HuggingFace,
|
|
27
|
+
* validating model names, and checking model availability. Supports automatic
|
|
28
|
+
* model type detection and prevents concurrent downloads of the same model.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import { WhisperDownloader } from 'node-av';
|
|
33
|
+
*
|
|
34
|
+
* // Download a GGML model
|
|
35
|
+
* const modelPath = await WhisperDownloader.downloadModel({
|
|
36
|
+
* model: 'base',
|
|
37
|
+
* outputPath: './models'
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* // Download a VAD model
|
|
41
|
+
* const vadPath = await WhisperDownloader.downloadVADModel('silero-v5.1.2', './models');
|
|
42
|
+
*
|
|
43
|
+
* // Check available models
|
|
44
|
+
* const categories = WhisperDownloader.getModelsByCategory();
|
|
45
|
+
* console.log(categories); // Map { 'tiny' => ['tiny', 'tiny.en', ...], ... }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare class WhisperDownloader {
|
|
49
|
+
static readonly DEFAULT_MODEL_PATH: string;
|
|
50
|
+
private static readonly DEFAULT_SRC;
|
|
51
|
+
private static readonly DEFAULT_PFX;
|
|
52
|
+
private static readonly TDRZ_SRC;
|
|
53
|
+
private static readonly TDRZ_PFX;
|
|
54
|
+
private static readonly VAD_SRC;
|
|
55
|
+
private static readonly VAD_PFX;
|
|
56
|
+
private static readonly activeDownloads;
|
|
57
|
+
private constructor();
|
|
58
|
+
/**
|
|
59
|
+
* Check if a model name is a valid GGML model.
|
|
60
|
+
*
|
|
61
|
+
* Validates whether the provided string matches one of the available
|
|
62
|
+
* GGML Whisper model names.
|
|
63
|
+
*
|
|
64
|
+
* @param model - Model name to validate
|
|
65
|
+
*
|
|
66
|
+
* @returns True if the model is a valid GGML model name
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* import { WhisperDownloader } from 'node-av';
|
|
71
|
+
*
|
|
72
|
+
* console.log(WhisperDownloader.isValidModel('base')); // true
|
|
73
|
+
* console.log(WhisperDownloader.isValidModel('large-v3')); // true
|
|
74
|
+
* console.log(WhisperDownloader.isValidModel('invalid')); // false
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
static isValidModel(model: string): model is WhisperModelName;
|
|
78
|
+
/**
|
|
79
|
+
* Check if a model name is a valid VAD model.
|
|
80
|
+
*
|
|
81
|
+
* Validates whether the provided string matches one of the available
|
|
82
|
+
* Silero VAD model names.
|
|
83
|
+
*
|
|
84
|
+
* @param model - Model name to validate
|
|
85
|
+
*
|
|
86
|
+
* @returns True if the model is a valid VAD model name
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* import { WhisperDownloader } from 'node-av';
|
|
91
|
+
*
|
|
92
|
+
* console.log(WhisperDownloader.isValidVADModel('silero-v5.1.2')); // true
|
|
93
|
+
* console.log(WhisperDownloader.isValidVADModel('invalid')); // false
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
static isValidVADModel(model: string): model is WhisperVADModelName;
|
|
97
|
+
/**
|
|
98
|
+
* Get all available GGML models grouped by category.
|
|
99
|
+
*
|
|
100
|
+
* Returns a map of model categories (tiny, base, small, medium, large)
|
|
101
|
+
* with their corresponding model variants.
|
|
102
|
+
*
|
|
103
|
+
* @returns Map of category names to model name arrays
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* import { WhisperDownloader } from 'node-av';
|
|
108
|
+
*
|
|
109
|
+
* const categories = WhisperDownloader.getModelsByCategory();
|
|
110
|
+
* console.log(categories.get('base'));
|
|
111
|
+
* // ['base', 'base.en', 'base-q5_1', 'base.en-q5_1', 'base-q8_0']
|
|
112
|
+
*
|
|
113
|
+
* // List all categories
|
|
114
|
+
* for (const [category, models] of categories) {
|
|
115
|
+
* console.log(`${category}: ${models.length} variants`);
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
static getModelsByCategory(): Map<string, string[]>;
|
|
120
|
+
/**
|
|
121
|
+
* Get the download URL for a model.
|
|
122
|
+
*
|
|
123
|
+
* Constructs the HuggingFace download URL for a given model name.
|
|
124
|
+
* Automatically detects whether it's a GGML or VAD model if type is not specified.
|
|
125
|
+
* Handles special models like tinydiarize variants.
|
|
126
|
+
*
|
|
127
|
+
* @param model - Model name
|
|
128
|
+
*
|
|
129
|
+
* @param type - Model type (auto-detected if not provided)
|
|
130
|
+
*
|
|
131
|
+
* @returns Full download URL for the model
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* import { WhisperDownloader } from 'node-av';
|
|
136
|
+
*
|
|
137
|
+
* // GGML model URL
|
|
138
|
+
* const url = WhisperDownloader.getModelUrl('base');
|
|
139
|
+
* console.log(url);
|
|
140
|
+
* // 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin'
|
|
141
|
+
*
|
|
142
|
+
* // VAD model URL
|
|
143
|
+
* const vadUrl = WhisperDownloader.getModelUrl('silero-v5.1.2');
|
|
144
|
+
* console.log(vadUrl);
|
|
145
|
+
* // 'https://huggingface.co/ggml-org/whisper-vad/resolve/main/ggml-silero-v5.1.2.bin'
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
static getModelUrl(model: string, type?: WhisperModelType): string;
|
|
149
|
+
/**
|
|
150
|
+
* Check if a model file already exists.
|
|
151
|
+
*
|
|
152
|
+
* Checks whether a model file has already been downloaded to the specified path.
|
|
153
|
+
* Useful for skipping redundant downloads.
|
|
154
|
+
*
|
|
155
|
+
* @param model - Model name
|
|
156
|
+
*
|
|
157
|
+
* @param outputPath - Directory path to check
|
|
158
|
+
*
|
|
159
|
+
* @returns True if the model file exists
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* import { WhisperDownloader } from 'node-av';
|
|
164
|
+
*
|
|
165
|
+
* if (WhisperDownloader.modelExists('base', './models')) {
|
|
166
|
+
* console.log('Model already downloaded');
|
|
167
|
+
* } else {
|
|
168
|
+
* await WhisperDownloader.downloadModel({
|
|
169
|
+
* model: 'base',
|
|
170
|
+
* outputPath: './models'
|
|
171
|
+
* });
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
static modelExists(model: string, outputPath: string): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Find whisper-cli executable in system PATH.
|
|
178
|
+
*
|
|
179
|
+
* Searches for whisper-cli binary in system PATH and local build directory.
|
|
180
|
+
* Returns the path to the executable if found.
|
|
181
|
+
*
|
|
182
|
+
* @returns Path to whisper-cli executable, or null if not found
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* import { WhisperDownloader } from 'node-av';
|
|
187
|
+
*
|
|
188
|
+
* const cliPath = await WhisperDownloader.findWhisperCli();
|
|
189
|
+
* if (cliPath) {
|
|
190
|
+
* console.log(`Found whisper-cli at: ${cliPath}`);
|
|
191
|
+
* } else {
|
|
192
|
+
* console.log('whisper-cli not found');
|
|
193
|
+
* }
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
static findWhisperCli(): Promise<string | null>;
|
|
197
|
+
/**
|
|
198
|
+
* Download a Whisper model file.
|
|
199
|
+
*
|
|
200
|
+
* Downloads a GGML or VAD model from HuggingFace to the specified directory.
|
|
201
|
+
* Automatically detects model type based on model name if not specified.
|
|
202
|
+
* Prevents race conditions when the same model is downloaded concurrently.
|
|
203
|
+
* Returns immediately if the model file already exists.
|
|
204
|
+
*
|
|
205
|
+
* @param options - Download configuration options
|
|
206
|
+
*
|
|
207
|
+
* @returns Path to the downloaded model file
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* import { WhisperDownloader } from 'node-av';
|
|
212
|
+
*
|
|
213
|
+
* // Download GGML model (auto-detected)
|
|
214
|
+
* const path = await WhisperDownloader.downloadModel({
|
|
215
|
+
* model: 'base',
|
|
216
|
+
* outputPath: './models'
|
|
217
|
+
* });
|
|
218
|
+
* console.log(`Downloaded to: ${path}`);
|
|
219
|
+
*
|
|
220
|
+
* // Download VAD model (auto-detected)
|
|
221
|
+
* const vadPath = await WhisperDownloader.downloadModel({
|
|
222
|
+
* model: 'silero-v5.1.2',
|
|
223
|
+
* outputPath: './models'
|
|
224
|
+
* });
|
|
225
|
+
*
|
|
226
|
+
* // Explicit type specification
|
|
227
|
+
* const explicitPath = await WhisperDownloader.downloadModel({
|
|
228
|
+
* model: 'base',
|
|
229
|
+
* outputPath: './models',
|
|
230
|
+
* type: 'ggml'
|
|
231
|
+
* });
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
static downloadModel(options: DownloadOptions): Promise<string>;
|
|
235
|
+
/**
|
|
236
|
+
* Download a VAD model (convenience method).
|
|
237
|
+
*
|
|
238
|
+
* Convenience wrapper for downloading VAD models without specifying type.
|
|
239
|
+
* Equivalent to calling downloadModel() with type: 'vad'.
|
|
240
|
+
*
|
|
241
|
+
* @param model - VAD model name
|
|
242
|
+
*
|
|
243
|
+
* @param outputPath - Directory path for download (default: current directory)
|
|
244
|
+
*
|
|
245
|
+
* @returns Path to the downloaded VAD model file
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* import { WhisperDownloader } from 'node-av';
|
|
250
|
+
*
|
|
251
|
+
* const vadPath = await WhisperDownloader.downloadVADModel(
|
|
252
|
+
* 'silero-v5.1.2',
|
|
253
|
+
* './models'
|
|
254
|
+
* );
|
|
255
|
+
* console.log(`VAD model downloaded to: ${vadPath}`);
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
static downloadVADModel(model: WhisperVADModelName, outputPath?: string): Promise<string>;
|
|
259
|
+
/**
|
|
260
|
+
* Download multiple Whisper models.
|
|
261
|
+
*
|
|
262
|
+
* Downloads multiple models sequentially to avoid overwhelming the network.
|
|
263
|
+
* Each model is validated and downloaded using the same logic as downloadModel().
|
|
264
|
+
*
|
|
265
|
+
* @param models - Array of model names to download
|
|
266
|
+
*
|
|
267
|
+
* @param outputPath - Directory path for downloads (default: current directory)
|
|
268
|
+
*
|
|
269
|
+
* @param type - Model type for all models (auto-detected if not provided)
|
|
270
|
+
*
|
|
271
|
+
* @returns Array of paths to downloaded model files
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* import { WhisperDownloader } from 'node-av';
|
|
276
|
+
*
|
|
277
|
+
* // Download multiple GGML models
|
|
278
|
+
* const paths = await WhisperDownloader.downloadModels(
|
|
279
|
+
* ['tiny', 'base', 'small'],
|
|
280
|
+
* './models'
|
|
281
|
+
* );
|
|
282
|
+
* console.log(`Downloaded ${paths.length} models`);
|
|
283
|
+
*
|
|
284
|
+
* // Download multiple VAD models
|
|
285
|
+
* const vadPaths = await WhisperDownloader.downloadModels(
|
|
286
|
+
* ['silero-v5.1.2', 'silero-v6.2.0'],
|
|
287
|
+
* './models',
|
|
288
|
+
* 'vad'
|
|
289
|
+
* );
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
static downloadModels(models: (WhisperModelName | WhisperVADModelName)[], outputPath?: string, type?: WhisperModelType): Promise<string[]>;
|
|
293
|
+
/**
|
|
294
|
+
* Follow HTTP redirects recursively to download a file.
|
|
295
|
+
*
|
|
296
|
+
* Handles HTTP redirects (301, 302, 307, 308) up to a maximum of 5 redirects.
|
|
297
|
+
* Downloads the file to the specified output path.
|
|
298
|
+
*
|
|
299
|
+
* @param url - URL to download
|
|
300
|
+
*
|
|
301
|
+
* @param outputPath - Local file path to save the download
|
|
302
|
+
*
|
|
303
|
+
* @param redirectCount - Current redirect count (used internally)
|
|
304
|
+
*
|
|
305
|
+
* @returns Promise that resolves when the download is complete
|
|
306
|
+
*
|
|
307
|
+
* @internal
|
|
308
|
+
*/
|
|
309
|
+
private static followRedirect;
|
|
310
|
+
}
|