tencent cloud

Cloud Infinite

Obtain Media Information avinfo

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-12-25 17:00:21

Description

This API is used to obtain information about media files, such as metadata of audio and video files.

Authorization Description

When you use a sub-account, you need to add the cos:GetObject permission to the action in the authorization policy. For all operation interfaces supported by COS, see COS action.

Service Activation

To use this feature, you need to bind Bucket in advance and activate the Cloud Infinite service.
To use this feature, you need to activate the service for Media Processing in advance via the console or API.
Note:
After Cloud Infinite is bound, if you manually unbind Cloud Infinite from the Bucket, you will not be able to continue using this feature.

Use Limits

When using this interface, please first confirm the relevant restrictions. For details, see Usage Limits.

Fee Instructions

This interface is a paid service, and the incurred fees will be charged by Cloud Infinite. Detailed billing instructions can be found in Media Processing fees.


Request

Request sample

GET /<ObjectKey>?ci-process=avinfo HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: <GMT Date>
Authorization: <Auth String>
Content-Length: <length>
Note:
Authorization: Auth String. For details, see the Request Signature documentation.

Request header

This API only uses common request headers. For details, see Common Request Headers.

Request Parameter

The parameter description is as follows:
Node Name (Keyword)
Description
Type
Required
ObjectKey
Name of the object file. For example, test.mp4
String
Yes
ci-process
Operation type. Fixed value: avinfo, which represents the feature for obtaining media information.
String
Yes
magicvar
Parameter for magic variables. When set to "1", the audio/video stream information will be parsed separately and encapsulated in the output.
String
No

Request body

The request has no request body.

Response

Response Headers

This API only returns common response headers. For details, see Common Response Headers.

Response Body

The response body returns application/json data, and the content containing complete node data is shown below:

