swesterfeld / audiowmark

Audio Watermarking
GNU General Public License v3.0
396 stars 79 forks source link

add watermark twice #28

Closed junlicn closed 1 year ago

junlicn commented 1 year ago

is it possible to support adding watermark twice, that means I could get two different watermarking from the same wav? for example, I add watermarking for user copyright information first, then after transfered the audio file to client, add watermarking of user who download or play it.

swesterfeld commented 1 year ago

Yes, as long as you use two different keys, it should be possible to add two different watermarks. However of course if you can avoid it, it is better to use just one watermark which is better for the quality.

junlicn commented 1 year ago

what's the theory and process of two different watermark by only two keys? and another question, only consider technical engineer factors, is it possible to implement two watermakr by adding first watermark at first 50 second block, and adding second watermark at second 50 seconds block, and repeat this operation in the remaining blocks ?

swesterfeld commented 1 year ago

First of all, if you haven't read the README section on recommendations for the payload, you can do so here:

https://github.com/swesterfeld/audiowmark#recommendations-for-the-watermarking-payload

We kind-of assume that 128-bit messages ought to be enough for everyone.

what's the theory and process of two different watermark by only two keys?

As a user create two keys using audiowmark gen-key and use audiowmark add --key to twice to add the watermark. Use audiowmark get --key to get the message.

To see why using two different keys works you could look at the decoder code for single raw bits from the watermark.

The simplest possible decoder is here: https://github.com/swesterfeld/audiowmark/blob/eced66fcf2145fe3e25bf08af47ac1a4d17ac0b0/src/wmget.cc#L101

This computes umag and dmag as sum of pseudo randomly selected amplitude bins from the FFT spectrum of each frame. Simplified if (umag > dmag) we decode an 1 bit, otherwise 0. Which amplitude bins are used is depends on the key. So if you use different keys for watermarking you can embed / decode different message bits in the same spectrum.

Btw I didn't do excessive testing for using two keys, it appears to work but it may be a little less robust than using just one key.

and another question, only consider technical engineer factors, is it possible to implement two watermakr by adding first watermark at first 50 second block, and adding second watermark at second 50 seconds block, and repeat this operation in the remaining blocks ?

Yes you could do that. However there are cases in audiowmark where we currently assume that the A and B blocks carry the same data bits (but use different error correction coding). The most important feature is probably clip decoding. If you just have any randomly choosen small clip, we'll try to decode the message bits from the clip. It doesn't need to contain a full block.

Lets assume that we have a "short" N seconds clip. At any possible location, audiowmark will try to decode the message bits from the clip, including if there is only a partial A and B block.

See also this comment:

https://github.com/swesterfeld/audiowmark/blob/eced66fcf2145fe3e25bf08af47ac1a4d17ac0b0/src/wmget.cc#L437

So it wouldn't be totally easy to change the code to no longer make the assumption that A and B blocks can be decoded together.