eidoriantan / mp3tag.js

MP3 tagging library written in pure JavaScript for Node.js and browsers
https://mp3tag.js.org
MIT License
85 stars 9 forks source link

[BUG] mp3tag.buffer always return corrupt buffer #632

Closed aervxa closed 9 months ago

aervxa commented 10 months ago

Describe the bug mp3tag.buffer returns corrupt buffer

Codes used

    const buffer = myBuffer // My working audio buffer

    const mp3tag = new MP3Tag(buffer, true);

    mp3tag.read();

    mp3tag.tags.title = "Title";
    mp3tag.tags.artist = "Artist";

    mp3tag.save({ strict: true });

    // Check for error
    if (mp3tag.error !== "") {
        console.log(mp3tag.error);
        throw new Error("Error"); // Which never runs because there IS no error
    }

    mp3tag.read();
    await fsPromise.writeFile("audio-original.mp3", buffer); // normal good audio
    await fsPromise.writeFile("audio.mp3", mp3tag.buffer); // corrupt audio

Expected behavior I expect audio.mp3 file to be playable 💀

Additional context I tried JSON.parse() for the buffer but that gives an error, which means it's a corrupt file? idk

eidoriantan commented 10 months ago

Would you be able to provide a sample audio so I could test this on my end?

aervxa commented 10 months ago

@eidoriantan Github only supports these attachments: GIF, JPEG, JPG, MOV, MP4, PNG, SVG, WEBM, CPUPROFILE, CSV, DMP, DOCX, FODG, FODP, FODS, FODT, GZ, JSON, JSONC, LOG, MD, ODF, ODG, ODP, ODS, ODT, PATCH, PDF, PPTX, TGZ, TXT, XLS, XLSX or ZIP.

I use fent/ytdl-core download this as MP3: https://www.youtube.com/watch?v=srodNyimqTM

Here is a temp file: https://file.io/cV99LGuWMFfT

eidoriantan commented 10 months ago

Okay, will test this once I'm available

aervxa commented 10 months ago

Also, Do it in buffer type not saved in file

aervxa commented 10 months ago

any updates?

aervxa commented 10 months ago

Realized the problem was with the file. For some reason it wasn't even editable in windows default properties section.