如何使用 Azure 媒体服务生成 Sprite 缩略图
How to generate Sprite Thumbnails using 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
)
};
这很完美,没有问题,但是我如何让它也为视频生成 Sprite Thumbnail,在查找时,我遇到了这个 https://docs.microsoft.com/en-us/azure/media-services/previous/generate-thumbnail-sprite 并且根据这个应该使用以下内容来生成媒体服务 2.0 的 sprite
{
"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
)
},
有没有办法在媒体服务中生成精灵?
是的,缩略图 Sprite 编码现在可以使用 v3。文档将很快更新。您需要将 Microsoft.Azure.Management.Media nugget 包更新到版本 3.0.2 或更高版本。
我添加了一个可以执行此操作的示例应用程序:https://github.com/Azure-Samples/media-services-v3-dotnet/tree/master/VideoEncoding/EncodingWithMESCustomPresetAndSprite
我将切入基础,我有以下 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
)
};
这很完美,没有问题,但是我如何让它也为视频生成 Sprite Thumbnail,在查找时,我遇到了这个 https://docs.microsoft.com/en-us/azure/media-services/previous/generate-thumbnail-sprite 并且根据这个应该使用以下内容来生成媒体服务 2.0 的 sprite
{
"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
)
},
有没有办法在媒体服务中生成精灵?
是的,缩略图 Sprite 编码现在可以使用 v3。文档将很快更新。您需要将 Microsoft.Azure.Management.Media nugget 包更新到版本 3.0.2 或更高版本。
我添加了一个可以执行此操作的示例应用程序:https://github.com/Azure-Samples/media-services-v3-dotnet/tree/master/VideoEncoding/EncodingWithMESCustomPresetAndSprite