Skip to content

Instantly share code, notes, and snippets.

@jeromewu
Created September 2, 2020 07:05
Show Gist options
  • Save jeromewu/73deef83b7a402b3076facf6e7e00b46 to your computer and use it in GitHub Desktop.
Save jeromewu/73deef83b7a402b3076facf6e7e00b46 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const Module = require('./dist/ffmpeg-core');
Module.onRuntimeInitialized = () => {
const data = Uint8Array.from(fs.readFileSync('./flame.avi'));
Module.FS.writeFile('flame.avi', data);
const ffmpeg = Module.cwrap('proxy_main', 'number', ['number', 'number']);
const args = ['ffmpeg', '-hide_banner'];
const argsPtr = Module._malloc(args.length * Uint32Array.BYTES_PER_ELEMENT);
args.forEach((s, idx) => {
const buf = Module._malloc(s.length + 1);
Module.writeAsciiToMemory(s, buf);
Module.setValue(argsPtr + (Uint32Array.BYTES_PER_ELEMENT * idx), buf, 'i32');
})
ffmpeg(args.length, argsPtr);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment