音视频处理MCT

    模板接口Preset-API

    创建模板

    接口描述

    当系统预设的Preset无法满足需求时,用户可以通过此接口创建自定义的Preset。

    请求(Request)

    • 请求语法:

      POST /v{version}/preset HTTP/1.1
      accept-encoding: gzip, deflate
      x-bce-date: {utc-date-string}
      connection: keep-alive
      accept: */*
      host: media.bj.baidubce.com
      x-bce-request-id: {bce-request-id}
      content-type: application/json
      authorization: {bce-authorization-string}
    • 请求头域:无特殊Header参数
    • 请求参数(以下均为Requestbody参数):
    字段名称 字段类型 必要性 字段描述 可选值 默认值
    presetName String 必选 模板模板名称 - -
    description String 可选 转码模板描述; - -
    container String 必选 音视频文件的容器 mp4, flv, hls, mp3, m4a, a-hls, pcm, dash -
    transmux Bool 可选 是否仅执行容器格式转换 true, false false
    clip Object 可选 是否截取音视频片段 - -
    + startTimeInSecond Number 可选 视频片段的起始时间 - -
    + durationInSecond Number 可选 视频片段的持续时间 - -
    audio Object 可选 音频输出信息的集合,不设置audio相关参数则转码输出不包含音频流,如果保留音频流则必须设置此对象 - -
    + bitRateInBps Number 可选 音频目标码率(输出为pcm格式时不可选,设置静音mute时可不填,否则必选) 大于0 -
    + sampleRateInHz Number 可选 音频采样率; 22050, 32000, 44100, 48000, 96000 不填写,表示与输入保持一致
    + channels Number 可选 音频声道数目 1, 2 不填写,表示与输入一致
    + pcmFormat String 可选 PCM音频格式,仅当container=pcm时有效 s16le -
    + volumeAdjust Object 可选 音量相关参数设置 - -
    ++ mute Bool 可选 是否进行静音操作,当设置了mute时,Job中不允许有audio类型的insert。mute和其它audio参数同时设置时,优先进行静音(mute)操作 true, false false
    ++ norm Bool 可选 是否进行音频归一化操作 true, false false
    ++ gain Number 可选 音量调节的大小,单位db,值为正则增大音量 -60 ~ 60 -
    video Object 可选 视频输出信息的集合,不设置vedio相关参数则转码输出不包含视频流,如果保留视频流则必须设置此对象 - -
    + codec String 可选 视频编码信息集合 h264,h265(h265只支持 main profile), h265_bd265 h264
    + codecOptions Object 可选 视频编码的配置选项 - -
    ++ profile String 可选 档次 baseline, main, high baseline
    + bitRateInBps Number 必选 视频目标码率 - -
    + crf Number 可选 恒定质量因子,若设置了crf值,bitRateInBps可表示最大目标码率 1 ~ 51 -
    + maxFrameRate Number 可选 目标视频最大帧率 10,15, 23.97, 24, 25, 29.97, 30, 50, 60 -
    + maxWidthInPixel Number 可选 目标视频的最大宽度 128 ~ 4096 不填写,表示与原始视频保持一致
    + maxHeightInPixel Number 可选 目标视频的最大高度 96 ~ 3072 不填写,表示与原始视频保持一致
    + sizingPolicy String 可选 尺寸伸缩策略 keep、shrinkToFit、stretch、shrinkToFitBlur,keep表示保持原始视频宽高比,shrinkToFit表示保持原始视频宽高比并加黑边,stretch表示拉伸原始视频,shrinkToFitBlur同shrinkToFit除了黑边替换为高斯模糊 keep
    + autoAdjustResolution Bool 可选 当原视频为竖形时,自动调整模版的宽小于高,保证缩放比最小,反之亦然(仅当sizingPolicy为keep时可以设置) true,false false
    + playbackSpeed Number 可选 回放速度,值低于1.0时为减速视频,高于1.0时为加速视频(不可同时指定音频设置) 0.05 ~ 20.0 -
    encryption Object 可选 HLS加解密信息的集合 - -
    + strategy String 必选 视频加密策略 Fixed: 表示固定密钥加密,使用用户指定的密钥对视频进行加密,此时需要aesKey;
    Open:开放密钥,系统自动生成加密密钥,密钥公开,不设访问控制;
    PlayerBinding:绑定播放器,系统自动生成加密密钥,密钥设有访问控制;
    PlayerBinding模式下密钥设有访问控制,安全性比较高,推荐使用PlayerBinding模式。
    -
    + aesKey String 必选 AES128加密密钥 - -
    watermarkId String 可选 水印id(当transmux=true时不允许添加水印) - -
    watermarks Object 可选 多水印设置,不可同时指定watermarkId和watermarks - -
    + image Array 必选 多水印watermarkId数组 size最大为5 -
    transCfg Object 可选 转码配置信息 - -
    + transMode String 必选 转码模式 normal, twopass。当转码模式为twopass时,video不能为空。 -
    extraCfg Object 可选 转码额外配置
    + watermarkDisableWhitelist String 可选 设置不加水印的条件 当前可设置 portrait,表示竖屏视频不加水印 -
    + segmentDurationInSecond Number 可选 设置分片时长(仅当container为hls,a-hls,dash时可以设置) 取值范围 3.0 ~ 15.0,浮点数精度为小数点后三位以内 -
    + gopLength Number 可选 设置gop长度(仅当配置了video参数时可以设置;当segmentDurationInSecond和gopLength参数共存时,建议保证 segmentDurationInSecond*原视频帧率 为gopLength的整数倍) [0, 250],其中0表示结果视频只包含i帧 -
    + skipBlackFrame Bool 可选 智能检测并裁剪片头黑帧,最长截取前5s黑帧 true,false false
    • 请求示例:

      POST /v3/preset HTTP/1.1
      accept-encoding: gzip, deflate
      x-bce-date: 2015-03-24T13:08:44Z
      host: media.bj.baidubce.com
      accept: */*
      connection: keep-alive
      x-bce-request-id: 3807ce30-5264-45f2-9b52-26b78e24a750
      content-type: application/json
      authorization: bce-auth-v1/46bd9968a6194b4bbdf0341f2286ccce/2015-03-24T13:08:44Z/1800/host;x-bce-date/7e21c9cf1e4e2cc6921a407a388fe98df122c53b9f509043d841be76eb09a1f9
      
      {
          "presetName": "customlized_preset",
          "description": "A example preset description",
          "container": "mp4",
          "clip": {
              "startTimeInSecond": 0,
              "durationInSecond": 60
          },
          "audio": {
              "bitRateInBps": 256000
          },
          "video": {
              "codec": "h264",
              "codecOptions": {
                  "profile": "baseline"
              },
              "bitRateInBps": 1024000,
              "maxFrameRate": 30,
              "maxWidthInPixel": 4096,
              "maxHeightInPixel": 3072,
              "sizingPolicy": "keep",
              "playbackSpeed": 1.5
          },
          "watermarkId": "wmk-fekn2ydgq2fe9f1x"
      }

    响应(Response)

    • 响应头域:无特殊Header参数
    • 响应参数:无
    • 响应示例:

      HTTP/1.1 200 OK
      Transfer-Encoding: chunked
      x-bce-request-id: 3807ce30-5264-45f2-9b52-26b78e24a750
      Cache-Control: no-cache
      Server: BWS
      Date: Tue, 24 Mar 2015 13:37:10 GMT
      Content-Type: application/json;charset=UTF-8

    查询指定模板

    接口描述

    通过presetName查询指定的模板信息。

    请求(Request)

    • 请求语法:

      GET /v{version}/preset/{presetId} HTTP/1.1
      accept-encoding: gzip, deflate
      x-bce-date: {utc-date-string}
      host: media.bj.baidubce.com
      accept: */*
      connection: keep-alive
      x-bce-request-id: {bce-request-id}
      content-type: application/json
      authorization: {bce-authorization-string}
    • 请求头域:无特殊Header参数
    • 请求参数:无
    • 请求示例:

      GET /v3/preset/bce.video_mp4_1920x1080_3660kbps HTTP/1.1
      accept-encoding: gzip, deflate
      x-bce-date: 2015-03-24T13:37:10Z
      host: media.bj.baidubce.com
      accept: */*
      connection: keep-alive
      x-bce-request-id: 3807ce30-5264-45f2-9b52-26b78e24a750
      content-type: application/json
      authorization: bce-auth-v1/46bd9968a6194b4bbdf0341f2286ccce/2015-03-24T13:37:10Z/1800/host;x-bce-date/3e1bf9f50ae1fca2d704d61567810dde946fff3ca2e455676455a6f5c8cce596

    响应(Response)

    • 响应头域:无特殊Header参数
    • 响应参数:与[创建模板/请求/请求参数]保持一致,增加以下字段
    字段名称 字段类型 字段描述
    state String 模板状态,ACTIVE/INACTIVE
    createdTime String 模板创建的UTC格式的时间
    • 响应示例:

      HTTP/1.1 200 OK
      Transfer-Encoding: chunked
      x-bce-request-id: 3807ce30-5264-45f2-9b52-26b78e24a750
      Cache-Control: no-cache
      Server: BWS
      Date: Tue, 24 Mar 2015 13:37:10 GMT
      Content-Type: application/json;charset=UTF-8
      
      {
          "state": "ACTIVE",
          "createdTime": "2015-03-24T13:34:07Z",
          "presetName": "bce.video_mp4_1920x1080_3660kbps",
          "description": "A example preset description",
          "container": "mp4",
          "clip": {
              "startTimeInSecond": 0,
              "durationInSecond": 60
          },
          "audio": {
              "bitRateInBps": 256000,
              "channels": "auto"
          },
          "video": {
              "codec": "h264",
          "codecOptions": {
                  "profile": "baseline"
          },
          "bitRateInBps": 3660000,
          "maxFrameRate": 15,
          "maxWidth": 1920,
          "maxHeight": 1080,
          "sizingPolicy": "keep",
          "playbackSpeed": 1.5
          },
          "watermarkId": "wmk-fekn2ydgq2fe9f1x"
      }

    查询当前用户模板及所有系统模板

    接口描述

    用户查询其名下及系统提供的所有的模板,具体有哪些系统模板可以参考系统内置模板

    请求(Request)

    • 请求语法:

      GET /v{version}/preset HTTP/1.1
      accept-encoding: gzip, deflate
      x-bce-date: {utc-date-string}
      connection: keep-alive
      accept: */*
      host: media.bj.baidubce.com
      x-bce-request-id: {bce-request-id}
      content-type: application/json
      authorization: {bce-authorization-string}
    • 请求头域:无特殊Header参数
    • 请求参数:无
    • 请求示例:

      GET /v3/preset HTTP/1.1
      accept-encoding: gzip, deflate
      x-bce-date: 2015-03-24T13:37:10Z
      host: media.bj.baidubce.com
      accept: */*
      connection: keep-alive
      x-bce-request-id: 3807ce30-5264-45f2-9b52-26b78e24a750
      content-type: application/json
      authorization: bce-auth-v1/46bd9968a6194b4bbdf0341f2286ccce/2015-03-24T13:37:10Z/1800/host;x-bce-date/3e1bf9f50ae1fca2d704d61567810dde946fff3ca2e455676455a6f5c8cce596

    响应(Response)

    • 响应头域:无特殊Header参数
    • 响应参数:与[创建模板/请求/请求参数]保持一致,增加以下字段
    字段名称 字段类型 字段描述
    state String 模板状态,ACTIVE/INACTIVE
    createdTime String 模板创建的UTC格式的时间
    • 响应示例:

      HTTP/1.1 200 OK
      Transfer-Encoding: chunked
      x-bce-request-id: 3807ce30-5264-45f2-9b52-26b78e24a750
      Cache-Control: no-cache
      Server: BWS
      Date: Tue, 24 Mar 2015 13:37:10 GMT
      Content-Type: application/json;charset=UTF-8
      
      {
        "presets": [
          {
            "presetName": "bce.audio_hls_128kbps",
            "description": "hls audio,128kbps",
            "container": "hls",
            "transmux": false,
            "clip": {
              "startTimeInSecond": 0
            },
            "audio": {
              "sampleRateInHz": 44100,
              "channels": 2
            },
            "createTime": "2015-04-07T12:01:08Z"
          },
          {
            "presetName": "bce.audio_hls_160kbps",
            "description": "hls audio,160kbps",
            "container": "hls",
            "transmux": false,
            "clip": {
              "startTimeInSecond": 0
            },
            "audio": {
              "sampleRateInHz": 44100,
              "channels": 2
            },
            "createTime": "2015-04-07T12:01:08Z"
          },
          {
            "presetName": "bce.audio_hls_64kbps",
            "description": "hls audio,64kbps",
            "container": "hls",
            "transmux": false,
            "clip": {
              "startTimeInSecond": 0
            },
            "audio": {
              "sampleRateInHz": 22050,
              "channels": 2
            },
            "createTime": "2015-04-07T12:01:08Z"
          },
          {
            "presetName": "bce.audio_mp3_128kbps",
            "description": "mp3 audio,128kbps",
            "container": "mp3",
            "transmux": false,
            "clip": {
              "startTimeInSecond": 0
            },
            "audio": {
              "sampleRateInHz": 44100,
              "channels": 2
            },
            "createTime": "2015-04-07T12:01:09Z"
          },
          {
            "presetName": "bce.audio_mp3_160kbps",
            "description": "mp3 audio,160kbps",
            "container": "mp3",
            "transmux": false,
            "clip": {
              "startTimeInSecond": 0
            },
            "audio": {
              "sampleRateInHz": 44100,
              "channels": 2
            },
            "createTime": "2015-04-07T12:01:09Z"
          },
          {
            "presetName": "bce.audio_mp3_192kbps",
            "description": "mp3 audio,192kbps",
            "container": "mp3",
            "transmux": false,
            "clip": {
              "startTimeInSecond": 0
            },
            "audio": {
              "sampleRateInHz": 44100,
              "channels": 2
            },
            "createTime": "2015-04-07T12:01:09Z"
          },
          {
            "presetName": "bce.audio_mp3_320kbps",
            "description": "mp3 audio,320kbps",
            "container": "mp3",
            "transmux": false,
            "clip": {
              "startTimeInSecond": 0
            },
            "audio": {
              "sampleRateInHz": 44100,
              "channels": 2
            },
            "createTime": "2015-04-07T12:01:08Z"
          },
          {
            "presetName": "bce.audio_mp3_64kbps",
            "description": "mp3 audio,64kbps",
            "container": "mp3",
            "transmux": false,
            "clip": {
              "startTimeInSecond": 0
            },
            "audio": {
              "sampleRateInHz": 22050,
              "channels": 2
            },
            "createTime": "2015-04-07T12:01:09Z"
          }
        ]
      }

    删除指定模板

    接口描述

    用于删除用户指定presetName的用户模板

    请求(Request)

    • 请求语法:

      DELETE /v{version}/preset/{presetName} HTTP/1.1
      accept-encoding: gzip, deflate
      x-bce-date: {utc-date-string}
      connection: keep-alive
      accept: */*
      host: media.bj.baidubce.com
      x-bce-request-id: {bce-request-id}
      content-type: application/json
      authorization: {bce-authorization-string}
    • 请求头域:无特殊Header参数
    • 请求参数:无
    • 请求示例:

      DELETE /v3/preset/user-video-mp4-1080p-3660kbps HTTP/1.1
      accept-encoding: gzip, deflate
      x-bce-date: 2015-03-24T13:06:02Z
      connection: keep-alive
      accept: */*
      host: media.bj.baidubce.com
      x-bce-request-id: 6d0b0a36-2ffe-49d4-9d81-333a9ab9417e
      content-type: application/json
      authorization: bce-auth-v1/46bd9968a6194b4bbdf0341f2286ccce/2015-03-24T13:06:02Z/1800/host;x-bce-date/02f64774999996903cffa5ae4d6eef436127a96f581a4e8467497e239d824be8

    响应(Response)

    • 响应头域:无特殊Header参数
    • 响应参数:无
    • 响应示例:

      HTTP/1.1 200 OK
      x-bce-request-id: 6d0b0a36-2ffe-49d4-9d81-333a9ab9417e
      Cache-Control: no-cache

    更新指定模板

    接口描述

    用户可以通过此接口更新指定Preset。

    请求(Request)

    • 请求语法:

      PUT /v{version}/preset/{presetName} HTTP/1.1
      accept-encoding: gzip, deflate
      x-bce-date: {utc-date-string}
      connection: keep-alive
      accept: */*
      host: media.bj.baidubce.com
      x-bce-request-id: {bce-request-id}
      content-type: application/json
      authorization: {bce-authorization-string}
    • 请求头域:无特殊Header参数
    • 请求参数:同创建模板请求
    • 请求示例:

      PUT /v3/preset/customlized_preset HTTP/1.1
      accept-encoding: gzip, deflate
      x-bce-date: 2020-02-14T15:12:37Z
      host: media.bj.baidubce.com
      accept: */*
      connection: keep-alive
      x-bce-request-id: 0969b91e-1890-470b-b93b-97939f672e54
      content-type: application/json
      authorization: bce-auth-v1/46bd9968a6194b4bbdf0341f2286ccce/2020-02-14T15:12:37Z/1800/host;x-bce-date/7e21c9cf1e4e2cc6921a407a388fe98df122c53b9f509043d841be76eb09a1f9
      
      {
          "presetName": "customlized_preset",
          "description": "A example preset description",
          "container": "mp4",
          "clip": {
              "startTimeInSecond": 0,
              "durationInSecond": 60
          },
          "audio": {
              "bitRateInBps": 256000
          },
          "video": {
              "codec": "h264",
              "codecOptions": {
                  "profile": "baseline"
              },
              "bitRateInBps": 1024000,
              "maxFrameRate": 30,
              "maxWidthInPixel": 4096,
              "maxHeightInPixel": 3072,
              "sizingPolicy": "keep",
              "playbackSpeed": 1.5
          },
          "watermarkId": "wmk-fekn2ydgq2fe9f1x"
      }

    响应(Response)

    • 响应头域:无特殊Header参数
    • 响应参数:无
    • 响应示例:

      HTTP/1.1 200 OK
      Transfer-Encoding: chunked
      x-bce-request-id: 0969b91e-1890-470b-b93b-97939f672e54
      Cache-Control: no-cache
      Server: BWS
      Date: Fri, 14 Feb 2020 07:12:37 GMT
      Content-Type: application/json;charset=UTF-8
    上一篇
    视频转码任务接口Job-Transcoding-API
    下一篇
    媒体信息接口MediaInfo-API