Export (0) Print
Expand All
3 out of 4 rated this helpful - Rate this topic

Task Preset for Thumbnail Generation

Updated: February 18, 2014

This topic contains an XML configuration file and settings for generating thumbnail images from video content in Microsoft Azure Media Services. In Media Services, you can create thumbnail generation tasks and pass them to the Azure Media Encoder.

You are able to specify both the size of the image and the position of timeline via percentages. For example the preset below will produce an image at 100% of the source video resolution, and at positions 10%, 20%, …, 90% along the timeline.

<?xml version="1.0" encoding="utf-8"?>
<Thumbnail Size="100%,*" Type="Jpeg" Filename="{OriginalFilename}_{Size}_{ThumbnailTime}_{ThumbnailIndex}_{Date}_{Time}.{DefaultExtension}">
<Time Value="10%" Step="10%" Stop="95%"/>
</Thumbnail>

You have an option of using the Thumbnails preset provided by Media Services, as shown in the following example:


ITask task = job.Tasks.AddNew("My thumbnail task",
    processor,
    "Thumbnails",
    TaskOptions.ProtectedConfiguration);

Alternatively, you can create an XML configuration file to customize the settings and use it when creating a task:

  1. Create a file named Thumbnail.xml on your local computer and paste the following code in the file.

    <?xml version="1.0" encoding="utf-8"?>
    <Thumbnail Size="100%,*" Type="Jpeg" Filename="{OriginalFilename}_{Size}_{ThumbnailTime}_{ThumbnailIndex}_{Date}_{Time}.{DefaultExtension}">
    <Time Value="10%" Step="10%" Stop="95%"/>
    </Thumbnail>
    
    
  2. Reference this file as a configuration preset when you create Media Services tasks to generate thumbnail images by using Media Encoder.

    string configuration = File.ReadAllText(Path.GetFullPath(configFilePath + @"\Thumbnails.xml")); ;
    
    ITask task = job.Tasks.AddNew("My thumbnail task",
        processor,
        configuration,
        TaskOptions.ProtectedConfiguration);
    
    

This topic describes the elements and attributes that can be set in such a configuration file. For more information on how to use this configuration file with Media Services tasks, see Process Assets with the Media Services SDK for .NET.

Thumbnail Task Preset Settings

You can adjust the settings in the thumbnail task configuration file. There are two primary elements:

  • The <Thumbnail> element. This is the parent element. It specifies general settings for the thumbnail image that will be generated.

  • The <Time> element. This is a child of the <Thumbnail> element. It describes the time in the source video stream from which a thumbnail will be generated.

The following table summarizes the available settings.

Thumbnail element

Attribute Description

JpegQuality

The value in this field is an integer between 0 and 100 that specifies the level of compression in an image, if the image is a .jpeg file. The lower the number that is assigned to this property, the compression level will be higher and the image quality lower. So assigning 0 to the JpegQuality setting results in the highest compression (and lowest image quality), while assigning 100 results in no compression (and the highest image quality).

Filename

Specifies the file name of the generated thumbnail image. The default preset contains a template with replaceable fields that generates the image file name based on the original input file name, plus the time the thumbnail is created, plus a default file extension that is based on the file type in the Type setting.

The following replaceable fields can be used with the Filename attribute:

  • {OriginalFilename} - the filename component of the input asset.

  • {ThumbnailTime} - timecode corresponding to the frame used for the thumbnail, such as 00:00:00:05.

  • {Size} - size of the image.

  • {ThumbnailIndex} – index that starts with “1” for the first image, “2” for the second, etc.

  • {DefaultExtension}- one of .jpg, .png, .bmp, based on what is specified in the Type attribute.

<?xml version="1.0" encoding="utf-8"?>
<Thumbnail Size="100%,*" Type="Jpeg" Filename="{OriginalFilename}_{Size}_{ThumbnailTime}_{ThumbnailIndex}_{Date}_{Time}.{DefaultExtension}">
<Time Value="10%" Step="10%" Stop="95%"/>
</Thumbnail>


The configuration XML string above will generate thumbnail files with names in the following format: OriginalFilename_{Width=N, Height=N}_ThumbnailTime_ThumbnailIndex.DefaultExtension. For example, interview2_{Width=300, Height=169}_00.00.05_1.jpg.

You can also set the name of Media Services output files programmatically; you do not have to use the default name in the Filename setting.

Type

Indicates the image format type of the output file. Possible image file formats that you can specify in the Type setting include any of the following string values: "MemoryBMP"; "Bmp"; "Emf"; "Wmf"; "Gif"; "Jpeg"; "Png"; "Tiff"; "Exif"; "Icon".

Size

Sets the dimensions to be used for the thumbnail, specifying height and width in pixels. The format to specify the dimensions is: [height in pixels], [width in pixels]. An asterisk (*) character used in place of one of the dimensions means to maintain aspect ratio based on the height of the first video source stream.

Time element

Attribute Description

Value

A string value that indicates the start time in a video that will correspond with a sequence of thumbnails generated from the video. If no step is specified, this value is the sole time on which a generated thumbnail is based. The format of the string for the time value is: [hours]:[minutes]:[seconds].

Step (Optional)

A string value that describes the time increments in a video at which thumbnail images will be generated, if generating a sequence of thumbnails. The format of the string for the time value is: [hours]:[minutes]:[seconds].

Stop (Optional)

A string value that describes the end point in a video, if generating a sequence of thumbnails. The format of the string for the time value is: [hours]:[minutes]:[seconds].


Build Date:

2014-04-18
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.