@mux/ai 0.48.0 → 0.50.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/dist/{index-DxAt9Jq8.d.ts → index-BotaPu5M.d.ts} +1 -1
- package/dist/{index-DAuzEXly.d.ts → index-nu1UOAMW.d.ts} +4 -2
- package/dist/index.d.ts +50 -7
- package/dist/index.js +127 -38
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -2
- package/dist/primitives/index.js +12 -1
- package/dist/primitives/index.js.map +1 -1
- package/dist/{shots-BwpjZDpr.d.ts → shots-3wmvZnUV.d.ts} +11 -2
- package/dist/workflows/index.d.ts +2 -2
- package/dist/workflows/index.js +115 -14
- package/dist/workflows/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@ import { S as SafetyReport, e as PromptOverrides, h as SceneContextItemV1, D as
|
|
|
3
3
|
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
4
4
|
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|
5
5
|
import { createOpenAI } from '@ai-sdk/openai';
|
|
6
|
-
import { l as WorkflowCredentialsInput,
|
|
6
|
+
import { l as WorkflowCredentialsInput, M as MuxAsset, A as AssetTextTrack, f as ScopedMuxAIOptions, I as ImageSubmissionMode, i as TokenUsage, d as MuxAIOptions, b as ChunkingStrategy, k as VideoEmbeddingsResult, H as Hotspot, v as Shot, j as ToneType, g as StorageAdapter } from './shots-3wmvZnUV.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Language Code Conversion Utilities
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as WorkflowCredentialsInput, n as WorkflowScope, A as AssetTextTrack,
|
|
1
|
+
import { l as WorkflowCredentialsInput, n as WorkflowScope, A as AssetTextTrack, M as MuxAsset, T as TextChunk, b as ChunkingStrategy, q as CompletedShotsResult, D as DeletedShotsResult, r as ErroredShotsResult, H as Hotspot, s as HotspotOptions, t as HotspotResponse, u as PendingShotsResult, v as Shot, w as ShotRequestOptions, x as ShotsResult, y as SkippedShotsResult, z as WaitForShotsOptions, B as getHotspotsForAsset, F as getHotspotsForPlaybackId, G as getHotspotsForVideo, J as getShotsForAsset, K as requestShotsForAsset, L as waitForShotsForAsset } from './shots-3wmvZnUV.js';
|
|
2
2
|
|
|
3
3
|
interface HeatmapOptions {
|
|
4
4
|
/** Time window for results, e.g., '7:days' (default: '7:days') */
|
|
@@ -323,6 +323,7 @@ declare function getThumbnailUrls(playbackId: string, duration: number, options?
|
|
|
323
323
|
|
|
324
324
|
declare const index_CompletedShotsResult: typeof CompletedShotsResult;
|
|
325
325
|
declare const index_DEFAULT_STORYBOARD_WIDTH: typeof DEFAULT_STORYBOARD_WIDTH;
|
|
326
|
+
declare const index_DeletedShotsResult: typeof DeletedShotsResult;
|
|
326
327
|
declare const index_ErroredShotsResult: typeof ErroredShotsResult;
|
|
327
328
|
type index_HeatmapOptions = HeatmapOptions;
|
|
328
329
|
type index_HeatmapResponse = HeatmapResponse;
|
|
@@ -335,6 +336,7 @@ declare const index_PendingShotsResult: typeof PendingShotsResult;
|
|
|
335
336
|
declare const index_Shot: typeof Shot;
|
|
336
337
|
declare const index_ShotRequestOptions: typeof ShotRequestOptions;
|
|
337
338
|
declare const index_ShotsResult: typeof ShotsResult;
|
|
339
|
+
declare const index_SkippedShotsResult: typeof SkippedShotsResult;
|
|
338
340
|
type index_ThumbnailOptions = ThumbnailOptions;
|
|
339
341
|
type index_TranscriptFetchOptions = TranscriptFetchOptions;
|
|
340
342
|
type index_TranscriptResult = TranscriptResult;
|
|
@@ -379,7 +381,7 @@ declare const index_stripVttMetadataBlocks: typeof stripVttMetadataBlocks;
|
|
|
379
381
|
declare const index_vttTimestampToSeconds: typeof vttTimestampToSeconds;
|
|
380
382
|
declare const index_waitForShotsForAsset: typeof waitForShotsForAsset;
|
|
381
383
|
declare namespace index {
|
|
382
|
-
export { index_CompletedShotsResult as CompletedShotsResult, index_DEFAULT_STORYBOARD_WIDTH as DEFAULT_STORYBOARD_WIDTH, index_ErroredShotsResult as ErroredShotsResult, type index_HeatmapOptions as HeatmapOptions, type index_HeatmapResponse as HeatmapResponse, index_Hotspot as Hotspot, index_HotspotOptions as HotspotOptions, index_HotspotResponse as HotspotResponse, index_LOW_CONFIDENCE_THRESHOLD as LOW_CONFIDENCE_THRESHOLD, index_MAX_CUE_TEXT_CHARS as MAX_CUE_TEXT_CHARS, index_PendingShotsResult as PendingShotsResult, index_Shot as Shot, index_ShotRequestOptions as ShotRequestOptions, index_ShotsResult as ShotsResult, type index_ThumbnailOptions as ThumbnailOptions, type index_TranscriptFetchOptions as TranscriptFetchOptions, type index_TranscriptResult as TranscriptResult, type index_VTTCue as VTTCue, type index_VTTCueBudgetChunkingOptions as VTTCueBudgetChunkingOptions, type index_VTTDurationChunk as VTTDurationChunk, type index_VTTDurationChunkingOptions as VTTDurationChunkingOptions, index_WaitForShotsOptions as WaitForShotsOptions, index_buildTranscriptUrl as buildTranscriptUrl, index_buildVttFromCueBlocks as buildVttFromCueBlocks, index_buildVttFromTranslatedCueBlocks as buildVttFromTranslatedCueBlocks, index_chunkByTokens as chunkByTokens, index_chunkText as chunkText, index_chunkVTTCues as chunkVTTCues, index_chunkVTTCuesByBudget as chunkVTTCuesByBudget, index_chunkVTTCuesByDuration as chunkVTTCuesByDuration, index_concatenateVttSegments as concatenateVttSegments, index_estimateTokenCount as estimateTokenCount, index_extractTextFromVTT as extractTextFromVTT, index_extractTimestampedTranscript as extractTimestampedTranscript, index_fetchTranscriptForAsset as fetchTranscriptForAsset, index_filterVttByScope as filterVttByScope, index_findCaptionTrack as findCaptionTrack, index_getHeatmapForAsset as getHeatmapForAsset, index_getHeatmapForPlaybackId as getHeatmapForPlaybackId, index_getHeatmapForVideo as getHeatmapForVideo, index_getHotspotsForAsset as getHotspotsForAsset, index_getHotspotsForPlaybackId as getHotspotsForPlaybackId, index_getHotspotsForVideo as getHotspotsForVideo, index_getReadyTextTracks as getReadyTextTracks, index_getReliableLanguageCode as getReliableLanguageCode, index_getShotsForAsset as getShotsForAsset, index_getStoryboardUrl as getStoryboardUrl, index_getThumbnailUrls as getThumbnailUrls, index_parseVTTCues as parseVTTCues, index_replaceCueText as replaceCueText, index_requestShotsForAsset as requestShotsForAsset, index_sanitizeUntrustedText as sanitizeUntrustedText, index_secondsToTimestamp as secondsToTimestamp, index_splitVttPreambleAndCueBlocks as splitVttPreambleAndCueBlocks, index_stripVttMetadataBlocks as stripVttMetadataBlocks, index_vttTimestampToSeconds as vttTimestampToSeconds, index_waitForShotsForAsset as waitForShotsForAsset };
|
|
384
|
+
export { index_CompletedShotsResult as CompletedShotsResult, index_DEFAULT_STORYBOARD_WIDTH as DEFAULT_STORYBOARD_WIDTH, index_DeletedShotsResult as DeletedShotsResult, index_ErroredShotsResult as ErroredShotsResult, type index_HeatmapOptions as HeatmapOptions, type index_HeatmapResponse as HeatmapResponse, index_Hotspot as Hotspot, index_HotspotOptions as HotspotOptions, index_HotspotResponse as HotspotResponse, index_LOW_CONFIDENCE_THRESHOLD as LOW_CONFIDENCE_THRESHOLD, index_MAX_CUE_TEXT_CHARS as MAX_CUE_TEXT_CHARS, index_PendingShotsResult as PendingShotsResult, index_Shot as Shot, index_ShotRequestOptions as ShotRequestOptions, index_ShotsResult as ShotsResult, index_SkippedShotsResult as SkippedShotsResult, type index_ThumbnailOptions as ThumbnailOptions, type index_TranscriptFetchOptions as TranscriptFetchOptions, type index_TranscriptResult as TranscriptResult, type index_VTTCue as VTTCue, type index_VTTCueBudgetChunkingOptions as VTTCueBudgetChunkingOptions, type index_VTTDurationChunk as VTTDurationChunk, type index_VTTDurationChunkingOptions as VTTDurationChunkingOptions, index_WaitForShotsOptions as WaitForShotsOptions, index_buildTranscriptUrl as buildTranscriptUrl, index_buildVttFromCueBlocks as buildVttFromCueBlocks, index_buildVttFromTranslatedCueBlocks as buildVttFromTranslatedCueBlocks, index_chunkByTokens as chunkByTokens, index_chunkText as chunkText, index_chunkVTTCues as chunkVTTCues, index_chunkVTTCuesByBudget as chunkVTTCuesByBudget, index_chunkVTTCuesByDuration as chunkVTTCuesByDuration, index_concatenateVttSegments as concatenateVttSegments, index_estimateTokenCount as estimateTokenCount, index_extractTextFromVTT as extractTextFromVTT, index_extractTimestampedTranscript as extractTimestampedTranscript, index_fetchTranscriptForAsset as fetchTranscriptForAsset, index_filterVttByScope as filterVttByScope, index_findCaptionTrack as findCaptionTrack, index_getHeatmapForAsset as getHeatmapForAsset, index_getHeatmapForPlaybackId as getHeatmapForPlaybackId, index_getHeatmapForVideo as getHeatmapForVideo, index_getHotspotsForAsset as getHotspotsForAsset, index_getHotspotsForPlaybackId as getHotspotsForPlaybackId, index_getHotspotsForVideo as getHotspotsForVideo, index_getReadyTextTracks as getReadyTextTracks, index_getReliableLanguageCode as getReliableLanguageCode, index_getShotsForAsset as getShotsForAsset, index_getStoryboardUrl as getStoryboardUrl, index_getThumbnailUrls as getThumbnailUrls, index_parseVTTCues as parseVTTCues, index_replaceCueText as replaceCueText, index_requestShotsForAsset as requestShotsForAsset, index_sanitizeUntrustedText as sanitizeUntrustedText, index_secondsToTimestamp as secondsToTimestamp, index_splitVttPreambleAndCueBlocks as splitVttPreambleAndCueBlocks, index_stripVttMetadataBlocks as stripVttMetadataBlocks, index_vttTimestampToSeconds as vttTimestampToSeconds, index_waitForShotsForAsset as waitForShotsForAsset };
|
|
383
385
|
}
|
|
384
386
|
|
|
385
387
|
export { getReliableLanguageCode as A, getStoryboardUrl as B, getThumbnailUrls as C, DEFAULT_STORYBOARD_WIDTH as D, parseVTTCues as E, replaceCueText as F, sanitizeUntrustedText as G, type HeatmapOptions as H, secondsToTimestamp as I, splitVttPreambleAndCueBlocks as J, stripVttMetadataBlocks as K, LOW_CONFIDENCE_THRESHOLD as L, MAX_CUE_TEXT_CHARS as M, vttTimestampToSeconds as N, type ThumbnailOptions as T, type VTTCue as V, type HeatmapResponse as a, type TranscriptFetchOptions as b, type TranscriptResult as c, type VTTCueBudgetChunkingOptions as d, type VTTDurationChunk as e, type VTTDurationChunkingOptions as f, buildTranscriptUrl as g, buildVttFromCueBlocks as h, index as i, buildVttFromTranslatedCueBlocks as j, chunkByTokens as k, chunkText as l, chunkVTTCues as m, chunkVTTCuesByBudget as n, chunkVTTCuesByDuration as o, concatenateVttSegments as p, estimateTokenCount as q, extractTextFromVTT as r, extractTimestampedTranscript as s, fetchTranscriptForAsset as t, filterVttByScope as u, findCaptionTrack as v, getHeatmapForAsset as w, getHeatmapForPlaybackId as x, getHeatmapForVideo as y, getReadyTextTracks as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, M as MUX_TRACK_PASSTHROUGH_MAX_CHARS, R as ReplaceAndCreateTextTrackInput, b as ReplaceAndCreateTextTrackResult, c as ReplaceAndCreateTrackInput, d as ReplaceExistingTracksPolicy, e as ReplaceSourceTrackInput, f as ReplaceableTrackType, S as SourceTrackReplacementPolicy, g as SupportedISO639_1, h as SupportedISO639_3, T as TextTrackReplacementPlan, i as TextTrackSummary, j as TextTrackTarget, k as TrackSummary, l as TrackTarget, m as buildMuxAiTrackPassthrough, n as findNameCollisionTextTracks, o as findSameLanguageTextTracks, p as getLanguageCodePair, q as getLanguageName, r as isDuplicateTrackNameError, s as isMuxGeneratedTextTrack, t as isUndeterminedLanguageCode, u as isValidISO639_1, v as isValidISO639_3, w as normalizeTrackLanguageCode, x as normalizeTrackName, y as planSourceTrackReplacement, z as planTextTrackReplacement, A as replaceAndCreateTextTrack, B as replaceAndCreateTrack, C as replaceSourceTrack, D as summarizeTextTrack, E as toISO639_1, F as toISO639_3, G as validateTrackPassthrough, H as workflows } from './index-
|
|
2
|
-
import { W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './shots-
|
|
3
|
-
export { A as AssetTextTrack, C as ChunkEmbedding, b as ChunkingStrategy, E as Encrypted, c as EncryptedPayload, I as ImageSubmissionMode,
|
|
1
|
+
export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, M as MUX_TRACK_PASSTHROUGH_MAX_CHARS, R as ReplaceAndCreateTextTrackInput, b as ReplaceAndCreateTextTrackResult, c as ReplaceAndCreateTrackInput, d as ReplaceExistingTracksPolicy, e as ReplaceSourceTrackInput, f as ReplaceableTrackType, S as SourceTrackReplacementPolicy, g as SupportedISO639_1, h as SupportedISO639_3, T as TextTrackReplacementPlan, i as TextTrackSummary, j as TextTrackTarget, k as TrackSummary, l as TrackTarget, m as buildMuxAiTrackPassthrough, n as findNameCollisionTextTracks, o as findSameLanguageTextTracks, p as getLanguageCodePair, q as getLanguageName, r as isDuplicateTrackNameError, s as isMuxGeneratedTextTrack, t as isUndeterminedLanguageCode, u as isValidISO639_1, v as isValidISO639_3, w as normalizeTrackLanguageCode, x as normalizeTrackName, y as planSourceTrackReplacement, z as planTextTrackReplacement, A as replaceAndCreateTextTrack, B as replaceAndCreateTrack, C as replaceSourceTrack, D as summarizeTextTrack, E as toISO639_1, F as toISO639_3, G as validateTrackPassthrough, H as workflows } from './index-BotaPu5M.js';
|
|
2
|
+
import { M as MuxAsset, W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './shots-3wmvZnUV.js';
|
|
3
|
+
export { A as AssetTextTrack, C as ChunkEmbedding, b as ChunkingStrategy, E as Encrypted, c as EncryptedPayload, I as ImageSubmissionMode, d as MuxAIOptions, P as PlaybackAsset, e as PlaybackPolicy, f as ScopedMuxAIOptions, g as StorageAdapter, T as TextChunk, h as TokenChunkingConfig, i as TokenUsage, j as ToneType, U as UsageMetadata, V as VTTChunkingConfig, k as VideoEmbeddingsResult, l as WorkflowCredentialsInput, m as WorkflowMuxClient, n as WorkflowScope, o as decryptFromWorkflow, p as encryptForWorkflow } from './shots-3wmvZnUV.js';
|
|
4
4
|
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
|
|
5
|
-
export { i as primitives } from './index-
|
|
5
|
+
export { i as primitives } from './index-nu1UOAMW.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import './summarization-BFmhXeAu.js';
|
|
8
8
|
import '@ai-sdk/anthropic';
|
|
@@ -10,7 +10,7 @@ import '@ai-sdk/google';
|
|
|
10
10
|
import '@ai-sdk/openai';
|
|
11
11
|
import '@mux/ts';
|
|
12
12
|
|
|
13
|
-
var version = "0.
|
|
13
|
+
var version = "0.50.0";
|
|
14
14
|
|
|
15
15
|
type MuxAiErrorType = "validation_error" | "processing_error" | "timeout_error" | "content_policy_error";
|
|
16
16
|
/**
|
|
@@ -43,6 +43,50 @@ declare class MuxAiError extends Error {
|
|
|
43
43
|
}
|
|
44
44
|
declare function wrapError(error: unknown, message: string): never;
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Which file to read from an asset whose static renditions come from the
|
|
48
|
+
* deprecated `mp4_support` option.
|
|
49
|
+
*
|
|
50
|
+
* - `ready`: serve `name`. `filesizeBytes` is set when Mux reports it.
|
|
51
|
+
* - `preparing`: Mux is still generating the files; check again later.
|
|
52
|
+
* - `unusable`: the files will never be usable as-is. `reason` is customer-safe.
|
|
53
|
+
*/
|
|
54
|
+
type LegacyMp4SupportRendition = {
|
|
55
|
+
kind: "ready";
|
|
56
|
+
name: string;
|
|
57
|
+
filesizeBytes?: number;
|
|
58
|
+
} | {
|
|
59
|
+
kind: "preparing";
|
|
60
|
+
} | {
|
|
61
|
+
kind: "unusable";
|
|
62
|
+
reason: string;
|
|
63
|
+
};
|
|
64
|
+
/** Guide for the Static Renditions API that replaces `mp4_support`. */
|
|
65
|
+
declare const STATIC_RENDITIONS_GUIDE_URL = "https://www.mux.com/docs/guides/enable-static-mp4-renditions";
|
|
66
|
+
/**
|
|
67
|
+
* Whether the asset uses the deprecated `mp4_support` option rather than the
|
|
68
|
+
* Static Renditions API.
|
|
69
|
+
*/
|
|
70
|
+
declare function usesLegacyMp4Support(asset: MuxAsset): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Picks the static rendition file to read from an asset that uses the
|
|
73
|
+
* deprecated `mp4_support` option. Returns `undefined` for every other asset.
|
|
74
|
+
*
|
|
75
|
+
* Renditions created by `mp4_support` cannot be managed through the Static
|
|
76
|
+
* Renditions API, and their `files` carry no per-file `status`, so readiness
|
|
77
|
+
* comes from the aggregate `static_renditions.status`. Callers must read the
|
|
78
|
+
* returned file as-is and never create, delete, or update static renditions
|
|
79
|
+
* on these assets.
|
|
80
|
+
*/
|
|
81
|
+
declare function resolveLegacyMp4SupportRendition(asset: MuxAsset): LegacyMp4SupportRendition | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Returns a customer-safe error when a ready `mp4_support` file is larger than
|
|
84
|
+
* `maxBytes`, or `undefined` when it fits or its size is unknown.
|
|
85
|
+
*/
|
|
86
|
+
declare function getLegacyMp4SupportRenditionSizeError(rendition: Extract<LegacyMp4SupportRendition, {
|
|
87
|
+
kind: "ready";
|
|
88
|
+
}>, maxBytes: number): string | undefined;
|
|
89
|
+
|
|
46
90
|
type MuxPlaybackService = "image" | "stream";
|
|
47
91
|
/**
|
|
48
92
|
* Builds the playback origin for a Mux domain, matching Mux Player's `customDomain`
|
|
@@ -72,7 +116,6 @@ interface WorkflowStorageClientOptions {
|
|
|
72
116
|
* operations compatible across edge/ESM and Node runtimes.
|
|
73
117
|
*/
|
|
74
118
|
declare class WorkflowStorageClient {
|
|
75
|
-
static classId: string;
|
|
76
119
|
private readonly accessKeyId?;
|
|
77
120
|
private readonly secretAccessKey?;
|
|
78
121
|
constructor(options?: WorkflowStorageClientOptions);
|
|
@@ -84,4 +127,4 @@ declare class WorkflowStorageClient {
|
|
|
84
127
|
}
|
|
85
128
|
declare function createWorkflowStorageClient(options?: WorkflowStorageClientOptions): WorkflowStorageClient;
|
|
86
129
|
|
|
87
|
-
export { MuxAiError, type MuxAiErrorType, type MuxPlaybackService, StoragePresignGetObjectInput, StoragePutObjectInput, WorkflowCredentials, type WorkflowCredentialsProvider, WorkflowStorageClient, createWorkflowStorageClient, getMuxPlaybackOrigin, setWorkflowCredentialsProvider, version, wrapError };
|
|
130
|
+
export { type LegacyMp4SupportRendition, MuxAiError, type MuxAiErrorType, MuxAsset, type MuxPlaybackService, STATIC_RENDITIONS_GUIDE_URL, StoragePresignGetObjectInput, StoragePutObjectInput, WorkflowCredentials, type WorkflowCredentialsProvider, WorkflowStorageClient, createWorkflowStorageClient, getLegacyMp4SupportRenditionSizeError, getMuxPlaybackOrigin, resolveLegacyMp4SupportRendition, setWorkflowCredentialsProvider, usesLegacyMp4Support, version, wrapError };
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
|
-
var version = "0.
|
|
8
|
+
var version = "0.50.0";
|
|
9
9
|
|
|
10
10
|
// src/lib/language-codes.ts
|
|
11
11
|
var ISO639_1_TO_3 = {
|
|
@@ -747,6 +747,58 @@ function wrapError(error, message) {
|
|
|
747
747
|
throw wrapped;
|
|
748
748
|
}
|
|
749
749
|
|
|
750
|
+
// src/lib/mux-static-renditions.ts
|
|
751
|
+
var STATIC_RENDITIONS_GUIDE_URL = "https://www.mux.com/docs/guides/enable-static-mp4-renditions";
|
|
752
|
+
var LEGACY_MP4_SUPPORT_FILE_PREFERENCE = {
|
|
753
|
+
"capped-1080p": ["capped-1080p.mp4", "audio.m4a"],
|
|
754
|
+
"audio-only": ["audio.m4a"],
|
|
755
|
+
"audio-only,capped-1080p": ["audio.m4a", "capped-1080p.mp4"],
|
|
756
|
+
"standard": ["low.mp4", "audio.m4a"]
|
|
757
|
+
};
|
|
758
|
+
var BYTES_PER_GB = 1e9;
|
|
759
|
+
function usesLegacyMp4Support(asset) {
|
|
760
|
+
return asset.mp4_support !== void 0 && asset.mp4_support !== "none";
|
|
761
|
+
}
|
|
762
|
+
function parseFilesizeBytes(filesize) {
|
|
763
|
+
const bytes = typeof filesize === "string" ? Number(filesize) : filesize;
|
|
764
|
+
return typeof bytes === "number" && Number.isFinite(bytes) && bytes > 0 ? bytes : void 0;
|
|
765
|
+
}
|
|
766
|
+
function resolveLegacyMp4SupportRendition(asset) {
|
|
767
|
+
if (!usesLegacyMp4Support(asset)) {
|
|
768
|
+
return void 0;
|
|
769
|
+
}
|
|
770
|
+
const status = asset.static_renditions?.status;
|
|
771
|
+
if (status === void 0 || status === "preparing") {
|
|
772
|
+
return { kind: "preparing" };
|
|
773
|
+
}
|
|
774
|
+
if (status !== "ready") {
|
|
775
|
+
return {
|
|
776
|
+
kind: "unusable",
|
|
777
|
+
reason: `This asset uses the deprecated mp4_support setting, and its static renditions are ${status}. Move the asset to the Static Renditions API (${STATIC_RENDITIONS_GUIDE_URL}) and add an audio-only static rendition, then retry.`
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
const files = asset.static_renditions?.files ?? [];
|
|
781
|
+
for (const name of LEGACY_MP4_SUPPORT_FILE_PREFERENCE[asset.mp4_support] ?? []) {
|
|
782
|
+
const file = files.find((candidate) => candidate.name === name);
|
|
783
|
+
if (file) {
|
|
784
|
+
return { kind: "ready", name, filesizeBytes: parseFilesizeBytes(file.filesize) };
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
return {
|
|
788
|
+
kind: "unusable",
|
|
789
|
+
reason: `This asset uses the deprecated mp4_support setting ("${asset.mp4_support}"), and none of its static renditions can be used by this workflow. Move the asset to the Static Renditions API (${STATIC_RENDITIONS_GUIDE_URL}) and add an audio-only static rendition, then retry.`
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
function formatGigabytes(bytes) {
|
|
793
|
+
return `${Math.round(bytes / BYTES_PER_GB * 100) / 100} GB`;
|
|
794
|
+
}
|
|
795
|
+
function getLegacyMp4SupportRenditionSizeError(rendition, maxBytes) {
|
|
796
|
+
if (rendition.filesizeBytes === void 0 || rendition.filesizeBytes <= maxBytes) {
|
|
797
|
+
return void 0;
|
|
798
|
+
}
|
|
799
|
+
return `This asset uses the deprecated mp4_support setting, and its ${rendition.name} static rendition (${formatGigabytes(rendition.filesizeBytes)}) is larger than the ${formatGigabytes(maxBytes)} this workflow can process. Move the asset to the Static Renditions API (${STATIC_RENDITIONS_GUIDE_URL}) and add an audio-only static rendition, then retry.`;
|
|
800
|
+
}
|
|
801
|
+
|
|
750
802
|
// src/lib/workflow-crypto.ts
|
|
751
803
|
import { gcm } from "@noble/ciphers/aes.js";
|
|
752
804
|
var BASE64_CHUNK_SIZE = 32768;
|
|
@@ -1689,27 +1741,6 @@ async function createPresignedGetUrl({
|
|
|
1689
1741
|
return `${resolvedEndpoint.origin}${canonicalUri}?${queryWithSignature}`;
|
|
1690
1742
|
}
|
|
1691
1743
|
|
|
1692
|
-
// src/lib/workflow-serialization.ts
|
|
1693
|
-
var WORKFLOW_CLASS_REGISTRY = /* @__PURE__ */ Symbol.for("workflow-class-registry");
|
|
1694
|
-
function registerWorkflowSerializationClass(classId, cls) {
|
|
1695
|
-
const globalObject = globalThis;
|
|
1696
|
-
let registry = globalObject[WORKFLOW_CLASS_REGISTRY];
|
|
1697
|
-
if (!registry) {
|
|
1698
|
-
registry = /* @__PURE__ */ new Map();
|
|
1699
|
-
globalObject[WORKFLOW_CLASS_REGISTRY] = registry;
|
|
1700
|
-
}
|
|
1701
|
-
registry.set(classId, cls);
|
|
1702
|
-
const serializableClass = cls;
|
|
1703
|
-
if (serializableClass.classId !== classId) {
|
|
1704
|
-
Object.defineProperty(cls, "classId", {
|
|
1705
|
-
value: classId,
|
|
1706
|
-
writable: false,
|
|
1707
|
-
enumerable: false,
|
|
1708
|
-
configurable: false
|
|
1709
|
-
});
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
|
|
1713
1744
|
// src/lib/workflow-storage-client.ts
|
|
1714
1745
|
var WorkflowStorageClient = class {
|
|
1715
1746
|
constructor(options = {}) {
|
|
@@ -1761,8 +1792,6 @@ var WorkflowStorageClient = class {
|
|
|
1761
1792
|
return new this(value);
|
|
1762
1793
|
}
|
|
1763
1794
|
};
|
|
1764
|
-
WorkflowStorageClient.classId = "WorkflowStorageClient";
|
|
1765
|
-
registerWorkflowSerializationClass(WorkflowStorageClient.classId, WorkflowStorageClient);
|
|
1766
1795
|
function createWorkflowStorageClient(options = {}) {
|
|
1767
1796
|
return new WorkflowStorageClient(options);
|
|
1768
1797
|
}
|
|
@@ -2321,8 +2350,10 @@ async function fetchShotsFromManifest(shotsManifestUrl) {
|
|
|
2321
2350
|
async function transformShotsResponse(data) {
|
|
2322
2351
|
switch (data.status) {
|
|
2323
2352
|
case "pending":
|
|
2353
|
+
case "skipped":
|
|
2354
|
+
case "deleted":
|
|
2324
2355
|
return {
|
|
2325
|
-
status:
|
|
2356
|
+
status: data.status,
|
|
2326
2357
|
createdAt: data.created_at
|
|
2327
2358
|
};
|
|
2328
2359
|
case "errored":
|
|
@@ -2409,6 +2440,15 @@ async function waitForShotsForAsset(assetId, options = {}) {
|
|
|
2409
2440
|
if (result.status === "errored") {
|
|
2410
2441
|
throw new MuxAiError(`Shot generation failed for asset ${assetId}.`);
|
|
2411
2442
|
}
|
|
2443
|
+
if (result.status === "skipped") {
|
|
2444
|
+
throw new MuxAiError(
|
|
2445
|
+
`Shot generation was skipped for asset ${assetId}; the asset may have no video track.`,
|
|
2446
|
+
{ type: "validation_error" }
|
|
2447
|
+
);
|
|
2448
|
+
}
|
|
2449
|
+
if (result.status === "deleted") {
|
|
2450
|
+
throw new MuxAiError(`Shots for asset ${assetId} have been deleted.`, { type: "validation_error" });
|
|
2451
|
+
}
|
|
2412
2452
|
if (attempt < normalizedMaxAttempts - 1) {
|
|
2413
2453
|
await sleep(normalizedPollIntervalMs);
|
|
2414
2454
|
}
|
|
@@ -8546,8 +8586,9 @@ async function getSummaryAndTagsInternal(assetId, options, collectedUsage) {
|
|
|
8546
8586
|
|
|
8547
8587
|
// src/workflows/translate-audio.ts
|
|
8548
8588
|
import { sleep as sleep2 } from "workflow";
|
|
8549
|
-
var STATIC_RENDITION_POLL_INTERVAL_MS =
|
|
8550
|
-
var STATIC_RENDITION_MAX_ATTEMPTS =
|
|
8589
|
+
var STATIC_RENDITION_POLL_INTERVAL_MS = 1e4;
|
|
8590
|
+
var STATIC_RENDITION_MAX_ATTEMPTS = 180;
|
|
8591
|
+
var MAX_DUBBING_SOURCE_BYTES = 1e9;
|
|
8551
8592
|
var DUBBING_POLL_INTERVAL_MS = 1e4;
|
|
8552
8593
|
var DEFAULT_DUBBING_POLL_TIMEOUT_SECONDS = 7200;
|
|
8553
8594
|
function getReadyAudioStaticRendition(asset) {
|
|
@@ -8648,6 +8689,40 @@ async function waitForAudioStaticRendition({
|
|
|
8648
8689
|
{ type: "timeout_error", retryable: true }
|
|
8649
8690
|
);
|
|
8650
8691
|
}
|
|
8692
|
+
async function waitForLegacyMp4SupportRendition({
|
|
8693
|
+
assetId,
|
|
8694
|
+
initialAsset,
|
|
8695
|
+
credentials
|
|
8696
|
+
}) {
|
|
8697
|
+
let rendition = resolveLegacyMp4SupportRendition(initialAsset);
|
|
8698
|
+
for (let attempt = 1; rendition?.kind === "preparing" && attempt <= STATIC_RENDITION_MAX_ATTEMPTS; attempt++) {
|
|
8699
|
+
console.warn(
|
|
8700
|
+
`\u231B Waiting for mp4_support static renditions (attempt ${attempt}/${STATIC_RENDITION_MAX_ATTEMPTS})`
|
|
8701
|
+
);
|
|
8702
|
+
await sleep2(STATIC_RENDITION_POLL_INTERVAL_MS);
|
|
8703
|
+
rendition = resolveLegacyMp4SupportRendition(await retrieveAsset(assetId, credentials));
|
|
8704
|
+
}
|
|
8705
|
+
if (!rendition) {
|
|
8706
|
+
throw new MuxAiError(
|
|
8707
|
+
"The asset's static rendition settings changed while waiting for them. Please try again.",
|
|
8708
|
+
{ type: "processing_error", retryable: true }
|
|
8709
|
+
);
|
|
8710
|
+
}
|
|
8711
|
+
if (rendition.kind === "preparing") {
|
|
8712
|
+
throw new MuxAiError(
|
|
8713
|
+
"Timed out waiting for the static rendition to become ready. Please try again in a moment.",
|
|
8714
|
+
{ type: "timeout_error", retryable: true }
|
|
8715
|
+
);
|
|
8716
|
+
}
|
|
8717
|
+
if (rendition.kind === "unusable") {
|
|
8718
|
+
throw new MuxAiError(rendition.reason, { type: "validation_error" });
|
|
8719
|
+
}
|
|
8720
|
+
const sizeError = getLegacyMp4SupportRenditionSizeError(rendition, MAX_DUBBING_SOURCE_BYTES);
|
|
8721
|
+
if (sizeError) {
|
|
8722
|
+
throw new MuxAiError(sizeError, { type: "validation_error" });
|
|
8723
|
+
}
|
|
8724
|
+
return rendition.name;
|
|
8725
|
+
}
|
|
8651
8726
|
async function createElevenLabsDubbingJob({
|
|
8652
8727
|
sourceUrl,
|
|
8653
8728
|
assetId,
|
|
@@ -8856,7 +8931,8 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
8856
8931
|
}
|
|
8857
8932
|
let currentAsset = initialAsset;
|
|
8858
8933
|
let createdStaticRenditionId;
|
|
8859
|
-
|
|
8934
|
+
const isLegacyMp4SupportAsset = usesLegacyMp4Support(initialAsset);
|
|
8935
|
+
if (!isLegacyMp4SupportAsset && !hasReadyAudioStaticRendition(currentAsset)) {
|
|
8860
8936
|
console.warn("\u274C No ready audio static rendition found. Requesting one now...");
|
|
8861
8937
|
const renditionStatus = currentAsset.static_renditions?.status ?? "not_requested";
|
|
8862
8938
|
if (renditionStatus === "not_requested" || renditionStatus === "errored") {
|
|
@@ -8873,21 +8949,30 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
8873
8949
|
let captionsPresignedUrl;
|
|
8874
8950
|
let captionsTrackId;
|
|
8875
8951
|
try {
|
|
8876
|
-
|
|
8877
|
-
|
|
8952
|
+
let sourceRenditionName = "audio.m4a";
|
|
8953
|
+
if (isLegacyMp4SupportAsset) {
|
|
8954
|
+
sourceRenditionName = await waitForLegacyMp4SupportRendition({
|
|
8878
8955
|
assetId,
|
|
8879
8956
|
initialAsset: currentAsset,
|
|
8880
8957
|
credentials
|
|
8881
8958
|
});
|
|
8959
|
+
} else {
|
|
8960
|
+
if (!hasReadyAudioStaticRendition(currentAsset)) {
|
|
8961
|
+
currentAsset = await waitForAudioStaticRendition({
|
|
8962
|
+
assetId,
|
|
8963
|
+
initialAsset: currentAsset,
|
|
8964
|
+
credentials
|
|
8965
|
+
});
|
|
8966
|
+
}
|
|
8967
|
+
const audioRendition = getReadyAudioStaticRendition(currentAsset);
|
|
8968
|
+
if (!audioRendition) {
|
|
8969
|
+
throw new MuxAiError(
|
|
8970
|
+
"Unable to obtain an audio-only static rendition for this asset. Please verify static renditions are enabled in Mux.",
|
|
8971
|
+
{ type: "validation_error" }
|
|
8972
|
+
);
|
|
8973
|
+
}
|
|
8882
8974
|
}
|
|
8883
|
-
|
|
8884
|
-
if (!audioRendition) {
|
|
8885
|
-
throw new MuxAiError(
|
|
8886
|
-
"Unable to obtain an audio-only static rendition for this asset. Please verify static renditions are enabled in Mux.",
|
|
8887
|
-
{ type: "validation_error" }
|
|
8888
|
-
);
|
|
8889
|
-
}
|
|
8890
|
-
let audioUrl = `${await getMuxStreamOrigin(credentials)}/${playbackId}/audio.m4a`;
|
|
8975
|
+
let audioUrl = `${await getMuxStreamOrigin(credentials)}/${playbackId}/${sourceRenditionName}`;
|
|
8891
8976
|
if (policy === "signed") {
|
|
8892
8977
|
audioUrl = await signUrl(audioUrl, playbackId, "video", void 0, credentials);
|
|
8893
8978
|
}
|
|
@@ -9903,6 +9988,7 @@ async function translateCaptionsInternal(assetId, trackId, toLanguageCode, optio
|
|
|
9903
9988
|
export {
|
|
9904
9989
|
MUX_TRACK_PASSTHROUGH_MAX_CHARS,
|
|
9905
9990
|
MuxAiError,
|
|
9991
|
+
STATIC_RENDITIONS_GUIDE_URL,
|
|
9906
9992
|
WorkflowStorageClient,
|
|
9907
9993
|
buildMuxAiTrackPassthrough,
|
|
9908
9994
|
createWorkflowStorageClient,
|
|
@@ -9912,6 +9998,7 @@ export {
|
|
|
9912
9998
|
findSameLanguageTextTracks,
|
|
9913
9999
|
getLanguageCodePair,
|
|
9914
10000
|
getLanguageName,
|
|
10001
|
+
getLegacyMp4SupportRenditionSizeError,
|
|
9915
10002
|
getMuxPlaybackOrigin,
|
|
9916
10003
|
isDuplicateTrackNameError,
|
|
9917
10004
|
isMuxGeneratedTextTrack,
|
|
@@ -9926,10 +10013,12 @@ export {
|
|
|
9926
10013
|
replaceAndCreateTextTrack,
|
|
9927
10014
|
replaceAndCreateTrack,
|
|
9928
10015
|
replaceSourceTrack,
|
|
10016
|
+
resolveLegacyMp4SupportRendition,
|
|
9929
10017
|
setWorkflowCredentialsProvider,
|
|
9930
10018
|
summarizeTextTrack,
|
|
9931
10019
|
toISO639_1,
|
|
9932
10020
|
toISO639_3,
|
|
10021
|
+
usesLegacyMp4Support,
|
|
9933
10022
|
validateTrackPassthrough,
|
|
9934
10023
|
version,
|
|
9935
10024
|
workflows_exports as workflows,
|