1

I am fetching data from a remove url that hosts some audio. For instance: https://www.listennotes.com/e/p/98bcfa3fd1b44727913385938788bcc5/

I do this with the following code:

const buffer = await (await fetch(url)).arrayBuffer();

How do I trim/cut this ArrayBuffer from the audio by time. For example, I might want to the ArrayBuffer/Blob between the 12 seconds and 60 seconds.

All the solutions I have found are web solutions. I am hoping for a way to do this server side with node.

jmecs
  • 143
  • 2
  • 13
  • MP3 file is just a collection of multiple MP3 frames. You need to know some details about the MP3 like sampling frequency etc (audio metadata can be extracted from first 4 bytes of each MP3 frame). Assuming 44100hz then your per frame (audio) duration is around 26 milliseconds. Assuming you used CBR (not VBR) then each frame length is same size in bytes. To reach 12 seconds you skip past 461 frames. Then keep the next following 1385 MP3 frames to create your 48 second clip. You can read [about MP3 header](http://www.mp3-tech.org/programmer/frame_header.html). Use a **hex editor** to check. – VC.One May 12 '22 at 09:04

0 Answers0