Skip to content

Instantly share code, notes, and snippets.

@pjobson
Created Nov 11, 2020
Embed
What would you like to do?
Convert AVI to MP4
#!/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