A Node.js package to download YouTube videos as MP3 files. This package extracts audio from YouTube videos and converts it to MP3 format.
npm install gimmeytmp3
- Node.js 16 or higher
- FFmpeg installed on your system
- Windows PowerShell (for Windows users)
FFmpeg is required for audio conversion. Follow these instructions to install it on your system:
-
Download the FFmpeg build from the official website or use a package manager like Chocolatey:
choco install ffmpeg
-
Add FFmpeg to your PATH:
- Right-click on "This PC" or "My Computer" and select "Properties"
- Click on "Advanced system settings"
- Click on "Environment Variables"
- In the "System variables" section, find and select the "Path" variable, then click "Edit"
- Click "New" and add the path to the FFmpeg
bin
folder (e.g.,C:\FFmpeg\bin
) - Click "OK" on all dialogs to save the changes
Using Homebrew:
brew install ffmpeg
sudo apt update
sudo apt install ffmpeg
sudo dnf install ffmpeg
After installing FFmpeg, verify it's working by running:
ffmpeg -version
This package uses yt-dlp to download YouTube videos. On Windows, the package will automatically download and use yt-dlp if it's not already installed. On other platforms, you may need to install yt-dlp manually:
brew install yt-dlp
sudo apt install yt-dlp # Debian/Ubuntu
sudo dnf install yt-dlp # Fedora
import { downloadMP3 } from "gimmeytmp3";
// Basic usage
try {
const mp3Path = await downloadMP3(
"https://www.youtube.com/watch?v=dQw4w9WgXcQ"
);
console.log(`MP3 saved to: ${mp3Path}`);
} catch (error) {
console.error(`Error: ${error.message}`);
}
// With custom output directory
const outputDir = "./downloads";
const mp3Path = await downloadMP3(
"https://www.youtube.com/watch?v=dQw4w9WgXcQ",
outputDir
);
// With no progress output
const options = { showProgress: false };
const mp3Path = await downloadMP3(
"https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"./downloads",
options
);
# Install globally
npm install -g gimmeytmp3
# Basic usage
gimmeytmp3 https://www.youtube.com/watch?v=dQw4w9WgXcQ
# Specify output directory
gimmeytmp3 https://www.youtube.com/watch?v=dQw4w9WgXcQ ./downloads
# Using options
gimmeytmp3 --quiet https://www.youtube.com/watch?v=dQw4w9WgXcQ
gimmeytmp3 -q -o ./downloads https://www.youtube.com/watch?v=dQw4w9WgXcQ
Available options:
-q, --quiet
: Suppress progress output-o, --output
: Specify output directory
A simple web interface example is included in the examples/web-interface
directory. To run it:
-
Install the required dependencies:
cd examples/web-interface npm install express
-
Start the server:
node index.js
-
Open
http://localhost:3000
in your browser and use the form to download YouTube videos as MP3 files.
If you get an error like FFmpeg is not installed
or spawn ffmpeg ENOENT
:
- Make sure FFmpeg is installed (see installation instructions above)
- Verify FFmpeg is in your PATH by running
ffmpeg -version
in your terminal - Restart your terminal or command prompt after installing FFmpeg
If you encounter PowerShell execution policy issues:
- Run PowerShell as Administrator
- Execute
Set-ExecutionPolicy RemoteSigned
to allow local scripts to run - Confirm the change when prompted