ffmpeg errors

node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: spawn ffmpeg EAGAIN
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -11,
  code: 'EAGAIN',
  syscall: 'spawn ffmpeg',
  path: 'ffmpeg',
  spawnargs: [
    '-i',
    '/home/brunommpreto/Music/CloudMusic/TBT Prod. - Gangsta Gangsta(TBT Remix).mp3',
    '-analyzeduration',
    '0',
    '-loglevel',
    '0',
    '-acodec',
    'libopus',
    '-f',
    'opus',
    '-ar',
    '48000',
    '-ac',
    '2',
    'pipe:1'
  ]
}


here is my code, part of it:
try {
                        // Replace 'path/to/your/local/folder' with the path to your local folder containing audio files
                        const folderPath='/home/brunommpreto/Music/CloudMusic/';
                        //If theres already a queue avoid re-reading them
                        if (!queue.length && !running) {
                            // Read all files in the folder
                            const files=fs.readdirSync(folderPath);
                            let i=0;
                            for (const file of files) {
                                if (file.toLowerCase().endsWith('.mp3')) {
                                    const filePath=path.join(folderPath, file.replace(/(['"()])/g, '\\$1'));
                                    const resource=await createAudioResource(filePath, { inputType: StreamType.WebmOpus });
                                    queue.push(resource);
                                    i++;
                                    console.log("Loaded " + i + " of " + files.length)
                                }
                            }
                            queue=queue.sort((a, b) => 0.5 - Math.random())
                        }

                        if (!isPlaying) {
                            await playNextTrack(newState);
                            running = true
                        }
                    } catch (error) {
                        console.error('Error joining voice channel:', error);
                    }
Was this page helpful?