UNPKG

@adonis-agora/media

Version:

Media-library for AdonisJS — owner collections (MIME whitelist, single-file replace, ordering), image conversions (eager/lazy), pluggable content transformers (HLS video via mediabunny, metadata probe, image blur-up placeholder), and column attachments, a

56 lines • 2.38 kB
import type { Transformer, TransformerContext, TransformResult } from '../transformer.js'; /** What probing a media file yields — persisted verbatim as the conversion's `meta`. */ export interface MediaProbeSummary { /** Container format name (e.g. `MP4`), when the engine can tell. */ format?: string; /** Full MIME type including codecs parameter, when the engine can tell. */ mimeType?: string; durationSeconds?: number; width?: number; height?: number; videoCodec?: string | null; audioCodec?: string | null; audioSampleRate?: number; audioChannels?: number; hasVideo: boolean; hasAudio: boolean; } /** * The engine seam of {@link MetadataProbeTransformer}: local file in, metadata out. Default engine * is mediabunny (lazy); tests inject a fake. */ export interface MediaProbeEngine { probe(sourcePath: string): Promise<MediaProbeSummary>; } export interface MetadataProbeTransformerOptions<Name extends string = 'probe'> { /** Conversion name on the record. Default `'probe'`. */ name?: Name; /** * Run inside attach. Default `false`: probing is CPU-cheap but reads the original, and on a * remote disk that read is a download. Opt in for collections of small files. */ eager?: boolean; /** Replace the mediabunny engine — e.g. `engines.ffprobe()`, or your own {@link MediaProbeEngine}. */ engine?: MediaProbeEngine; } /** * The built-in **metadata-only** {@link Transformer}: reads a media file's technical metadata — * duration, resolution, codecs, channel layout — and persists it as * `record.conversions['probe'].meta`, writing **no artifact at all**. The reference implementation * of the "derive metadata, not files" transformer shape; the model for a blurhash/thumbhash * placeholder transformer. * * ```ts * await media.library.transform(id, 'probe') * const record = await media.library.find(id) * record.conversions.probe?.meta // { durationSeconds: 41.6, width: 1920, ... } * ``` */ export declare class MetadataProbeTransformer<Name extends string = 'probe'> implements Transformer { readonly name: Name; readonly eager: boolean; private readonly engine; constructor(options?: MetadataProbeTransformerOptions<Name>); transform(context: TransformerContext): Promise<TransformResult>; } //# sourceMappingURL=probe.d.ts.map