Last active
May 1, 2020 10:16
-
-
Save jeromewu/7be506f80a8f9b88ce79ff3b748355b9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { getModule } = require('./util/module'); | |
| const strList2ptr = require('./util/strList2ptr'); | |
| module.exports = (inputPath, outputExt) => { | |
| const Module = getModule(); | |
| const data = new Uint8Array(fs.readFileSync(inputPath)); | |
| const ffmpeg = Module.cwrap('ffmpeg', 'number', ['number', 'number']); | |
| const args = ['./ffmpeg', '-i', 'input.avi', `output.${outputExt}`]; | |
| Module.FS.writeFile('input.avi', data); | |
| ffmpeg(args.length, strList2ptr(args)); | |
| return Buffer.from(Module.FS.readFile(`output.${outputExt}`)); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment