How to determine the length of the MP3 file header?

I am writing a diff program and copying whole files or segments based on changes at both ends (Rsync-esque ... but more like Unison). The main idea is to keep my music folder (all mp3s) up to date in several places.

I would like to send segmented updates if only small parts of the file have changed, and not copying the entire file. To do this, I need a way to separate file segments.

I initially tried to generate hashes for blocks of each file (every n bytes I would have a hash of a segment). I noticed that when I changed one attribute (id3v2 tag to mp3), all the hashed blocks would change. This makes sense as I assume the headline is growing as it has acquired new information.

This leads me to my actual question. I would like to know how to determine the length of the mp3 header, so I could create 2 comparable hashes.

1) Meta information of the file (header)

2) Actual mpeg stream with sound (this hash should remain unchanged if all I do is change the tag information)

Have I missed anything else?

Thank!

T

+3
source share
3 answers

I ended up using TagLibSharp. developer.novell.com/wiki/index.php/TagLib_Sharp

0
source

If you want to define header information, you either:

  • a) you need to use an mp3 library that can do parsing for you, or
  • b) mp3- .
+1

If you want to check the length of id3v2 tags, you can find out information about its structure at http://www.id3.org/id3v2.4.0-structure .

If you read the first 3 bytes and they are equal to "ID3", then skip the 7th byte, then read the size of the header. Be careful because the size is stored as a "synchsafe integer".

+1
source

Source: https://habr.com/ru/post/1730925/


All Articles