Installing chromaprint for encoding and decoding fingerprints

1,942 views
Skip to first unread message

God Usopp

unread,
Feb 15, 2016, 8:07:25 AM2/15/16
to AcoustID
Hello. 

I'm trying to install chromaprint in order to encode fingerprints and also to decode encoded fingerprints on my server.

Here is what I've got. I used these commands.

cd chromaprint
[chromaprint]# cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=/usr -DLIB_SUFFIX=64 .

[chromaprint]# make install
[ 48%] Built target chromaprint
[ 97%] Built target chromaprint_p
[100%] Building C object examples/CMakeFiles/fpcalc.dir/fpcalc.c.o
/root/chromaprint/examples/fpcalc.c:4:27: error: libavutil/opt.h: No such file o                                     r directory
/root/chromaprint/examples/fpcalc.c: In function ‘decode_audio_file’:
/root/chromaprint/examples/fpcalc.c:36: warning: implicit declaration of functio                                     n ‘avformat_open_input’
/root/chromaprint/examples/fpcalc.c:41: warning: implicit declaration of functio                                     n ‘avformat_find_stream_info’
/root/chromaprint/examples/fpcalc.c:46: warning: implicit declaration of functio                                     n ‘av_find_best_stream’
/root/chromaprint/examples/fpcalc.c:55: error: ‘AVCodecContext’ has no member na                                     med ‘request_sample_fmt’
/root/chromaprint/examples/fpcalc.c:55: error: ‘AV_SAMPLE_FMT_S16’ undeclared (f                                     irst use in this function)
/root/chromaprint/examples/fpcalc.c:55: error: (Each undeclared identifier is re                                     ported only once
/root/chromaprint/examples/fpcalc.c:55: error: for each function it appears in.)
/root/chromaprint/examples/fpcalc.c:57: warning: implicit declaration of functio                                     n ‘avcodec_open2’
/root/chromaprint/examples/fpcalc.c:104: warning: implicit declaration of functi                                     on ‘avcodec_decode_audio4’
/root/chromaprint/examples/fpcalc.c:130: error: ‘AVFrame’ has no member named ‘n                                     b_samples’
/root/chromaprint/examples/fpcalc.c:130: error: ‘AVFrame’ has no member named ‘n                                     b_samples’
/root/chromaprint/examples/fpcalc.c:156: warning: implicit declaration of functi                                     on ‘avcodec_free_frame’
/root/chromaprint/examples/fpcalc.c:170: warning: implicit declaration of functi                                     on ‘avformat_close_input’
make[2]: *** [examples/CMakeFiles/fpcalc.dir/fpcalc.c.o] Error 1
make[1]: *** [examples/CMakeFiles/fpcalc.dir/all] Error 2
make: *** [all] Error 2

I believe I've got a chromaprint package and i'm running make install but this is what I get. Right now i'm just trying to get fpcalc to work from the terminal but eventually I would like to get chromaprint to work with python... like in the acoustid python scripts.

chromaprint.decode_fingerprint(fingerprint_string)

God Usopp

unread,
Feb 15, 2016, 12:28:54 PM2/15/16
to AcoustID
I already have ffmpeg installed... doesn't this mean that avcodec and avformat are installed?

ffmpeg shows:

 libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0

Philipp Wolfer

unread,
Feb 15, 2016, 12:32:51 PM2/15/16
to acou...@googlegroups.com
2016-02-15 18:28 GMT+01:00 God Usopp <hakigo...@gmail.com>:

I already have ffmpeg installed... doesn't this mean that avcodec and avformat are installed?

ffmpeg shows:

 libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0


If you are using Linux on some distributions you have to install separate dev packages as the header files do not get installed by default. On Ubuntu there are e.g. libavformat-dev, libavcodec-dev etc.

Philipp

Lukáš Lalinský

unread,
Feb 15, 2016, 12:39:48 PM2/15/16
to Acoustid
If it's at all possible, I'd suggest to either use system packages (I believe chromaprint is packaged in EPEL) or the fpcalc binaries from https://acoustid.org/chromaprint

You are compiling a version of chromaprint from 2013 (that's the last commit I see in your repo), so I can't give you much guarantees about that. :)

It's best if you download and use the latest stable version, if you want to compile it on your own.

Also, I don't know the FFmpeg API versions without checking, but the versions you have seem old to me, I'm not sure if they are supported by chromaprint.

