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

625
Views
Node.js - How to get remote audio file's duration?

I have a binaries storage bucket (in Firebase Storage) and I am implementing a node.js Cloud Function which gets an audio (audio/m4a or audio/caf), verifies it format and duration, and then associate its uri with a document in my database (or deletes the audio file if its duration is not valid).

Before creating the document in my database, I need to validate the audio file.

For downloading the files from the storage I am using this function:

exports.downloadBinaryFileFromUrl = function (fileUrl) {
  /* This function downloads a binary-encoded file from its URL and returns it */
  return axios
    .get(fileUrl, {
      responseType: "arraybuffer",
    })
    .then((res) => Buffer.from(res.data, "binary"))
    .catch((err) => {
      if (err.response) {
        /* 
          The request was made and the server responded with a status code
          that falls out of the range of 2xx
        */
        throw err.response.data;
      } else if (err.request) {
        // Client never received a response, or request never left
        throw err.request;
      } else {
        // Something happened in setting up the request that triggered an Error
        throw new Error(`Error: ${err.message}`);
      }
    });
};

Any ideas how to get the audio file's duration using Node.js?

over 4 years ago · Santiago Trujillo
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!