Querying Transcoding Templates

You can query custom transcoding templates and system presets by template ID or page number. For details, see the API for querying transcoding templates.

Notes

  • You can query one or more custom transcoding templates by template ID. A maximum of 10 transcoding templates can be queried at a time.
  • You can query templates based on the page number and number of records on each page.

Core Code

1
2
3
4
5
6
7
8
9
// Set template parameters.
QueryTemplateReq queryTemplateReq = new QueryTemplateReq();
// Set the template ID. A maximum of 10 transcoding templates can be queried.
queryTemplateReq.setTemplateIds(new Integer[]{215, 156});

// Send a request.
QueryTemplateResponse queryTemplateResponse = mpcClient.queryTemplate(queryTemplateReq);
// Return the query results.
System.out.println(new Gson().toJson(queryTemplateResponse));

Full Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Service process:
* 1. Import the SDK package MPCSDK.jar.
* 2. Set configuration items, including the endpoint, AK, SK, and project ID, for accessing MPC and authorization.
* 3. Set request parameters for querying a transcoding template.
* 4: Send a request.
* 5. Return the results.
*/
import com.google.gson.Gson;
import com.huawei.mpc.client.ClientConfig;
import com.huawei.mpc.client.MpcClient;
import com.huawei.mpc.client.MpcConfig;
import com.huawei.mpc.model.template.QueryTemplateReq;
import com.huawei.mpc.model.template.QueryTemplateResponse;


// Set the method for constructing MPC configuration items.
MpcConfig mpcconfig = new MpcConfig();
// Mandatory. Set the endpoint of MPC. For details, see section "Obtaining Key Parameters."
mpcConfig.setEndPoint(endPoint);
// Mandatory. Set the user's project ID. For details, see section "Obtaining Key Parameters."
mpcConfig.setProjectId(projectId);

// Mandatory. Set the SK. For details, see section "Obtaining Key Parameters."
mpcConfig.setSk(sk);

// Mandatory. Set the AK. For details, see section "Obtaining Key Parameters."
mpcConfig.setAk(ak);
       
/*if you need proxy*/
// Optional. Set the proxy if necessary.
/*
ClientConfig clientConfig = new ClientConfig();
// Set the IP address of the proxy server.
clientConfig.setProxyHost(proxyHost);
// Set the port number of the proxy server.
clientConfig.setProxyPort(Integer.parseInt(proxyPort));
// Set the username for accessing the proxy server.
clientConfig.setProxyUserName(proxyUserName);
// Set the password for accessing the proxy server.
clientConfig.setProxyPassword(proxyPassword);
*/

// MPC construction method
MpcClient mpcClient = new MpcClient(mpcconfig);
/*
* proxy provided
// MPC construction method. If a proxy needs to be configured, use this construction method.
* MpcClient mpcClient=new MpcClient(mpcconfig, clientConfig);
*/

// Set template parameters.
QueryTemplateReq queryTemplateReq = new QueryTemplateReq();
// Set the template ID. A maximum of 10 transcoding templates can be queried.
queryTemplateReq.setTemplateIds(new Integer[]{215, 156});

// Send a request.
QueryTemplateResponse queryTemplateResponse = mpcClient.queryTemplate(queryTemplateReq);
// Return the query results.
System.out.println(new Gson().toJson(queryTemplateResponse));