If you want to get the Python wrapper working, either install it from a system package or "pip install pyacoustid".

Lukas



--
You received this message because you are subscribed to the Google Groups "AcoustID" group.
To unsubscribe from this group and stop receiving emails from it, send an email to acoustid+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

God Usopp

unread,
Feb 15, 2016, 2:06:47 PM2/15/16
to AcoustID
Thank you, Lukas. Installing pyacoustid was much easier than what I thought had to be done. :D

I now have chromaprint.py in /usr/lib/python2.6/site-packages/

Now, when running my py script, I get this error.

File "/usr/lib/python2.6/site-packages/chromaprint.py", line 37, in <module>
    raise ImportError("couldn't find libchromaprint")
ImportError: couldn't find libchromaprint

I've installed the EPEL repository. I'm a linux newbie... so I'm a bit confused as to how I use a third party repository? I see libchromaprint is here https://www.rpmfind.net/linux/RPM/epel/7/x86_64/l/libchromaprint-1.0-1.el7.x86_64.html what next?

I tried: 
yum --enablerepo=epel install libchromaprint
but there was no package. What am I doing wrong?

God Usopp

unread,
Feb 15, 2016, 2:36:52 PM2/15/16
to AcoustID
I can't seem to find a yum equivalent for those packages. xD

God Usopp

unread,
Feb 16, 2016, 6:03:52 AM2/16/16
to AcoustID
I've successfully installed chromaprint using your chromaprint package without any errors. https://acoustid.org/chromaprint

But I'm still getting this traceback from my python script:

Traceback (most recent call last):
  File "start.py", line 2, in <module>
    import chromaprint

  File "/usr/lib/python2.6/site-packages/chromaprint.py", line 37, in <module>
    raise ImportError("couldn't find libchromaprint")

Here is my python script. I'm new to using python WSGI, so that part may not be correct, but I'm still having problems with import chromaprint. Getting "couldn't find libchromaprint"

from bottle import route, run, template
import chromaprint
@route('/fingerprint/lookup/<fp>')
def index(fp):
    return template('{{fingerprint}}', fingerprint = chromaprint.decode_fingerprint(fp))
run(host='162.144.152.248', port=8080)

I found libchromaprint in the EPEL repository but I'm having problems understanding how to install this.


Sorry for all the questions. I really want to get this setup and keep running into problems. My ignorance of linux isn't helping... but I'm learning a lot working on this! 
I appreciate all of your help! :)

On Monday, February 15, 2016 at 12:39:48 PM UTC-5, Lukáš Lalinský wrote:

Lukáš Lalinský

unread,
Feb 16, 2016, 6:10:20 AM2/16/16
to Acoustid
On Tue, Feb 16, 2016 at 12:03 PM, God Usopp <hakigo...@gmail.com> wrote:
 
Sorry for all the questions. I really want to get this setup and keep running into problems. My ignorance of linux isn't helping... but I'm learning a lot working on this! 
I appreciate all of your help! :)

If you are new to Linux, I'd really suggest to use a better distribution. If you used a recent version of Debian or Ubuntu, all these troubles would go away. You would simply run "apt-get install python-acoustid" and be done with it. It would install the Python library, Chromaprint and everything else it depends on automatically. Your choice of an old CentOS makes the problem harder than it has to be. I can't help you much installing the software on that, sorry.

Lukas



God Usopp

unread,
Feb 16, 2016, 6:39:07 AM2/16/16
to AcoustID
I wish I could change to ubuntu, but I don't have control over the OS of the server I'm using. I guess there's not much I can do.

I appreciate your responses. I'll probably keep searching for a solution. If I work on this project more in the future, I will definitely use Ubuntu.

Thank you :)

God Usopp

unread,
Feb 16, 2016, 10:54:29 AM2/16/16
to AcoustID
Would it be too complicated to re-create whatever algorithm chromaprint uses to decode a fingerprint? Probably a bit more complicated than I would think, but I thought I would ask. :P

Lukáš Lalinský

unread,
Feb 16, 2016, 11:03:12 AM2/16/16
to Acoustid
On Tue, Feb 16, 2016 at 4:54 PM, God Usopp <hakigo...@gmail.com> wrote:
Would it be too complicated to re-create whatever algorithm chromaprint uses to decode a fingerprint? Probably a bit more complicated than I would think, but I thought I would ask. :P

I did that last week, so it's not impossible.


