Zip an audio file In NodeJS with archiver in fly

210 views Asked by At

I use node-youtube-dl to have a stream to download a video and I want to convert it to mp3 using fluent-ffmmpeg. I also want to zip this mp3 audio to send to the client to download it but I cannot figure how to zip the mp3 audio. I find every corner of StackOverflow but I did not find any solution. Please help me! Thanks

const stream = youtubedl(url);
const videoTitle = await youtube.getVideoTitle(url);
const converter = new ffmpeg({ source: stream });
const zip = archiver('zip');

// This does not work since converter.toFormat('mp3') is not a stream
zip.append(converter.toFormat('mp3'), {
  name: `${videoTitle}.${toFormat}`
});
zip.finalize();

I really appreciate if you can help me! Thanks again

0

There are 0 answers