Skip to content

c++ implementation of the fingerprinting algorithm suggested in the dejavu audio fingerprinting project

License

Notifications You must be signed in to change notification settings

soundhive/dejavu_cpp_port

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dejavu C++ port (audio fingerprinting)

This is a C++ implementation of the fingerprinting algorithm suggested in the dejavu audio fingerprinting project (https://github.com/worldveil/dejavu specifically: the fingerprint.py file). link on how dejavu works

Prerequisites

The "fingerprint" function will accept array of floats as an input (raw audio PCM data). It will returns a list of hashes with offsets (as a json string).

Dependencies

Example usage on Debian

apt install build-essential ffmpeg libopencv-dev libboost-thread-dev
cd dejavu_cpp_port
mkdir build
cd build
cmake ..
make
cd ../

Example run:

~/dejavu_cpp_port ~> ./build/bin/fingerprint
[{"hash":"8736b04e6e0fbc58d032","offset":"7"}
,{"hash":"b4e63c079f54ffc5ef12","offset":"7"}
,{"hash":"7520c79e12d590fee83b","offset":"7"}
,{"hash":"62623d0877ac8a92b053","offset":"7"}
,{"hash":"a8f58a0df43f5b3af85a","offset":"7"}
,{"hash":"8083728131d5f7a23734","offset":"7"}
,{"hash":"f30372836464cd40e237","offset":"7"}
,{"hash":"faa8ce3862e0b94cd2c6","offset":"7"}
,{"hash":"74f8e1601a5598a18eb5","offset":"7"}
,{"hash":"2cfbc298df696dd3d841","offset":"7"}
...

Why the C++ port?

  1. You can run C++ code on iOS or Android (tested it myself, works Flawlessly).
  2. In theory: performance boost. In practice: didn't see much difference.

Demo

The main function will load a test mp3 file, uncompressed it using ffmpeg (as a mono channel, 22050 sample rate), feed it to fingerprint function, then prints the list of hashes-offsets.

Update 2020: Include it in react-native/iOS/Android

Now a sample code is provided in a different repository that demonstrates how to include this function in a react-native project. Blog post is available that explains how to do it.

Final notes

  • I wrote this code initially for prototype purposes. while I have tested the correctness of the algorithm output, I didn't optimise the code to C++ best standards. If you want to improve the code in this manner I will gladly accept pull requests.
  • Performance (speed wise) is really slow when the audio input is large. However on small audio files (<10 seconds) it is similar or better than python implementation. For now, I'm not interested to look after this issue. If you have a fix, PR.

About

c++ implementation of the fingerprinting algorithm suggested in the dejavu audio fingerprinting project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 94.3%
  • CMake 5.7%