云服务器内容精选

  • 音视频转码 音视频转码是指将原始音视频文件转换成另一个音视频文件,可以改变原始音视频文件的格式、编码、码率、帧率等参数。 表1 功能说明 参数 特性说明 支持输入格式 音视频文件格式:MP4、TS、MOV、FLV、MPG、MXF、WMV、ADTS、AVI、MKV、MPEG、GIF、WAV等。 视频编码格式:H.264、 H.265、 MPEG-2、MPEG-4、MJPEG、VP6/7/8/9、WMV1/2/3、ProRes 422等。 音频编码格式:AAC、 AC3、EAC3、HE-AAC、MP2、MP3、PCM(s161e,s16be,s241e,s24be,dvd)、WMA等。 字幕格式:SRT格式,文字编码格式为UTF-8。 支持输出格式 音视频文件格式:DASH、HLS、MP4、MP3、ADTS等。 视频编码格式:H264、 H265等。 音频编码格式:HE_AAC、AAC、MP3等。 图片文件格式:GIF等。 音频提取 从视频文件中单独分离出纯音频文件。 视频提取 从视频文件中单独分离出视频,无音频信息。 字幕合入 支持嵌入外部字幕文件,优化用户体验。 水印 转码时为视频添加静态图文水印,实现视频内容的防伪溯源和版权保护。 转码后的音视频规格可以根据实际需求进行自定义,详见自定义转码模板。
  • 转码模板 为满足多样化使用场景, 媒体处理 预置了大量的音视频转码模板,同时也支持自定义转码模板。 预置模板:无需额外配置,可以直接调用,包含纯音频模板和音视频模板,高清低码模板,覆盖了所有的输出格式、编码格式,以及常见的分辨率和码率。按转码输出路数,预置模板可以分为如下两类: 一进一出转码模板:一个音视频文件转码后输出文件只有一个。 一进多出转码模板:一个音视频文件转码后输出文件最多可以有9个。 自定义模板:根据实际需求设置转码模板的视频参数和音频参数。支持一进一出转码模板和一进多出转码模板,其中一进多出模板最多支持设置6路输出规格。
  • 视频加密 视频加密是指采用HLS AES-128标准协议对转码后的HLS视频内容进行加密。 安全级别较高,终端兼容性好。 支持在转码同时对视频内容进行加密。 对转码后的HLS视频内容进行加密处理时,您需注意以下事项: 输入的IV必须是安全随机数,且长度为128bit。 输入的Key必须是安全随机数生成的,且长度为128bit。 密钥服务器需对终端获取密钥的请求进行身份校验,并且开启加密传输,防止密钥泄漏。 为不同的转码请求设置不同的IV向量,避免因部分文件的IV和密钥泄漏而影响其它文件。
  • SDK介绍 媒体处理SDK提供了创建转码任务、取消转码任务、查询转码任务、创建转码配置模板、删除转码配置模板、更新转码配置模板、查询转码配置模板等。 目前暂提供了JAVA、Python和Go三种语言SDK,若您有其它开发语言的需求,建议您通过媒体处理API进行调用。 媒体处理SDK代码不支持转义。 如果无法正常打开GitHub仓库,请检查您所使用的网络是否可以正常访问公网。由于GitHub的服务器部署在国外,国内用户访问时容易遇到无法打开的情况,请切换网络后再尝试打开。 表1 服务端SDK 语言 Github地址 参考文档 JAVA huaweicloud-sdk-java-v3 Java SDK使用指导 Python huaweicloud-sdk-python-v3 Python SDK使用指导 Go huaweicloud-sdk-go-v3 Go SDK使用指导
  • 错误码 当您调用API时,如果遇到“APIGW”开头的错误码,请参见API网关错误码进行处理。 状态码 错误码 错误信息 描述 处理措施 400 MPC.10089 The template file does not exist. 模板文件不存在 模板文件不存在,请检查 400 MPC.10090 The template file does not exist. 模板文件不存在 模板文件不存在,请检查 400 MPC.10091 The template name already exists. 模板名字重复 模板名字重复,请检查 400 MPC.10155 The subtitle file list and M3U8 file do not contain the specified default language. 字幕文件列表和M3U8文件中均不存在指定默认语言 字幕文件列表和M3U8文件中均不存在指定默认语言 400 MPC.10156 File deletion failed. 文件删除失败 文件删除失败 400 MPC.10202 Invalid request parameter. MPC 请求参数非法 请检查参数是否正确 400 MPC.10204 Incorrect request method. MPC 请求方式不正确 请检查请求方式 400 MPC.10205 Incorrect request content type. MPC 请求内容类型不正确 请检查请求内容类型 400 MPC.10223 An agency has been created. 委托授权已创建 委托授权已创建,请检查 400 MPC.10224 The agency has been deleted. 委托授权已被删除 委托授权已被删除,请检查 400 MPC.10230 The template group already exists. 模板组已存在 模板组已存在,请检查 400 MPC.10231 The template group does not exist. 模板组不存在 模板组不存在,请检查 401 MPC.10203 Identity authentication failed. MPC 认证失败 请检查Token等认证参数是否正确 401 MPC.10206 You have not completed real-name authentication. MPC 用户未实名认证 请检查用户是否实名认证 401 MPC.10207 Your account is in an abnormal state. MPC 用户处于异常状态 请检查用户状态是否正确 401 MPC.10208 Tenant ID verification failed, please check. MPC 租户ID校验失败 请检查租户ID是否正确 403 MPC.10010 Invalid input parameters. 输入参数错误 输入参数错误,请检查。 403 MPC.10211 The task does not exist. 任务不存在 转码任务不存在,请检查 403 MPC.10212 Operation failed. The task is in progress or has been completed. MPC 操作失败,任务处理中或已经处理完成 任务处理中或已经处理完成,请检查 403 MPC.10214 The topic does not exist. MPC 主题不存在 主题不存在,请检查 403 MPC.10215 The topic already exists. MPC 主题已经存在 主题已经存在,请检查 403 MPC.10226 The resource does not exist. 资源不存在 资源不存在,请检查 403 MPC.10240 Failed to obtain the basic information about the media file. 获取媒体文件基本信息失败。 请检查是否已授权桶,且obs桶未配置kms加密。 403 MPC.10243 Due to security reasons, your account has been restricted from purchasing certain pay-per-use cloud service resources according to the CLOUD Customer Agreement. If you have any questions, contact customer service. 您的账号可能存在风险,已根据《云用户协议》限制您购买部分按需计费的云服务资源。如有疑问,请联系客服咨询处理。 您的账号可能存在风险,已根据《云用户协议》限制您购买部分按需计费的云服务资源。如有疑问,请联系客服咨询处理。 403 MPC.10244 Insufficient account balance. Top up your account. 您的账户余额不足,无法开通资源,请立即充值。 您的账户余额不足,无法开通资源,请立即充值。 406 MPC.10051 The selected template is a super-resolution template and is not supported. 所选模板为超分辨率模板,暂不支持 请检查转码模板是否正确 406 MPC.10052 Failed to obtain the input file. 无法获取源文件,请检查路径 无法获取源文件,请检查路径 406 MPC.10053 The input file does not exist. 源文件不存在 源文件不存在,请检查 406 MPC.10054 Failed to obtain the subtitle file. 无法获取字幕文件 无法获取字幕文件,请检查路径 406 MPC.10055 The audio sampling rate 7,350 is not supported. 输出音频AAC时,不支持采样率为7350,请修改 不支持采样率为7350,请修改 406 MPC.10056 This type of output frame rate is not supported. 不支持该类输出帧率 不支持该类输出帧率,请修改 406 MPC.10057 This type of output bitrate is not supported. 不支持该类输出视码率 不支持该类输出视码率,请修改 406 MPC.10058 This type of output video width is not supported. 不支持该类输出视频宽度 不支持该类输出视频宽度,请修改 406 MPC.10059 This type of output video height is not supported. 不支持该类输出视频高度 不支持该类输出视频高度,请修改 406 MPC.10060 This type of I-frame interval is not supported. 不支持该类输出视频I帧间隔 不支持该类输出视频I帧间隔,请修改 406 MPC.10061 Capturing snapshots at non-fixed intervals is not supported. 不支持非固定时间间隔截图,请修改为固定时间间隔截图 请修改为固定时间间隔截图 406 MPC.10062 Invalid video codec. 截图场景下视频codec错误 截图场景下视频codec错误,请修改 406 MPC.10063 Invalid video format. 截图场景下视频format错误 截图场景下视频format错误,请修改 406 MPC.10064 Multiple watermarks are not supported. 不支持水印多路输入,目前仅支持2路输入 不支持水印多路输入,目前仅支持2路输入,请修改 406 MPC.10065 Invalid output file format. 不支持该类输出文件格式 不支持该类输出文件格式,请检查 406 MPC.10066 The input file format does not match the actual format. 输入文件格式与实际格式不符,请检查 输入文件格式与实际格式不符,请检查 406 MPC.10067 Failed to obtain the ID of the video codec. 获取视频CODEC ID 失败 获取视频CODEC ID 失败,请检查 406 MPC.10068 Failed to obtain the ID of the audio codec. 获取音频CODEC ID 失败 获取音频CODEC ID 失败,请检查 406 MPC.10069 Failed to obtain the ID of the subtitle codec. 获取字幕CODEC ID 失败 获取字幕CODEC ID 失败,请检查 406 MPC.10070 Failed to obtain the encoding/decoding format. 获取编解码格式失败 获取编解码格式失败,请检查 406 MPC.10071 Failed to obtain the parameters of the input video stream. 无法获取输入视频流的相关参数信息 无法获取输入视频流的相关参数信息,请检查 406 MPC.10072 Invalid frame rate of the video stream. 视频流帧率信息错误 视频流帧率信息错误,请检查 406 MPC.10080 Invalid frame rate of the input file. 输入文件视频帧率错误 输入文件视频帧率错误,请检查 406 MPC.10081 The file does not contain audio streams. 文件缺失音频流,请检查输入文件 文件缺失音频流,请检查输入文件 406 MPC.10082 Failed to obtain the input audio or video stream. 无法获取输入视频流(音频或视频),请自检 无法获取输入视频流(音频或视频),请检查 406 MPC.10083 This type of codec is not supported. 不支持该类编码类型 不支持该类编码类型,请检查 406 MPC.10084 This chroma subsampling format is not supported. 不支持此种色度采样格式 不支持此种色度采样格式,请检查 406 MPC.10085 The file format is not supported. 文件格式不支持 文件格式不支持,请检查 406 MPC.10086 Failed to obtain the input file. 无法获取源文件,请检查路径 无法获取源文件,请检查路径 406 MPC.10087 Invalid task parameters. 查询任务参数错误 查询任务参数错误,请检查 406 MPC.10088 The image file does not exist. 图片文件不存在 图片文件不存在,请检查 406 MPC.10092 The image file does not exist. 图片文件不存在 图片文件不存在,请检查 406 MPC.10093 The file name exceeds the maximum length. 文件名过长 文件名过长,请检查 406 MPC.10094 Invalid file format. 文件格式异常 文件格式异常,请检查 406 MPC.10095 The watermark is placed in a wrong position. 水印的位置错误 水印的位置错误,请检查 406 MPC.10096 Invalid watermark size. 水印的大小错误 水印的大小错误,请检查 406 MPC.10097 Invalid watermark scaling ratio. 水印缩放比例错误 水印缩放比例错误,请检查 406 MPC.10098 Invalid watermark duration. 水印持续时长错误 水印持续时长错误,请检查 406 MPC.10099 The media stream type is not supported. 不支持的媒体流类型 不支持的媒体流类型,请检查 406 MPC.10100 An error occurred when parsing the video frame rate information. 解析视频帧率信息错误 解析视频帧率信息错误,请检查 406 MPC.10101 Invalid input parameters. 输入参数错误 输入参数错误,请检查 406 MPC.10102 Failed to open the input file. 源文件打开异常,请检查 源文件打开异常,请检查 406 MPC.10103 Open GOP is not supported. 不支持OPEN GOP素材 不支持OPEN GOP素材,请检查 406 MPC.10104 Internal error. 服务内部异常,请重试或联系工程师 服务内部异常,请重试或联系工程师 406 MPC.10105 An error occurred during transcoding. 转码进程异常 转码进程异常,请重试或联系工程师 406 MPC.10106 The audio sampling rate is lower than 12,000. The audio will be discarded. 音频采样率低于12000,音频被丢弃 音频采样率低于12000,音频被丢弃 406 MPC.10107 Invalid input video resolution. 原始视频分辨率错误 原始视频分辨率错误 406 MPC.10108 The audio sampling rate of the input video is incorrect. 原始视频的音频采样率错误 原始视频的音频采样率错误 406 MPC.10109 Invalid resolution in the template. 模板分辨率错误 模板分辨率错误 406 MPC.10110 The video encoding format of the input file is not supported. 片源视频编码格式特殊,暂不不支持 片源视频编码格式特殊,暂不不支持 406 MPC.10111 Failed to obtain the file from OBS. 获取obs文件失败 获取obs文件失败 406 MPC.10112 The video or audio format of the input file is not supported. 片源的视频或音频格式不支持 片源的视频或音频格式不支持 406 MPC.10113 The DTS of the input file is not supported. 片源的dts异常,暂不支持 片源的dts异常,暂不支持 406 MPC.10114 The header information of the input file is incorrect. 片源文件头信息有误,请检查 片源文件头信息有误,请检查 406 MPC.10115 The watermark cannot be scaled down by more than 256 times. 水印图片缩小倍数超过256倍,暂不支持 水印图片缩小倍数超过256倍,暂不支持 406 MPC.10116 The audio encoding format of the input file is not supported. 片源的音频编码格式,暂不支持 片源的音频编码格式,暂不支持 406 MPC.10117 The audio and video in the input file are not synchronized. 片源的音频和视频不同步 片源的音频和视频不同步 406 MPC.10118 Failed to upload files to the OBS path. 上传文件到obs失败 上传文件到obs失败,请重试或联系工程师 406 MPC.10119 Invalid input data. 片源数据无效 片源数据无效,请检查 406 MPC.10120 The task does not exist. 任务不存在 任务不存在,请检查 406 MPC.10121 The subtitle file does not exist. 字幕文件不存在,请检查 字幕文件不存在,请检查 406 MPC.10122 The resolution in the template is greater than the input video resolution. 模板分辨率大于原视频分辨率 模板分辨率大于原视频分辨率,请检查 406 MPC.10123 The header information of the input file is incorrect. 片源文件头信息有误,请检查 片源文件头信息有误,请检查 406 MPC.10124 Some data in the input file are missing. 片源部分数据缺失,请检查片源是否可以完整 片源部分数据缺失,请检查片源是否可以完整 406 MPC.10125 Input data error. 片源数据问题,请检查片源能否播放 片源数据问题,请检查片源能否播放 406 MPC.10126 Input data error. 片源数据问题,请检查片源能否播放 片源数据问题,请检查片源能否播放 406 MPC.10127 Failed to obtain the level-1 m3u8 when an HLS media file is encrypted with DRM. DRM加密,HLS格式获取一级m3u8失败 DRM加密,HLS格式获取一级m3u8失败,请检查 406 MPC.10128 Failed to obtain the level-2 m3u8 when an HLS media file is encrypted with DRM. DRM加密,HLS格式获取二级m3u8失败 DRM加密,HLS格式获取二级m3u8失败,请检查 406 MPC.10129 Failed to obtain the index file when a DASH media file is encrypted with DRM. DRM加密,DASH格式获取索引文件失败 DRM加密,DASH格式获取索引文件失败,请检查 406 MPC.10130 The HLS content fails to be encrypted using DRM. DRM加密,HLS格式加密失败 DRM加密,HLS格式加密失败,请检查 406 MPC.10131 Failed to modify the index file when an HLS media file is encrypted with DRM. DRM加密,HLS格式更新索引文件失败 DRM加密,HLS格式更新索引文件失败,请检查 406 MPC.10132 Failed to obtain the IV during DRM encryption. DRM加密,DASH获取iv失败 DRM加密,DASH获取iv失败,请检查 406 MPC.10133 The DASH content fails to be encrypted using DRM. DRM加密,DASH格式加密失败 DRM加密,DASH格式加密失败,请检查 406 MPC.10134 Failed to modify the index file when a DASH media file is encrypted with DRM. DRM加密,DASH格式更新索引文件失败 DRM加密,DASH格式更新索引文件失败,请检查 406 MPC.10135 Failed to package the digital watermark due to the incorrect xformat configuration. 数字水印转封装失败,配置xformat的错误 数字水印转封装失败,配置xformat的错误,请检查 406 MPC.10136 Failed to package the digital watermark because xformat fails to be started. 数字水印转封装失败,启动xformat失败 数字水印转封装失败,启动xformat失败,请检查 406 MPC.10137 Failed to package the digital watermark because xformat fails to create a task. 数字水印转封装失败,xformat创建task失败 数字水印转封装失败,xformat创建task失败,请检查 406 MPC.10138 Failed to package the digital watermark because xformat fails to query the task. 数字水印转封装失败,xformat查询任务失败 数字水印转封装失败,xformat查询任务失败,请检查 406 MPC.10139 Failed to package the digital watermark because the xformat task timed out. 数字水印转封装失败,xformat任务超时 数字水印转封装失败,xformat任务超时,请重试或联系工程师 406 MPC.10140 The I-frame interval exceeds 500. 输出i帧间隔超过500,暂不支持 输出i帧间隔超过500,暂不支持,请修改 406 MPC.10141 The input file is an audio file. The selected template contains video parameters. 片源为纯音频文件,选择模板包含视频参数,暂不支持 片源为纯音频文件,选择模板包含视频参数,请检查 406 MPC.10143 Invalid index file content. 输入的索引文件内容非法 输入的索引文件内容非法 406 MPC.10144 Black bars seem to be on the input video. 无法确定片源黑边的具体位置, 片源的四周疑似有黑边, 需要对片源进行人工审核 无法确定片源黑边的具体位置, 片源的四周疑似有黑边, 需要对片源进行人工审核 406 MPC.10145 Data frames imported to the detection module seem to be not enough for identifying the specific position of the black bar. 无法确定片源黑边的具体位置,疑似没有足够的数据帧输入至黑边检测模块,需要对片源进行人工审核 无法确定片源黑边的具体位置, 疑似没有足够的数据帧输入至黑边检测模块,需要对片源进行人工审核 406 MPC.10146 The black bar seems to overlap with subtitles. 无法确定片源黑边的具体位置,疑似片源的下黑边和字幕存在重叠,需要对片源进行人工审核 无法确定片源黑边的具体位置,疑似片源的下黑边和字幕存在重叠,需要对片源进行人工审核 406 MPC.10147 The black bar seems to overlap with the watermark. 无法确定片源黑边的具体位置,疑似片源的上黑边和水印存在重叠,需要对片源进行人工审核 无法确定片源黑边的具体位置,疑似片源的上黑边和水印存在重叠,需要对片源进行人工审核 406 MPC.10148 The black bars seem to be asymmetric. 无法确定片源黑边的具体位置,疑似片源的左右黑边不对称,需要对片源进行人工审核 无法确定片源黑边的具体位置,疑似片源的左右黑边不对称,需要对片源进行人工审核 406 MPC.10149 The specific position of the black bar cannot be identified. 无法确定片源黑边的具体位置, 需要对片源进行人工审核 无法确定片源黑边的具体位置, 需要对片源进行人工审核 406 MPC.10150 The cropped black bar size exceeds the input video size. 强制黑边裁剪值超出原视频大小, 请人工审核 强制黑边裁剪值超出原视频大小, 请人工审核 406 MPC.10151 Failed to download the subtitle file in the slicing phase. 切片阶段下载字幕文件失败 切片阶段下载字幕文件失败,请检查 406 MPC.10152 The video encoding format of the input file is not supported. 片源视频编码格式特殊,暂不不支持 片源视频编码格式特殊,暂不不支持 406 MPC.10153 Input file error. 片源问题,请确认片源是否能完整播放 片源问题,请确认片源是否能完整播放 406 MPC.10154 Failed to open the input file. 输入文件无法打开,请检查输入片源是否能播放 输入文件无法打开,请检查输入片源是否能播放 406 MPC.10200 System error. MPC 服务异常,通用状态码 请联系工程师解决 406 MPC.10201 Internal communication error. 服务内部通信异常 请联系工程师解决 406 MPC.10209 Invalid input or output OBS path. MPC 对象存储源地址或者目的地址不正确 请检查对象存储源地址或者目的地址 406 MPC.10210 Failed to obtain the input file from OBS. MPC 获取对象存储源文件失败 对象存储源文件获取失败,请检查 406 MPC.10213 Operation failed. The task is not in the final state. MPC 操作失败,任务未进入终态 任务未进入终态,请检查 406 MPC.10216 Failed to set event notifications. You do not have the permission to publish messages to the topic. MPC 设置 消息通知 失败,无权限发布消息到主题 设置消息通知失败,无权限发布消息到主题,请检查 406 MPC.10217 The usage exceeds the OBT quota. MPC 公测限额,用量超过阈值 用量超过阈值,请检查 406 MPC.10218 The task has completed. MPC 任务处理成功 任务处理成功,请检查 406 MPC.10219 Invalid request parameter. 请求参数非法 请求参数非法,请检查 406 MPC.10220 The task has expired. MPC 任务已过期 任务已过期,请检查 406 MPC.10221 Internal service error. 内部服务异常 请检查模板并重试 406 MPC.10222 Key parameters in the template are inconsistent. 自定义模板参数错误 对象存储源文件获取错误,请检查 406 MPC.10225 KMS service error. HW_KMS 服务处理异常 请联系工程师解决 406 MPC.10227 You do not have the permission to access the requested resource. 没有权限访问 没有权限访问,请检查 406 MPC.10228 Your account is in arrears. Top up your account. 用户已冻结,请尽快充值 用户已冻结,请尽快充值 406 MPC.10229 You do not have the permission to perform this operation. 无角色权限执行该的操作 无角色权限执行该的操作,请检查 406 MPC.10232 GIF task failed. gif任务失败 gif任务失败,请检查 406 MPC.10233 Packaging task failed. 转封装任务失败 转封装任务失败,请检查 406 MPC.10234 The function is temporarily brought offline. 功能下线 功能下线,请检查 406 MPC.10235 Identity authentication failed due to an invalid token. 请求Token为Domain级别,Token无效 请检查Token是否正确 406 MPC.10236 You do not have permission to access the OBS bucket. 账号桶操作无权限 请联系租户管理员进行桶授权或者租户管理员给子账号赋予OBS权限 406 MPC.10237 API Gateway rate limiting APIGW 流控 服务APIGW流控,请检查 500 MPC.10001 IAM service exception. IAM 服务处理异常 请联系工程师解决 500 MPC.10002 OBS service exception. OBS 服务处理异常 请联系工程师解决 500 MPC.10003 SMN service exception. SMN 服务处理异常 请联系工程师解决 500 MPC.10004 CBC service exception. CBC 服务处理异常 请联系工程师解决 500 MPC.10005 SDR service exception. SDR 服务处理异常 请联系工程师解决 500 MPC.10006 ZK service exception. ZK 服务处理异常 请联系工程师解决 500 MPC.10007 MONGO service exception. MONGO 服务处理异常 请联系工程师解决 500 MPC.10008 MPE service exception. MPE处理错误 请联系工程师解决 500 MPC.10050 XCODE service exception. XCODE 服务处理异常 请联系工程师解决 父主题: 附录
  • 获取AK和SK 注意:访问密钥对账号具有完全的访问权限,如果访问密钥泄露,会带来数据泄露风险,为了账号安全性,建议您定期更换并妥善保存访问密钥。每个账号最多只能创建2个密钥。 登录管理控制台。 鼠标移动至用户名,在下拉列表中单击“我的凭证”。 在左侧导航栏中选择“访问密钥”。 单击“新增访问密钥”,在弹出的页面中输入账号密码及短信验证码。 图1 访问密钥 单击“确定”,即可下载一个命名为“credentials.csv”的文件,其中包含AK和SK。
  • 代码示例 调用前请根据实际情况替换如下变量:"SDK_AK"、"SDK_SK"、{your endpoint string} 以及 {your project id}。 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 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcore.http.http_config import HttpConfig from huaweicloudsdkmpc.v1 import * def list_transcoding_task(client): try: request = ListTranscodingTaskRequest(task_id = [1900293]) response = client.list_transcoding_task(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) if __name__ == "__main__": ak = os.environ["SDK_AK"] sk = os.environ["SDK_SK"] project_id = os.environ["{your project id}"] endpoint = "{your endpoint}" config = HttpConfig.get_default_config() config.ignore_ssl_verification = True credentials = BasicCredentials(ak, sk, project_id) mpc_client = MpcClient.new_builder(MpcClient) \ .with_http_config(config) \ .with_credentials(credentials) \ .with_endpoint(endpoint) \ .build() list_transcoding_task(mpc_client)
  • 安装SDK 媒体转码服务端SDK支持python 3及以上版本。执行“ python --version”检查当前python的版本信息。 使用服务端SDK前,您需要安装“huaweicloudsdkcore ”和“huaweicloudsdkmpc”,具体的SDK版本号请参见SDK开发中心。 使用pip安装 执行如下命令安装Python SDK核心库以及相关服务库: 1 2 3 4 # 安装核心库 pip install huaweicloudsdkcore # 安装MPC服务库 pip install huaweicloudsdkmpc 使用源码安装 执行如下命令安装Python SDK核心库以及相关服务库: 1 2 3 4 5 6 7 # 安装核心库 cd huaweicloudsdkcore-${version} python setup.py install # 安装MPC服务库 cd huaweicloudsdkmpc-${version} python setup.py install
  • 代码示例 - 初始化MpcClient Endpoint调用前请您根据实际情况填写,并替换如下变量:"SDK_AK"、"SDK_SK"、{your endpoint string}和{your project id}。 package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.http.HttpConfig; import com.huaweicloud.sdk.mpc.v1.MpcClient; public class InitMpc { private static HttpConfig httpConfig; private static BasicCredentials auth; private static String endpoint; private static MpcClient mpcClient; public static MpcClient getMpcClient() { httpConfig = HttpConfig.getDefaultHttpConfig().withIgnoreSSLVerification(true).withTimeout(3); //http代理设置,请根据实际情况设置 //httpConfig.withProxyHost("xxxxx").withProxyPort(xxxxx).withProxyUsername("xxxxx"). // withProxyPassword("xxxxx"); String ak = System.getenv("SDK_AK"); String sk = System.getenv("SDK_SK"); String projectId = System.getenv("PROJECT_ID"); endpoint = "https://mpc.region01.myhuaweicloud.com"; auth = new BasicCredentials().withAk(ak).withSk(sk).withProjectId(projectId); mpcClient = MpcClient.newBuilder() .withHttpConfig(httpConfig) .withCredential(auth) .withEndpoint(endpoint) .build(); return mpcClient; } }
  • 代码示例 调用前请根据实际情况替换如下变量:"SDK_AK"、"SDK_SK"、{your endpoint string}以及{your project id}。 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 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/config" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/httphandler" mpc "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mpc/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mpc/v1/model" "net/http" ) func RequestHandler(request http.Request) { fmt.Println(request) } func ResponseHandler(response http.Response) { fmt.Println(response) } ak := os.Getenv("SDK_AK") sk := os.Getenv("SDK_SK") projectId := os.Getenv("{your project id}") func main() { client := mpc.NewMpcClient( mpc.MpcClientBuilder(). WithEndpoint("{your endpoint}"). WithCredential( basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build()). WithHttpConfig(config.DefaultHttpConfig(). WithIgnoreSSLVerification(true). WithHttpHandler(httphandler. NewHttpHandler(). AddRequestHandler(RequestHandler). AddResponseHandler(ResponseHandler))). Build()) request := &model.ListTranscodingTaskRequest{ TaskId:&[]int64{1900293}, } response, err := client.ListTranscodingTask(request) if err == nil { fmt.Println("%+v\n",response) } else { fmt.Println(err) } }
  • 安装SDK 媒体转码Go SDK支持go 1.14及以上版本。执行go version检查当前Go的版本信息。 使用go get安装Go SDK,执行如下命令安装Go SDK库以及相关依赖库,具体的SDK版本号请参见SDK开发中心。 1 2 3 4 # 安装Go库 go get github.com/huaweicloud/huaweicloud-sdk-go-v3 # 安装依赖 go get github.com/json-iterator/go
  • 开始使用 导入依赖模块。 1 2 3 4 5 6 7 8 9 import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/config" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/httphandler" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mpc/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mpc/v1/model" "net/http" ) 配置客户端属性。 默认配置 1 2 # Use default configuration httpConfig := config.DefaultHttpConfig() 代理配置(可选)。 1 2 3 4 5 6 7 8 9 username := os.Getenv("USER_NAME") password := os.Getenv("USER_PASSWARD") // 根据需要配置网络代理 httpConfig.WithProxy(config.NewProxy(). WithSchema("http"). WithHost("proxy.huaweicloud.com"). WithPort(80). WithUsername(username). WithPassword(password)) SSL配置(可选) 1 2 // 根据需要配置是否跳过SSL证书校验 httpConfig.WithIgnoreSSLVerification(true); 初始化认证信息。 支持两种方式认证,您可以根据实际情况进行选择。 使用永久AK/SK 首先需要获取永久AK和SK,以及projectId,您可以参考开发前准备获取。 1 2 3 4 5 6 7 8 ak := os.Getenv("SDK_AK") sk := os.Getenv("SDK_SK") projectId := os.Getenv("PROJECT_ID") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() 使用临时AK/SK 首先需要获得临时AK、SK和SecurityToken,您可以通过token获取或者通过委托授权获取。 1 2 3 4 5 6 7 8 9 10 ak := os.Getenv("SDK_AK") sk := os.Getenv("SDK_SK") projectId := os.Getenv("PROJECT_ID") securityToken := os.Getenv("SECURITY_TOKEN") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). WithSecurityToken(securityToken). Build() 相关参数说明如下所示: ak:账号Access Key。 sk:账号Secret Access Key 。 projectId:云服务所在项目ID ,根据你想操作的项目所属区域选择对应的项目ID。 securityToken:采用临时AK/SK认证场景下的安全票据。 初始化客户端。 1 2 3 4 5 6 7 8 # 初始化MPC的客户端 client := mpc.NewMpcClient ( mpcMpcClientBuilder(). WithEndpoint(endpoint). // endpoint值如 "https://mpc.region01.myhuaweicloud.com" WithCredential(auth). WithHttpConfig(config.DefaultHttpConfig()). Build()) endpoint:MPC应用区域和各服务的终端节点,具体请参见地区和终端节点。 发送请求并查看响应。 1 2 3 4 5 6 7 8 9 10 // 初始化请求,以调用接口查询转码模板为例 request := &model.ListTranscodingTaskRequest{ TaskId:&[]int64{1900293}, } response, err := client.ListTranscodingTask(request) if err == nil { fmt.Printf("%+v\n",response) } else { fmt.Println(err) } 异常处理。 表1 异常处理 一级分类 一级分类说明 ServiceResponseError service response error url.Error connect endpoint error 1 2 3 4 5 6 7 # 异常处理 response, err := client.ListTranscodingTask(request) if err == nil { fmt.Println(response) } else { fmt.Println(err) } 原始Http侦听器。 在某些场景下可能对业务发出的Http请求进行Debug,需要看到原始的Http请求和返回信息,SDK提供侦听器功能来获取原始的为加密的Http请求和返回信息。 原始信息打印仅在debug阶段使用,请不要在生产系统中将原始的Http头和Body信息打印到日志,这些信息并未加密且其中包含敏感数据;当Body体为二进制内容,即Content-Type标识为二进制时 body为"***",详细内容不输出。 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 func RequestHandler(request http.Request) { fmt.Println(request) } func ResponseHandler(response http.Response) { fmt.Println(response) } ak := os.Getenv("SDK_AK") sk := os.Getenv("SDK_SK") projectId := os.Getenv("{your project id}") client := mpc.NewMpcClient( mpc.MpcClientBuilder(). WithEndpoint("{your endpoint}"). WithCredential( basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build()). WithHttpConfig(config.DefaultHttpConfig(). WithIgnoreSSLVerification(true). WithHttpHandler(httphandler. NewHttpHandler(). AddRequestHandler(RequestHandler). AddResponseHandler(ResponseHandler))).Build())
  • 使用限制 单账号跟踪的事件可以通过 云审计 控制台查询。多账号的事件只能在账号自己的事件列表页面去查看,或者到组织追踪器配置的OBS桶中查看,也可以到组织追踪器配置的 CTS /system日志流下面去查看。 用户通过云审计控制台只能查询最近7天的操作记录。如果需要查询超过7天的操作记录,您必须配置转储到 对象存储服务 (OBS)或 云日志 服务(LTS),才可在OBS桶或LTS日志组里面查看历史事件信息。否则,您将无法追溯7天以前的操作记录。 云上操作后,1分钟内可以通过云审计控制台查询管理类事件操作记录,5分钟后才可通过云审计控制台查询数据类事件操作记录。 CTS新版事件列表不显示数据类审计事件,您需要在旧版事件列表查看数据类审计事件。 云审计控制台对用户的操作事件日志保留7天,过期自动删除,不支持人工删除。
  • 操作前提 用户使用MPC服务前,需要参考本节完成如下操作。 实名认证:个人用户或者企业用户,均需完成实名认证,操作请参考实名认证。 首次开通风险提示:首次购买MPC服务,会进入如图1所示的页面,用户需查看各个计费项的计费详情,并仔细阅读下方的《华为云媒体处理服务协议》后,再开通使用MPC服务。 图1 开通媒体处理服务 账户余额:MPC服务默认按需计费,产生的服务费用将直接从您的账户余额中扣除。建议您及时关注账户余额和状态,保证账户可用且余额充足。
  • SDK集成示例 转封装功能的详细说明和示例代码,请参考创建转封装任务。 教育网站开发人员支持接入MPC的SDK核心代码,如下所示: ObsObjInfo input = new ObsObjInfo().withBucket("mpc-east-2").withLocation("region01").withObject("ok.flv"); ObsObjInfo output = new ObsObjInfo().withBucket("mpc-east-2").withLocation("region01").withObject("output"); //创建转封装请求 CreateRemuxTaskRequest req = new CreateRemuxTaskRequest() .withBody(new CreateRemuxTaskReq().withInput(input).withOutput(output) // 设置转封装参数 .withOutputParam(new RemuxOutputParam() //设置转封装格式 .withFormat("HLS") //转成hls切片间隔 .withSegmentDuration(5))); //发送转封装请求 CreateRemuxTaskResponse rsp = initMpcClient().createRemuxTask(req); System.out.println(rsp.toString())
提示

您即将访问非华为云网站,请注意账号财产安全