Created
November 11, 2020 12:35
-
-
Save pjobson/83ca443b7e9e8cdc22312b1be4467979 to your computer and use it in GitHub Desktop.
Convert AVI to MP4
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
#!/usr/bin/env node | |
const fs = require('fs'); | |
const path = require('path'); | |
const process = require('process'); | |
const shellescape = require('shell-escape'); | |
const child_process = require('child_process'); | |
const avi = process.argv[2]; | |
const outpath = path.resolve(process.argv[3] || path.parse(avi).dir); | |
const init = async () => { | |
const outfile = `${path.parse(avi).name}\.mp4`; | |
const inp = shellescape([avi]); | |
const out = shellescape([`${outpath}/${outfile}`]); | |
if (fs.existsSync(`${outpath}/${outfile}`)) { | |
console.log(`Exiting, file exists: ${outpath}/${outfile}`); | |
process.exit(0); | |
} | |
const command = `/home/pjobson/.local/bin/ffpb -n -i ${inp} -c:v libx264 -preset ultrafast -crf 22 -c:a copy -ac 2 ${out}`; | |
child_process.execSync( | |
command, | |
{stdio: 'inherit'} | |
); | |
}; | |
init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment