/*! * Copyright (c) 2025-present, Vanilagy and contributors * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { Muxer } from "../muxer"; import type { Output, OutputAudioTrack, OutputSubtitleTrack, OutputTrack, OutputVideoTrack } from "../output"; import { type IsobmffOutputFormat } from "../output-format"; import type { EncodedPacket, PacketType } from "../packet"; import { type SubtitleConfig, type SubtitleCue, type SubtitleMetadata } from "../subtitles"; export declare const GLOBAL_TIMESCALE = 1000; export type Sample = { timestamp: number; decodeTimestamp: number; duration: number; data: Uint8Array | null; size: number; type: PacketType; timescaleUnitsToNextSample: number; }; type Chunk = { /** The lowest presentation timestamp in this chunk */ startTimestamp: number; samples: Sample[]; offset: number | null; moofOffset: number | null; }; export type IsobmffTrackData = { muxer: IsobmffMuxer; timescale: number; samples: Sample[]; sampleQueue: Sample[]; timestampProcessingQueue: Sample[]; timeToSampleTable: { sampleCount: number; sampleDelta: number; }[]; compositionTimeOffsetTable: { sampleCount: number; sampleCompositionTimeOffset: number; }[]; lastTimescaleUnits: number | null; lastSample: Sample | null; finalizedChunks: Chunk[]; currentChunk: Chunk | null; compactlyCodedChunkTable: { firstChunk: number; samplesPerChunk: number; }[]; } & ({ track: OutputVideoTrack; type: "video"; info: { width: number; height: number; decoderConfig: VideoDecoderConfig; /** * The "Annex B transformation" involves converting the raw packet data from Annex B to * "MP4" (length-prefixed) format. * https://stackoverflow.com/questions/24884827 */ requiresAnnexBTransformation: boolean; }; } | { track: OutputAudioTrack; type: "audio"; info: { numberOfChannels: number; sampleRate: number; decoderConfig: AudioDecoderConfig; /** * The "PCM transformation" is making every sample in the sample table be exactly one PCM audio sample long. * Some players expect this for PCM audio. */ requiresPcmTransformation: boolean; }; } | { track: OutputSubtitleTrack; type: "subtitle"; info: { config: SubtitleConfig; }; lastCueEndTimestamp: number; cueQueue: SubtitleCue[]; nextSourceId: number; cueToSourceId: WeakMap; }); export type IsobmffVideoTrackData = IsobmffTrackData & { type: "video"; }; export type IsobmffAudioTrackData = IsobmffTrackData & { type: "audio"; }; export type IsobmffSubtitleTrackData = IsobmffTrackData & { type: "subtitle"; }; export type IsobmffMetadata = { name?: string; }; export declare const getTrackMetadata: (trackData: IsobmffTrackData) => IsobmffMetadata; export declare const intoTimescale: (timeInSeconds: number, timescale: number, round?: boolean) => number; export declare class IsobmffMuxer extends Muxer { format: IsobmffOutputFormat; private writer; private boxWriter; private fastStart; isFragmented: boolean; isQuickTime: boolean; private auxTarget; private auxWriter; private auxBoxWriter; private mdat; private ftypSize; trackDatas: IsobmffTrackData[]; private allTracksKnown; creationTime: number; private finalizedChunks; private nextFragmentNumber; private maxWrittenTimestamp; private minimumFragmentDuration; constructor(output: Output, format: IsobmffOutputFormat); start(): Promise; private allTracksAreKnown; getMimeType(): Promise; private getVideoTrackData; private getAudioTrackData; private getSubtitleTrackData; addEncodedVideoPacket(track: OutputVideoTrack, packet: EncodedPacket, meta?: EncodedVideoChunkMetadata): Promise; addEncodedAudioPacket(track: OutputAudioTrack, packet: EncodedPacket, meta?: EncodedAudioChunkMetadata): Promise; private maybePadWithSilence; addSubtitleCue(track: OutputSubtitleTrack, cue: SubtitleCue, meta?: SubtitleMetadata): Promise; private processWebVTTCues; private createSampleForTrack; private processTimestamps; private registerSample; private addSampleToTrack; private finalizeCurrentChunk; private interleaveSamples; private finalizeFragment; private registerSampleFastStartReserve; private computeSampleTableSizeUpperBound; onTrackClose(track: OutputTrack): Promise; /** Finalizes the file, making it ready for use. Must be called after all video and audio chunks have been added. */ finalize(): Promise; } export {}; //# sourceMappingURL=isobmff-muxer.d.ts.map