I will cut to the basic, I have the following TransformOutput
which encodes the Videos(SD/HD) and also creates Thumbnail.
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
)
};
This works perfect, no issues but How do I make this also generate Sprite Thumbnail for the video, while looking up, I came across this https://learn.microsoft.com/en-us/azure/media-services/previous/generate-thumbnail-sprite and according to this the following should be used to generate the sprite for Media Service 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"
}
}
]
}
I am trying to convert this in my code (to media services 3.0) but seems to be no luck, it looks like there is not spriteColumn
available
,new JpgImage(
start: "00:00:01",
step: "5%",
range: "100%",
layers: new JpgLayer[]{
new JpgLayer(
width: "10%",
height: "10%",
quality: 90
)
},
spriteColumn: 10 //<<<THIS
)
},
Is there a way to generate sprite in Media Services?
Yes, Thumbnail Sprite encoding is now possible with v3. Documentation will be updated soon. You need to update Microsoft.Azure.Management.Media nugget package to version 3.0.2 or later.
I added a sample app that does it : https://github.com/Azure-Samples/media-services-v3-dotnet/tree/master/VideoEncoding/EncodingWithMESCustomPresetAndSprite
Preset is there : https://github.com/Azure-Samples/media-services-v3-dotnet/blob/master/VideoEncoding/EncodingWithMESCustomPresetAndSprite/Program.cs#L261-L287