Add Watermarks

Last update:2024-01-15 14:29:21

Watermarks serve as an efficient form of copyright protection. At CDNetworks, we support adding visible watermarks to your videos, helping to safeguard against illegal piracy. Currently, we offer four distinct types of watermarks:

  • Image watermarks: This allows the insertion of an image as a watermark. It features adaptive scaling, ensuring the watermark image adjusts in line with any changes to the video resolution.

  • Video watermarks: This allows for a video to be inserted as a watermark. This type of watermark is typically appropriate for applications whereby advertising videos are embedded into the source video without disrupting the main video’s playback.

  • Text watermarks: This allows text to be inserted as a watermark. Please note that adaptive scaling is not supported with text watermarks.

  • Dynamic watermarks: With this type of watermark, the position will shift either at a fixed time interval or at specific times.

At CDNetworks, we provide support for adding watermarks to a variety of video formats and codecs, including:

  • Supported formats: MP4, FLV, M3U8, TS, MKV, MOV, WMV, AVI, VP8, VP9, RealVideo, Windows Media Video, and more.
  • Supported codecs: H.265, H.264, H.263, MPEG, and more.

This process can be used in conjunction with other media processing operations within a single API call.

How to Use

Structure your fops in the request body as follows:

<op>/<Format>
    /wmImage2/<value>
    /wmGravity/<value>
    /wmauto/<value>
    /wmWidth/<value>
    /wmHeight/<value>
    /wmDissolve/<value>
    /wmdx/<value>
    /wmdy/<value>
    /wmInterval/<value>
    /multiConvertTime/<value>
    /wmText/<value>
    /wmFont/<value>
    /wmFontColor/<value>
    /wmFontSize/<value>
    /wmFontDissolve/<value>
    /wmFontBorderWidth/<value>
    /wmFontBorderColor/<value>
    /wmTextGravity/<value>
    /wmtextdx/<value>
    /wmtextdy/<value>
    /wmTextInterval/<value>
    /wmFontBold/<value>
    |saveas/<Urlsafe_Base64_Encode(bucket:filekey)>

Common Parameters

Parameter Required Description
op Yes Operation type. For media video/audio processing, set the operation type to avthumb.
format Yes Target format for output, such as flv, mp4, m3u8, etc.
saveas No This parameter defines the output location and filename as a URL-safe Base64-encoded string with the pseudocode Urlsafe_Base64_Encode(bucket:savedfilename).

Image and Video Watermark Parameters

