Example 2: Create a Recording Template
Scenario
If you want to record a live stream and store the recordings in VOD, you can call an API to configure a recording template.
This section describes how to configure a recording template by calling an API.
Prerequisites
- You have determined the region where the streaming domain name for which the recording template needs to be configured is located and obtained the endpoint of the region from Regions and Endpoints.
- You have obtained the project ID of the region where the streaming domain name is located. For details, see Obtaining a Project ID.
Overall Process
Procedure
- Log in to the Live console and obtain the target streaming domain name.
- Obtain a user token and use it to authenticate the calling of Live APIs.
For details, see Making an API Request. CN North-Beijing4 is used as an example. If you need to call a Live API in another region, replace the endpoint with the IAM endpoint of the corresponding region.
POST https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens Content-Type: application/json { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "password": "password", "domain": { "name": "domainname" } } } }, "scope": { "project": { "name": "projectname" } } } }As shown in Figure 1, information in the red box indicates the user token. - Call the API for creating a recording template to configure recording parameters.
- Select the POST request method and enter the request URI.
https://{endpoint}/v1/{project_id}/record/config - In the request header, add X-Auth-Token and set its value to be the token obtained in 2.
- Specify the following parameters in the request body:
{ "domain" : "play.example.huawei.com", "app_name" : "live", "record_duration" : 900, "record_format" : "flv", "record_location" : "vod", "record_prefix" : "{DomainName}/{AppName}/{StreamName}/{StartTime}-{EndTime}" } - If the request succeeds, only a status code 201 Created is returned.
- Select the POST request method and enter the request URI.
- Start recording the live stream and store the recording in VOD. For details about how to obtain recording files, see Managing Recordings.
Last Article: Example 1: Creating a Transcoding Template
Next Article: Example 3: Disable a Live Stream

Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.