Created
September 2, 2020 07:05
-
-
Save jeromewu/73deef83b7a402b3076facf6e7e00b46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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