使用媒体服务编码时对视频进行子剪辑 - RESTSubclip a video when encoding with Media Services - REST

在使用作业对视频进行编码时,可以对其进行剪裁或子剪辑。You can trim or subclip a video when encoding it using a Job. 此功能适用于使用 BuiltInStandardEncoderPreset 预设或 StandardEncoderPreset 预设生成的任何转换This functionality works with any Transform that is built using either the BuiltInStandardEncoderPreset presets, or the StandardEncoderPreset presets.

本主题中的 REST 示例创建了一个作业,该作业会在提交编码作业时剪裁视频。The REST example in this topic creates a job that trims a video as it submits an encoding job.

必备条件Prerequisites

若要完成本主题中所述的步骤,必须:To complete the steps described in this topic, you have to:

创建子剪辑作业Create a subclipping job

  1. 在下载的 Postman 集合中,选择“转换和作业” -> “使用子剪辑创建作业” 。In the Postman collection that you downloaded, select Transforms and jobs -> Create Job with Sub Clipping.

    PUT 请求如下所示:The PUT request looks like this:

    https://management.chinacloudapi.cn/subscriptions/:subscriptionId/resourceGroups/:resourceGroupName/providers/Microsoft.Media/mediaServices/:accountName/transforms/:transformName/jobs/:jobName?api-version={{api-version}}
    
  2. 使用你的转换名称更新“transformName”环境变量的值。Update the value of "transformName" environment variable with your transform name.

  3. 选择“正文” 选项卡,并使用输出资产名称更新“myOutputAsset”。Select the Body tab and update the "myOutputAsset" with your output Asset name.

    {
      "properties": {
        "description": "A Job with transform cb9599fb-03b3-40eb-a2ff-7ea909f53735 and single clip.",
    
        "input": {
          "@odata.type": "#Microsoft.Media.JobInputHttp",
          "baseUri": "https://nimbuscdn-nimbuspm.streaming.mediaservices.windows.net/2b533311-b215-4409-80af-529c3e853622/",
          "files": [
                "Ignite-short.mp4"
            ],
          "start": {
            "@odata.type": "#Microsoft.Media.AbsoluteClipTime",
            "time": "PT10S"
          },
          "end": {
            "@odata.type": "#Microsoft.Media.AbsoluteClipTime",
            "time": "PT40S"
          }
        },
    
        "outputs": [
          {
            "@odata.type": "#Microsoft.Media.JobOutputAsset",
            "assetName": "myOutputAsset"
          }
        ],
        "priority": "Normal"
      }
    }
    
  4. 按“发送”。 Press Send.

    你会看到响应,其中包含有关已创建和提交的作业以及作业状态的信息。You see the Response with the info about the job that was created and submitted and the job's status.

后续步骤Next steps

如何对自定义转换进行编码How to encode with a custom transform