Local PCM file to MP3 in Node

Im making a discord bot where currently, for 10 seconds, it reads the voice channel’s audio and writes the file, though it outputs it into a pcm file rather than the desired mp3. My code is currently:

const channel =;


        const connection = await channel.join();
        const receiver = connection.receiver.createStream(message.member, {
            mode: "pcm",
            end: "silence"

            const writer = receiver.pipe(fs.createWriteStream('./recording.pcm'));
            writer.on('finish', () => {

Basically, after 5 seconds from joining the channel, it leaves then writes that audio into said pcm file. I want to either write the file to mp3 from the start or have something write it into an mp3 file. I’ve tried node-lame but either cant seem to figure it out or it doesn’t work on my windows computer. I’ve added this

const Lame = require("node-lame").Lame;

                const encoder = new Lame({
                    output: "./test.mp3",
                    bitrate: 192,


right after channel.leave() but even then cant seem to figure it out. This is also based off of this forum Discord.js record MP3 of voice channel? and I’ve tried the ffmpeg comment they gave, but then it simply just does nothing and I have no clue to make it work like my current code.


Update the copyright year in all of your GitHub repos

This Scrapy project uses Redis and Kafka to create a distributed on demand scraping cluster