Parameter Required Description
wmImage2 No The image or video to be embedded into the video as the watermarks. The parameter must be formatted in the <bucket>:<path> manner and then securely encoded using URL-safe Base64. For instance, test:1.jpg means adding the image named 1.jpg, found in the test bucket, as the watermark for the video. Once Base64 encoded, the final value of this parameter becomes dGVzdDoxLmpwZw==.
You can also incorporate multiple watermark files into the same video by linking different watermark files with a comma in the parameter. For example, Url-Safe-Base64-Encode(test:1.jpg),Url-Safe-Base64-Encode(test:2.jpg). Likewise, the properties of multiple watermarks can also be set at the same time, simply separated by commas. For example, set different widths to each watermakers with values separated by commas, <wmWidth1> ,<wmWidth2> ....
wmGravity No the placement of watermarks, refer to the wmGravity Parameters for more details.
wmauto No This parameter specifies whether the size of image and video watermarks will scale adaptively according to the video resolution.
1 - Image and video watermarks will scale adaptively.
0 (default) - Watermarks will retain their original size and not scale adaptively.
For example, the original video resolution is 1200x600 and the watermark size is 40x40. After the video is transcoded, the resolution changes to 300x200. The watermark image will also scale adaptively to 10x10.
wmWidth No The width of the image and video watermark. The value can be a specific value or a percentage. The percentage represents the percentage of the size of the watermark in the entire video screen.
For example, wmWidth=50% means that the watermark size is half of the entire video screen, and wmWidth=40 means that the width of the watermark is 40 pixels.
Note that when the value is 0 or less than 0, the width is adaptive and will be adjusted and scaled accordingly based on the aspect ratio of the video screen.
wmHeight No The height of the image and video watermark. The value can be a specific value or a percentage. The percentage represents the percentage of the size of the watermark in the entire video screen.
For example, wmHeight=20% means that the watermark size is 1/5 of the entire video screen, and wmHeight=60 means that the height of the watermark is 60 pixels.
Note that when the value is 0 or less than 0, the height is adaptive and will be adjusted and scaled accordingly based on the aspect ratio of the video screen. When wmWidth and wmHeight are both 0 or less than 0, the size of the watermark will not be set.
wmDissolve No The transparency level for both image and video watermarks, with a value range of 1-100. A value of 100 signifies opacity, while 0 corresponds to full transparency.
Please be aware that should the value exceed the specified range, it will automatically be adjusted to fall within this range. For instance, a value of -4 will be reset to 0, and 120 will be reduced to 100.
The default setting for this parameter is 100.
wmdx No The horizontal offset on the basis of the parameter wmGravity. A positive value results in a rightward shift, while a negative value induces a leftward shift, all relative to the wmGravity parameter.
It is essential to use this parameter in conjunction with wmGravity, ensuring that the number of parameters aligns consistently with wmGravity.
wmdy No The vertical offset on the basis of the parameter wmGravity. A positive value results in an upward shift, while a negative value induces a downward shift, all relative to the wmGravity parameter.
It is essential to use this parameter in conjunction with wmGravity, ensuring that the number of parameters aligns consistently with wmGravity.
wmInterval No The time interval, in seconds, between moments when the text watermark is expected to have a change.
multiConvertTime No Changes to the watermark are set to occur at specified time points, separated by commas. As an example, using 5,10,20 means the watermark will adjust at the 5th, 10th, and 20th seconds during video playback.
Please be aware that this parameter is incompatible with the wmInterval parameter; they cannot be utilized concurrently.

Text Watermark Parameters

Parameter Required Description
wmText No The text to be incorporated as watermarks in the video, which has to be securely encoded using URL-safe Base64.
It’s also possible to add multiple texts by separating different segments with a comma in the parameter. For example, Url-Safe-Base64-Encode(text1),Url-Safe-Base64-Encode(text2). Likewise, the properties of multiple text can also be set at the same time, simply separated by commas. For example, set the size of each text with values separated by commas, < wmFontSize1f> ,< wmFontSize2> ....
Please note that if the text is in Simplified Chinese, ensure it’s UTF-8 encoded to avoid potential display errors due to incompatible codecs.
wmFont No The font of the text watermark, which requires URL-safe Base64 encoding. The name of the font can only consist of numbers, upper and lower case letters, spaces, and hyphens ("-").
If there’s a need to switch fonts, multiple fonts must be included. These font names should be first linked by commas before being encoded in URL-safe Base64 format, following this pattern:
<Urlsafe_Base64_Encode(<Font1>,<Font2>…)>.
wmFontColor No The watermark text color, which should be encoded in URL-safe Base64. The color value should be a string format, either as 0xrrggb or &Hrrggbb, representing the RGB components of the color. These prefixes, 0x and &H, are optional.
To include multiple colors, simply connect the different colors with commas before encoding them. The syntax for encoding multiple colors is as follows:
<Urlsafe_Base64_Encode(<Color1>,<Color2>…)>.
wmFontSize No The font size of the text watermark. which can be given as a specific pixel value or a percentage. If a specific value is used, it denotes the absolute pixel height of the font. Conversely, if a percentage is used, it specifies the watermark font height relative to the video screen height. For instance, a value of 10 implies a watermark text height of 10 pixels; 10% reflects the text height as one-tenth of the total video screen height.
If the value is in pixels, it should fall within the range of 5 to 2160. If given as a percentage, it should be within the range of more than 0% to 100%. The default setting is set at 6%.
wmFontDissolve No The transparency level for both image and video watermarks, with a value range of 1-100. A value of 100 signifies opacity, while 0 corresponds to full transparency.
Please be aware that should the value exceed the specified range, it will automatically be adjusted to fall within this range. For instance, a value of -4 will be reset to 0, and 120 will be reduced to 100. The default setting for this parameter is 100.
wmFontBorderWidth No The font stroke for the text watermark , which supports transformation and is an integer type. A value less than or equal to 0 signifies no stroke, while any value above 0 indicates a stroke. The default value is set to 0.
wmFontBorderColor No The color for the text watermark font stroke - if transformation support is necessary - should first be comma-separated, then encoded using URL-safe Base64. The formatting follows the same pattern as wmFontColor. By default, the value is set to 0x000000, representing the color black.
wmTextGravity No The location of the text watermark, following the same format as wmGravity.
If the text watermark’s position requires adjustment during video playback, multiple watermark locations should be established, each separated by a comma.
wmtextdx No The horizontal offset on the basis of the parameter wmGravity. A positive value results in a rightward shift, while a negative value induces a leftward shift, all relative to the wmGravity parameter.
It is essential to use this parameter in conjunction with wmGravity, ensuring that the number of parameters aligns consistently with wmGravity.
wmtextdy No The verticaltal offset on the basis of the parameter wmGravity. A positive value results in a upward shift, while a negative value induces a downward shift, all relative to the wmGravity parameter.
It is essential to use this parameter in conjunction with wmGravity, ensuring that the number of parameters aligns consistently with wmGravity.
wmTextInterval No The time interval, in seconds, between moments when the text watermark is expected to change. This value should be equal to or greater than 1.
wmFontBold No Whether to set the text watermark in bold.
1 - Bolded
0 (default) - Unbolded

