Skip to main content

Convert

const convertedFile = modfy.convert(
{
inputFiles: ['./input.mp4'],
to: {
format: 'MOV',
codec: 'H.264' // Optional, will otherwise revert to the default codec for that format
}
},
'sync', // Can be 'async', 'sync', or 'client'
'https://yourdomain.com/modfyWebhook'
)

Arguments#

ParameterTypeDescription
formatstringDesired format output
codecstring?If not specified, the default codec for that format will be used

The default formats are AVI, MOV, MP4, WMV, WEBM with new formats constantly being added. Let us know if you want a new supported format! Full class reference is below

Typing#

modfy.convert(
{
inputFiles: AcceptedFiles,
to: ToFile
},
processType: ProcessType,
webhookUrl?: string
): Promise<Uint8Array> | Promise<{ id: string, uuid: string }>
type ToFile = {
format: FormatKey // From the keys of the default formats
codec?: CodecKey // From the keys of the default codecs
}
type ProcessType = "sync" | "client" | "async"
/**
* This interface is a wrapper for a file object which takes a buffer
* with the mimeType and name of the file
*/
type ModfyFile = {
name: string
mimeType?: string
buffer: Buffer
}
type StoredFiles = File[] | ModfyFile[]
/**
* This type represents the accepted file inputs
*
* There are three accepted file input types
* 1. Array of Html File Object
* 2. Array of Strings, File Paths (Node only)
* 3. Array of {buffer, name, mimeType}
Here we are supporting buffers directly but require that you provide the name and mimeType
*/
type AcceptedFiles = StoredFiles | string[]

Caveats#

  • All files in the input array must be of same type
  • String paths are only supported in node