A low-latency Discord bot for streaming live microphone audio into a voice channel on Windows using FFmpeg (DirectShow) and @discordjs/voice. The bot supports listing microphones, selecting by index, hot-swapping devices while streaming, and start/stop controls—all without additional audio routing software.
Note: Desktop/system audio streaming is not included in this version. This bot streams microphone input only via DirectShow.
- 🎙️ Live microphone streaming to Discord voice channels
- 🔁 Hot-swap microphones while streaming (no reconnect required)
- 📋 List all DirectShow audio devices with indices
- ⚡ Low-latency FFmpeg capture tuned for Windows
- 🧠 Safe start/stop lifecycle (no orphan FFmpeg processes)
- Windows 10/11
- Node.js v18+ (tested with Node 22)
- FFmpeg with DirectShow support (in
PATH) - Discord Bot Token
discord.js@discordjs/voice@discordjs/opusprism-media
npm init -y
npm install discord.js @discordjs/voice @discordjs/opus prism-mediaEnsure ffmpeg.exe is accessible:
ffmpeg -versionTemporary (current terminal only):
$env:DISCORD_TOKEN="YOUR_BOT_TOKEN_HERE"Permanent (recommended):
- System Properties → Environment Variables
- Add User Variable:
- Name:
DISCORD_TOKEN - Value: your bot token
- Name:
Restart your terminal after setting permanently.
Edit this line in index.js to match one of your DirectShow mic names:
let selectedMic = "Microphone (3- USB Audio CODEC )";You can always change it at runtime with commands.
From the project directory:
node index.jsYou should see:
Logged in as YourBotName#1234
Lists all available DirectShow microphone devices with indices.
Example output:
0: Microphone (USB Audio CODEC)
1: Microphone (HyperX Cloud Flight Wireless)
2: Microphone (NVIDIA Broadcast)
Selects a microphone by index.
- If not streaming: sets the mic for next start
- If already streaming: hot-swaps the mic live
Example:
!mic 2
Joins the voice channel you are currently in and starts streaming the selected microphone.
Stops the microphone stream and leaves the voice channel.
Shows whether the mic stream is currently running and which device is selected.
To verify FFmpeg can see your microphones:
ffmpeg -list_devices true -f dshow -i dummyLook for entries marked (audio) and ensure the device name matches exactly.
The FFmpeg pipeline is already optimized for low latency using:
-fflags nobuffer-flags low_delay-probesize 32-analyzeduration 0-rtbufsize 16M
Typical end-to-end latency is sub-second on most systems.
- Microphone audio only (no system/desktop audio in this version)
- Windows-only (uses DirectShow)
- One active voice stream per bot instance
- Only stream audio you have permission to broadcast
- Inform users in the voice channel when live audio is being relayed
- The bot does not record or store audio
- Ensure Windows microphone permissions allow desktop apps
- Check the mic is not in exclusive mode
- Verify the device name exactly matches FFmpeg output
Ensure @discordjs/opus is installed:
npm install @discordjs/opusMIT — use, modify, and distribute freely.
If you want to extend this project with desktop audio, mixing, push-to-talk, or per-role permissions, this codebase is a solid foundation to build on.