swesterfeld / audiowmark

Audio Watermarking
GNU General Public License v3.0
397 stars 78 forks source link

Self Implementation #27

Open AmirZandi13 opened 1 year ago

AmirZandi13 commented 1 year ago

Hi @swesterfeld. Thanks again for your great package. I have a problem with this approach. and it's about running a shell execution in my wrapper. I have so many requests and I have to respond them below 0.5 milliseconds so preferably it's better to implement the logic of this package in my wrapper. Could you please tell me about the logic of this package and what is going on behind the scenes of that? And what sources did you use to implement that?

Thanks

swesterfeld commented 1 year ago

I don't think that shell execution is a big problem from a performance point of view. The reason is that watermarking itself is kind-of expensive. Also usually you'd have to re-encode the audio before you send it. So I'd expect to see most of the actual CPU time being spent on watermarking and compression (for instance mp3/aac encoding), and not so much in the shell execution (especially on Linux where spawning sub processes is quite fast). But I'd encourage you to measure the actual CPU usage for serving a typical request yourself.

Could you please tell me about the logic of this package and what is going on behind the scenes of that?

Well, adding "developer documentation" that describes details on how everything works is on my TODO, but I don't have time to do it right now. So I can only quote from the README:

Internally, audiowmark is using the patchwork algorithm to hide the data in the spectrum of the audio file. The signal is split into 1024 sample frames. For each frame, some pseoudo-randomly selected amplitudes of the frequency bands of a 1024-value FFTs are increased or decreased slightly, which can be detected later. The algorithm used here is inspired by

Martin Steinebach: Digitale Wasserzeichen für Audiodaten.
Darmstadt University of Technology 2004, ISBN 3-8322-2507-2

It is German though, an english short description of the patchwork algorithm by the same author is available here:

https://onlinelibrary.wiley.com/doi/epdf/10.1002/047134608X.W8281

but developing something like audiowmark from scratch is quite a lot of research / development you'd need to invest.