How to compare mp3 programmatically

后端 未结 8 493
南笙
南笙 2020-12-29 00:25

I like to be able to compare mp3’s programmatically. The problem I don’t know by what. Header? Histogram? channels? Does anyone have experience with this subject?

相关标签:
8条回答
  • 2020-12-29 00:47

    I like to be able to compare mp3’s programmatically

    I had the same question. I found that itunes had altered many of my Amazon MP3 downloads, changing the time/date stamps, the file sizes and therefore the MD5 signatures. My backups suddenly had many near duplicate files.

    When I did a VIM diff, I could see that the changes were limited to very small parts of the files. The files looked identical side by side in Audacity even at a close zoom.

    My solution is to create a headerless WAV dump of the mp3 and then compare the MD5 signatures of each WAV. FFMPEG can do the translation quite easily.

    ffmpeg -y -i $mp3 $mp3.wav;
    md5sum $mp3.wav
    

    I created a hash with MD5 as key pointing to the original MP3 file spec. Put the wav file on an SSD for speed.

    Brute force, but it works.

    0 讨论(0)
  • 2020-12-29 00:54

    To answer your question better I think we need to know exactly what you are looking to do.

    If you are looking to compare the actual song, musicDNS have a library that are able to create audio fingerprints. The library called libOFA can be found here. This fingerprinting system is used by for example musicbrainz to match digital audiofiles to their database. In theory you can use this to compare two different digital files.

    If you are looking to compare tag data (id3v1/id3v2) there are a lot of libraries that can do that for you, taglib is mentioned and also libmpg123 have their own functions to extract tag data.

    The good thing about the libOFA approach is that you can compare different formats to each other since the fingerprinting is done on the audio itself.

    0 讨论(0)
  • 2020-12-29 00:54

    If you're just looking to compare mp3s based on the tags, I'd recommend taglib.

    0 讨论(0)
  • 2020-12-29 00:59

    What do you mean by comparing ? The meta-data (author, title, etc...), the audio data ? For what purpose ?

    On popular and basic way to compare audio data is to compute some kind of distance on some spectral features, such as MFCC:

    http://en.wikipedia.org/wiki/Mel_frequency_cepstral_coefficient

    0 讨论(0)
  • 2020-12-29 01:03

    I frequently use fdupes on linux to locate duplicate files. fdupes uses md5 checksums.

    0 讨论(0)
  • 2020-12-29 01:05

    I guess there are a number of approaches you could take to this:

    1. Compare tags

    You could compare the data held in mp3's tags. The tags are held in the ID3 format. There are a number of libraries to help you access the tags, tagLib is a popular choice (TagLib Sharp for .net apps)

    2. Acoustic fingerprint

    This is by far the most robust method, allowing you to find matches regardless of the compression or even format. A unique fingerprint is created from the actual audio from the file allowing the song to be identified echoprint is an opensource example of this.

    3. Creating a hash from the file

    This is a quicker method allowing you to find file with content that matches exactly.


    Some further reading:

    • There's an interesting MSDN article about managing an mp3 collection (including reading the tags) here: link text (It's in visual basic but might still be useful.)

    • There's a little description of the file format here: link text

    0 讨论(0)
提交回复
热议问题