@mux/ai 0.48.0 → 0.49.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 -6
- package/dist/index.js +127 -15
- 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 +1 -1
|
@@ -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.49.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`
|
|
@@ -84,4 +128,4 @@ declare class WorkflowStorageClient {
|
|
|
84
128
|
}
|
|
85
129
|
declare function createWorkflowStorageClient(options?: WorkflowStorageClientOptions): WorkflowStorageClient;
|
|
86
130
|
|
|
87
|
-
export { MuxAiError, type MuxAiErrorType, type MuxPlaybackService, StoragePresignGetObjectInput, StoragePutObjectInput, WorkflowCredentials, type WorkflowCredentialsProvider, WorkflowStorageClient, createWorkflowStorageClient, getMuxPlaybackOrigin, setWorkflowCredentialsProvider, version, wrapError };
|
|
131
|
+
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.49.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;
|
|
@@ -2321,8 +2373,10 @@ async function fetchShotsFromManifest(shotsManifestUrl) {
|
|
|
2321
2373
|
async function transformShotsResponse(data) {
|
|
2322
2374
|
switch (data.status) {
|
|
2323
2375
|
case "pending":
|
|
2376
|
+
case "skipped":
|
|
2377
|
+
case "deleted":
|
|
2324
2378
|
return {
|
|
2325
|
-
status:
|
|
2379
|
+
status: data.status,
|
|
2326
2380
|
createdAt: data.created_at
|
|
2327
2381
|
};
|
|
2328
2382
|
case "errored":
|
|
@@ -2409,6 +2463,15 @@ async function waitForShotsForAsset(assetId, options = {}) {
|
|
|
2409
2463
|
if (result.status === "errored") {
|
|
2410
2464
|
throw new MuxAiError(`Shot generation failed for asset ${assetId}.`);
|
|
2411
2465
|
}
|
|
2466
|
+
if (result.status === "skipped") {
|
|
2467
|
+
throw new MuxAiError(
|
|
2468
|
+
`Shot generation was skipped for asset ${assetId}; the asset may have no video track.`,
|
|
2469
|
+
{ type: "validation_error" }
|
|
2470
|
+
);
|
|
2471
|
+
}
|
|
2472
|
+
if (result.status === "deleted") {
|
|
2473
|
+
throw new MuxAiError(`Shots for asset ${assetId} have been deleted.`, { type: "validation_error" });
|
|
2474
|
+
}
|
|
2412
2475
|
if (attempt < normalizedMaxAttempts - 1) {
|
|
2413
2476
|
await sleep(normalizedPollIntervalMs);
|
|
2414
2477
|
}
|
|
@@ -8546,8 +8609,9 @@ async function getSummaryAndTagsInternal(assetId, options, collectedUsage) {
|
|
|
8546
8609
|
|
|
8547
8610
|
// src/workflows/translate-audio.ts
|
|
8548
8611
|
import { sleep as sleep2 } from "workflow";
|
|
8549
|
-
var STATIC_RENDITION_POLL_INTERVAL_MS =
|
|
8550
|
-
var STATIC_RENDITION_MAX_ATTEMPTS =
|
|
8612
|
+
var STATIC_RENDITION_POLL_INTERVAL_MS = 1e4;
|
|
8613
|
+
var STATIC_RENDITION_MAX_ATTEMPTS = 180;
|
|
8614
|
+
var MAX_DUBBING_SOURCE_BYTES = 1e9;
|
|
8551
8615
|
var DUBBING_POLL_INTERVAL_MS = 1e4;
|
|
8552
8616
|
var DEFAULT_DUBBING_POLL_TIMEOUT_SECONDS = 7200;
|
|
8553
8617
|
function getReadyAudioStaticRendition(asset) {
|
|
@@ -8648,6 +8712,40 @@ async function waitForAudioStaticRendition({
|
|
|
8648
8712
|
{ type: "timeout_error", retryable: true }
|
|
8649
8713
|
);
|
|
8650
8714
|
}
|
|
8715
|
+
async function waitForLegacyMp4SupportRendition({
|
|
8716
|
+
assetId,
|
|
8717
|
+
initialAsset,
|
|
8718
|
+
credentials
|
|
8719
|
+
}) {
|
|
8720
|
+
let rendition = resolveLegacyMp4SupportRendition(initialAsset);
|
|
8721
|
+
for (let attempt = 1; rendition?.kind === "preparing" && attempt <= STATIC_RENDITION_MAX_ATTEMPTS; attempt++) {
|
|
8722
|
+
console.warn(
|
|
8723
|
+
`\u231B Waiting for mp4_support static renditions (attempt ${attempt}/${STATIC_RENDITION_MAX_ATTEMPTS})`
|
|
8724
|
+
);
|
|
8725
|
+
await sleep2(STATIC_RENDITION_POLL_INTERVAL_MS);
|
|
8726
|
+
rendition = resolveLegacyMp4SupportRendition(await retrieveAsset(assetId, credentials));
|
|
8727
|
+
}
|
|
8728
|
+
if (!rendition) {
|
|
8729
|
+
throw new MuxAiError(
|
|
8730
|
+
"The asset's static rendition settings changed while waiting for them. Please try again.",
|
|
8731
|
+
{ type: "processing_error", retryable: true }
|
|
8732
|
+
);
|
|
8733
|
+
}
|
|
8734
|
+
if (rendition.kind === "preparing") {
|
|
8735
|
+
throw new MuxAiError(
|
|
8736
|
+
"Timed out waiting for the static rendition to become ready. Please try again in a moment.",
|
|
8737
|
+
{ type: "timeout_error", retryable: true }
|
|
8738
|
+
);
|
|
8739
|
+
}
|
|
8740
|
+
if (rendition.kind === "unusable") {
|
|
8741
|
+
throw new MuxAiError(rendition.reason, { type: "validation_error" });
|
|
8742
|
+
}
|
|
8743
|
+
const sizeError = getLegacyMp4SupportRenditionSizeError(rendition, MAX_DUBBING_SOURCE_BYTES);
|
|
8744
|
+
if (sizeError) {
|
|
8745
|
+
throw new MuxAiError(sizeError, { type: "validation_error" });
|
|
8746
|
+
}
|
|
8747
|
+
return rendition.name;
|
|
8748
|
+
}
|
|
8651
8749
|
async function createElevenLabsDubbingJob({
|
|
8652
8750
|
sourceUrl,
|
|
8653
8751
|
assetId,
|
|
@@ -8856,7 +8954,8 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
8856
8954
|
}
|
|
8857
8955
|
let currentAsset = initialAsset;
|
|
8858
8956
|
let createdStaticRenditionId;
|
|
8859
|
-
|
|
8957
|
+
const isLegacyMp4SupportAsset = usesLegacyMp4Support(initialAsset);
|
|
8958
|
+
if (!isLegacyMp4SupportAsset && !hasReadyAudioStaticRendition(currentAsset)) {
|
|
8860
8959
|
console.warn("\u274C No ready audio static rendition found. Requesting one now...");
|
|
8861
8960
|
const renditionStatus = currentAsset.static_renditions?.status ?? "not_requested";
|
|
8862
8961
|
if (renditionStatus === "not_requested" || renditionStatus === "errored") {
|
|
@@ -8873,21 +8972,30 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
8873
8972
|
let captionsPresignedUrl;
|
|
8874
8973
|
let captionsTrackId;
|
|
8875
8974
|
try {
|
|
8876
|
-
|
|
8877
|
-
|
|
8975
|
+
let sourceRenditionName = "audio.m4a";
|
|
8976
|
+
if (isLegacyMp4SupportAsset) {
|
|
8977
|
+
sourceRenditionName = await waitForLegacyMp4SupportRendition({
|
|
8878
8978
|
assetId,
|
|
8879
8979
|
initialAsset: currentAsset,
|
|
8880
8980
|
credentials
|
|
8881
8981
|
});
|
|
8982
|
+
} else {
|
|
8983
|
+
if (!hasReadyAudioStaticRendition(currentAsset)) {
|
|
8984
|
+
currentAsset = await waitForAudioStaticRendition({
|
|
8985
|
+
assetId,
|
|
8986
|
+
initialAsset: currentAsset,
|
|
8987
|
+
credentials
|
|
8988
|
+
});
|
|
8989
|
+
}
|
|
8990
|
+
const audioRendition = getReadyAudioStaticRendition(currentAsset);
|
|
8991
|
+
if (!audioRendition) {
|
|
8992
|
+
throw new MuxAiError(
|
|
8993
|
+
"Unable to obtain an audio-only static rendition for this asset. Please verify static renditions are enabled in Mux.",
|
|
8994
|
+
{ type: "validation_error" }
|
|
8995
|
+
);
|
|
8996
|
+
}
|
|
8882
8997
|
}
|
|
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`;
|
|
8998
|
+
let audioUrl = `${await getMuxStreamOrigin(credentials)}/${playbackId}/${sourceRenditionName}`;
|
|
8891
8999
|
if (policy === "signed") {
|
|
8892
9000
|
audioUrl = await signUrl(audioUrl, playbackId, "video", void 0, credentials);
|
|
8893
9001
|
}
|
|
@@ -9903,6 +10011,7 @@ async function translateCaptionsInternal(assetId, trackId, toLanguageCode, optio
|
|
|
9903
10011
|
export {
|
|
9904
10012
|
MUX_TRACK_PASSTHROUGH_MAX_CHARS,
|
|
9905
10013
|
MuxAiError,
|
|
10014
|
+
STATIC_RENDITIONS_GUIDE_URL,
|
|
9906
10015
|
WorkflowStorageClient,
|
|
9907
10016
|
buildMuxAiTrackPassthrough,
|
|
9908
10017
|
createWorkflowStorageClient,
|
|
@@ -9912,6 +10021,7 @@ export {
|
|
|
9912
10021
|
findSameLanguageTextTracks,
|
|
9913
10022
|
getLanguageCodePair,
|
|
9914
10023
|
getLanguageName,
|
|
10024
|
+
getLegacyMp4SupportRenditionSizeError,
|
|
9915
10025
|
getMuxPlaybackOrigin,
|
|
9916
10026
|
isDuplicateTrackNameError,
|
|
9917
10027
|
isMuxGeneratedTextTrack,
|
|
@@ -9926,10 +10036,12 @@ export {
|
|
|
9926
10036
|
replaceAndCreateTextTrack,
|
|
9927
10037
|
replaceAndCreateTrack,
|
|
9928
10038
|
replaceSourceTrack,
|
|
10039
|
+
resolveLegacyMp4SupportRendition,
|
|
9929
10040
|
setWorkflowCredentialsProvider,
|
|
9930
10041
|
summarizeTextTrack,
|
|
9931
10042
|
toISO639_1,
|
|
9932
10043
|
toISO639_3,
|
|
10044
|
+
usesLegacyMp4Support,
|
|
9933
10045
|
validateTrackPassthrough,
|
|
9934
10046
|
version,
|
|
9935
10047
|
workflows_exports as workflows,
|