Convert video to animated image

Updated at:
Copy as MD

This topic describes how to use the Intelligent Media Management (IMM) media transcoding API operation to convert videos into animated images.

Overview

Video-to-animated-image conversion transforms a video file into an animated image format, such as GIF or WebP, for easy sharing and embedding on websites and social media.

zhuandongtu

Scenarios

  • Social media sharing: Animated images let users share short video clips on social platforms to express emotions, humorous moments, or key information.

  • Online memes: Convert videos into animated images to create fun or humorous memes that enhance online conversations.

  • Tutorials and demos: Use animated images in teaching or demonstrations to show software operations or step-by-step instructions, helping viewers quickly understand complex concepts and procedures.

  • Live streams and event replays: During games, events, or live streams, use animated images to quickly clip and share exciting moments with viewers, boosting engagement.

Supported audio and video formats

Category

Format

Audio

All mainstream formats, such as AAC, MP3, WAV, FLAC, WMA, AC3, and OPUS.

Video

All mainstream formats, such as MP4, MPEG-TS, MKV, MOV, AVI, FLV, M3U8, WebM, WMV, RM, and VOB.

How to use

Prerequisites

  • Create an AccessKey. For more information, see Create an AccessKey.

  • Activate Object Storage Service (OSS) and create a bucket. For more information, see Create a bucket.

  • Activate Intelligent Media Management (IMM). For more information, see Activate IMM.

  • Create a project in the IMM console. For more information, see Create a project.

    Note
    • You can also call an API operation to create a project. For more information, see Create a project.

    • You can call the ListProjects operation to list all projects that are created in a specified region.

Step 1: Upload a file

Use the OSS console to upload your media file to a bucket in the same region as your IMM project.

On the upload page, keep File ACL set to the default value Inherit Bucket, click Scan Files, and select the media file to upload.

Step 2: Use IMM to convert video to animated image

Call the Create Media Transcoding Job API to create a video-to-animated-image conversion job.

Billing

During video-to-animated-image conversion, you incur charges from both OSS and IMM.

  • OSS billing: For detailed pricing, see OSS Pricing.

    API

    Billable item

    Description

    GetObject

    GET requests

    Charged based on the number of successful requests.

    Infrequent Access data retrieval capacity

    If retrieved data is stored in the Infrequent Access storage class, you are charged for the volume of retrieved data.

    Real-time access of Archive objects data retrieval capacity

    If you read Archive objects from a bucket that has real-time access of Archive objects enabled, you are charged based on the volume of retrieved data.

    Transfer acceleration

    If transfer acceleration is enabled and you access your bucket using an acceleration endpoint, you are charged based on the data volume transferred.

    PutObject

    PUT requests

    Charged based on the number of successful requests.

    Storage fee

    Charged based on the storage class, size, and duration of object storage.

    HeadObject

    GET requests

    Charged based on the number of successful requests.

  • For IMM, see IMM billing items for detailed pricing.

    Important

    Starting at 11:00 UTC+8 on July 28, 2025, the IMM video-to-animated-image service will change from free to a paid model. For more information, see IMM billing adjustment announcement.

    API

    Billable item

    Description

    CreateMediaConvertTask

    MediaAnimation

    Charged based on the number of output animated image frames.

Parameter examples

The following examples use the IMM project test-project and the file oss://test-bucket/video-demo/brewing.mov to perform video-to-animated-image conversion.

For more information about ApsaraVideo Media Processing features and usage, see Media transcoding.

Note
  • You can use the media transcoding API operation to process video files in the OpenAPI Explorer. Refer to the SDK code examples.

  • Do not set the Target.URI and Target.Container parameters for video-to-animated-image conversion.

  • GIF animated images have lower quality. Use WebP for better quality, but note that this increases file size.

  • We recommend setting FrameRate to 10–15. If not set, it defaults to 1 divided by Interval.

Generate an animated thumbnail from the entire video

Transcoding settings

  • Animated image format: WebP

  • Frame sampling interval: 1 second

  • Animated image frame rate: 15

  • Animated image resolution: half the source video resolution

  • Scaling method: scale without preserving black bars. For more information about scaling methods, see Scaling methods.

  • Output file path: oss://test-bucket/video-demo/animation.webp

  • Transcoding completion notification: send an MNS message to the MNS topic “test-mns-topic”

For an SDK example, see OpenAPI Explorer. The example parameters are pre-filled. Modify them as needed before testing.

Request parameters

{
  "ProjectName": "test-project",
  "Notification": {
    "MNS": {
      "TopicName": "test-mns-topic"
    }
  },
  "Sources": [
    {
      "URI": "oss://test-bucket/video-demo/brewing.mov"
    }
  ],
  "Targets": [
    {
      "Image": {
        "Animations": [
          {
            "Format": "webp",
            "FrameRate": 15,
            "Height": 0.5,
            "Interval": 1,
            "ScaleType": "fit",
            "URI": "oss://test-bucket/video-demo/animation.{autoext}",
            "Width": 0.5
          }
        ]
      }
    }
  ]
}

Generate an animated thumbnail from seconds 5 to 30 of the video

Transcoding settings

  • Animated image format: WebP

  • Frame sampling start time: second 5

  • Frame sampling duration: 25 seconds

  • Frame sampling interval: 1 second

  • Animated image frame rate: 15

  • Animated image resolution: half the source video resolution

  • Scaling method: scale without preserving black bars. For more information about scaling methods, see Scaling methods.

  • Output file path: oss://test-bucket/video-demo/animation.webp

  • Transcoding completion notification: send an MNS message to the MNS topic “test-mns-topic”

For an SDK example, see OpenAPI Explorer. The example parameters are pre-filled. Modify them as needed before testing.

Request parameters

{
  "ProjectName": "test-project",
  "Notification": {
    "MNS": {
      "TopicName": "test-mns-topic"
    }
  },
  "Sources": [
    {
      "Duration": 25,
      "StartTime": 5,
      "URI": "oss://test-bucket/video-demo/brewing.mov"
    }
  ],
  "Targets": [
    {
      "Image": {
        "Animations": [
          {
            "Format": "webp",
            "FrameRate": 15,
            "Height": 0.5,
            "Interval": 1,
            "ScaleType": "fit",
            "URI": "oss://test-bucket/video-demo/animation.{autoext}",
            "Width": 0.5
          }
        ]
      }
    }
  ]
}