NodeJS: Difference between revisions

278 bytes added ,  15 March 2020
Line 85: Line 85:
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
const {spawn} = require('child_process');
const {spawn} = require('child_process');
const {spawnSync} = require('child_process');
</syntaxhighlight>
</syntaxhighlight>


Example:
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
const {spawnSync} = require('child_process');
spawnSync("ffmpeg", flatten([
  "-i", file,
  "-c:v libx265 -crf 28 -preset medium -c:a libopus -b:a 128K".split(" "),
  "-y", output_path
]), {
  cwd: process.cwd(),
  env: process.env,
  stdio: [process.stdin, process.stdout, process.stderr],
  encoding: 'utf-8'
});
</syntaxhighlight>
</syntaxhighlight>