Skip to main content

Trim

const trimmedFile = modfy.trim(
{
inputFiles: [karaokeVideo],
start: 10, // Video will start at 10 seconds
end: 15 // Video will end at 15 seconds
},
'sync' // Can be 'async' | 'sync' | 'client',
webhookUrl? : string // When using async must pass this paramater
)

Arguments#

This operation has three arguments:

  1. An array of input files (more about files here)
  2. Type of processing: client or server or async. More about processing types here
  3. An object containing a start and end value

Full class reference is below

Typing#

modfy.trim(
{
inputFiles: AcceptedFiles,
greyscale: {
start: number,
end: number
}
},
processType: ProcessType,
webhookUrl?: string
): Promise<Uint8Array> | Promise<{ id: string, uuid: string }>
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

Example#

// Snippet
// File here is a HTML File directly from DOM input
const trimmedVIdeo = modfy.convert(
{
inputFiles: [karaokeVideo],
start: 10, // Video will start at 10 seconds
end: 15 // Video will end at 15 seconds
},
'sync' // Can be 'async' | 'sync' | 'client',
webhookUrl? : string // When using async must pass this paramater
)