Stream watermarking¶
Overview¶
A watermark can be applied to stream captured while translating it to subscribers. To do this, the following parameter should be added to flashphoner.properties file to specify watermark PNG file name:
Watermark PNG file should be placed to /usr/local/FlashphonerWebCallServer/conf catalog.
Watermark can be added only using the commercial license because Flashphoner watermark will be added to all streams when trial license is used.
If watermark picture contains black regions, those regions will not be displayed because black is background color for video playback.
Stream transcoding must be enabled to add watermark, because stream must be decoded and then encoded with picture applied for further broadcasting. To enable transcoding, the stream resolution can be set explicitly when publishing
session.createStream({name:'stream1',constraints:{audio:true,video:{width:640,height:480}}}).publish();
and playing the stream
session.createStream({name:'stream1',constraints:{audio:true,video:{width:320,height:240}}}).play();
In this case all the streams are publishing on server in 640x480 resolution and are playing in 320x240. That automatically enables transcoding, rescaling from 640x480 to 320x240 and watermark applying.
Stream watermarking will increase the server load approximately 0.5-1 core for each incoming video stream depending on video transcoded resolution. For example, 16 incoming streams handling may require 8-16 core server. In this regard, it is recommended to apply watermark on stream publisher source if possible.
Static watermark configuration¶
The following parameters are available for static watermark:
| Parameter | Description | Example |
|---|---|---|
| watermark_size | Watermark size in pixels | 100x100 |
| watermark_frame_size | Video frame size in pixels, for watermark scaling | 1280x720 |
| watermark_x | Watermark top left corner X coordinate | 10 |
| watermark_y | Watermark top left corner X coordinate | 10 |
| watermark_margin_top | Watermark top margin in pixels | 15 |
| watermark_margin_bottom | Watermark bottom margin in pixels | 15 |
| watermark_margin_left | Watermark left margin in pixels | 15 |
| watermark_margin_right | Watermark right margin in pixels | 15 |
| watermark_text | Text watermark content | A text watermark |
| watermark_text_align | Text watermark alignment | TOP_LEFTTOP_CENTERTOP_RIGHTCENTERBOTTOM_LEFTBOTTOM_CENTERBOTTOM_RIGHTEXTERNAL_TOP_CENTEREXTERNAL_BOTTOM_CENTER |
| watermark_font | Text watermark font name | Serif |
| watermark_font_size | Text watermark font size in points | 40 |
| watermark_text_colour | Text watermark color | 0xFFFFFF |
| watermark_text_background_colour | Text watermark background color | 0x2B2A2B |
| watermark_text_background_opacity | Text watermark background opacity | 100 |
| watermark_text_padding_top | Text watermark top padding | 5 |
| watermark_text_padding_bottom | Text watermark bottom padding | 5 |
| watermark_text_padding_left | Text watermark left padding | 5 |
| watermark_text_padding_right | Text watermark right padding | 5 |
Watermark picture mixing with alpha channels support¶
Some watermark picture colors may be distorted or invisible (transparent) when applying this picture as watermark. It depends on alpha channel values of the picture applied. Since build 5.2.1064 the following parameter is added to enable watermark picture mixing with alpha channels support
Note that alpha channels support implementation today executes a many subsequent operations. This can lead to CPU load increasing and low quality of the resulting image. In the future, it is planned to be implemented using parallel mixing on GPU.
Watermark picture alpha channel threshold¶
Since build 5.3.98 the parameter was added to detect picture alpha channel correctly
In this case, watermark will be displayed with transparent background.
Watermark picture downloading from external site¶
Since build 5.2.2087 a watermark picture may be downloaded from external site by URL
There will be black picture in output stream if server is not available, or the file is not found on the server with a corresponding error message in server log
09:41:01,342 WARN CustomWatermark - API-ASYNC-pool-7-thread-3 Can't read custom watermark file - https://server/pics/watermark.png
java.net.ConnectException: Connection refused (Connection refused)
or
09:43:36,235 WARN CustomWatermark - API-ASYNC-pool-7-thread-3 Can't read custom watermark file - https://server/pics/watermark.png
java.io.FileNotFoundException: https://server/pics/watermark.png
Known issues¶
1. Default watermark (black picture) will be used if is damaged or absent¶
Symptoms
Black picture in output stream when watermark is added, there is a message in server log
Solution
Use only correct PNG file to add watermark