Example 1: Create a Transcoding Template
Scenario
If you need to use a custom transcoding template for audio and video transcoding, create a transcoding template before submitting a transcoding task.
Prerequisites
- You have obtained the project ID of the region where the transcoding template is to be created. For details, see Obtaining a Project ID.
- You have determined the region where the transcoding template to be created is located and obtained the endpoint of MPC for this region from the Regions and Endpoints.
Overall Process
Involved APIs
To use token-based authentication, obtain a user token and add X-Auth-Token to the request header of the service API when making an API request.
Procedure
- Obtain a user token and use it to authenticate the calling of MPC APIs.
Obtain the username, password, domainname, and projectname from the My Credentials page. Call the following API to obtain the token. For details, see Making an API Request.
POST https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens Content-Type: application/json { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "********", //Username "password": "********", //Login password "domain": { "name": "domainname" //Name of the account to which the user belongs } } } }, "scope": { "project": { "name": "*******" //Project name } } } }
As shown in Figure 1, information in the red box indicates the user token.
- Select the POST request method and enter the request URI.
https://{endpoint}/v1/{project_id}/template/transcodings
mpc.cn-north-4.myhuaweicloud.com is the endpoint of MPC. You can obtain the endpoint from Regions and Endpoints.The region where an IAM API is called must be the same as the region where an MPC API is called. For example, the user token obtained when you call an IAM API in the CN North-Beijing4 region can only be used to authenticate the requests for calling MPC APIs in the CN North-Beijing4 region.
- In the request header, add X-Auth-Token and set its value to be the token obtained in 1.
- Pass the following parameters to the request body:
{ "template_name":"MP4_H.264_1920x1080_6000_HEAAC", "video":{ "codec":1, "bitrate":6000, "profile":3, "level":15, "preset":3, "ref_frames_count":4, "max_iframes_interval":5, "bframes_count":4, "frame_rate":1, "width":1920, "height":1080, "aspect_ratio":0 }, "audio":{ "codec":1, "sample_rate":4, "bitrate":128, "channels":2 }, "common":{ "PVC":0, "hls_interval":5, "dash_interval":5, "pack_type":1 } }
If the request succeeds, the transcoding template ID is returned. The status code is 201 Created.
{ "template_id":1001 }
If the request fails, the following error code and error description are returned:
{ "error_code": "MPC.100101", "error_msg": "template error, it's name MP4_H.264_1920x1080_6000_HEAAC is same with template 274764." }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot