ZEGOCLOUD's SDKs provide the ability to watermark your video stream. For example, businesses and organizations can use the watermark feature to display their logo on the video.
This document mainly describes how to implement the watermark and screenshot features with the Video Call SDK.
Before you begin, make sure you complete the following:
Create a project in ZEGOCLOUD Admin Console and get the AppID and AppSign of your project.
Refer to the Quick Start doc to complete the SDK integration and basic function implementation.
Currently, the imageURL
parameter in the ZegoWatermark
object supports the following two path formats:
Accessing the image via the absolute path
file://[absolute path of the image]
: The image must be stored in the directory of the Android app. For example, if the image is stored in the private directory of the Android app: /sdcard/Android/data/im.zego.zegoexpressapp/ZegoLogo.png
, then the imageURL
should be constructed as: file:///sdcard/Android/data/im.zego.zegoexpressapp/ZegoLogo.png
.
// Images in "JPG" and "PNG" formats can be used as watermarks. If the image is stored in the assets directory of the Android project, the [imageURL] should start with a prefix "asset://" followed by the absolute path of the image. If the image is stored in a directory on the Android device, the [imageURL] should start with a prefix "file://" followed by the absolute path of the image.
String imageURL = "file:///sdcard/Android/data/im.zego.zegoexpressapp/ZegoLogo.png";
Rect layout = new Rect(0,0,300,600);
ZegoWatermark watermark = new ZegoWatermark(imageURL, layout);
sdk.setPublishWatermark(watermark, true);
Accessing the Image in the Assets directory of the android project
asset://[image file name]
: If the image is stored in the assets
directory of the Android project, the imageURL
should start with a prefix asset://
followed by the file name of the image.
For example, asset://ZegoLogo.png
.
```java
// Images in "JPG" and "PNG" formats can be used as watermarks. If the image is stored in the assets directory of the Android project, the [imageURL] should start with a prefix "asset://" followed by the absolute path of the image. If the image is stored in a directory on the Android device, the [imageURL] should start with a prefix "file://" followed by the absolute path of the image.
String imageURL = "asset://ZegoLogo.png";
Rect layout = new Rect(0,0,300,600);
ZegoWatermark watermark = new ZegoWatermark(imageURL,layout);
sdk.setPublishWatermark(watermark, true);
```
takePublishStreamSnapshot
method.engine.takePublishStreamSnapshot(new IZegoPublisherTakeSnapshotCallback() {
@Override
public void onPublisherTakeSnapshotResult(int errorCode, Bitmap image) {
//Save snapshot.
}
});
takePlayStreamSnapshot
method.engine.takePlayStreamSnapshot(streamID,new IZegoPlayerTakeSnapshotCallback() {
@Override
public void onPlayerTakeSnapshotResult(int errorCode, Bitmap image) {
//Save snapshot.
}
});
}
How to set the limageURL
property of the ZegoWatermark
object?
Images in "JPG" and "PNG" formats can be used as watermarks. If the image is stored in the assets directory of the Android project, the imageURL
should start with the prefix asset://
followed by the absolute path of the image. If the image is stored in a directory on the Android device, the imageURL
should start with the prefix file://
followed by the absolute path of the image.
How to set the layout
property of the ZegoWatermark
object?
The watermark area cannot exceed the size set by the encoding resolution of the stream.
For more details about the encoding resolution of the stream, refer to the setVideoConfig
method.