如何通过REST API使用Media Encoder Standard修剪视频 [英] How to trim a video using Media Encoder Standard via REST API
问题描述
我在MSDN论坛上提出这个问题,但一如以往,没有任何意义等待来自那里的回复。
我现在要做的是让用户使用媒体编码器标准编码器和自定义预设来修剪视频的开始和结束。但是,由于没有记录任何地方(尽管是推荐编码器),我无法让它工作。这是我添加到标准编码预设的JSON对象中:
customPreset.Sources = [
{
'Clips':[
{
'StartTime':'00:00:10',//样本值
'EndTime':'00:02:03'
}
]
}
];
其余的预设是稍微修改的自适应比特率预设,已经测试正常工作: / p>
编解码器:[
{
KeyFrameInterval:00:00:02,
H264Layers:[
{
个人资料:自动,
级别:汽车,
比特率:5500,
MaxBitrate:6000,
BufferWindow:00:00:05,
宽度:1920,
高度:1080,
BFrames :3,
ReferenceFrames:3,
AdaptiveBFrame:true,
Type:H264Layer,
FrameRate:0/1
},
... //等等,然后缩略图和音频配置文件的图像层
但是,当我启动一个编码作业时,这个 Sources
属性被添加到预设中,生成的资产不会被修剪。所以我假设我在做错人物?由于Microsoft似乎并不想要记录这个编码器(至少现在),有没有人做过这样的事情,可以告诉我如何修改预设以启用这个任务?
我很可能需要进行更多的高级编辑,比如子剪辑,拼接和添加自定义音轨,以便知道编码预设中的所有内容(以及这些MES实际上支持)。
我刚刚尝试了以下预设,并成功修剪了我的视频。 Source元素在末尾定义。
I asked this question on the MSDN forums, but as always - there's no point in waiting on a reply from there.
What I am trying to do for now is to enable users to trim the start and end of their videos using the Media Encoder Standard encoder and a custom preset. However because it is not documented anywhere (despite being the "recommended" encoder), I can't get it to work. Here is what I add to the standard encoding preset JSON object:
customPreset.Sources = [
{
'Clips': [
{
'StartTime': '00:00:10', //sample values
'EndTime': '00:02:03'
}
]
}
];
The rest of the preset is a slightly modified adaptive bitrate preset, that's been tested to work fine:
"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
However when I start an encoding job with this Sources
property being added to the preset, the resulting asset is not trimmed. So I am assuming I am doing someone wrong? Since Microsoft don't seem to want to document this encoder(at least for now), is there anyone who's done something like this who can tell me how to modify the preset to enable this task?
I will most likely need to do more advanced editing, like sub-clipping, stitching and adding custom audio tracks later on so it would be helpful to know where all that goes in the encoding preset(and what of this MES actually supports).
I just tried the following preset and successfully trimmed my video on demand. The Sources element is defined at the end.
{
"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"
}
]
}
这篇关于如何通过REST API使用Media Encoder Standard修剪视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!