Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const command = shellEscape([
ffmpegPath,
'-ss', '00:05:00.00',
'-t', '00:15:00.00',
'-i', file,
'-af', 'volumedetect',
'-f', 'null', '/dev/null',
])
console.log(`Running: ${command}`)
let buffer = ''
const options = {stdio: [process.stdin, process.stdout, 'pipe']}
spawn(command, options)
.stderr.on('data', data => {
const chunk = data.toString()
buffer += chunk
console.log(chunk)
})
.on('error', err => {
reject(err)
})
.on('close', () => {
const maxVol = /max_volume: (-?[\d\.]+) dB/.exec(buffer)
if (!maxVol) {
return resolve({file, episode, gain: 0})
}
console.log(`Detected max volume: ${maxVol[1]}dB`)
'-ab', '96k',
'-ac', '1',
'-id3v2_version', '3',
'-write_id3v1', '1',
'-af', `volume=${gain}dB`,
'-metadata', `title=${title}`,
'-metadata', `artist=${artist}`,
'-metadata', `track=${number}`,
'-metadata', `date=${year}`,
'-metadata', 'language=eng',
'-metadata', `comment=${url}`,
outputPath,
])
const options = {stdio: 'inherit'}
console.log(`Running: ${command}`)
spawn(command, options).on('exit', process.exit)
}
return new Promise((resolve, reject) => {
const cmd = getCommand(command, args);
const child = spawnCommand(cmd, {
stdio: silent ? undefined : 'inherit',
env: getEnv(context),
cwd,
});
child.on('exit', (exitCode) => {
if (exitCode !== 0) {
return reject(
new ExecuteError(`The command "${cmd}" failed with error code ${exitCode}`, cmd, exitCode)
);
}
return resolve(exitCode);
});
child.on('error', (error) =>