How to compare mp3 programmatically

2020-02-23 05:34发布

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条回答
家丑人穷心不美
2楼-- · 2020-02-23 05:53

It looks like Chromaprint would do what you're looking for. It transforms PCM data in audio fingerprints which you can then use to compare.

They have a C API library (it's actually written in C++, though), a python front end, and also some utilities to convert the results in JSON which means you could use another language to manipulate the data. I don't think that they provide the compare function itself, though.

Also if you're using a Linux system, it's likely that you will find a package for it.

查看更多
够拽才男人
3楼-- · 2020-02-23 06:02

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.

查看更多
smile是对你的礼貌
4楼-- · 2020-02-23 06:02

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

查看更多
甜甜的少女心
5楼-- · 2020-02-23 06:04

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.

查看更多
6楼-- · 2020-02-23 06:06

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

查看更多
仙女界的扛把子
7楼-- · 2020-02-23 06:07

I wrote my master's thesis on audio fingerprinting. The thesis lists a few open source solutions to the problem of comparing what the music sounds like, and provides performance comparisons between them. Might be overkill, but there are some really decent applications out there.

If you only want to compare by tagged data, the standard to look into is ID3. There are basically two versions, the first is very simple (ID3v1) and consists of a 128 byte block at the end of an MP3. ID3v2 puts a larger, variable sized block at the beginning of the MP3.

查看更多
登录 后发表回答