Skip to content

Instantly share code, notes, and snippets.

@pjobson
Created November 11, 2020 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjobson/83ca443b7e9e8cdc22312b1be4467979 to your computer and use it in GitHub Desktop.
Save pjobson/83ca443b7e9e8cdc22312b1be4467979 to your computer and use it in GitHub Desktop.
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