The short video SDK provides a variety of features, product-level interaction, and an abundant video material library that contains music videos (MVs), stickers, bubbles, and word art. The short video SDK also allows you to create custom effects to meet the material requirements in different scenarios and industries. This topic describes how to configure word art.
Overview
Word art is an effect based on subtitles. A word art resource package folder contains a word art configuration file named config.json and some picture materials. You can use the editing API operation provided by the short video SDK to apply a word art effect by specifying the folder of a word art resource package.
- config.json: the word art configuration file. This file is required. For more information about how to configure the configuration file, see Parameters in config.json.
- icon.png: the word art thumbnail. This file is optional.
- lieheng.png: the word art texture. This file is optional. You can set the word art effect based on this texture if corresponding configurations are made in the configuration file.
Configure the word art resource package
Parameter | Type | Required | Description |
---|---|---|---|
version | String | Yes | The version number. Default value: 1. |
color | String | Yes | The font color. Format: #AARRGGBB or #RRGGBB. |
texture | String | No | The word art texture. Only the JPG and PNG formats are supported. This file must be placed in the same folder as config.json. The texture for each word is the same. The part where the text and the texture overlap is applied. |
outline1 | JSONObject | Yes | The first-layer outline. For more information about the attributes of outline1, see Outline attributes. |
outline2 | JSONObject | No | The second-layer outline. This outline has the same data structure as outline1. For more information about the attributes of outline2, see Outline attributes. |
Attribute | Type | Required | Description |
---|---|---|---|
type | String | Yes | The type of the font. The default value is normal, which means that the system font is used. |
data | JSONArray | Yes | The color and width of an outline. For more information, see Sub-attributes of the data attribute. If you set the type attribute to normal, a maximum of three color configurations can be made for the data attribute. If more than three color configurations exist, only the first three color configurations take effect. |
Sub-attribute | Type | Required | Description |
---|---|---|---|
color | String | Yes | The outline color. Format: #AARRGGBB or #RRGGBB. |
width | float | Yes | The outline width. Valid values: 0 to 64. The width of the next data attribute must be greater than this value. Note For all outlines, the width of a data attribute must be greater than the width of the previous data attribute. |
{
"outline1": {
"type": "normal",
"data":[ // data1
{
"color": "#5350DD",
"width": 2
},
{ // data2
"color": "#B5FAA7",
"width": 4
}
]
},
"outline2": {
"type": "normal",
"data":[
{ // data3
"color": "#6E58F8",
"width": 8
},
{ // data4
"color": "#69F88C",
"width": 10
},
{ // data5
"color": "#FA55D8",
"width": 12
}
]
}
}
Configuration example
- The folder structure of the demo package:
├── config.json
├── icon.png
└── lieheng.png
- The following code shows how config.json is configured:
{ "version": 1, "color":"#000000", "texture": "lieheng.png", "outline1": { "type": "normal", "data":[ { "color": "#ffffff", "width": 8 } ] }, "outline2": { "type": "normal", "data":[ { "color": "#000000", "width": 15 } ] } }
Use word art in the short video SDK
- Android
Call the
AliyunPasterControllerCompoundCaption.setFontEffectTemplate
method to apply the word art effect. For more information, see Configure subtitles and animated stickers. - iOS
Call the
AliyunCaptionStickerController.setFontEffectTemplate
method to apply the word art effect. For more information, see Configure subtitles and animated stickers.