如何使用Azure Media Services生成精灵缩略图



我将切换到基本,我有以下TransformOutput,它对视频(SD/HD(进行编码,还创建缩略图。

TransformOutput[] outputs = new TransformOutput[]
{
// Create a new TransformOutput with a custom Standard Encoder Preset
// This demonstrates how to create custom codec and layer output settings
new TransformOutput(
new StandardEncoderPreset(
codecs: new Codec[]
{
// Add an AAC Audio layer for the audio encoding
new AacAudio(
channels: 2,
samplingRate: 48000,
bitrate: 128000,
profile: AacAudioProfile.AacLc
),
// Next, add a H264Video for the video encoding
new H264Video (
// Set the GOP interval to 2 seconds for both H264Layers
keyFrameInterval:TimeSpan.FromSeconds(2),
// Add H264Layers, one at HD and the other at SD. Assign a label that you can use for the output filename
layers:  new H264Layer[]
{
new H264Layer (
bitrate: 1000000, // Units are in bits per second
width: "1280",
height: "720",
label: "HD" // This label is used to modify the file name in the output formats
),
new H264Layer (
bitrate: 600000,
width: "640",
height: "360",
label: "SD"
)
}
),
// Also generate a set of PNG thumbnails
new PngImage(
start: "25%",
step: "25%",
range: "80%",
layers: new PngLayer[]{
new PngLayer(
width: "50%",
height: "50%"
)
}
)
},
// Specify the format for the output files - one for video+audio, and another for the thumbnails
formats: new Format[]
{
// Mux the H.264 video and AAC audio into MP4 files, using basename, label, bitrate and extension macros
// Note that since you have multiple H264Layers defined above, you have to use a macro that produces unique names per H264Layer
// Either {Label} or {Bitrate} should suffice
new Mp4Format(
filenamePattern:"Video-{Basename}-{Label}-{Bitrate}{Extension}"
),
new PngFormat(
filenamePattern:"Thumbnail-{Index}{Extension}"
)
}
),
onError: OnErrorType.StopProcessingJob,
relativePriority: Priority.Normal
)
};

这工作得很完美,没有问题,但我如何使它也为视频生成精灵缩略图,在查找时,我发现了这个https://learn.microsoft.com/en-us/azure/media-services/previous/generate-thumbnail-sprite根据这一点,以下内容应用于生成媒体服务2.0 的子画面

{
"Version": 1.0,
"Codecs": [
{
"Start": "00:00:01",
"Type": "JpgImage",
"Step": "5%",
"Range": "100%",
"JpgLayers": [
{
"Type": "JpgLayer",
"Width": "10%",
"Height": "10%",
"Quality": 90
}
],
"SpriteColumn": 10
}
],
"Outputs": [
{
"FileName": "{Basename}_{Index}{Extension}",
"Format": {
"Type": "JpgFormat"
}
}
]
}

我正试图在我的代码中转换它(到媒体服务3.0(,但似乎没有运气,看起来没有spriteColumn可用的

,new JpgImage(
start: "00:00:01",
step: "5%",
range: "100%",
layers: new JpgLayer[]{
new JpgLayer(
width: "10%",
height: "10%",
quality: 90
)
},
spriteColumn: 10 //<<<THIS
)
}, 

有没有办法在媒体服务中生成精灵?

是的,Thumbnail Sprite编码现在可以使用v3了。文档将很快更新。您需要更新Microsoft。蔚蓝色的经营媒体金块包至3.0.2或更高版本。

我添加了一个示例应用程序:https://github.com/Azure-Samples/media-services-v3-dotnet/tree/master/VideoEncoding/EncodingWithMESCustomPresetAndSprite

预设在那里:https://github.com/Azure-Samples/media-services-v3-dotnet/blob/master/VideoEncoding/EncodingWithMESCustomPresetAndSprite/Program.cs#L261-L287

最新更新