All Products
Search
Document Center

ApsaraVideo VOD:Frame animation

Last Updated:Feb 22, 2024

You can use the frame animation feature to transform a specific part of a video into a dynamic image. This feature is widely used for social media and news report platforms and marketing promotions. ApsaraVideo VOD allows you to generate dynamic images in the GIF and WebP formats. This topic describes how to capture dynamic images from a video.

Overview

A dynamic image is a group of static images that switch at a specific frequency to create a dynamic effect. Most dynamic images are in the GIF format, while WebP images are less frequently used. When you use the frame animation feature, ApsaraVideo VOD transforms a specific part of a video into a dynamic image file.

You can export dynamic images in the GIF or WebP format based on your business requirements. The following table describes the features of these formats.

Format

Benefit

GIF

GIF images provide high compatibility and are often used to decorate websites.

WebP

WebP images are smaller in size than GIF images. However, WebP images are not supported by some browsers, such as Internet Explorer, Safari, iOS 3.2 to 13.7, and KaiOS browser.

Scenarios

  • Content sharing on social media platforms: You can transform a specific part of a video into a GIF dynamic image and quickly share the dynamic image with other users. This also allows you to capture the highlights of videos to attract viewers.

  • Marketing promotion: You can transform the highlights of videos into dynamic images for advertising. This improves the click-through rate (CTR) and conversion rate by stimulating the interest of viewers. You can also use dynamic images on e-commerce platforms to present the features of a product.

  • Distribution of news and entertainment information: You can transform the key information in the video content into a dynamic image. This way, the information can be displayed in a concise manner. You can also transform the trailers and exciting moments of your show into dynamic images. This allows viewers to quickly browse the key events.

  • Teaching demonstration: You can use dynamic images to explain complex concepts or steps in online courses. This helps students better understand and memorize the knowledge.

Billing rules

The fees for frame animation are included in your video transcoding bill. You are charged based on the output resolution and the duration. For more information, see Billing of basic services.

Usage notes

  • A snapshot may fail to be captured in the following scenarios: the source file is an audio file that excludes image information, the source file is damaged, or the container format of the source file is invalid.

  • Dynamic image files are asynchronously generated. You can obtain the status of a frame animation job from the DynamicImageComplete callback.

  • The time required to generate a dynamic image varies based on the file size, the duration of the video, and the length of the animation.

Prerequisites

  • ApsaraVideo VOD is activated. For more information, see Activate ApsaraVideo VOD.

  • The RAM user or RAM role that you use has corresponding permissions to access ApsaraVideo VOD. We recommend that you use a RAM user or RAM role to perform operations to improve the security of your account and resources. For more information, see Create and grant permissions to a RAM user.

Step 1: Create a frame animation template

A large number of parameters are used when the system generates dynamic images. If you submit a frame animation request that includes all parameters, the feature becomes difficult to use. ApsaraVideo VOD provides frame animation templates. You can configure the relevant parameters in a template, and then specify the ID of the template when you submit a frame animation request.

Create a frame animation template by using the console

  1. Log on to the ApsaraVideo VOD console.

  2. In the left-side navigation pane, choose Configuration Management > Media Processing > Frame Animation Templates.

  3. On the Frame Animation Templates page, click Add Template. On the Create Frame Animation Template page, create a frame animation template. The following table describes the parameters.

    Parameter

    Description

    Template Name

    The name of the frame animation template. The name must be 4 to 64 characters in length. It can contain letters, digits, hyphens (-), and underscores (_).

    Output Format

    The format of the output dynamic image. Valid values: gif and webp.

    Frame Rate

    The frame rate of the dynamic image. Valid values: (0,60].

    Size (Width × Height)

    The width and height of the dynamic image. Unit: pixels.

    Note
    • If you do not configure Width or Height, the width and height of the dynamic image are the same as those of the input video.

    • If you configure only Width or Height, the other parameter is automatically set based on the aspect ratio of the input video to ensure that the dynamic image is not distorted.

    Trim Mode

    The method that is used to capture a specific part of the video to generate a dynamic image. You can select Trim from Beginning or Trim from Beginning and End.

    From Beginning

    The period of time that is trimmed from the beginning of the video. Valid values: 0.000 to 86399.999. Unit: seconds.

    Duration

    The duration of the dynamic image. Valid values: 0.000 to 86399.999. Unit: seconds.

    Note

    This parameter is required only if you set Trim Mode to Trim from Beginning.

    From End

    The period of time that is trimmed from the end of the video. Valid values: 0.000 to 86399.999. Unit: seconds.

    Note

    This parameter is required if you set Trim Mode to Trim from Beginning and End.

    Use as Default Cover

    If you enable this feature, the captured dynamic image is automatically used as the video thumbnail.

  4. Click Save.

    After the template is created, you can view the template on the Frame Animation Templates page.动图模板.png

