Encode

Encode API.

type ApiEncodeFunction = (args: ApiEncodeRequest, opts?: ServerJobOptions) => Promise<DataOrError<(MediaResource|Encoding)>>
/**
 * Configuration options for the encode
 * endpoint of an Api.
 */
interface ApiEncodeOptions 
extends ApiCodeOptions {
  addResource?: boolean
  requestResource?: boolean
  updateResource?: boolean
}
/**
 * A request for the encode endpoint of an
 * Api.
 */
interface ApiEncodeRequest 
extends CodeArgs {
  arg: StorableMash
  mashMedia?: Array
  mediaId?: string
  opt?: object
  resourceId?: string
  source?: EncodingSource
}
interface Command 
extends EventEmitter {
  _getArguments: () => Strings
  addInput: (input: string) => Command
  addInputOptions: (options: Strings) => Command
  addOptions: (options: Strings) => Command
  addOutputOption: (option: string) => Command
  addOutputOptions: (options: Strings) => Command
  complexFilter: (spec: FfmpegFilter) => Command
  ffprobe: (callback: CommandProbeFunction) => void
  kill: (signal: string) => void
  map: (spec: string) => Command
  noAudio: () => Command
  noVideo: () => Command
  output: (destination: string) => Command
  run: () => void
  save: (output: string) => Command
}
interface CommandFile 
extends MediaFile {
  asset: Media
  avType?: 'audio' | 'video'
  content?: string
  file: AbsolutePath
  inputId: string
  inputOptions?: ValueRecord
  outputOptions?: ValueRecord
  path?: AbsolutePath
  type: MediaFileType
}
interface CommandFileArgs 
extends CommandFileOptions, CacheArgs {
  audible?: boolean
  clipTime: TimeRange
  time: Time
  visible?: boolean
}
interface CommandFileOptions  {
  time: Time
}
interface CommandFilter  {
  filter: string
  inputs: Strings
  options: ValueRecord | string
  outputs: Strings
}
interface CommandFilterArgs  {
  chainInput: string
  clipTime: TimeRange
  commandFiles: Array<CommandFile>
  duration: number
  filterInput?: string
  track: number
}
interface CommandInput  {
  avType?: AudibleType
  inputOptions?: ValueRecord
  outputOptions?: ValueRecord
  source: string
}
interface CommandInputRecord 
extends Record<string, CommandInput> {}
interface CommandOptions 
extends EncodeDescription {
  avType?: AudibleType
  commandFilters: Array<CommandFilter>
  duration: number
  inputsById: CommandInputRecord
  output: OutputOptions
}
interface EncodeCommands  {
  audibleDescriptions?: Array<EncodeDescription>
  encodingSource: EncodingSource
  outputOptions: OutputOptions
  visibleDescriptions?: Array<EncodeDescription>
}
interface EncodeDescription 
extends CodeDescription {
  avType?: AudibleType
  commandFilters: Array<CommandFilter>
  duration: number
  inputsById: CommandInputRecord
}
type EncodeOutputOptions = AudioOutputOptions | VideoOutputOptions | ImageOutputOptions
interface EncodeProperties  {}
interface Encoding 
extends StoredEncode {
  bytes?: number
  createdAt?: number
  decoded?: UnknownRecord
  deletedAt?: number
  error?: NamedError
  extension: string
  id: string
  request?: EndpointRequest
  source: string
  storedAt?: number
  type: string
  updatedAt?: number
}
type EncodingSource = MediaType
type FfmpegFilter = OrArray<StringOrFilter>
interface MashCommand  {
  assetsServerPromise: () => Promise<DataOrError<number>>
  audible: boolean
  avType?: AudibleType
  duration: number
  encodeDescription: () => Promise<EncodeDescription>
  filters: () => Promise<Array<CommandFilter>>
  inputs: () => Promise<CommandInputRecord>
  precodeDescription: () => Promise<PrecodeDescription>
  time: Time
  visible: boolean
}
interface MashCommandArgs  {
  clip?: Clip
  mashDescription: ServerMashDescription
  time: Time
}
interface PrecodeCommands  {
  commandDescriptions: Array<PrecodeDescription>
  outputOptions: VideoOutputOptions
  times: Array<Time>
}
interface PrecodeDescription 
extends CodeDescription {
  clip: Clip
  commandFilters: Array<CommandFilter>
  duration: number
  inputsById: CommandInputRecord
}
interface RunningCommand 
extends WithId {
  command: Command
  commandArguments: Strings
  commandString: (destination: string) => string
  id: string
  kill: () => void
  writePromise: (destination: string) => Promise<DataOrError<string>>
}
type SystemCommandFunction = (args: SystemCommandRequest) => Promise<DataOrError<string>>
interface SystemCommandRequest  {
  args: OrArray<string>
  command: string
}
/** @implements Api */
class FfmpegApi
extends ServerApi {
  add?: ApiAddFunction
  apiStoreDelete: StoreDeleteFunction
  apis?: ApiApisFunction
  args: ApiOptions
  bitmapsPath: (resourcePath: AbsolutePath, options: OutputOptions, duration: number) => AbsolutePath
  decode?: ApiDecodeFunction
  delete?: ApiDeleteFunction
  download?: ApiDownloadFunction
  encode?: ApiEncodeFunction
  find?: ApiFindFunction
  host: Plugins
  id: string
  insert?: ApiInsertFunction
  jobStatus: (identified: MediaResource, opts?: ServerJobOptions) => Promise<DataOrError<(MediaResource|StoredResource)>>
  mash?: ApiMashFunction
  media?: ApiMediaFunction
  remove?: ApiRemoveFunction
  status?: ApiStatusFunction
  transcode?: ApiTranscodeFunction
  upload?: ApiUploadFunction
}
/** @implements ApisPlugin */
class FfmpegApisPlugin
extends ServerApisPlugin {
  _apiFfmpeg: ApisApiFunction
  add: ApisAddFunction
  api: ApisApiFunction
  apis: Array<Api>
  assureOwned: ApisAssureOwnedFunction
  fetch: ApisFetchFunction
  find: ApisFindFunction
  findOptions: ApisFindOptionsFunction
  install: function
  mediaMasher: MediaMasher
  options: ApisOptionsFunction
  remove: ApisRemoveFunction
  unauthedUserId: string
}
/** @implements MashCommand */
class MashCommandClass {
  _id: StringOrNot
  assetsServerPromise: () => Promise<DataOrError<number>>
  audible: boolean
  avType?: AudibleType
  baseCommandFilePromise: (media: Media, args: FilesCacheArgs, commandFile: CommandFile) => Promise<DataOrError<number>>
  clip: () => Clip | undefined
  commandFilePromise: (media: Media, args: FilesCacheArgs, commandFile: CommandFile) => Promise<DataOrError<number>>
  commandFiles: (instance: Instance | VisibleInstance, cacheArgs: CommandFileArgs) => Array<CommandFile>
  commandRawFilePromise: (media: Media, args: FilesCacheArgs, file: CommandFile) => Promise<DataOrError<number>>
  commandSvgFilePromise: (media: VisibleMedia, args: FilesCacheArgs, file: CommandFile) => Promise<DataOrError<number>>
  duration: number
  encodeDescription: () => Promise<EncodeDescription>
  filters: () => Promise<Array<CommandFilter>>
  id: () => string
  inputCommandFiles: () => Promise<Array<CommandFile>>
  inputs: () => Promise<CommandInputRecord>
  mediaType: MediaType
  precodeDescription: () => Promise<PrecodeDescription>
  time: Time
  visible: boolean
}
function ffmpegCommand(
): Command
function ffmpegCommandString(
  host: Plugins, 
  args: Strings, 
  destination: string, 
  expanded?: boolean
): string
function ffmpegFilters(
  command: Command, 
  commandFilters: Array<CommandFilter>
): void
function ffmpegInput(
  command: Command, 
  input: string | CommandInput
): void
function ffmpegInputs(
  command: Command, 
  record: CommandInputRecord
): void
function ffmpegOptions(
  command: Command, 
  outputOptions: OutputOptions
): void
function ffmpegSavePromise(
  host: Plugins, 
  command: Command, 
  outputPath: string
): Promise<DataOrError<string>>
/** Type guard for Encoding */
function isEncoding(
  value: unknown
): boolean
const ERROR_FFMPEG = 'error.ffmpeg'