spawn ENOENT error when trying to convert to mp3

Viewed 294

I was trying to make a youtube video to mp3 converter using an npm package called youtube-mp3-downloader the npm documentation says I have to download FFmpeg inorder for the program to run so I did download the FFmpeg windows build. And then I added the FFmpeg binary path to the code in order to run the program and get the expected output which is the mp3 file saved to a specified location and the output data but every time I run the program I get the error spawn ../client/ffmpeg-4.4-full_build/bin ENOENT. When I research about the error I came accross that I have to install the ffmpeg and the fluent-ffmpeg dependencies to my node module and so I did but the error is still there. What am I doing wrong?

var YoutubeMp3Downloader = require("youtube-mp3-downloader");

//Configure YoutubeMp3Downloader with your settings
var YD = new YoutubeMp3Downloader({
  // FFmpeg binary location *Where the error is arising
  "ffmpegPath": "../client/ffmpeg-4.4-full_build/bin",
  // Output file location (default: the home directory)
  "outputPath": "../client/audio",
  // Desired video quality (default: highestaudio)
  "youtubeVideoQuality": "highestaudio",
  "queueParallelism": 2, // Download parallelism (default: 1)
  // Interval in ms for the progress reports (default: 1000)
  "progressTimeout": 2000,
  "allowWebm": false // Enable download from WebM sources (default: false)
});

//Download video and save as MP3 file
YD.download("Vhd6Kc4TZls");

YD.on("finished", function(err, data) {
  console.log(JSON.stringify(data));
});

YD.on("error", function(error) {
  console.log(error);
});

YD.on("progress", function(progress) {
  console.log(JSON.stringify(progress));
});

1 Answers

I had the same issue, I fixed it by specifying the exact path to the ffmpeg.exe file.

If you set the ffmpegPath to ../client/ffmpeg-4.4-full_build/bin/ffmpeg.exe in your object, it should work.

Related