Answer the question
In order to leave comments, you need to log in
How to get id3 length in mp3 file?
The length of id3 data is stored in 6-9 bytes. The peculiarity of specifying the length of ID3v2 data is that in each byte the 7th bit is not used and is always set to 0.
Manually using a calculator, I can calculate this length, but how can I calculate it programmatically? How to ignore this 7th bit?
In decimal format, bytes 6-9 contain the following numbers: 0 5 45 56. How to get the length in bytes using this data. The length in this case is 87746 bytes.
Answer the question
In order to leave comments, you need to log in
PHP -> php.net/manual/ru/ref.id3.php
C/C# -> https://taglib.github.io/
Delphi -> www.delphi.int.ru/articles/1
About MP3 itself like everyone else arranged in it -> habr.ru/p/103635
JS using File Api and Typed Arrays
function uint7ArrayToUint28(uint7Array) {
var uint28 = 0;
for (var i = 0, pow = 21; pow >= 0; pow -= 7, i++) {
uint28 += uint7Array[i] << pow;
}
return uint28;
}
var firstTenBytes = new Uint8Array(arrayBuffer, 0, 10);
var id3TagSize = uint7ArrayToUint28([
firstTenBytes[6], firstTenBytes[7],
firstTenBytes[8], firstTenBytes[9]
]) + 10;
var size = bytes[9];
size += bytes[8] << 7;
size += bytes[7] << 14;
size += bytes[6] << 21;
size += 10; // заголовок
var size = 56;
size += 45 << 7; // 5760 + 56 = 5816
size += 5 << 14; // 81920 + 5816 = 87736
size += 0 << 21; // 0 + 87736 = 87736 - размер ID3 тега без заголовка
size += 10; // 87736 + 10 = 87746 - размер ID3 тега
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question