wmGravity Parameters

Parameter Description
TOP_LEFT The watermark is placed in the upper left corner of the frame.
TOP_CENTER The watermark is placed in the center of the top edge of the frame.
TOP_RIGHT The watermark is placed in the upper right corner of the frame.
CENTER_LEFT The watermark is placed in center of the left edge of the frame.
CENTER The watermark is placed in the exact center of the frame.
CENTER_RIGHT The watermark is placed in the center of the right edge of the frame.
BOTTOM_LEFT The watermark is placed in the bottom left corner of the frame.
BOTTOM_CENTER The watermark is placed in the center of the bottom edge of the frame.
BOTTOM_RIGHT The watermark is placed in the bottom right corner of the frame.

Request Example

Example 1: Add Image Watermarks

This example demonstrates how to add an image watermark to the test.mp4 video in the vod-wcs-test001 bucket, with the watermark image watermark.jpg file located in the same bucket. The watermark should be dynamically transformed every 5 seconds, with the following actions:
(1) The watermark is initially placed in the top left corner of the video.
(2) After 5 seconds, the watermark moves to the top right corner, shifted 20 pixels to the left.
(3) After another 5 seconds, the watermark returns to the top left corner.

Pseudocode format for the request:

curl -v -X POST 
–d "bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode(test.mp4)&fops=Urlsafe_Base64_Encode(avthumb/mp4/wmImage2/Urlsafe_Base64_Encode(vod-wcs-test001:watermark.jpg) /wmGravity/TOP_LEFT,TOP_RIGHT/wmInterval/5/wmdx/0,-20/wmdy/0,0/wmWidth/20%/wmHeight/20%|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test_watermark.mp4))&force=1&separate=1" 
–H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"

Actual request format:

-curl -v -X POST 
-d "bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9tcDQvd21JbWFnZTIvZG05a0xYZGpjeTEwWlhOME1EQXhPbmRoZEdWeWJXRnlheTVxY0djPS93bUdyYXZpdHkvVE9QX0xFRlQsVE9QX1JJR0hUL3dtSW50ZXJ2YWwvNS93bWR4LzAsLTIwL3dtZHkvMCwwL3dtV2lkdGgvMjAlL3dtSGVpZ2h0LzIwJXxzYXZlYXMvZG05a0xYZGpjeTEwWlhOME1EQXhPblJsYzNSZmQyRjBaWEp0WVhKckxtMXdOQT09&force=1&separate=1"
-H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"

