This topic describes the parameters and examples to capture video snapshots.

Precautions

  • OSS currently can only capture images from video objects in H.264 format.
  • By default, captured images are not stored. You must manually download the captured images to the local device.

Parameters

Operation type: video

Operation name: snapshot

Parameter Description Valid value
t The time when the image needs to capture. [0, video duration]

Unit: ms

w The width of the image to capture. If this parameter is set to 0, the width of the image is automatically calculated. [0, video width]

Unit: pixel (px)

h The height of the image to capture. If this parameter is set to 0, the height of the image is automatically calculated. If w and h are both set to 0, the width and height of the captured image are the same as those of the video file. [0, video height]

Unit: px

m The mode to capture the image. If this parameter is not specified, the image is captured in default mode. In other words, the image at the specified point in time in the video is captured. If this parameter is set to fast, the most recent key image before the specified time is captured. fast
f The format of the image to capture. jpg and png
ar Specifies whether to automatically rotate the image based on the video information. If this parameter is set to auto, the system automatically rotates the image based on the video information. auto

Examples

  • Use the fast mode to capture the image at the 7th second of the video. Export it as a JPG image with the width of 800 px and height of 600 px.

    The URL used to process the image is in the following format: <Original video URL>? x-oss-process=video/snapshot,t_7000,f_jpg,w_800,h_600,m_fast.

  • Capture the image at the 50th second of the video accurately. Export it as a JPG image with the width of 800 px and height of 600 px.

    The URL used to process the image is in the following format: <Source video URL>? x-oss-process=video/snapshot,t_50000,f_jpg,w_800,h_600.