Watermark
VideoEditor SDK supports several configuration options for WatermarkSettings
allowing flexible adaptation to different needs and use cases.
If adding the watermark is the only editing operation to be performed, please set the output mode to EXPORT_ALWAYS
to export the video with the watermark.
Watermark image#
Here, we set the image for the watermark by providing an ImageSource
created from a resource drawable. Alternatively, you can also create it from a File
or a Uri
.
The watermark itself is not processed, so to achieve the effect of transparency, make sure that your input image supports that (use a PNG file with an alpha channel).
Size#
The default size of the watermark relative to the smaller side of the video is 20%. In this example, we set it to 30%.
Inset#
The default inset of the watermark relative to the smaller side of the video is 5%. In this example, we set it to 10%.
Alignment#
The default alignment of the watermark is bottom left. In this example, we set it to bottom right.
class VideoWatermark(private val activity: AppCompatActivity) : Example(activity) {override fun invoke() {// In this example, we do not need access to the Uri(s) after the editor is closed// so we pass false in the constructorval settingsList = VideoEditorSettingsList(false)// Set the source as the Uri of the video to be loaded.configure<LoadSettings> {it.source = activity.resourceUri(R.raw.skater)}settingsList.configure<WatermarkSettings> {it.image = ImageSource.create(R.drawable.imgly_watermark)// By default, the value of size is 0.2. For this example, we change it to 0.3it.size = 0.3f// By default, the value of inset is 0.05. For this example, we change it to 0.1it.inset = 0.1f// By default, the alignment for the watermark is bottom left. For this example, we change it to bottom rightit.alignment = WatermarkSettings.Alignment.BOTTOM_RIGHT}// Start the video editor using VideoEditorBuilder// The result will be obtained in onActivityResult() corresponding to EDITOR_REQUEST_CODEVideoEditorBuilder(activity).setSettingsList(settingsList).startActivityForResult(activity, EDITOR_REQUEST_CODE)// Release the SettingsList once donesettingsList.release()}override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {intent ?: returnif (requestCode == EDITOR_REQUEST_CODE) {// Wrap the intent into an EditorSDKResultval result = EditorSDKResult(intent)when (result.resultStatus) {EditorSDKResult.Status.CANCELED -> showMessage("Editor cancelled")EditorSDKResult.Status.EXPORT_DONE -> showMessage("Result saved at ${result.resultUri}")else -> {}}}}}