Example 2: Add Video Watermarks

This example demonstrates how to add a dynamic video watermark to the test.mp4 video file in the vod-wcs-test001 bucket, with the watermark video watermark.mp4 located in the same bucket. The watermark video should occupy 1/5 of the main video. The processed video file should be saved in the vod-wcs-test001 bucket with the name test_video.mp4.

Pseudocode format for the request:

curl -v -X POST 
–d "bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode(test.mp4)&fops=Urlsafe_Base64_Encode(avthumb/mp4/wmImage2/Urlsafe_Base64_Encode(vod-wcs-test001:watermark.mp4)/wmGravity/TOP_LEFT/wmWidth/20%/wmHeight/20%|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test_video.mp4))&force=1&separate=1"
–H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"

Actual request format:

-curl -v -X POST 
-d "bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9tcDQvd21JbWFnZTIvZG05a0xYZGpjeTEwWlhOME1EQXhPbmRoZEdWeWJXRnlheTV0Y0RRPS93bUdyYXZpdHkvVE9QX0xFRlQvd21XaWR0aC8yMCUvd21IZWlnaHQvMjAlfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmZG1sa1pXOHViWEEw&force=1&separate=1"
-H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"

Example 3: Add Text Watermarks

This example implements adding a text watermark to the test.mp4 video file in the vod-wcs-test001 bucket, with the watermark text “CDNetworks”, in the Arial Unicode MS font. The processed video file should be saved in the vod-wcs-test001 bucket with the name test_file.mp4.

Pseudocode format for the request:

curl -v -X POST 
–d "bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode(test.mp4)&fops=Urlsafe_Base64_Encode(avthumb/mp4/wmText/Urlsafe_Base64_Encode(CDNetworks)/wmFont/Urlsafe_Base64_Encode(Arial Unicode MS)/wmTextGravity/TOP_LEFT|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test_file.mp4))&force=1&separate=1" –H "Authorization:mgrAuthorization_A:mgrAuthorization_B"
–H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"

Actual request format:

-curl -v -X POST 
-d "bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9tcDQvd21UZXh0L0ppTjROMFkxTVRzbUkzZzFRa0pHT3lZamVEYzVSREU3SmlONE5qSTRNRHNnSmlONE56QkNPVHNtSTNnMk5FRkVPeVlqZURVeVFUQTdKaU40T1RBeFJqcz0vd21Gb250L1FYSnBZV3dnVlc1cFkyOWtaU0JOVXc9PS93bVRleHRHcmF2aXR5L1RPUF9MRUZUfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNXRjRFE9&force=1&separate=1"
-H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"

Supported Watermark Fonts

Font Parameter
Noto Sans CJK SC Noto Sans CJK SC Regular
- Noto Sans CJK SC Black
- Noto Sans CJK SC Bold
- Noto Sans CJK SC DemiLight
- Noto Sans CJK SC Light
- Noto Sans CJK SC Medium
- Noto Sans CJK SC Thin
Noto Sans Mono CJK SC Noto Sans Mono CJK SC Regular
- Noto Sans Mono CJK SC Bold
Noto Serif CJK SC Noto Serif CJK SC
- Noto Serif CJK SC Black
- Noto Serif CJK SC ExtraLight
- Noto Serif CJK SC Light
- Noto Serif CJK SC Medium
- Noto Serif CJK SC SemiBold
Roboto Roboto
- Roboto Condensed
- Roboto Condensed Light
- Roboto Black
- Roboto Light
- Roboto Medium
- Roboto Thin
文泉驿等宽正黑 WenQuanYi Zen Hei Mono
文泉驿点阵正黑 WenQuanYi Zen Hei Sharp
文泉驿正黑 WenQuanYi Zen Hei
Is the content of this document helpful to you?
Yes
I have suggestion
Submitted successfully! Thank you very much for your feedback, we will continue to strive to do better!