Create a frame animation template by calling API operations

To create a frame animation template, call the AddVodTemplate operation and specify DynamicImage for the TemplateType parameter. You can configure other parameters based on your business requirements.

After the template is created, the VodTemplateId field is returned.

Step 2: (Optional) Configure event notifications for a frame animation job

Before you submit a frame animation job, we recommend that you configure the DynamicImageComplete event notification. This way, you can obtain the status of the frame animation job and the URL of the captured dynamic image after the job is complete. For more information, see DynamicImageComplete.

For more information about how to configure event notifications, see Configure callbacks.

Step 3: Submit a frame animation job

Submit a frame animation job by using the console

  1. Create a workflow that contains a Frame Animation node.

    If you want to submit a frame animation job by using the ApsaraVideo VOD console, you must create a workflow, add a Frame Animation node, and then specify the frame animation template that you created in Step 1. For more information about how to create a workflow, see Manage workflows.

  2. Submit a frame animation job.

    • Scenario 1: Submit a frame animation job when you upload a video

      1. Log on to the ApsaraVideo VOD console. In the left-side navigation pane, choose Media Files > Audio/Video.

      2. On the Video and Audio page, click Upload. On the Upload Media page, click Add Media.

      3. Specify the upload method and storage bucket, and select the video that you want to upload. Then, select Use Workflow from the drop-down list and then select the workflow that you created.

      4. Click Upload.

    • Scenario 2: Submit a frame animation job after a video is uploaded

      1. Log on to the ApsaraVideo VOD console. In the left-side navigation pane, choose Media Files > Audio/Video.

      2. On the Video and Audio page, find the file for which you want to capture a dynamic image and click Media Processing in the Actions column.

      3. In the Media Processing dialog box, set Processing Type to Use Workflow and select the workflow that you created from the Workflow drop-down list.

      4. Click Upload.

Submit a frame animation job by calling API operations

  • Scenario 1: Submit a frame animation job when you upload a video

    1. Create a workflow that contains a Frame Animation node.

      Create a workflow, add a Frame Animation node in the workflow, and then specify the frame animation template that you created in Step 1. For more information about how to create a workflow, see Manage workflows.

    2. To submit a frame animation job by calling the following API operations, specify the ID of the workflow that you created in the previous step for the WorkflowId parameter and configure other request parameters based on your business requirements.

  • Scenario 2: Submit a frame animation job after a video is uploaded

    To submit a frame animation job for a specific video, call the SubmitDynamicImageJob operation, set the DynamicImageTemplateId parameter to the ID of the frame animation template that you created in Step 1, and configure other request parameters based on your business requirements.

Step 4: Obtain information about the captured dynamic image

  • If you have configured the DynamicImageComplete event notification, you can view whether the dynamic image is generated from the callback message. We recommend that you configure the DynamicImageComplete event notification.

  • After the dynamic image is captured, call the ListDynamicImage operation to obtain information about the dynamic image.

Note

If you have set the dynamic image as the video thumbnail, call the GetVideoInfo operation to obtain the URL of the dynamic image.