aadsm / jsmediatags

Media Tags Reader (ID3, MP4, FLAC)
Other
752 stars 128 forks source link

TrackNumber only 1 Byte /256 eq to 0 #139

Closed ARGO1960 closed 3 years ago

ARGO1960 commented 3 years ago

Hi, thanks for making this.great work. I'm parsing mp4 files from my webserver the ID3V2 data is written with ID3Tag. There the Track number shows correct. like 256 upto 2000 but when I use jsmediatag.min.js and read the files it shows track number 256 as 0 and 257 as 1.. 512 is 0 again... image

aadsm commented 3 years ago

Maybe it's only reading 1 byte, that's why it resets at every 2^(n>7). However, still odd, because the trkn is a string and should be parsed as such. Can you share the file so I can take a look?

ARGO1960 commented 3 years ago

Sure get it from here let me know when you have it ill remove it again. If you change the track number to 257 you see it shows up as 1.

aadsm commented 3 years ago

I have it now, thanks.

aadsm commented 3 years ago

Oh, can you give me one with the track set to 257? I need a file with the problem you're reporting. No idea how to change it.

ARGO1960 commented 3 years ago

Sure: https://www.dropbox.com/s/68dqmz37ffbhppd/0257_Ilse%20DeLange%20-%20Miracle.mp4?dl=1 But that 256 one shows as 0 and this one will show as 1. Only tracks below 256 so 1..255 show correct. BTW to edit in windows i use this editor https://www.mp3tag.de/en/

aadsm commented 3 years ago

Thanks for the example. I was able to find an off by one error, and also realized the trkn is a short and not a byte! However, this last file you gave me had track 256 though...

You can see the whole atom here:

$ hexdump  -n 32 -C amy.mp4 -s 257119
0003ec5f  00 00 00 20 74 72 6b 6e  00 00 00 18 64 61 74 61  |... trkn....data|
0003ec6f  00 00 00 00 00 00 00 00  00 00 01 00 00 00 00 00  |................|

0x01 0x00 is the 2 byte short with the track number which corresponds to 256.

ARGO1960 commented 3 years ago

image Ok great you found it. As for 256/257 I see binary 01 00 that represents 01 X 256 + 0 x1 == 256 as the editor really gives 257 as track (see screenshot) I expect an 2nd complementary notation or so. But anyway great I think byte=>short should be the fix. Great work really!!. Thanks again for all the hard work and time you put into this. Regards. Arnold