无编码器的天蓝色媒体服务视频剪辑

时间:2018-01-23 11:46:31

标签: azure azure-media-services

我正在使用azure media service存储我的资源,例如视频。现在我想trim视频到头一分钟。假设视频为5 minute,那么我想将其修剪为first 1 minute。我尝试使用以下代码

{  
  "Version": 1.0, 
  "Sources": [
    {
      "StartTime": "00:00:04",
      "Duration": "00:00:16"
    }
  ],  
  "Codecs": [  
    {  
      "KeyFrameInterval": "00:00:02",  
      "SceneChangeDetection": true,  
      "H264Layers": [  
        {  
          "Profile": "Auto",  
          "Level": "auto",  
          "Bitrate": 4500,  
          "MaxBitrate": 4500,  
          "BufferWindow": "00:00:05",  
          "Width": 1280,  
          "Height": 720,  
          "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"  
      }  
    }  
  ]  
}  

我的问题是,有没有办法在不指定视频codecs的情况下修剪视频,因为我只是想修剪视频而不想编码。比如使用这段代码

{
  "Version": "1.0",
  "Sources": [
    {
      "StartTime": "00:00:00",
      "Duration": "00:01:00"
    }
  ],
  "Outputs": [
    {
      "FileName": "$filename$.mp4",
      "Format": {
        "Type": "MP4Format"
      }
    }
  ]
}

1 个答案:

答案 0 :(得分:1)

我认为你想要一个输出MP4来下载/交付离线。

如果满足以下条件:

  1. Source是MP4文件,或者它使用与MP4文件格式兼容的视频/音频编解码器(例如H.264视频,AAC音频)和
  2. 源使用封闭的GOP进行编码
  3. 然后,您应该能够使用以下预设JSON,告诉编码器复制输入视频和音频:

    {
      "Version": "1.0",
      "Sources": [
        {
          "StartTime": "00:00:00",
          "Duration": "00:01:00"
        }
      ],
      "Outputs": [
        {
          "FileName": "$filename$.mp4",
          "Format": {
            "Type": "MP4Format"
          }
        }
      ],
      "Codecs": [
        {
          "Type": "CopyVideo"
        },
        {
          "Type": "CopyAudio"
        }
      ]
    }