-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
define function:
export const execute = async (file: string, commandParts: CommandPartsType) => {
// const blob = await readFile(file);
// if (!blob) return;
const ffmpeg = new FFmpeg();
// write to file system
await ffmpeg.writeFile(commandParts.input, file);
// convert mp4 to avi
await ffmpeg.exec(commandParts.executeParts);
// read from file system
const result: Uint8Array = ffmpeg.readFile(commandParts.output);
downloadData(result, commandParts.output)
// free memory
ffmpeg.deleteFile(commandParts.input);
ffmpeg.deleteFile(commandParts.output);
// const result: Uint8Array = ffmpeg.exec(commandParts).export()
// const result: Uint8Array | undefined = await ffmpeg
// .input({ source: blob })
// .ouput({ format: 'avi' })
// .export()
}
usage:
// export type CommandPartsType = {
// input: string
// output: string
// executeParts: string[]
// }
// files[0]: URL.createObjectURL(file)
await execute(files[0], commandParts)
error:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'FS')
at O.writeFile (@diffusion-studio_ffmpeg-js.js?v=77f8ebdb:217:52)
at async execute (ffmpeg-js.ts?t=1721995298380:24:3)
at async onSubmit (VideoToX.tsx?t=1721995362784:98:5)
at async chunk-Q3LFL7AZ.js?v=77f8ebdb:1637:9
Metadata
Metadata
Assignees
Labels
No labels