- Documentation
- Video Call
- Upgrade using advanced features
- Advanced features
- Configure the video
- Watermark the video
- Take snapshots
Watermark your video/Take snapshots
Introduction
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.
Prerequisites
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.
Using stream watermark
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 theimageURL
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 theassets
directory of the Android project, theimageURL
should start with a prefixasset://
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);
```
Using snapshot feature
- To take a snapshot of the published images, call the
takePublishStreamSnapshot
method.
engine.takePublishStreamSnapshot(new IZegoPublisherTakeSnapshotCallback() {
@Override
public void onPublisherTakeSnapshotResult(int errorCode, Bitmap image) {
//Save snapshot.
}
});
- To take a snapshot of the played images, call the
takePlayStreamSnapshot
method.
engine.takePlayStreamSnapshot(streamID,new IZegoPlayerTakeSnapshotCallback() {
@Override
public void onPlayerTakeSnapshotResult(int errorCode, Bitmap image) {
//Save snapshot.
}
});
}
FAQ
How to set the
limageURL
property of theZegoWatermark
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 prefixasset://
followed by the absolute path of the image. If the image is stored in a directory on the Android device, theimageURL
should start with the prefixfile://
followed by the absolute path of the image.
How to set the
layout
property of theZegoWatermark
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.