function downloadMp3({ mp3File, params: { videoId } }, res, next) { if ( mp3File ) { next() } ytdl.getInfo(`http://www.youtube.com/watch?v=${videoId}`, { quality: 'highestaudio' }, function(err, info) { var stream = ytdl.downloadFromInfo(info, { quality: 'highestaudio' }) ffmpeg(stream) .audioBitrate(info.formats[0].audioBitrate) .withAudioCodec("libmp3lame") .toFormat("mp3") .saveToFile(`mp3/${videoId}.mp3`) .on("error", function(err) { console.log('error', err) res.json(err) }) .on("end", function() { next() }) }) }