import { F as File, g as FileReturn, B as BaseStorage } from "../packem_shared/storage.d-C9EdfTf1.js"; import { A as AudioTransformerConfig, b as AudioTransformResult, c as AudioResampleOptions, d as AudioChannelMixOptions, e as AudioTransformOptions, f as AudioTransformationStep, B as BaseTransformer } from "../packem_shared/types.d-D1TIRqKW.js"; import 'node:stream'; import 'node:timers'; import 'node:crypto'; import 'node:http'; import 'lru-cache'; /** * Audio transformer that uses storage backends and Mediabunny to retrieve and transform audio files * * Supports audio transformations with query parameters for on-demand audio processing. * @example * ```ts * const transformer = new AudioTransformer(storage, { * maxAudioSize: 50 * 1024 * 1024, // 50MB * cache: new Map() * }); * * // Programmatic usage - resample audio * const result = await transformer.resample('audio-id', { * sampleRate: 44100 * }); * * // URL-based transformations * // GET /files/audio-id?sampleRate=48000&codec=aac&bitrate=128000 * // GET /files/audio-id?numberOfChannels=1&format=mp3 * ``` * * ## Supported Query Parameters * * - `sampleRate`: Sample rate in Hz (Number) * - `numberOfChannels`: Number of channels (Number) * - `codec`: Audio codec - aac/opus/mp3/vorbis/flac * - `bitrate`: Audio bitrate in bits per second (Number) * - `format`: Output format - mp3/wav/ogg/aac/flac */ declare class AudioTransformer extends BaseTransformer, TFile, TFileReturn> { /** * Creates a new AudioTransformer instance. * @param storage The storage backend for retrieving and storing audio files. * @param config Configuration options for audio transformation including cache settings, codec defaults, and size limits. */ constructor(storage: BaseStorage, config?: AudioTransformerConfig); /** * Resamples audio to different sample rate. * @param fileId Unique identifier of the audio file to resample. * @param options Resample options including target sample rate. * @returns Promise resolving to transformed audio result. */ resample(fileId: string, options: AudioResampleOptions): Promise>; /** * Changes number of channels (up/downmixing). * @param fileId Unique identifier of the audio file to process. * @param options Channel mix options including target number of channels. * @returns Promise resolving to transformed audio result. */ mixChannels(fileId: string, options: AudioChannelMixOptions): Promise>; /** * Converts audio format or codec. * @param fileId Unique identifier of the audio file to convert. * @param format Target audio format (e.g., "mp3", "wav", "ogg"). * @param options Additional transform options. * @returns Promise resolving to transformed audio result. */ convertFormat(fileId: string, format: string, options?: AudioTransformOptions): Promise>; /** * Transcodes audio to different codec. * @param fileId Unique identifier of the audio file to transcode. * @param codec Target audio codec (e.g., "aac", "opus", "mp3"). * @param options Additional transform options. * @returns Promise resolving to transformed audio result. */ transcode(fileId: string, codec: AudioTransformOptions["codec"], options?: Omit): Promise>; /** * Applies a custom transformation pipeline to an audio file. * @param fileId Unique identifier of the audio file to transform. * @param steps Array of transformation steps to apply in sequence. * @returns Promise resolving to transformed audio result. */ transform(fileId: string, steps: AudioTransformationStep[]): Promise>; /** * Apply multiple transformations in sequence using Mediabunny */ private applyTransformations; /** * Convert transformation steps to Mediabunny audio options * @param steps Array of audio transformation steps to convert * @returns Mediabunny audio options object for conversion * @private */ private stepsToAudioOptions; /** * Determine output format based on transformation steps * @param steps Array of audio transformation steps * @returns Mediabunny output format instance (defaults to MP3) * @private */ private determineOutputFormat; /** * Convert format string to Mediabunny output format * @param format Audio format string (aac, flac, mp3, ogg, wav) * @returns Mediabunny output format instance * @private */ private formatStringToOutputFormat; /** * Validate that the file is a supported audio file * @param file The file to validate * @returns Promise that resolves if validation passes * @throws Error if file size exceeds limits, wrong content type, unsupported format, or invalid audio * @private */ private validateAudio; /** * Create transformation result with metadata * @param buffer The transformed audio buffer * @param originalFile The original file information * @returns Audio transformation result with metadata * @private */ private createTransformResult; /** * Generate cache key for transformation * @param fileId The file identifier * @param steps Array of transformation steps * @returns Unique cache key string * @private */ private generateCacheKey; } export { AudioTransformer as default };