jpatel
jpatel

Reputation: 135

azure media service video trim without encoder

I am using azure media service to store my assets like video. Now i want to trim video to first one minute. suppose video is 5 minute then i want to trim it to first 1 minute. I tried with following code

{  
  "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"  
      }  
    }  
  ]  
}  

My question is , is there any way to trim video without specifying video codecs because i just want to trim video don't want to encode. like using this code

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

Upvotes: 1

Views: 232

Answers (1)

Anil Murching
Anil Murching

Reputation: 595

I presume you want an output MP4 for downloading/delivering offline.

If the following conditions are satisfied:

  1. Source is an MP4 file, or it uses video/audio codecs that are compatible with the MP4 file format (eg. H.264 video, AAC audio), and
  2. The source is encoded with closed GOPs

Then, you should be able to use the following preset JSON, that tells the encoder to copy the input video and audio:

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

Upvotes: 1

Related Questions