Skip to content

[FEATURE] Avoid having to read the entire file into memory #648

@jimmywarting

Description

@jimmywarting

Is your feature request related to a problem? Please describe.
Your lib require reading the entire file into memory and using it as such:

    // MP3Tag Usage
    const mp3tag = new MP3Tag(buffer)
    mp3tag.read()
// want to have this
const mp3tag = await MP3Tag.fromBlob(blob)

Describe the solution you'd like
I wish there where a built read method that can accept a File/Blob where your library slice the file to read only the segments that are necessary.

I have some that are 1.5h long and is 216 mb
i just want to read, write, update, remove metadata.

I wish images where described as such:

{
  format: 'image/jpeg',
  type: 3,
  description: 'Content description',
  data: new File([ this.mp3.slice(star, end) ], 'front-conver.jpg', { type: 'image/jpeg' })
}

and i wish i could change the front/back cover using a Blob or a File myself.

and just like the getAudio() function i also wish it could just return a slice of the mp3 file without reading it into memory:

function getAudio() {
  return this.mp3.slice(start, end, type)
}

assemble

But how do you build / save the file afterwards then?
glad you asked: Just create a new file with all the parts

const result = new File([ id3header, blobCover, audioBlob, footer ], this.mp3.name, { type: this.mp3.type })

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions