Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
Ffmpeg crashes when downloading specific songs

I have a music bot that downloads songs to mp3 based on user input that can be jsut words or a link. Problem is when I pass a song like "jojo op 3" it searches for the song and when it returns a song name like "JoJo's Bizarre Adventure Opening 3 | 4K | 60FPS | Creditless" ffmpeg returns

Error: ffmpeg exited with code 1: ./musicSaves/JoJo's Bizarre Adventure Opening 3 | 4K | 60FPS | Creditless.mp3: Invalid argument

but for other songs such as gas gas gas by manuel it downloads it as normal and I cant for the life of me know why that is. Here is the downlaod code:

import puppeteer from 'puppeteer';
import youtubeMp3Converter from 'youtube-mp3-converter';

//Tries to find link in message using Regex
export function getLink(messageLink){
    const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/;
    let link = messageLink.match(urlRegex);
    
    if(link == null){
        findSongName(messageLink)
    } else {
        convertToMp3(link)
    }
}

//Converts source to mp3 to be played by audio player
async function convertToMp3(inputLink){
    const convertLinkToMp3 = youtubeMp3Converter('./musicSaves')
    const pathToMp3 = await convertLinkToMp3(inputLink)
}

//If link isn't found; tries to find source using puppeteer
async function findSongName(stringWithName){
    
    const searchYT = async (page, searchQuery) => {
        const encodedQuery = encodeURIComponent(searchQuery);
        const url = `https://www.youtube.com/results?search_query=${encodedQuery}`;
        await page.goto(url);
        const sel = "a#video-title";
        await page.waitForSelector(sel);
        return page.$$eval(sel, els =>
          els.map(e => ({
            title: e.textContent.trim(),
            href: e.href,
          }))
        );
      };
      
      let browser;
      (async () => {
        browser = await puppeteer.launch({headless: true});
        const [page] = await browser.pages();
        await page.setRequestInterception(true);
        page.on("request", req => {
          req.resourceType() === "image" ? req.abort() : req.continue();
        });
        const results = await searchYT(page, stringWithName);
        const finalLink = results[0].href;
        convertToMp3(finalLink);
      })()
        .catch(err => console.error(err))
        .finally(() => browser?.close());
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Remove the special characters from the filename. The ' and |.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!