UNPKG

@diffusionstudio/core-v4

Version:

A fast, browser based video compositing engine powered by WebCodecs

93 lines (92 loc) 2.18 kB
import { VideoCodec, AudioCodec } from 'mediabunny'; import { ContainerFormat } from './types'; import { Time } from '../types'; export interface AudioConfig { /** * Enable audio encoding * @default true */ enabled?: boolean; /** * A floating point number indicating the audio context's sample rate, in samples per second. * @default 48000 */ sampleRate?: number; /** * Defines the number of channels of the composed audio * @default 2 */ numberOfChannels?: number; /** * Defines the bitrate at which the audio should be rendered at * @default 128e3 */ bitrate?: number; /** * Defines the codec to use for the audio * @default 'aac' */ codec?: AudioCodec; } export interface VideoConfig { /** * Defines the codec to use for the video * @default 'avc' */ codec?: VideoCodec; /** * The full codec string as specified in the WebCodecs API Codec Registry. */ fullCodecString?: string; /** * Enable video encoding * @default true */ enabled?: boolean; /** * Defines the bitrate at which the video should be rendered at * @default 10e6 */ bitrate?: number; /** * Defines the fps at which the composition will be rendered * @default 30 */ fps?: number; /** * Multiplier of the composition size * @example 2 // 1080p -> 4K * @default 1 // 1080p -> 1080p */ resolution?: number; } export interface EncoderConfig { /** * Video encoding configuration */ video?: VideoConfig; /** * Audio encoding configuration */ audio?: AudioConfig; /** * Defines if the performance should be logged * @default false */ debug?: boolean; /** * Defines the output format of the encoded file * @default 'mp4' */ format?: ContainerFormat; /** * Defines the range of the composition to encode */ range?: { /** * Defines the time when the encoding should end * @default composition.duration */ end?: Time; }; }