Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Watermarking over WebRTC

45 views
Skip to first unread message

Irina R

unread,
May 19, 2022, 8:42:09 PM5/19/22
to audiowmark
 I am trying to use audiowmark with WebRTC. So far, I am just piping an ogg file through audiowmark, that works great. But the streaming won't always be sequential. How difficult would it be to dynamically watermark small random chunks of a file? 

Stefan Westerfeld

unread,
May 29, 2022, 10:37:10 AM5/29/22
to audio...@googlegroups.com
Hi!

Am 20.05.22 um 02:42 schrieb Irina R:
We do something similar for HLS. Suppose you have a two hour movie you
want to stream. If the user skips to minute 100, you don't want to
watermark the first 100 minutes of audio just to deliver a watermarked
version of the audio stream starting at minute 100. Although
watermarking is pretty fast, it would still provide a huge delay for the
user until the stream starts.

So instead, we split the audio stream into small segments. In the
preparation stage, audiowmark stores a bit of context for each segment,
so that the watermarker has 3 seconds of material before and after each
audio segment.

Finally, if the user skips to minute 100, the HLS player will request
the appropriate audio segment, and we can deliver a watermarked version
of the segment without watermarking the 100 minutes before it starts.

Of course right now, much of the code is pretty specific for HLS, and
the description I gave is a bit simplified, but in theory audiowmark can
watermark a "segment" of audio such that it fits perfectly to the
segment before and after it, so that all segments together will have a
valid watermark.

Cu... Stefan
--
Stefan Westerfeld, http://space.twc.de/~stefan

Irina R

unread,
Jun 9, 2022, 8:14:02 PM6/9/22
to audiowmark
Hi Stefan,

I think one fairly simple solution might be for us to break the .ogg file into multiple shorter files ~50 sec each, and watermark and stream them individually. What time interval would be the best? 

Also, as an unrelated question: I was trying to use ffmpeg to subtract watermarked ogg file from the original and thus hear just the watermark, but it got complicated. Do you by a chance know from the top of your head how to get ffmpeg to do that?

Thank you so much for all your help!

Stefan Westerfeld

unread,
Jun 13, 2022, 3:53:26 PM6/13/22
to audio...@googlegroups.com
Hi!

If you want to split into segments and watermark individually, you
should at least use a length that allows audiowmark write one whole data
block. It will tell you the number of data blocks written if you use
"audiowmark add" to generate the watermark. The first data block isn't
exactly written at the start of the audio input because some songs start
with a some silence. One data block is ~50 seconds + 5 seconds at the
beginning, so it would be safe to use 60 seconds.

However, it can happen that if you do it this way there will be audible
clicks if you concatenate the watermarked segments. To avoid this you
could crossfade the watermarked segments, for instance
- segment #1 second 0..61
- segment #2 second 60..121
- segment #3 second 120..181
...
and then play 60 seconds from segment #1, play 60 seconds by crossfading
the end of #1 with #2, play 60 seconds by crossfading the end of #2 and
#3 and so forth.

Another disadvantage is that you break the clip decoder if you watermark
60 second segments this way. If you have a random clip taken of a
regular watermarked file, it will either be a part of an A block, or a
part of a B block, or a part of an A block followed by a part of a B
block, or the other way round. In any case this is expected by the clip
decoder, and this means that if you for instance have only 20 seconds of
watermarked material, audiowmark will still be able to decode the
watermark on it (given sufficient strength). However, your segment
approach only contains A blocks and no regular watermark inbetween. So
in general if you get 20 seconds of your segment watermark, it may or
may not be decodable.

I think one possible way to deal with that would be to make your segment
length exactly as long as one A block plus one B block (not including
space for crossfading), which should be
- 2226 frames per data block
- 1024 samples per frame
- 2 blocks (one A and one B)
=> 2226*1024*2 => 4558848 samples at sample rate 44100
=> 103.375238095238 seconds

For non-44100 audio files, the number of seconds should still be correct
(or you could resample everything to 44100 before watermarking).


As for subtracting out the original content to get only the watermark,
you can do it with audiowmark using this:

$ audiowmark add /tmp/x.wav /tmp/y.wav f0 --test-no-limiter
[...]
$ audiowmark test-subtract /tmp/x.wav /tmp/y.wav /tmp/z.wav

The --test-no-limiter option disallows audiowmark to adjust the volume
of the output signal, which would be a problem if you want to subtract
both to get only the watermark part.

Cu... Stefan

Am 10.06.22 um 02:14 schrieb Irina R:
> <http://space.twc.de/~stefan>
>
> --
> You received this message because you are subscribed to the Google
> Groups "audiowmark" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to audiowmark+...@googlegroups.com
> <mailto:audiowmark+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/audiowmark/11453e48-e7e8-4cef-a294-fd6ede2eaa00n%40googlegroups.com
> <https://groups.google.com/d/msgid/audiowmark/11453e48-e7e8-4cef-a294-fd6ede2eaa00n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages