如何通过 REST 使用 Media Encoder Standard trim 视频 API

How to trim a video using Media Encoder Standard via REST API

asked this question on the MSDN forums,但一如既往 - 没有必要等待那里的回复。

我现在想做的是让用户能够使用 Media Encoder Standard 编码器和自定义预设 trim 开始和结束他们的视频。然而,因为它没有在任何地方记录(尽管是“推荐的”编码器),我无法让它工作。这是我添加到标准编码预设 JSON 对象的内容:

customPreset.Sources = [
  {
    'Clips': [
       {
         'StartTime': '00:00:10', //sample values
         'EndTime': '00:02:03'
       }
    ]
  }
];

预设的其余部分是经过稍微修改的自适应比特率预设,经测试可以正常工作:

"Codecs": [
{
  "KeyFrameInterval": "00:00:02",
  "H264Layers": [
    {
      "Profile": "Auto",
      "Level": "auto",
      "Bitrate": 5500,
      "MaxBitrate": 6000,
      "BufferWindow": "00:00:05",
      "Width": 1920,
      "Height": 1080,
      "BFrames": 3,
      "ReferenceFrames": 3,
      "AdaptiveBFrame": true,
      "Type": "H264Layer",
      "FrameRate": "0/1"
    },
    ...//and so on, then image layers for thumbnails and audio profile

然而,当我开始编码工作时将此 Sources 属性 添加到预设中,生成的资产不是 [​​=27=]med。所以我假设我做错了人?由于微软似乎不想记录这个编码器(至少现在是这样),有没有做过类似事情的人可以告诉我如何修改预设以启用此任务?

我很可能需要进行更高级的编辑,例如子剪辑、拼接和稍后添加自定义音轨,因此了解编码预设中的所有内容(以及此 MES 的内容)会很有帮助居然支持)。

我刚刚尝试了以下预设并成功地按需修剪了我的视频。 Sources 元素在最后定义。

{
  "Version": 1.0,
  "Codecs": [
    {
      "KeyFrameInterval": "00:00:02",
      "StretchMode": "AutoSize",
      "H264Layers": [
        {
          "Profile": "Auto",
          "Level": "auto",
          "Bitrate": 3400,
          "MaxBitrate": 3400,
          "BufferWindow": "00:00:05",
          "Width": 1280,
          "Height": 720,
          "BFrames": 3,
          "ReferenceFrames": 3,
          "AdaptiveBFrame": true,
          "Type": "H264Layer",
          "FrameRate": "0/1"
        },
        {
          "Profile": "Auto",
          "Level": "auto",
          "Bitrate": 2250,
          "MaxBitrate": 2250,
          "BufferWindow": "00:00:05",
          "Width": 960,
          "Height": 540,
          "BFrames": 3,
          "ReferenceFrames": 3,
          "AdaptiveBFrame": true,
          "Type": "H264Layer",
          "FrameRate": "0/1"
        },
        {
          "Profile": "Auto",
          "Level": "auto",
          "Bitrate": 1500,
          "MaxBitrate": 1500,
          "BufferWindow": "00:00:05",
          "Width": 960,
          "Height": 540,
          "BFrames": 3,
          "ReferenceFrames": 3,
          "AdaptiveBFrame": true,
          "Type": "H264Layer",
          "FrameRate": "0/1"
        },
        {
          "Profile": "Auto",
          "Level": "auto",
          "Bitrate": 1000,
          "MaxBitrate": 1000,
          "BufferWindow": "00:00:05",
          "Width": 640,
          "Height": 360,
          "BFrames": 3,
          "ReferenceFrames": 3,
          "AdaptiveBFrame": true,
          "Type": "H264Layer",
          "FrameRate": "0/1"
        },
        {
          "Profile": "Auto",
          "Level": "auto",
          "Bitrate": 650,
          "MaxBitrate": 650,
          "BufferWindow": "00:00:05",
          "Width": 640,
          "Height": 360,
          "BFrames": 3,
          "ReferenceFrames": 3,
          "AdaptiveBFrame": true,
          "Type": "H264Layer",
          "FrameRate": "0/1"
        },
        {
          "Profile": "Auto",
          "Level": "auto",
          "Bitrate": 400,
          "MaxBitrate": 400,
          "BufferWindow": "00:00:05",
          "Width": 320,
          "Height": 180,
          "BFrames": 3,
          "ReferenceFrames": 3,
          "AdaptiveBFrame": true,
          "Type": "H264Layer",
          "FrameRate": "0/1"
        }
      ],
      "Type": "H264Video"
    },
    {
      "Profile": "AACLC",
      "Channels": 2,
      "SamplingRate": 48000,
      "Bitrate": 128,
      "Type": "AACAudio"
    }
  ],
  "Outputs": [
    {
      "FileName": "{Basename}_{Width}x{Height}_{VideoBitrate}.mp4",
      "Format": {
        "Type": "MP4Format"
      }
    }
  ],
  "Sources": [
    {
      "StartTime": "00:00:04",
      "Duration": "00:00:16"
    }
  ]
}