But I'm not sure why do you want to use the compressed fingerprints. There is no reason if you are doing the app from scratch.

Lukas

God Usopp

unread,
Feb 17, 2016, 3:10:25 PM2/17/16
to AcoustID
Do pip install pyacoustid and apt-get install python-acoustid result in the same thing? I know I can't use apt on CentOS... is it possible to make a package for python-acoustid that would work with yum?

pip install pyacoustid installs the needed py scripts (chromaprint.py, fpcalc.py, acoustid.py... ect.)

Does apt-get install python-acoustid also install libchromaprint and other required software the scripts need?

Lukáš Lalinský

unread,
Feb 17, 2016, 4:08:48 PM2/17/16
to Acoustid
Both apt-get and yum have a concept of dependencies. The `python-acoustid` package knows that it needs libchromaprint to work, so it will install a package for that and that package knows it needs FFmpeg, so it will install FFmpeg packages, etc.

I don't know what version of CentOS are you using, but really what you need to do is not that hard:

 - compile and install ffmpeg -> ./configure; make; sudo make install
 - compile and install chromaprint -> cmake -DCMAKE_BUILD_TYPE=Release; make; sudo make install
 - pip install pyacoustid

If you want to make your life easier, convince whoever is managing the server you need to run this on to ugprade. On CentOS 7 with EPEL you should be able to `yum install chromaprint`. If you really need this done on the old CentOS quickly and can spend some money on it, contact me privately and I will set it up for you.

God Usopp

unread,
Feb 20, 2016, 1:37:03 PM2/20/16
to AcoustID
My only problem now seems to be libchromaprint. Python can't find it.

Traceback (most recent call last):
  File "start.py", line 2, in <module>
    import chromaprint
  File "/usr/lib/python2.6/site-packages/chromaprint.py", line 37, in <module>
    raise ImportError("couldn't find libchromaprint")
ImportError: couldn't find libchromaprint

find /usr/local/lib/libchroma* shows that there are some libchromaprint files in /usr/local/lib/

/usr/local/lib/libchromaprint.so
/usr/local/lib/libchromaprint.so.1
/usr/local/lib/libchromaprint.so.1.3.0

If these are the required libchromaprint files, is chromaprint looking at a different path for libchromaprint other than /usr/local/lib/?

What's the problem?

Lukáš Lalinský

unread,
Feb 21, 2016, 4:15:35 PM2/21/16
to Acoustid
It uses the standard path for dynamic libraries. The easiest way to fix this is by extending LD_LIBRARY_PATH:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

Lukas

God Usopp

unread,
Feb 21, 2016, 5:37:04 PM2/21/16
to AcoustID
Still unable to import chromaprint in python 

>>> import chromaprint
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/chromaprint.py", line 37, in <module>
    raise ImportError("couldn't find libchromaprint")
ImportError: couldn't find libchromaprint

Any more suggestions? :P

Lukáš Lalinský

unread,
Feb 22, 2016, 2:04:33 AM2/22/16
to Acoustid
I'm quite sure this should work. Can you please post here the entire command that you ran? And once you are in Python, please also run this:

>>> import os
>>> print os.environ['LD_LIBRARY_PATH']

God Usopp

unread,
Feb 22, 2016, 2:14:02 AM2/22/16
to AcoustID
In my previous post, I had ran "python" in the ssh terminal and then typed "import chromaprint", which resulted in the traceback error.

Now I have done this from your previous post:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

python

>>> import os
>>> print os.environ['LD_LIBRARY_PATH']
:/usr/local/lib

Lukáš Lalinský

unread,
Feb 22, 2016, 2:29:54 AM2/22/16
to Acoustid
Ok, this is a result of my messing up the SONAME of the library in 1.3.1. Normally you should have libchromaprint.so.0, but because of this you have libchromaprint.so.1, which is not recognized. And because it has already been included in some Linux distributions, I can't go just go back and fix it.

So I have changed pyacoustid to look for the right file - https://github.com/beetbox/pyacoustid/commit/56baf698bbb38fc97408ef9a6ab2cf53588e52f7

If you have previously installed pyacoustid with pip, the easiest way to upgrade would be:


Lukas




God Usopp

unread,
Feb 22, 2016, 3:11:27 AM2/22/16
to AcoustID
Thank you, Lukas!

It works now! :D
Reply all
Reply to author
Forward
0 new messages