本示例介绍使用Alibaba Cloud SDK for Java调用AddLiveStreamTranscode接口添加转码配置信息。

前提条件

请在pom.xml文件中增加以下依赖,准确的SDK版本号,请参见 阿里云开发工具包(SDK)

阿里云2000元代金券免费领,最新优惠1折抢购,2核4G云服务器仅799元/3年,新老用户同享,立即抢购>>>

<dependency>     <groupId&gt;com.aliyun</groupId>     <artifactId>aliyun-java-sdk-live</artifactId>     <version>3.7.5</version>  </dependency>

示例代码

import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.IAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ServerException; import com.aliyuncs.live.model.v20161101.AddLiveStreamTranscodeRequest; import com.aliyuncs.live.model.v20161101.AddLiveStreamTranscodeResponse; import com.aliyuncs.profile.DefaultProfile; import com.google.gson.Gson;  /**  * 添加转码配置  */ public class TestAddLiveStreamTranscode {      public static void main(String[] args) {         DefaultProfile profile = DefaultProfile.getProfile(                 "<your-region-id>",            // 地域ID                 "<your-access-key-id>",        // 您的AccessKey ID                 "<your-access-key-secret>" );  // 您的AccessKey Secret         IAcsClient client = new DefaultAcsClient(profile);          AddLiveStreamTranscodeRequest request = new AddLiveStreamTranscodeRequest();         /**          * 转码模版。目前有:          *          * 标准质量模板:lld、lsd、lhd、lud          * 高品质(窄带高清TM转码)模板:ld、sd、hd、ud          */         request.setTemplate("sd");         // 您的加速域名。         request.setDomain("live.aliyuntest.club");         // 直播流所属应用名称。         request.setApp("testApp");          try {             AddLiveStreamTranscodeResponse response = client.getAcsResponse(request);             System.out.println(new Gson().toJson(response));         } catch (ServerException e) {             e.printStackTrace();         } catch (ClientException e) {             System.out.println("ErrCode:" + e.getErrCode());             System.out.println("ErrMsg:" + e.getErrMsg());             System.out.println("RequestId:" + e.getRequestId());         }      } }