creeperyang / id3-parser

A pure JavaScript id3 tag parser.
54 stars 13 forks source link

TXXX type metadata added to ID3.4 by ffmpeg cannot be parsed #24

Open ivanpadavan opened 1 year ago

ivanpadavan commented 1 year ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch id3-parser@2.0.0 for the project I'm working on.

Without this little assumption it was impossible to parse metadata of TXXX type made by ffmpeg version 4.4 cat no-metadata.mp3 | ffmpeg -i pipe:0 -vn -acodec mp3 -metadata text="Привет мир!" -f mp3 test.mp3

Here is the diff that solved my problem:

diff --git a/node_modules/id3-parser/lib/parsers/v2parser.js b/node_modules/id3-parser/lib/parsers/v2parser.js
index 3fc9bb3..162ca24 100644
@@ -180,7 +181,7 @@ function parseFrame(bytes, minor, size) {
         // Value < text string according to encoding >
         if (header.id === 'TXXX') {
             variableStart = 11;
-            variableLength = utils_1.getEndpointOfBytes(bytes, encoding, variableStart) - variableStart;
+            variableLength = utils_1.getEndpointOfBytes(bytes, 0, variableStart) - variableStart;
             var value = {
                 description: utils_1.readBytesToString(bytes.slice(variableStart), encoding, variableLength),
                 value: '',

This issue body was partially generated by patch-package.