Types
Types and Zod schemas exported by @mcut/media.
Types
MediaProbe
interface MediaProbe {
durationMs: number
hasVideo: boolean
hasAudio: boolean
width?: number
height?: number
mimeType?: string
}The result of probeMedia, duration, which tracks exist, optional dimensions, and MIME type.
MediaOrigin
type MediaOrigin =
| { kind: 'blob'; blob: Blob; name: string }Where the bytes of a media file come from. Today the only member is a blob with a display name.
MediaProberId
type MediaProberId = 'mediabunny'The closed set of prober ids. Today the only member is mediabunny.
MediaProber
interface MediaProber {
id: MediaProberId
probe(origin: MediaOrigin, signal?: AbortSignal): Promise<MediaProbe>
}An engine that turns a MediaOrigin into a MediaProbe. createAsset accepts one so another engine can replace mediabunnyProber without changing its callers.
MediaProbeErrorCode
type MediaProbeErrorCode = 'unreadable' | 'no-tracks' | 'no-duration'Why a probe was rejected. unreadable when no demuxer or the browser can parse the file, no-tracks when it parses but has no audio or video track, no-duration when it has tracks but no measurable duration.
MediaSourceLike
type MediaSourceLike = Blob | stringA media source given as a blob or a URL string.
ThumbnailOptions
interface ThumbnailOptions {
width?: number
timeMs?: number
}Options for thumbnails, the output width and the source time to capture.
ExtractAudioOptions
interface ExtractAudioOptions {
sampleRate?: number
numberOfChannels?: number
onProgress?: (progress: number) => void
signal?: AbortSignal
}Options for extractAudioToWav, the output sample rate and channel count, a progress callback, and a signal that cancels the conversion and rejects with the signal's reason.
ActiveMediaItem
interface ActiveMediaItem {
assetId: AssetId
sourceTimeMs: number
rate: number
reversed?: boolean
}One video feed that is showing at a moment, with its source time, playback rate, and reversal.
PreviewSyncOptions
interface PreviewSyncOptions {
isPlaying: boolean
playbackRate: number
}The playback state passed to PreviewMediaPool.sync, the playing flag and the transport rate.
ContainerFormatId
type ContainerFormatId = keyof typeof containerFormatsA key of the containerFormats table, mp4, webm, or mkv.
ExportFontFaceInit
interface ExportFontFaceInit {
family: string
weight?: string
style?: string
unicodeRange?: string
source: ArrayBuffer | string
}A font face the export worker registers before rendering, given as binary data or a URL.
ExportProgress
interface ExportProgress {
progress: number
phase: 'audio' | 'video' | 'finalize'
}Export progress as a 0 to 1 fraction within the audio, video, or finalize phase.
ExportProjectOptions
interface ExportProjectOptions {
format?: ContainerFormatId
videoBitrate?: number | Quality
fonts?: ExportFontFaceInit[]
audioSources?: ReadonlyMap<ElementId, string>
onProgress?: (progress: ExportProgress) => void
signal?: AbortSignal
}Options for exportProject, the container format, video bitrate or quality, fonts, per-clip replacement audio URLs, progress callback, and abort signal.
ExportResult
interface ExportResult {
blob: Blob
extension: string
}The exported file as a blob together with its file extension.
ContainerFormat
interface ContainerFormat {
label: string
extension: string
mimeType: string
createOutputFormat: () => Promise<OutputFormat>
}A container format's label, file extension, MIME type, and factory for the Mediabunny output format that muxes it.
ContainerFormatEntry
interface ContainerFormatEntry extends ContainerFormat {
id: ContainerFormatId
}A ContainerFormat together with its id, as returned by listContainerFormats.
Filmstrip
interface Filmstrip {
canvas: HTMLCanvasElement | OffscreenCanvas
frameWidth: number
frameHeight: number
frameCount: number
timestampsMs: number[]
}The filmstrip canvas with its frame size, frame count, and the source timestamp of each frame.
FilmstripOptions
interface FilmstripOptions {
frameCount: number
frameWidth?: number
startMs?: number
endMs?: number
}Options for getFilmstrip, the frame count, frame width, and source range.
VideoPreviewCapability
interface VideoPreviewCapability {
name?: string
mimeType?: string
nativePreview?: boolean
}The asset fields that decide native preview eligibility, name, MIME type, and an explicit nativePreview override.
AudioPeaks
interface AudioPeaks {
peaks: Float32Array
durationMs: number
}Waveform peak buckets and the duration they cover.
AudioPeaksOptions
interface AudioPeaksOptions {
buckets?: number
startMs?: number
endMs?: number
}Options for extractAudioPeaks, the bucket count and the source range.
AudioActivity
interface AudioActivity {
durationMs: number
soundWindows: AudioActivityWindow[]
silenceWindows: AudioActivityWindow[]
summary: AudioActivitySummary
waveform?: number[]
}Sound and silence windows over a duration, a summary, and an optional waveform.
AudioActivityOptions
interface AudioActivityOptions {
startMs?: number
endMs?: number
frameMs?: number
threshold?: number
minSoundMs?: number
minSilenceMs?: number
paddingMs?: number
waveformBuckets?: number
}Options for activity analysis, the source range, frame size, threshold, minimum run lengths, padding, and waveform bucket count.
AudioActivitySummary
interface AudioActivitySummary {
soundMs: number
silenceMs: number
soundFraction: number
silenceFraction: number
peakRms: number
peakAmplitude: number
}Totals and fractions of sound and silence plus the peak RMS and peak amplitude.
AudioActivityWindow
interface AudioActivityWindow {
startMs: number
endMs: number
durationMs: number
rms: number
peakRms: number
peakAmplitude: number
}One sound or silence window with its bounds, duration, mean RMS, peak RMS, and peak amplitude.
ConstantSpeed
interface ConstantSpeed {
rate: number
sourceStartOffsetMs: number
sourceSpanMs: number
}A constant playback rate with the source offset where it starts and the source span it consumes.
StereoData
interface StereoData {
left: Float32Array
right: Float32Array
sampleRate: number
}Left and right PCM channels with their sample rate.
AudioSyncOptions
interface AudioSyncOptions {
windowS?: number
maxLagS?: number
rateHz?: number
signal?: AbortSignal
}Options for audio sync, the analysis window in seconds, the maximum lag, the envelope rate, and an abort signal.
SyncResult
interface SyncResult {
offsetMs: number
confidence: number
}A sync offset in milliseconds and the confidence of the match.
ProjectStill
The PNG blob from renderProjectStill, with its pixel width, pixel height, and the ids of the elements drawn.
RenderProjectStillOptions
Optional arguments for renderProjectStill. soloElementId draws only that element, including a multicam composite. width caps the PNG width and keeps the project aspect ratio.
SceneChangeOptions
Optional arguments for findSceneChanges. elementId picks a video or multicam clip and defaults to the first multicam, then the first video clip. source picks a multicam source and defaults to screen, then the first video source. startMs and endMs bound the scan in timeline time and default to the clip span. stepMs defaults to 500. sensitivity runs from 0 to 1 and defaults to 0.5, where a change needs 30% of the picture to change. maxChanges defaults to 40 and keeps the largest changes.
SceneChangeReport
The result of findSceneChanges. It names the element, the source, and the asset it read, the range, stepMs, sensitivity, the threshold fraction it used, and the number of samples. changes lists { timeMs, changed } in timeline order. segments lists the { startMs, endMs } stretches between changes. truncated is true when maxChanges dropped smaller changes.
ContactSheetOptions
Optional arguments for renderContactSheet. It takes the same elementId, source, startMs, and endMs as SceneChangeOptions, plus timesMs, count (default 12), columns (default a square grid), and thumbWidth in pixels (default 320).
ContactSheet
The PNG blob from renderContactSheet, with its pixel width and height, the column count, the element and source it read, and tiles, the timeline time of each tile in grid order.
FaceSample
FaceSample is { sourceMs, box }, one reading of createLocalFaceDetector at an integer source media time. box is the largest face as { x, y, w, h } fractions of the frame, or null when the frame has none. It fits FaceSample from @mcut/editor, so detect output goes straight to planCenterPerson.