{
"streams": [
{
"index": 0,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"codec_type": "video",
"codec_time_base": "1/30",
"codec_tag_string": "avc1",
"codec_tag": "0x31637661",
"width": 1152,
"height": 864,
"has_b_frames": 0,
"sample_aspect_ratio": "1:1",
"display_aspect_ratio": "4:3",
"pix_fmt": "yuv420p",
"level": 40,
"is_avc": "1",
"nal_length_size": "4",
"r_frame_rate": "15/1",
"avg_frame_rate": "15/1",
"time_base": "1/15000",
"start_time": "0.000000",
"duration": "6413.333333",
"nb_frames": "96200",
"tags": {
"creation_time": "2013-01-07 12:58:08",
"language": "eng",
"handler_name": "Video Media Handler"
}
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "Full name of the Advanced Audio encoder: Coding"
"codec_type": "audio",
"codec_time_base": "1/44100",
"codec_tag_string": "mp4a",
"codec_tag": "0x6134706d",
"sample_fmt": "s16",
"sample_rate": "44100",
"channels": 2,
"bits_per_sample": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/44100",
"start_time": "0.000000",
"duration": "6413.374694",
"nb_frames": "276201",
"tags": {
"creation_time": "2013-01-07 12:58:08",
"language": "eng",
"handler_name": "Sound Media Handler"
}
}
],
"format": {
"nb_streams": 2,
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
"format_long_name": "QuickTime/MPEG-4/Motion JPEG 2000 format",
"start_time": "0.000000",
"duration": "6413.359589",
"size": "101416337",
"bit_rate": "126506",
}
}
The specific content of the data is as follows:
Content of the Container node format (not returned when a valid value is not obtained for a field):
Node Name (Keyword)
Parent Node
Description
Type
nb_streams
format
The quantity of streams (including video, audio, and sub_info)
Integer
nb_programs
format
The number of programs
Integer
format_name
format
name of the container format
String
format_long_name
format
detailed name of the container format
String
start_time
format
Start time, in seconds
String
duration
format
Duration, in seconds
String
bit_rate
format
Bitrate, in kbps
String
size
format
Size, in Byte
String
When the magicvar parameter is not set, the returned content is as follows:
Node Name (Keyword)
Parent Node
Description
Type
streams
None.
information of the audio and video streams
Array
format
None.
Format information
Container
Detailed information of the Container node streams:
Node Name (Keyword)
Parent Node
Description
Type
index
streams
The ID of this stream
Integer
codec_type
streams
Stream type
String
codec_name
streams
name of the codec format
String
codec_long_name
streams
detailed name of the codec format
String
codec_time_base
streams
codec time_base
String
codec_tag_string
streams
Codec Tag Name
String
codec_tag
streams
Codec Tag
String
color_primaries
streams
Chroma
String
color_range
streams
Color Range
String
color_transfer
streams
Color Channel
String
profile
streams
Profile for video encoding
String
height
streams
Video height (in px)
Integer
width
streams
Video width (in px)
Integer
has_b_frames
streams
Whether there are B-frames. 1 for yes, 0 for no
String
refs
streams
Number of reference frames in video encoding
Integer
sample_aspect_ratio
streams
Sample Aspect Ratio
String
display_aspect_ratio
streams
Display Aspect Ratio
String
pix_fmt
streams
Pixel Format
String
filed_order
streams
Field Order
String
level
streams
Level of video encoding
Integer
r_frame_rate
streams
Video frame rate
String
avg_frame_rate
streams
Average frame rate
String
timebase
streams
time_base
String
start_time
streams
Stream start time, in seconds
String
duration
streams
Stream duration, in seconds
String
bit_rate
streams
Bitrate, in kbps
String
nb_frames
streams
Total frames
String
language
streams
Language
String
rotation
streams
Rotation angle
String
creation_time
streams
Stream creation time
String
sample_fmt
streams
Sample format
String
sample_rate
streams
Sampling Rate
String
channels
streams
Number of Channels
Integer
channel_layout
streams
Channel Format
String
When the magicvar parameter is set, the returned content is as follows:
Node Name (Keyword)
Parent Node
Description
Type
format
None.
Format information
Container
video
None.
video information
Container
audio
None.
audio information
Container
Detailed information of the Container node video:
Node Name (Keyword)
Parent Node
Description
Type
index
video
The ID of this stream
Integer
codec_type
video
Stream type, fixed as video.
String
codec_name
video
name of the codec format
String
codec_long_name
video
detailed name of the codec format
String
codec_time_base
video
codec time_base
String
codec_tag_string
video
Name of the Codec Tag
String
codec_tag
video
Codec Tag
String
color_primaries
video
Chroma
String
color_range
video
Color Range
String
color_transfer
video
Color Channel
String
profile
video
Video encoding profile
String
height
video
Video height (in px)
Integer
width
video
Video width (in px)
Integer
has_b_frames
video
Whether there are B-frames. 1 for yes, 0 for no
String
refs
video
Number of reference frames in video encoding
Integer
sample_aspect_ratio
video
Aspect Ratio of the Sample
String
display_aspect_ratio
video
Display Aspect Ratio
String
pix_fmt
video
Pixel Format
String
filed_order
video
Field Order
String
level
video
Level of video encoding
Integer
r_frame_rate
video
Video frame rate
String
avg_frame_rate
video
Average frame rate
String
timebase
video
time_base
String
start_time
video
Start time of the video, in seconds
String
duration
video
Video duration, in seconds
String
bit_rate
video
Bitrate, in kbps
String
nb_frames
video
Total frames
String
language
video
Language
String
rotation
video
Rotation angle
String
creation_time
video
Time of stream creation
String
Detailed information about the audio of the Container node:
Node Name (Keyword)
Parent Node
Description
Type
index
audio
The ID of this stream
Integer
codec_type
audio
Stream type, fixed as audio
String
codec_name
audio
Name of the codec format
String
codec_long_name
audio
detailed name of the codec format
String
codec_time_base
audio
codec time_base
String
codec_tag_string
audio
Codec Tag Name
String
codec_tag
audio
Codec Tag
String
sample_fmt
audio
Sample format
String
sample_rate
audio
Sampling Rate
String
channels
audio
Number of Channels
Integer
channel_layout
audio
Channel Format
String
timebase
audio
time_base
String
start_time
audio
Start time of the audio, in seconds
String
duration
audio
Audio duration, in seconds
String
bit_rate
audio
Bitrate, in kbps
String
language
audio
Language
String
creation_time
audio
Creation time of the stream
String

Error Codes

