play(unknown) { this.dispatchStream = new DispatchStream(this.connection) this.dispatchStream.once('finish', () => { this.emit('end') }) this.command = ffmpeg(unknown) .output(this.dispatchStream) .audioFrequency(48000) .audioChannels(1) .format('s16le') .on('error', (e) => { this.emit('error', e) }) this.command.run() }
function extractAudio(fileinfo) { let tempAudioPath = '/tmp/' + fileinfo.source.name + '.flac'; fileinfo.destination.temp.audio = tempAudioPath; return new Promise((resolve, reject) => { ffmpeg(fileinfo.destination.temp.video) .videoBitrate(19200) .inputOptions('-vn') .format('flac') .audioChannels(1) .output(tempAudioPath) .on('end', function () { console.log('extracted audio'); resolve(fileinfo); }) .on('error', function (err, stdout, stderr) { reject(err); }) .run(); }); }