README.adoc 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. = audiowmark - Audio Watermarking
  2. == Description
  3. `audiowmark` is an Open Source (GPL) solution for audio watermarking.
  4. A sound file is read by the software, and a 128-bit message is stored in a
  5. watermark in the output sound file. For human listeners, the files typically
  6. sound the same.
  7. However, the 128-bit message can be retrieved from the output sound file. Our
  8. tests show, that even if the file is converted to mp3 or ogg (with bitrate 128
  9. kbit/s or higher), the watermark usually can be retrieved without problems. The
  10. process of retrieving the message does not need the original audio file (blind
  11. decoding).
  12. Internally, audiowmark is using the patchwork algorithm to hide the data in the
  13. spectrum of the audio file. The signal is split into 1024 sample frames. For
  14. each frame, some pseoudo-randomly selected amplitudes of the frequency bands of
  15. a 1024-value FFTs are increased or decreased slightly, which can be detected
  16. later. The algorithm used here is inspired by
  17. Martin Steinebach: Digitale Wasserzeichen für Audiodaten.
  18. Darmstadt University of Technology 2004, ISBN 3-8322-2507-2
  19. == Open Source License
  20. `audiowmark` is *open source* software available under the *GPLv3
  21. or later* license.
  22. Copyright (C) 2018-2020 Stefan Westerfeld
  23. This program is free software: you can redistribute it and/or modify
  24. it under the terms of the GNU General Public License as published by
  25. the Free Software Foundation, either version 3 of the License, or
  26. (at your option) any later version.
  27. This program is distributed in the hope that it will be useful,
  28. but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30. GNU General Public License for more details.
  31. You should have received a copy of the GNU General Public License
  32. along with this program. If not, see <http://www.gnu.org/licenses/>.
  33. == Adding a Watermark
  34. To add a watermark to the soundfile in.wav with a 128-bit message (which is
  35. specified as hex-string):
  36. [subs=+quotes]
  37. ....
  38. *$ audiowmark add in.wav out.wav 0123456789abcdef0011223344556677*
  39. Input: in.wav
  40. Output: out.wav
  41. Message: 0123456789abcdef0011223344556677
  42. Strength: 10
  43. Time: 3:59
  44. Sample Rate: 48000
  45. Channels: 2
  46. Data Blocks: 4
  47. ....
  48. If you want to use `audiowmark` in any serious application, please read the
  49. section <<rec-payload>> on how to generate the 128-bit message. Typically these
  50. bits should be a *hash* or *HMAC* of some sort.
  51. The most important options for adding a watermark are:
  52. --key <filename>::
  53. Use watermarking key from file <filename> (see <<key>>).
  54. --strength <s>::
  55. Set the watermarking strength (see <<strength>>).
  56. == Retrieving a Watermark
  57. To get the 128-bit message from the watermarked file, use:
  58. [subs=+quotes]
  59. ....
  60. *$ audiowmark get out.wav*
  61. pattern 0:05 0123456789abcdef0011223344556677 1.324 0.059 A
  62. pattern 0:57 0123456789abcdef0011223344556677 1.413 0.112 B
  63. pattern 0:57 0123456789abcdef0011223344556677 1.368 0.086 AB
  64. pattern 1:49 0123456789abcdef0011223344556677 1.302 0.098 A
  65. pattern 2:40 0123456789abcdef0011223344556677 1.361 0.093 B
  66. pattern 2:40 0123456789abcdef0011223344556677 1.331 0.096 AB
  67. pattern all 0123456789abcdef0011223344556677 1.350 0.054
  68. ....
  69. The output of `audiowmark get` is designed to be machine readable. Each line
  70. that starts with `pattern` contains one decoded message. The fields are
  71. seperated by one or more space characters. The first field is a *timestamp*
  72. indicating the position of the data block. The second field is the *decoded
  73. message*. For most purposes this is all you need to know.
  74. The software was designed under the assumption that the message is a *hash* or
  75. *HMAC* of some sort. Before you start using `audiowmark` in any serious
  76. application, please read the section <<rec-payload>>. You - the user - should
  77. be able to decide whether a message is correct or not. To do this, on
  78. watermarking song files, you could *create a database entry* for each message
  79. you embedded in a watermark. During retrieval, you should perform a *database
  80. lookup* for each pattern `audiowmark get` outputs. If the message is not found,
  81. then you should assume that a decoding error occurred. In our example each
  82. pattern was decoded correctly, because the watermark was not damaged at all,
  83. but if you for instance use lossy compression (with a low bitrate), it may
  84. happen that only some of the decoded patterns are correct. Or none, if the
  85. watermark was damaged too much.
  86. The third field is the *sync score* (higher is better). The synchronization
  87. algorithm tries to find valid data blocks in the audio file, that become
  88. candidates for decoding.
  89. The fourth field is the *decoding error* (lower is better). During message
  90. decoding, we use convolutional codes for error correction, to make the
  91. watermarking more robust.
  92. The fifth field is the *block type*. There are two types of data blocks,
  93. A blocks and B blocks. A single data block can be decoded alone, as it
  94. contains a complete message. However, if during watermark detection an
  95. A block followed by a B block was found, these two can be decoded
  96. together (then this field will be AB), resulting in even higher error
  97. correction capacity than one block alone would have.
  98. To improve the error correction capacity even further, the `all` pattern
  99. combines all data blocks that are available. The combined decoded
  100. message will often be the most reliable result (meaning that even if all
  101. other patterns were incorrect, this could still be right).
  102. The most important options for getting a watermark are:
  103. --key <filename>::
  104. Use watermarking key from file <filename> (see <<key>>).
  105. --strength <s>::
  106. Set the watermarking strength (see <<strength>>).
  107. --detect-speed::
  108. --detect-speed-patient::
  109. Detect and correct replay speed difference (see <<speed>>).
  110. --json <file>::
  111. Write results to <file> in machine readable JSON format.
  112. [[key]]
  113. == Watermark Key
  114. Since the software is Open Source, a watermarking key should be used to ensure
  115. that the message bits cannot be retrieved by somebody else (which would also
  116. allow removing the watermark without loss of quality). The watermark key
  117. controls all pseudo-random parameters of the algorithm. This means that
  118. it determines which frequency bands are increased or decreased to store a
  119. 0 bit or a 1 bit. Without the key, it is impossible to decode the message
  120. bits from the audio file alone.
  121. Our watermarking key is a 128-bit AES key. A key can be generated using
  122. audiowmark gen-key test.key
  123. and can be used for the add/get commands as follows:
  124. audiowmark add --key test.key in.wav out.wav 0123456789abcdef0011223344556677
  125. audiowmark get --key test.key out.wav
  126. Keys can be named using the `gen-key --name` option, and the key name will be
  127. reported for each match:
  128. audiowmark gen-key oct23.key --name "October 2023"
  129. Finally, it is possible to use the `--key` option more than once for watermark
  130. detection. In this case, all keys that are specified will be tried. This is
  131. useful if you change keys on a regular basis, and passing multiple keys is
  132. more efficient than performing watermark detection multiple times with one
  133. key.
  134. audiowmark get --key oct23.key --key nov23.key --key dec23.key out.wav
  135. [[strength]]
  136. == Watermark Strength
  137. The watermark strength parameter affects how much the watermarking algorithm
  138. modifies the input signal. A stronger watermark is more audible, but also more
  139. robust against modifications. The default strength is 10. A watermark with that
  140. strength is recoverable after mp3/ogg encoding with 128kbit/s or higher. In our
  141. informal listening tests, this setting also has a very good subjective quality.
  142. A higher strength (for instance 15) would be helpful for instance if robustness
  143. against multiple conversions or conversions to low bit rates (i.e. 64kbit/s) is
  144. desired.
  145. A lower strength (for instance 6) makes the watermark less audible, but also
  146. less robust. Strengths below 5 are not recommended. To set the strength, the
  147. same value has to be passed during both, generation and retrieving the
  148. watermark. Fractional strengths (like 7.5) are possible.
  149. audiowmark add --strength 15 in.wav out.wav 0123456789abcdef0011223344556677
  150. audiowmark get --strength 15 out.wav
  151. [[rec-payload]]
  152. == Recommendations for the Watermarking Payload
  153. Although `audiowmark` does not specify what the 128-bit message stored in the
  154. watermark should be, it was designed under the assumption that the message
  155. should be a *hash* or *HMAC* of some sort.
  156. Lets look at a typical use case. We have a song called *Dreams* by an artist
  157. called *Alice*. A user called *John Smith* downloads a watermarked copy.
  158. Later, we find this file somewhere on the internet. Typically we want to answer
  159. the questions:
  160. * is this one of the files we previously watermarked?
  161. * what song/artist is this?
  162. * which user shared it?
  163. _When the user downloads a watermarked copy_, we construct a string that
  164. contains all information we need to answer our questions, for example
  165. like this:
  166. Artist:Alice|Title:Dreams|User:John Smith
  167. To obtain the 128-bit message, we can hash this string, for instance by
  168. using the first 128 bits of a SHA-256 hash like this:
  169. $ STRING='Artist:Alice|Title:Dreams|User:John Smith'
  170. $ MSG=`echo -n "$STRING" | sha256sum | head -c 32`
  171. $ echo $MSG
  172. ecd057f0d1fbb25d6430b338b5d72eb2
  173. This 128-bit message can be used as watermark:
  174. $ audiowmark add --key my.key song.wav song.wm.wav $MSG
  175. At this point, we should also *create a database entry* consisting of the
  176. hash value `$MSG` and the corresponding string `$STRING`.
  177. The shell commands for creating the hash are listed here to provide a
  178. simplified example. Fields (like the song title) can contain the characters `'`
  179. and `|`, so these cases need to be dealt with.
  180. _If we find a watermarked copy of the song on the net_, the first step is to
  181. detect the watermark message using
  182. $ audiowmark get --key my.key song.wm.wav
  183. pattern 0:05 ecd057f0d1fbb25d6430b338b5d72eb2 1.377 0.068 A
  184. pattern 0:57 ecd057f0d1fbb25d6430b338b5d72eb2 1.392 0.109 B
  185. [...]
  186. The second step is to perform a *database lookup* for each result returned by
  187. `audiowmark`. If we find a matching entry in our database, this is one of the
  188. files we previously watermarked.
  189. As a last step, we can use the string stored in the database, which contains
  190. the song/artist and the user that shared it.
  191. _The advantages of using a hash as message are:_
  192. 1. Although `audiowmark` sometimes produces *false positives*, this doesn't
  193. matter, because it is extremely unlikely that a false positive will match an
  194. existing database entry.
  195. 2. Even if a few *bit errors* occur, it is extremely unlikely that a song
  196. watermarked for user A will be attributed to user B, simply because all hash
  197. bits depend on the user. So this is a much better payload than storing a user
  198. ID, artist ID and song ID in the message bits directly.
  199. 3. It is *easy to extend*, because we can add any fields we need to the hash
  200. string. For instance, if we want to store the name of the album, we can simply
  201. add it to the string.
  202. 4. If the hash matches exactly, it is really *hard to deny* that it was this
  203. user who shared the song. How else could all 128 bits of the hash match the
  204. message bits decoded by `audiowmark`?
  205. [[speed]]
  206. == Speed Detection
  207. If a watermarked audio signal is played back a little faster or slower than the
  208. original speed, watermark detection will fail. This could happen by accident if
  209. the digital watermark was converted to an analog signal and back and the
  210. original speed was not (exactly) preserved. It could also be done intentionally
  211. as an attack to avoid the watermark from being detected.
  212. In order to be able to find the watermark in these cases, `audiowmark` can try
  213. to figure out the speed difference to the original audio signal and correct the
  214. replay speed before detecting the watermark. The search range for the replay
  215. speed is approximately *[0.8..1.25]*.
  216. Example: add a watermark to `in.wav` and increase the replay speed by 5% using
  217. `sox`.
  218. [subs=+quotes]
  219. ....
  220. *$ audiowmark add in.wav out.wav 0123456789abcdef0011223344556677*
  221. [...]
  222. *$ sox out.wav out1.wav speed 1.05*
  223. ....
  224. Without speed detection, we get no results. With speed detection the speed
  225. difference is detected and corrected so we get results.
  226. [subs=+quotes]
  227. ....
  228. *$ audiowmark get out1.wav*
  229. *$ audiowmark get out1.wav --detect-speed*
  230. speed 1.049966
  231. pattern 0:05 0123456789abcdef0011223344556677 1.209 0.147 A-SPEED
  232. pattern 0:57 0123456789abcdef0011223344556677 1.301 0.143 B-SPEED
  233. pattern 0:57 0123456789abcdef0011223344556677 1.255 0.145 AB-SPEED
  234. pattern 1:49 0123456789abcdef0011223344556677 1.380 0.173 A-SPEED
  235. pattern all 0123456789abcdef0011223344556677 1.297 0.130 SPEED
  236. ....
  237. The speed detection algorithm is not enabled by default because it is
  238. relatively slow (total cpu time required) and needs a lot of memory. However
  239. the search is automatically run in parallel using many threads on systems with
  240. many cpu cores. So on good hardware it makes sense to always enable this option
  241. to be robust to replay speed attacks.
  242. There are two versions of the speed detection algorithm, `--detect-speed` and
  243. `--detect-speed-patient`. The difference is that the patient version takes
  244. more cpu time to detect the speed, but produces more accurate results.
  245. == Short Payload (experimental)
  246. By default, the watermark will store a 128-bit message. In this mode, we
  247. recommend using a 128bit hash (or HMAC) as payload. No error checking is
  248. performed, the user needs to test patterns that the watermarker decodes to
  249. ensure that they really are one of the expected patterns, not a decoding
  250. error.
  251. As an alternative, an experimental short payload option is available, for very
  252. short payloads (12, 16 or 20 bits). It is enabled using the `--short <bits>`
  253. command line option, for instance for 16 bits:
  254. audiowmark add --short 16 in.wav out.wav abcd
  255. audiowmark get --short 16 out.wav
  256. Internally, a larger set of bits is sent to ensure that decoded short patterns
  257. are really valid, so in this mode, error checking is performed after decoding,
  258. and only valid patterns are reported.
  259. Besides error checking, the advantage of a short payload is that fewer bits
  260. need to be sent, so decoding will more likely to be successful on shorter
  261. clips.
  262. == Video Files
  263. For video files, `videowmark` can be used to add a watermark to the audio track
  264. of video files. To add a watermark, use
  265. [subs=+quotes]
  266. ....
  267. *$ videowmark add in.avi out.avi 0123456789abcdef0011223344556677*
  268. Audio Codec: -c:a mp3 -ab 128000
  269. Input: in.avi
  270. Output: out.avi
  271. Message: 0123456789abcdef0011223344556677
  272. Strength: 10
  273. Time: 3:53
  274. Sample Rate: 44100
  275. Channels: 2
  276. Data Blocks: 4
  277. ....
  278. To detect a watermark, use
  279. [subs=+quotes]
  280. ....
  281. *$ videowmark get out.avi*
  282. pattern 0:05 0123456789abcdef0011223344556677 1.294 0.142 A
  283. pattern 0:57 0123456789abcdef0011223344556677 1.191 0.144 B
  284. pattern 0:57 0123456789abcdef0011223344556677 1.242 0.145 AB
  285. pattern 1:49 0123456789abcdef0011223344556677 1.215 0.120 A
  286. pattern 2:40 0123456789abcdef0011223344556677 1.079 0.128 B
  287. pattern 2:40 0123456789abcdef0011223344556677 1.147 0.126 AB
  288. pattern all 0123456789abcdef0011223344556677 1.195 0.104
  289. ....
  290. The key and strength can be set using the command line options
  291. --key <filename>::
  292. Use watermarking key from file <filename> (see <<key>>).
  293. --strength <s>::
  294. Set the watermarking strength (see <<strength>>).
  295. Videos can be watermarked on-the-fly using <<hls>>.
  296. == Output as Stream
  297. Usually, an input file is read, watermarked and an output file is written.
  298. This means that it takes some time before the watermarked file can be used.
  299. An alternative is to output the watermarked file as stream to stdout. One use
  300. case is sending the watermarked file to a user via network while the
  301. watermarker is still working on the rest of the file. Here is an example how to
  302. watermark a wav file to stdout:
  303. audiowmark add in.wav - 0123456789abcdef0011223344556677 | play -
  304. In this case the file in.wav is read, watermarked, and the output is sent
  305. to stdout. The "play -" can start playing the watermarked stream while the
  306. rest of the file is being watermarked.
  307. If - is used as output, the output is a valid .wav file, so the programs
  308. running after `audiowmark` will be able to determine sample rate, number of
  309. channels, bit depth, encoding and so on from the wav header.
  310. Note that all input formats supported by audiowmark can be used in this way,
  311. for instance flac/mp3:
  312. audiowmark add in.flac - 0123456789abcdef0011223344556677 | play -
  313. audiowmark add in.mp3 - 0123456789abcdef0011223344556677 | play -
  314. == Input from Stream
  315. Similar to the output, the `audiowmark` input can be a stream. In this case,
  316. the input must be a valid .wav file. The watermarker will be able to
  317. start watermarking the input stream before all data is available. An
  318. example would be:
  319. cat in.wav | audiowmark add - out.wav 0123456789abcdef0011223344556677
  320. It is possible to do both, input from stream and output as stream.
  321. cat in.wav | audiowmark add - - 0123456789abcdef0011223344556677 | play -
  322. Streaming input is also supported for watermark detection.
  323. cat in.wav | audiowmark get -
  324. == Raw Streams
  325. So far, all streams described here are essentially wav streams, which means
  326. that the wav header allows `audiowmark` to determine sample rate, number of
  327. channels, bit depth, encoding and so forth from the stream itself, and the a
  328. wav header is written for the program after `audiowmark`, so that this can
  329. figure out the parameters of the stream.
  330. There are two cases where this is problematic. The first case is if the full
  331. length of the stream is not known at the time processing starts. Then a wav
  332. header cannot be used, as the wav file contains the length of the stream. The
  333. second case is that the program before or after `audiowmark` doesn't support wav
  334. headers.
  335. For these two cases, raw streams are available. The idea is to set all
  336. information that is needed like sample rate, number of channels,... manually.
  337. Then, headerless data can be processed from stdin and/or sent to stdout.
  338. --input-format raw::
  339. --output-format raw::
  340. --format raw::
  341. These can be used to set the input format or output format to raw. The
  342. last version sets both, input and output format to raw.
  343. --raw-rate <rate>::
  344. This should be used to set the sample rate. The input sample rate and
  345. the output sample rate will always be the same (no resampling is
  346. done by the watermarker). There is no default for the sampling rate,
  347. so this parameter must always be specified for raw streams.
  348. --raw-input-bits <bits>::
  349. --raw-output-bits <bits>::
  350. --raw-bits <bits>::
  351. The options can be used to set the input number of bits, the output number
  352. of bits or both. The number of bits can either be `16` or `24`. The default
  353. number of bits is `16`.
  354. --raw-input-endian <endian>::
  355. --raw-output-endian <endian>::
  356. --raw-endian <endian>::
  357. These options can be used to set the input/output endianness or both.
  358. The <endian> parameter can either be `little` or `big`. The default
  359. endianness is `little`.
  360. --raw-input-encoding <encoding>::
  361. --raw-output-encoding <encoding>::
  362. --raw-encoding <encoding>::
  363. These options can be used to set the input/output encoding or both.
  364. The <encoding> parameter can either be `signed` or `unsigned`. The
  365. default encoding is `signed`.
  366. --raw-channels <channels>::
  367. This can be used to set the number of channels. Note that the number
  368. of input channels and the number of output channels must always be the
  369. same. The watermarker has been designed and tested for stereo files,
  370. so the number of channels should really be `2`. This is also the
  371. default.
  372. == Other Command Line Options
  373. --output-format rf64::
  374. Regular wav files are limited to 4GB in size. By using this option,
  375. `audiowmark` will write RF64 wave files, which do not have this size limit.
  376. This is not the default because not all programs might be able to read RF64
  377. wave files.
  378. --q, --quiet::
  379. Disable all information messages generated by `audiomark`.
  380. --strict::
  381. This option will enable strict error checking, which may in some situations
  382. make `audiowmark` return an error, where it could continue.
  383. [[hls]]
  384. == HTTP Live Streaming
  385. === Introduction for HLS
  386. HTTP Live Streaming (HLS) is a protocol to deliver audio or video streams via
  387. HTTP. One example for using HLS in practice would be: a user watches a video
  388. in a web browser with a player like `hls.js`. The user is free to
  389. play/pause/seek the video as he wants. `audiowmark` can watermark the audio
  390. content while it is being transmitted to the user.
  391. HLS splits the contents of each stream into small segments. For the watermarker
  392. this means that if the user seeks to a position far ahead in the stream, the
  393. server needs to start sending segments from where the new play position is, but
  394. everything in between can be ignored.
  395. Another important property of HLS is that it allows separate segments for the
  396. video and audio stream of a video. Since we watermark only the audio track of a
  397. video, the video segments can be sent as they are (and different users can get
  398. the same video segments). What is watermarked are the audio segments only, so
  399. here instead of sending the original audio segments to the user, the audio
  400. segments are watermarked individually for each user, and then transmitted.
  401. Everything necessary to watermark HLS audio segments is available within
  402. `audiowmark`. The server side support which is necessary to send the right
  403. watermarked segment to the right user is not included.
  404. [[hls-requirements]]
  405. === HLS Requirements
  406. HLS support requires some headers/libraries from ffmpeg:
  407. * libavcodec
  408. * libavformat
  409. * libavutil
  410. * libswresample
  411. To enable these as dependencies and build `audiowmark` with HLS support, use the
  412. `--with-ffmpeg` configure option:
  413. [subs=+quotes]
  414. ....
  415. *$ ./configure --with-ffmpeg*
  416. ....
  417. In addition to the libraries, `audiowmark` also uses the two command line
  418. programs from ffmpeg, so they need to be installed:
  419. * ffmpeg
  420. * ffprobe
  421. === Preparing HLS segments
  422. The first step for preparing content for streaming with HLS would be splitting
  423. a video into segments. For this documentation, we use a very simple example
  424. using ffmpeg. No matter what the original codec was, at this point we force
  425. transcoding to AAC with our target bit rate, because during delivery the stream
  426. will be in AAC format.
  427. [subs=+quotes]
  428. ....
  429. *$ ffmpeg -i video.mp4 -f hls -master_pl_name replay.m3u8 -c:a aac -ab 192k \
  430. -var_stream_map "a:0,agroup:aud v:0,agroup:aud" \
  431. -hls_playlist_type vod -hls_list_size 0 -hls_time 10 vs%v/out.m3u8*
  432. ....
  433. This splits the `video.mp4` file into an audio stream of segments in the `vs0`
  434. directory and a video stream of segments in the `vs1` directory. Each segment
  435. is approximately 10 seconds long, and a master playlist is written to
  436. `replay.m3u8`.
  437. Now we can add the relevant audio context to each audio ts segment. This is
  438. necessary so that when the segment is watermarked in order to be transmitted to
  439. the user, `audiowmark` will have enough context available before and after the
  440. segment to create a watermark which sounds correct over segment boundaries.
  441. [subs=+quotes]
  442. ....
  443. *$ audiowmark hls-prepare vs0 vs0prep out.m3u8 video.mp4*
  444. AAC Bitrate: 195641 (detected)
  445. Segments: 18
  446. Time: 2:53
  447. ....
  448. This steps reads the audio playlist `vs0/out.m3u8` and writes all segments
  449. contained in this audio playlist to a new directory `vs0prep` which
  450. contains the audio segments prepared for watermarking.
  451. The last argument in this command line is `video.mp4` again. All audio
  452. that is watermarked is taken from this audio master. It could also be
  453. supplied in `wav` format. This makes a difference if you use lossy
  454. compression as target format (for instance AAC), but your original
  455. video has an audio stream with higher quality (i.e. lossless).
  456. === Watermarking HLS segments
  457. So with all preparations made, what would the server have to do to send a
  458. watermarked version of the 6th audio segment `vs0prep/out5.ts`?
  459. [subs=+quotes]
  460. ....
  461. *$ audiowmark hls-add vs0prep/out5.ts send5.ts 0123456789abcdef0011223344556677*
  462. Message: 0123456789abcdef0011223344556677
  463. Strength: 10
  464. Time: 0:15
  465. Sample Rate: 44100
  466. Channels: 2
  467. Data Blocks: 0
  468. AAC Bitrate: 195641
  469. ....
  470. So instead of sending out5.ts (which has no watermark) to the user, we would
  471. send send5.ts, which is watermarked.
  472. In a real-world use case, it is likely that the server would supply the input
  473. segment on stdin and send the output segment as written to stdout, like this
  474. [subs=+quotes]
  475. ....
  476. *$ [...] | audiowmark hls-add - - 0123456789abcdef0011223344556677 | [...]*
  477. [...]
  478. ....
  479. The usual parameters are supported in `audiowmark hls-add`, like
  480. --key <filename>::
  481. Use watermarking key from file <filename> (see <<key>>).
  482. --strength <s>::
  483. Set the watermarking strength (see <<strength>>).
  484. The AAC bitrate for the output segment can be set using:
  485. --bit-rate <bit_rate>::
  486. Set the AAC bit-rate for the generated watermarked segment.
  487. The rules for the AAC bit-rate of the newly encoded watermarked segment are:
  488. * if the --bit-rate option is used during `hls-add`, this bit-rate will be used
  489. * otherwise, if the `--bit-rate` option is used during `hls-prepare`, this bit-rate will be used
  490. * otherwise, the bit-rate of the input material is detected during `hls-prepare`
  491. == Compiling from Source
  492. Stable releases are available from http://uplex.de/audiowmark
  493. The steps to compile the source code are:
  494. ./configure
  495. make
  496. make install
  497. If you build from git (which doesn't include `configure`), the first
  498. step is `./autogen.sh`. In this case, you need to ensure that (besides
  499. the dependencies listed below) the `autoconf-archive` package is
  500. installed.
  501. == Dependencies
  502. If you compile from source, `audiowmark` needs the following libraries:
  503. * libfftw3
  504. * libsndfile
  505. * libgcrypt
  506. * libzita-resampler
  507. * libmpg123
  508. If you want to build with HTTP Live Streaming support, see also
  509. <<hls-requirements>>.
  510. == Building fftw
  511. `audiowmark` needs the single prevision variant of fftw3.
  512. If you are building fftw3 from source, use the `--enable-float`
  513. configure parameter to build it, e.g.::
  514. cd ${FFTW3_SOURCE}
  515. ./configure --enable-float --enable-sse && \
  516. make && \
  517. sudo make install
  518. or, when building from git
  519. cd ${FFTW3_GIT}
  520. ./bootstrap.sh --enable-shared --enable-sse --enable-float && \
  521. make && \
  522. sudo make install
  523. == Docker Build
  524. You should be able to execute `audiowmark` via Docker.
  525. Example that outputs the usage message:
  526. docker build -t audiowmark .
  527. docker run -v <local-data-directory>:/data --rm -i audiowmark -h