ytdl(url, { filter: function(format) { return format.container === 'mp4'; } })
.pipe(fs.createWriteStream('./songs/Battle-Scars.mp4'));
I am new to node.js and am trying to implement a youtube-mp3 converter, and I don't know how to make the following code run ONLY after the code above finishes running.
var proc = new ffmpeg({ source: './songs/Battle-Scars.mp4'})
.withAudioCodec('libmp3lame')
.toFormat('mp3')
.saveToFile('./songs/Battle-Scars.mp3', function(stdout, stderr) {
console.log('file has been converted succesfully');
});
I appreciate all the help and thanks in advance.