tencent cloud

Media Screenshot APIs
Last updated: 2024-03-01 14:57:12
Media Screenshot APIs
Last updated: 2024-03-01 14:57:12

Overview

This document provides an overview of APIs and SDK code samples for media screenshot.
Note:
The COS Python SDK version must be at least v5.1.9.11.
API
Operation
Description
Querying screenshot
Query the screenshot of media file at some time point
Note:
Before using this API, make sure that the media processing feature has been enabled in the data processing section in the console; otherwise, the error media bucket unbinded, bucket's host is unavailable will be reported. For more information, see Enabling Media Processing.

Querying Screenshot

Feature description

This API is used to query the screenshot of a media file at some time point.

Method prototype

def get_snapshot(Bucket, Key, Time, Width=None, Height=None, Format='jpg', Rotate='auto', Mode='exactframe', **kwargs)

Sample request

response = client.get_snapshot(
Bucket='examplebucket-1250000000',
Key='demo.mp4',
Time='1.5',
Width='480',
Format='png'
)
print(response)
response['Body'].get_stream_to_file('snapshot.jpg')

Parameter description

Parameter
Description
Required
Type
Bucket
Bucket name in the format of BucketName-APPID. For more information, see Bucket Overview.
Yes
String
Key
Object key, which is the unique identifier of the object in the bucket.
Yes
String
Time
Screenshot time point in seconds, which can contain a decimal point.
Yes
String
Width
Screenshot width. Default value: 0.
No
String
Height
Screenshot height. Default value: 0. If width and height are both 0, the width and height of the video are used. If one of them is 0, the other value is used to automatically adapt to the aspect ratio of the video.
No
String
Format
Screenshot format. Valid values: jpg, png. Default value: jpg.
No
String
Rotate
Image rotation method. auto: Rotate automatically according to the video rotation information. off: Do not rotate. Default value: auto.
No
String
Mode
Frame capturing method. keyframe: Capture the last keyframe before the specified time point. exactframe: Capture the frame at a specified time point. Default value: exactframe.
No
String
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback