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
source
share