This request operation has no special error messages. For common error messages, see Error Codes.

Practical Case

Request 1: Magic Variable Not Set

GET /for-test.mp4?ci-process=avinfo HTTP/1.1
Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.com
Date: Fri, 10 Mar 2016 09:45:46 GMT
Authorization: q-sign-algorithm=sha1&q-ak=***************************************&q-key-time=1484213027;32557109027&q-header-list=host&q-url-param-list=acl&q-signature=****************************************
Content-Length: 0

Response 1

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 666
Connection: keep-alive
Date: Fri, 10 Mar 2016 09:45:46 GMT
Server: tencent-ci
x-cos-request-id: NTg3NzRiMjVfYmRjMzVfMTViMl82ZGZmNw==

{
"format": {
"bit_rate": "1166.619000",
"duration": "27.000000",
"format_long_name": "QuickTime / MOV",
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
"nb_programs": 0,
"nb_streams": 2,
"size": "3937340",
"start_time": "0.000000"
},
"streams": [{
"avg_frame_rate": "30/1",
"bit_rate": "1028.621000",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"codec_name": "h264",
"codec_tag": "0x31637661",
"codec_tag_string": "avc1",
"codec_time_base": "1/15360",
"codec_type": "video",
"color_primaries": "bt709",
"color_range": "tv",
"color_transfer": "bt709",
"duration": "27.000000",
"has_b_frames": "2",
"height": 1280,
"index": 0,
"language": "und",
"level": 31,
"nb_frames": "810",
"pix_fmt": "yuv420p",
"profile": "High",
"r_frame_rate": "30/1",
"refs": 1,
"rotation": "0.000000",
"start_time": "0.000000",
"timebase": "1/15360",
"width": 720
}, {
"bit_rate": "129.505000",
"channel_layout": "stereo",
"channels": 2,
"codec_long_name": "AAC (Advanced Audio Coding)",
"codec_name": "aac",
"codec_tag": "0x6134706d",
"codec_tag_string": "mp4a",
"codec_time_base": "1/44100",
"codec_type": "audio",
"duration": "26.915011",
"index": 1,
"language": "und",
"sample_fmt": "fltp",
"sample_rate": "44100",
"start_time": "0.000000",
"timebase": "1/44100"
}]
}

Request 2: Set Magic Variables

GET /for-test.mp4?ci-process=avinfo&magicvar=1 HTTP/1.1
Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.com
Date: Fri, 10 Mar 2016 09:45:46 GMT
Authorization: q-sign-algorithm=sha1&q-ak=***************************************&q-key-time=1484213027;32557109027&q-header-list=host&q-url-param-list=acl&q-signature=****************************************
Content-Length: 0

Response 2


{
"audio": {
"bit_rate": "129.505000",
"channel_layout": "stereo",
"channels": 2,
"codec_long_name": "AAC (Advanced Audio Coding)",
"codec_name": "aac",
"codec_tag": "0x6134706d",
"codec_tag_string": "mp4a",
"codec_time_base": "1/44100",
"codec_type": "audio",
"duration": "26.915011",
"index": 1,
"language": "und",
"sample_fmt": "fltp",
"sample_rate": "44100",
"start_time": "0.000000",
"timebase": "1/44100"
},
"format": {
"bit_rate": "1166.619000",
"duration": "27.000000",
"format_long_name": "QuickTime / MOV",
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
"nb_programs": 0,
"nb_streams": 2,
"size": "3937340",
"start_time": "0.000000"
},
"video": {
"avg_frame_rate": "30/1",
"bit_rate": "1028.621000",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"codec_name": "h264",
"codec_tag": "0x31637661",
"codec_tag_string": "avc1",
"codec_time_base": "1/15360",
"codec_type": "video",
"color_primaries": "bt709",
"color_range": "tv",
"color_transfer": "bt709",
"duration": "27.000000",
"has_b_frames": "2",
"height": 1280,
"index": 0,
"language": "und",
"level": 31,
"nb_frames": "810",
"pix_fmt": "yuv420p",
"profile": "High",
"r_frame_rate": "30/1",
"refs": 1,
"rotation": "0.000000",
"start_time": "0.000000",
"timebase": "1/15360",
"width": 720
}
}

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백