From fc32d319450ac33e8c7cbdf4b95f387dca53eef5 Mon Sep 17 00:00:00 2001 From: sujal-into Date: Fri, 22 Nov 2024 18:01:26 +0545 Subject: [PATCH] fix: types for the mp4box package --- packages/utils/types/mp4box.d.ts | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 packages/utils/types/mp4box.d.ts diff --git a/packages/utils/types/mp4box.d.ts b/packages/utils/types/mp4box.d.ts new file mode 100644 index 000000000..49d1aefce --- /dev/null +++ b/packages/utils/types/mp4box.d.ts @@ -0,0 +1,43 @@ +declare module "mp4box" { + export interface MP4FileInfo { + duration: number; // Duration in timescale units + timescale: number; // Timescale of the file + isFragmented: boolean; // Whether the MP4 is fragmented + brands: string[]; // Major and compatible brands + created: Date; // Creation time + modified: Date; // Modification time + tracks: MP4Track[]; // Array of tracks in the file + } + + export interface MP4Track { + id: number; // Track ID + type: string; // Track type (e.g., "video", "audio") + codec: string; // Codec used for this track + language: string; // Language of the track + created: Date; // Creation time + modified: Date; // Modification time + timescale: number; // Timescale for the track + duration: number; // Duration in timescale units + bitrate: number; // Average bitrate of the track + width?: number; // Video width (if applicable) + height?: number; // Video height (if applicable) + sampleCount: number; // Number of samples in the track + samples: any[]; // Detailed sample information + } + + export interface MP4ArrayBuffer extends ArrayBuffer { + fileStart: number; // Start position of the buffer in the file + } + + export interface MP4BoxFile { + onReady?: (info: MP4FileInfo) => void; + onError?: (error: string) => void; + appendBuffer(data: ArrayBuffer): number; + start(): void; + stop(): void; + flush(): void; + createFile(): MP4BoxFile; + } + + export function createFile(): MP4BoxFile; +}