node-av 6.0.0-beta.8 → 6.0.0
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/README.md +2 -1
- package/dist/api/bitstream-filter.js +0 -2
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +169 -9
- package/dist/api/decoder.js +351 -43
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/encoder.d.ts +129 -0
- package/dist/api/encoder.js +288 -41
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter.js +0 -2
- package/dist/api/filter.js.map +1 -1
- package/dist/api/muxer.d.ts +19 -0
- package/dist/api/muxer.js +44 -24
- package/dist/api/muxer.js.map +1 -1
- package/dist/api/rtp-stream.d.ts +14 -11
- package/dist/api/rtp-stream.js +22 -47
- package/dist/api/rtp-stream.js.map +1 -1
- package/dist/api/scaler.js.map +1 -1
- package/dist/api/utilities/async-queue.js +0 -2
- package/dist/api/utilities/async-queue.js.map +1 -1
- package/dist/api/utilities/codec-format.d.ts +87 -0
- package/dist/api/utilities/codec-format.js +117 -0
- package/dist/api/utilities/codec-format.js.map +1 -0
- package/dist/api/utilities/index.d.ts +1 -0
- package/dist/api/utilities/index.js +2 -0
- package/dist/api/utilities/index.js.map +1 -1
- package/dist/api/utilities/whisper-model.d.ts +20 -0
- package/dist/api/utilities/whisper-model.js +61 -2
- package/dist/api/utilities/whisper-model.js.map +1 -1
- package/dist/constants/bsf-options.d.ts +8 -1
- package/dist/constants/constants.d.ts +2 -0
- package/dist/constants/constants.js +2 -0
- package/dist/constants/constants.js.map +1 -1
- package/dist/constants/format-options.d.ts +4 -0
- package/dist/lib/binding.d.ts +2 -0
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/frame.d.ts +8 -0
- package/dist/lib/frame.js +10 -0
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/native-types.d.ts +12 -0
- package/dist/lib/packet.d.ts +8 -0
- package/dist/lib/packet.js +10 -0
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/utilities.d.ts +45 -0
- package/dist/lib/utilities.js +49 -0
- package/dist/lib/utilities.js.map +1 -1
- package/package.json +16 -16
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { AVPixelFormat, AVSampleFormat } from '../../constants/index.js';
|
|
2
|
+
import type { ChannelLayout } from '../../lib/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Pick a codec-supported sample rate, keeping the input rate when accepted and
|
|
5
|
+
* otherwise choosing the numerically nearest supported one.
|
|
6
|
+
*
|
|
7
|
+
* @param rate - Input sample rate in Hz
|
|
8
|
+
*
|
|
9
|
+
* @param supported - Codec's supported sample rates, or null when unrestricted
|
|
10
|
+
*
|
|
11
|
+
* @returns A sample rate the codec accepts
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* pickSupportedRate(48000, [44100, 48000]); // 48000 (kept)
|
|
16
|
+
* pickSupportedRate(96000, [44100, 48000]); // 48000 (nearest supported)
|
|
17
|
+
* pickSupportedRate(48000, null); // 48000 (codec unrestricted)
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function pickSupportedRate(rate: number, supported: number[] | null): number;
|
|
21
|
+
/**
|
|
22
|
+
* Pick a codec-supported sample format, keeping the input when accepted.
|
|
23
|
+
*
|
|
24
|
+
* When the input format is unsupported, prefers the lowest-precision supported
|
|
25
|
+
* format that still meets the input's bit depth (so converting incurs no silent
|
|
26
|
+
* precision loss); if none reach it, takes the highest-precision one available.
|
|
27
|
+
* Ties break toward matching planar/packed layout. This improves on FFmpeg CLI's
|
|
28
|
+
* naive "first supported format" fallback without any downside.
|
|
29
|
+
*
|
|
30
|
+
* @param fmt - Input sample format
|
|
31
|
+
*
|
|
32
|
+
* @param supported - Codec's supported sample formats, or null when unrestricted
|
|
33
|
+
*
|
|
34
|
+
* @returns A sample format the codec accepts
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
39
|
+
*
|
|
40
|
+
* // s32 input: prefer fltp (preserves bit depth) over the lossy s16 a naive pick would take
|
|
41
|
+
* pickSupportedSampleFormat(AV_SAMPLE_FMT_S32, [AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP]); // fltp
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function pickSupportedSampleFormat(fmt: AVSampleFormat, supported: AVSampleFormat[] | null): AVSampleFormat;
|
|
45
|
+
/**
|
|
46
|
+
* Pick a codec-supported channel layout.
|
|
47
|
+
*
|
|
48
|
+
* Keeps the input layout when the codec accepts its channel count, otherwise picks
|
|
49
|
+
* the supported layout with the nearest channel count (rather than blindly the
|
|
50
|
+
* first), minimizing how much up/down-mixing the resampler must perform.
|
|
51
|
+
*
|
|
52
|
+
* @param layout - Input channel layout
|
|
53
|
+
*
|
|
54
|
+
* @param supported - Codec's supported channel layouts, or null when unrestricted
|
|
55
|
+
*
|
|
56
|
+
* @returns A channel layout the codec accepts
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* import { avChannelLayoutDefault } from 'node-av';
|
|
61
|
+
*
|
|
62
|
+
* // 7.1 (8ch) input into a codec supporting stereo + 5.1 -> nearest count is 5.1 (6ch)
|
|
63
|
+
* const picked = pickSupportedLayout(avChannelLayoutDefault(8), [avChannelLayoutDefault(2), avChannelLayoutDefault(6)]);
|
|
64
|
+
* console.log(picked.nbChannels); // 6
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function pickSupportedLayout(layout: ChannelLayout, supported: ChannelLayout[] | null): ChannelLayout;
|
|
68
|
+
/**
|
|
69
|
+
* Pick a codec-supported pixel format, keeping the input when accepted and
|
|
70
|
+
* otherwise the least-loss supported format (via `avcodec_find_best_pix_fmt_of_list`,
|
|
71
|
+
* which weighs color depth, chroma subsampling, and alpha).
|
|
72
|
+
*
|
|
73
|
+
* @param fmt - Input pixel format
|
|
74
|
+
*
|
|
75
|
+
* @param supported - Codec's supported pixel formats, or null when unrestricted
|
|
76
|
+
*
|
|
77
|
+
* @returns A pixel format the codec accepts
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* import { AV_PIX_FMT_RGB24, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P } from 'node-av/constants';
|
|
82
|
+
*
|
|
83
|
+
* // rgb24 into a codec's formats -> yuv444p (least chroma loss, not the first entry)
|
|
84
|
+
* pickSupportedPixelFormat(AV_PIX_FMT_RGB24, [AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P]); // yuv444p
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare function pickSupportedPixelFormat(fmt: AVPixelFormat, supported: AVPixelFormat[] | null): AVPixelFormat;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { avcodecFindBestPixFmtOfList, avGetBytesPerSample, avSampleFmtIsPlanar } from '../../lib/utilities.js';
|
|
2
|
+
/**
|
|
3
|
+
* Pick a codec-supported sample rate, keeping the input rate when accepted and
|
|
4
|
+
* otherwise choosing the numerically nearest supported one.
|
|
5
|
+
*
|
|
6
|
+
* @param rate - Input sample rate in Hz
|
|
7
|
+
*
|
|
8
|
+
* @param supported - Codec's supported sample rates, or null when unrestricted
|
|
9
|
+
*
|
|
10
|
+
* @returns A sample rate the codec accepts
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* pickSupportedRate(48000, [44100, 48000]); // 48000 (kept)
|
|
15
|
+
* pickSupportedRate(96000, [44100, 48000]); // 48000 (nearest supported)
|
|
16
|
+
* pickSupportedRate(48000, null); // 48000 (codec unrestricted)
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function pickSupportedRate(rate, supported) {
|
|
20
|
+
if (!supported || supported.length === 0 || supported.includes(rate)) {
|
|
21
|
+
return rate;
|
|
22
|
+
}
|
|
23
|
+
return supported.reduce((best, r) => (Math.abs(r - rate) < Math.abs(best - rate) ? r : best), supported[0]);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Pick a codec-supported sample format, keeping the input when accepted.
|
|
27
|
+
*
|
|
28
|
+
* When the input format is unsupported, prefers the lowest-precision supported
|
|
29
|
+
* format that still meets the input's bit depth (so converting incurs no silent
|
|
30
|
+
* precision loss); if none reach it, takes the highest-precision one available.
|
|
31
|
+
* Ties break toward matching planar/packed layout. This improves on FFmpeg CLI's
|
|
32
|
+
* naive "first supported format" fallback without any downside.
|
|
33
|
+
*
|
|
34
|
+
* @param fmt - Input sample format
|
|
35
|
+
*
|
|
36
|
+
* @param supported - Codec's supported sample formats, or null when unrestricted
|
|
37
|
+
*
|
|
38
|
+
* @returns A sample format the codec accepts
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
43
|
+
*
|
|
44
|
+
* // s32 input: prefer fltp (preserves bit depth) over the lossy s16 a naive pick would take
|
|
45
|
+
* pickSupportedSampleFormat(AV_SAMPLE_FMT_S32, [AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP]); // fltp
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export function pickSupportedSampleFormat(fmt, supported) {
|
|
49
|
+
if (!supported || supported.length === 0 || supported.includes(fmt)) {
|
|
50
|
+
return fmt;
|
|
51
|
+
}
|
|
52
|
+
const inBytes = avGetBytesPerSample(fmt);
|
|
53
|
+
const inPlanar = avSampleFmtIsPlanar(fmt);
|
|
54
|
+
// Reaching the input's bit depth dominates the score; among those the smallest
|
|
55
|
+
// excess wins (and among formats that fall short, the highest depth). The planar
|
|
56
|
+
// match is a final tie-break.
|
|
57
|
+
const score = (cand) => {
|
|
58
|
+
const bytes = avGetBytesPerSample(cand);
|
|
59
|
+
const planar = avSampleFmtIsPlanar(cand) === inPlanar ? 1 : 0;
|
|
60
|
+
return (bytes >= inBytes ? 1_000_000 - (bytes - inBytes) * 1000 : bytes * 1000) + planar;
|
|
61
|
+
};
|
|
62
|
+
return supported.reduce((best, cand) => (score(cand) > score(best) ? cand : best), supported[0]);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Pick a codec-supported channel layout.
|
|
66
|
+
*
|
|
67
|
+
* Keeps the input layout when the codec accepts its channel count, otherwise picks
|
|
68
|
+
* the supported layout with the nearest channel count (rather than blindly the
|
|
69
|
+
* first), minimizing how much up/down-mixing the resampler must perform.
|
|
70
|
+
*
|
|
71
|
+
* @param layout - Input channel layout
|
|
72
|
+
*
|
|
73
|
+
* @param supported - Codec's supported channel layouts, or null when unrestricted
|
|
74
|
+
*
|
|
75
|
+
* @returns A channel layout the codec accepts
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* import { avChannelLayoutDefault } from 'node-av';
|
|
80
|
+
*
|
|
81
|
+
* // 7.1 (8ch) input into a codec supporting stereo + 5.1 -> nearest count is 5.1 (6ch)
|
|
82
|
+
* const picked = pickSupportedLayout(avChannelLayoutDefault(8), [avChannelLayoutDefault(2), avChannelLayoutDefault(6)]);
|
|
83
|
+
* console.log(picked.nbChannels); // 6
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export function pickSupportedLayout(layout, supported) {
|
|
87
|
+
if (!supported || supported.length === 0 || supported.some((l) => l.nbChannels === layout.nbChannels)) {
|
|
88
|
+
return layout;
|
|
89
|
+
}
|
|
90
|
+
return supported.reduce((best, l) => (Math.abs(l.nbChannels - layout.nbChannels) < Math.abs(best.nbChannels - layout.nbChannels) ? l : best), supported[0]);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Pick a codec-supported pixel format, keeping the input when accepted and
|
|
94
|
+
* otherwise the least-loss supported format (via `avcodec_find_best_pix_fmt_of_list`,
|
|
95
|
+
* which weighs color depth, chroma subsampling, and alpha).
|
|
96
|
+
*
|
|
97
|
+
* @param fmt - Input pixel format
|
|
98
|
+
*
|
|
99
|
+
* @param supported - Codec's supported pixel formats, or null when unrestricted
|
|
100
|
+
*
|
|
101
|
+
* @returns A pixel format the codec accepts
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* import { AV_PIX_FMT_RGB24, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P } from 'node-av/constants';
|
|
106
|
+
*
|
|
107
|
+
* // rgb24 into a codec's formats -> yuv444p (least chroma loss, not the first entry)
|
|
108
|
+
* pickSupportedPixelFormat(AV_PIX_FMT_RGB24, [AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P]); // yuv444p
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export function pickSupportedPixelFormat(fmt, supported) {
|
|
112
|
+
if (!supported || supported.length === 0 || supported.includes(fmt)) {
|
|
113
|
+
return fmt;
|
|
114
|
+
}
|
|
115
|
+
return avcodecFindBestPixFmtOfList(supported, fmt);
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=codec-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec-format.js","sourceRoot":"","sources":["../../../src/api/utilities/codec-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAK/G;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,SAA0B;IACxE,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;Q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tils } from './channel-layout.js';
|
|
3
|
+
export { pickSupportedLayout, pickSupportedPixelFormat, pickSupportedRate, pickSupportedSampleFormat } from './codec-format.js';
|
|
3
4
|
export { ImageUtils, type ImageAllocation } from './image.js';
|
|
4
5
|
export { MediaTypeUtils } from './media-type.js';
|
|
5
6
|
export { PixelFormatUtils } from './pixel-format.js';
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export { AudioSampleUtils } from './audio-sample.js';
|
|
3
3
|
// Channel Layouts
|
|
4
4
|
export { ChannelLayoutUtils } from './channel-layout.js';
|
|
5
|
+
// Codec-format negotiation
|
|
6
|
+
export { pickSupportedLayout, pickSupportedPixelFormat, pickSupportedRate, pickSupportedSampleFormat } from './codec-format.js';
|
|
5
7
|
// Image
|
|
6
8
|
export { ImageUtils } from './image.js';
|
|
7
9
|
// Media
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/utilities/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,OAAO,EAAE,gBAAgB,EAA0D,MAAM,mBAAmB,CAAC;AAE7G,kBAAkB;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,QAAQ;AACR,OAAO,EAAE,UAAU,EAAwB,MAAM,YAAY,CAAC;AAE9D,QAAQ;AACR,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,eAAe;AACf,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,gBAAgB;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,YAAY;AACZ,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,YAAY;AACZ,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,2BAA2B;AAC3B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,iBAAiB,GAKlB,MAAM,oBAAoB,CAA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@ -290,6 +290,26 @@ export declare class WhisperDownloader {
|
|
|
290
290
|
* ```
|
|
291
291
|
*/
|
|
292
292
|
static downloadModels(models: (WhisperModelName | WhisperVADModelName)[], outputPath?: string, type?: WhisperModelType): Promise<string[]>;
|
|
293
|
+
/**
|
|
294
|
+
* Download a URL to a file, retrying transient failures.
|
|
295
|
+
*
|
|
296
|
+
* Rate limiting (HTTP 429, common when several CI runners hit the model host
|
|
297
|
+
* from a shared IP pool), server errors (5xx), and network errors are retried
|
|
298
|
+
* with exponential backoff, honoring a numeric `Retry-After` header as the
|
|
299
|
+
* lower bound (capped at 30 s per wait). Other HTTP errors (e.g. 404) fail
|
|
300
|
+
* immediately. Each attempt truncates and rewrites the output file.
|
|
301
|
+
*
|
|
302
|
+
* @param url - URL to download
|
|
303
|
+
*
|
|
304
|
+
* @param outputPath - Local file path to save the download
|
|
305
|
+
*
|
|
306
|
+
* @returns Promise that resolves when the download is complete
|
|
307
|
+
*
|
|
308
|
+
* @throws {Error} The last download error once the retries are exhausted
|
|
309
|
+
*
|
|
310
|
+
* @internal
|
|
311
|
+
*/
|
|
312
|
+
private static downloadWithRetry;
|
|
293
313
|
/**
|
|
294
314
|
* Follow HTTP redirects recursively to download a file.
|
|
295
315
|
*
|
|
@@ -5,6 +5,21 @@ import { dirname, resolve } from 'node:path';
|
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = dirname(__filename);
|
|
8
|
+
/**
|
|
9
|
+
* Download error carrying the HTTP status (and a numeric Retry-After, when sent)
|
|
10
|
+
* so the retry logic can tell transient failures from permanent ones.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
class DownloadHttpError extends Error {
|
|
15
|
+
statusCode;
|
|
16
|
+
retryAfterSeconds;
|
|
17
|
+
constructor(message, statusCode, retryAfterSeconds) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.statusCode = statusCode;
|
|
20
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
8
23
|
/**
|
|
9
24
|
* Standard GGML Whisper models
|
|
10
25
|
*/
|
|
@@ -352,7 +367,7 @@ export class WhisperDownloader {
|
|
|
352
367
|
// Start new download to temporary file
|
|
353
368
|
const url = this.getModelUrl(model, modelType);
|
|
354
369
|
const tmpFilePath = `${filePath}.tmp`;
|
|
355
|
-
const downloadPromise = this.
|
|
370
|
+
const downloadPromise = this.downloadWithRetry(url, tmpFilePath)
|
|
356
371
|
.then(async () => {
|
|
357
372
|
// Rename temporary file to final name after successful download
|
|
358
373
|
await rename(tmpFilePath, filePath);
|
|
@@ -443,6 +458,46 @@ export class WhisperDownloader {
|
|
|
443
458
|
}
|
|
444
459
|
return downloadedPaths;
|
|
445
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* Download a URL to a file, retrying transient failures.
|
|
463
|
+
*
|
|
464
|
+
* Rate limiting (HTTP 429, common when several CI runners hit the model host
|
|
465
|
+
* from a shared IP pool), server errors (5xx), and network errors are retried
|
|
466
|
+
* with exponential backoff, honoring a numeric `Retry-After` header as the
|
|
467
|
+
* lower bound (capped at 30 s per wait). Other HTTP errors (e.g. 404) fail
|
|
468
|
+
* immediately. Each attempt truncates and rewrites the output file.
|
|
469
|
+
*
|
|
470
|
+
* @param url - URL to download
|
|
471
|
+
*
|
|
472
|
+
* @param outputPath - Local file path to save the download
|
|
473
|
+
*
|
|
474
|
+
* @returns Promise that resolves when the download is complete
|
|
475
|
+
*
|
|
476
|
+
* @throws {Error} The last download error once the retries are exhausted
|
|
477
|
+
*
|
|
478
|
+
* @internal
|
|
479
|
+
*/
|
|
480
|
+
static async downloadWithRetry(url, outputPath) {
|
|
481
|
+
const maxRetries = 3;
|
|
482
|
+
for (let attempt = 0;; attempt++) {
|
|
483
|
+
try {
|
|
484
|
+
await this.followRedirect(url, outputPath, 0);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
catch (error) {
|
|
488
|
+
// Permanent client errors (404 wrong URL, 403, ...) are not retryable;
|
|
489
|
+
// 429/5xx and plain network errors (no statusCode) are.
|
|
490
|
+
const status = error instanceof DownloadHttpError ? error.statusCode : undefined;
|
|
491
|
+
const retryable = status === undefined || status === 429 || status >= 500;
|
|
492
|
+
if (!retryable || attempt >= maxRetries) {
|
|
493
|
+
throw error;
|
|
494
|
+
}
|
|
495
|
+
const backoffMs = 1000 * 2 ** attempt;
|
|
496
|
+
const retryAfterMs = error instanceof DownloadHttpError && error.retryAfterSeconds !== undefined ? error.retryAfterSeconds * 1000 : 0;
|
|
497
|
+
await new Promise((r) => setTimeout(r, Math.min(Math.max(backoffMs, retryAfterMs), 30_000)));
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
446
501
|
/**
|
|
447
502
|
* Follow HTTP redirects recursively to download a file.
|
|
448
503
|
*
|
|
@@ -483,7 +538,11 @@ export class WhisperDownloader {
|
|
|
483
538
|
if (response.statusCode !== 200) {
|
|
484
539
|
// Destroy the response to close the connection
|
|
485
540
|
response.destroy();
|
|
486
|
-
|
|
541
|
+
// Carry the status (and a numeric Retry-After, e.g. on 429 rate limits)
|
|
542
|
+
// so downloadWithRetry can decide whether and how long to back off.
|
|
543
|
+
const retryAfter = Number(response.headers['retry-after']);
|
|
544
|
+
const retryAfterSeconds = Number.isFinite(retryAfter) ? retryAfter : undefined;
|
|
545
|
+
reject(new DownloadHttpError(`Failed to download: HTTP ${response.statusCode}`, response.statusCode ?? 0, retryAfterSeconds));
|
|
487
546
|
return;
|
|
488
547
|
}
|
|
489
548
|
const fileStream = createWriteStream(outputPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whisper-model.js","sourceRoot":"","sources":["../../../src/api/utilities/whisper-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,S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,CAAC;oBACnB,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE;wBACpB,MAAM,CAAC,GAAG,CAAC,CAAC;oBACd,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;gBAEH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;oBAC3B,QAAQ,GAAG,IAAI,CAAC;oBAChB,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE;wBACpB,MAAM,CAAC,GAAG,CAAC,CAAC;oBACd,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC1B,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Use with `BitStreamFilterAPI.create()` for name autocomplete. Unknown names
|
|
10
10
|
* still pass through via the `(string & {})` fallback in the API signature.
|
|
11
11
|
*/
|
|
12
|
-
export type BsfName = 'aac_adtstoasc' | 'ahx_to_mp2' | 'apv_metadata' | 'av1_frame_merge' | 'av1_frame_split' | 'av1_metadata' | 'chomp' | 'dca_core' | 'dovi_rpu' | 'dts2pts' | 'dump_extra' | 'dv_error_marker' | 'eac3_core' | 'eia608_to_smpte436m' | 'evc_frame_merge' | 'extract_extradata' | 'filter_units' | 'h264_metadata' | 'h264_mp4toannexb' | 'h264_redundant_pps' | 'hapqa_extract' | 'hevc_metadata' | 'hevc_mp4toannexb' | 'imxdump' | 'lcevc_metadata' | 'media100_to_mjpegb' | 'mjpeg2jpeg' | 'mjpegadump' | 'mov2textsub' | 'mpeg2_metadata' | 'mpeg4_unpack_bframes' | 'noise' | 'null' | 'opus_metadata' | 'pcm_rechunk' | 'pgs_frame_merge' | 'prores_metadata' | 'remove_extra' | 'setts' | 'showinfo' | 'smpte436m_to_eia608' | 'text2movsub' | 'trace_headers' | 'truehd_core' | 'vp9_metadata' | 'vp9_raw_reorder' | 'vp9_superframe' | 'vp9_superframe_split' | 'vvc_metadata' | 'vvc_mp4toannexb';
|
|
12
|
+
export type BsfName = 'aac_adtstoasc' | 'ahx_to_mp2' | 'apv_metadata' | 'av1_frame_merge' | 'av1_frame_split' | 'av1_metadata' | 'chomp' | 'dca_core' | 'dovi_rpu' | 'dovi_split' | 'dts2pts' | 'dump_extra' | 'dv_error_marker' | 'eac3_core' | 'eia608_to_smpte436m' | 'evc_frame_merge' | 'extract_extradata' | 'filter_units' | 'h264_metadata' | 'h264_mp4toannexb' | 'h264_redundant_pps' | 'hapqa_extract' | 'hevc_metadata' | 'hevc_mp4toannexb' | 'imxdump' | 'lcevc_metadata' | 'media100_to_mjpegb' | 'mjpeg2jpeg' | 'mjpegadump' | 'mov2textsub' | 'mpeg2_metadata' | 'mpeg4_unpack_bframes' | 'noise' | 'null' | 'opus_metadata' | 'pcm_rechunk' | 'pgs_frame_merge' | 'prores_metadata' | 'remove_extra' | 'setts' | 'showinfo' | 'smpte436m_to_eia608' | 'text2movsub' | 'trace_headers' | 'truehd_core' | 'vp9_metadata' | 'vp9_raw_reorder' | 'vp9_superframe' | 'vp9_superframe_split' | 'vvc_metadata' | 'vvc_mp4toannexb';
|
|
13
13
|
export interface BsfOptionsMap {
|
|
14
14
|
/**
|
|
15
15
|
* @see https://ffmpeg.org/ffmpeg-bitstream-filters.html#apv_005fmetadata
|
|
@@ -56,6 +56,13 @@ export interface BsfOptionsMap {
|
|
|
56
56
|
/** DV metadata compression mode */
|
|
57
57
|
compression?: 'none' | 'limited' | 'extended';
|
|
58
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* @see https://ffmpeg.org/ffmpeg-bitstream-filters.html#dovi_005fsplit
|
|
61
|
+
*/
|
|
62
|
+
dovi_split: {
|
|
63
|
+
/** Which Dolby Vision components to keep in the output bitstream */
|
|
64
|
+
mode?: 'bl' | 'bl_rpu' | 'el' | 'el_rpu';
|
|
65
|
+
};
|
|
59
66
|
/**
|
|
60
67
|
* @see https://ffmpeg.org/ffmpeg-bitstream-filters.html#dump_005fextra
|
|
61
68
|
*/
|
|
@@ -701,6 +701,7 @@ export declare const AV_PKT_DATA_3D_REFERENCE_DISPLAYS: AVPacketSideDataType;
|
|
|
701
701
|
export declare const AV_PKT_DATA_RTCP_SR: AVPacketSideDataType;
|
|
702
702
|
export declare const AV_PKT_DATA_EXIF: AVPacketSideDataType;
|
|
703
703
|
export declare const AV_PKT_DATA_DYNAMIC_HDR_SMPTE_2094_APP5: AVPacketSideDataType;
|
|
704
|
+
export declare const AV_PKT_DATA_HEVC_CONF: AVPacketSideDataType;
|
|
704
705
|
export type AVSideDataParamChangeFlags = number & {
|
|
705
706
|
readonly [__ffmpeg_brand]: 'AVSideDataParamChangeFlags';
|
|
706
707
|
};
|
|
@@ -743,6 +744,7 @@ export declare const AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: AVStreamGroup
|
|
|
743
744
|
export declare const AV_STREAM_GROUP_PARAMS_TILE_GRID: AVStreamGroupParamsType;
|
|
744
745
|
export declare const AV_STREAM_GROUP_PARAMS_LCEVC: AVStreamGroupParamsType;
|
|
745
746
|
export declare const AV_STREAM_GROUP_PARAMS_TREF: AVStreamGroupParamsType;
|
|
747
|
+
export declare const AV_STREAM_GROUP_PARAMS_DOLBY_VISION: AVStreamGroupParamsType;
|
|
746
748
|
export type AVLangCodespace = number & {
|
|
747
749
|
readonly [__ffmpeg_brand]: 'AVLangCodespace';
|
|
748
750
|
};
|
|
@@ -665,6 +665,7 @@ export const AV_PKT_DATA_3D_REFERENCE_DISPLAYS = 38;
|
|
|
665
665
|
export const AV_PKT_DATA_RTCP_SR = 39;
|
|
666
666
|
export const AV_PKT_DATA_EXIF = 40;
|
|
667
667
|
export const AV_PKT_DATA_DYNAMIC_HDR_SMPTE_2094_APP5 = 41;
|
|
668
|
+
export const AV_PKT_DATA_HEVC_CONF = 42;
|
|
668
669
|
export const AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 4;
|
|
669
670
|
export const AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 8;
|
|
670
671
|
export const AV_SMPTE_436M_WRAPPING_TYPE_VANC_FRAME = 1;
|
|
@@ -695,6 +696,7 @@ export const AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION = 2;
|
|
|
695
696
|
export const AV_STREAM_GROUP_PARAMS_TILE_GRID = 3;
|
|
696
697
|
export const AV_STREAM_GROUP_PARAMS_LCEVC = 4;
|
|
697
698
|
export const AV_STREAM_GROUP_PARAMS_TREF = 5;
|
|
699
|
+
export const AV_STREAM_GROUP_PARAMS_DOLBY_VISION = 6;
|
|
698
700
|
export const AV_LANG_ISO639_2_BIBL = 0;
|
|
699
701
|
export const AV_LANG_ISO639_2_TERM = 1;
|
|
700
702
|
export const AV_LANG_ISO639_1 = 2;
|