获取信息功能(info)可以获取指定视频资源的元信息。本文介绍获取信息相关参数说明和使用示例。
使用请求 URL 获取指定视频元信息时,您只需要在请求 URL 中增加 info
,无需设置其他请求参数。
返回参数部分说明如下:
注意
不同视频格式返回结果可能存在差异。
{ "streams": [ { "index": 0, # 流索引编号 "codec_name": "aac", # 编码器名称 "codec_long_name": "AAC (Advanced Audio Coding)", # 编码器详细名称 "codec_type": "audio", # 编码器类型 "codec_tag_string": "mp4a", # 编码标签名 "codec_tag": "0x6134706d", # 编码标签 "sample_fmt": "fltp", # 采样格式 "sample_rate": "44100", # 采样率 "channels": 2, # 通道数量 "channel_layout": "stereo", # 通道格式 "r_frame_rate": "0/0", # 帧率 "avg_frame_rate": "0/0", # 平均帧率 "time_base": "1/44100", # 编码时基 "start_time": "0.000000", # 音频开始时间 "duration": "596.474195", # 音频时长 "bit_rate": "125587", # 比特率 "nb_frames": "25688", # 总帧数 "tags": { # 标签信息 "language": "und", # 语言 "handler_name": "(C) 2007 Google Inc. v08.13.2007.", # 处理器名称 } }, { "index": 1, # 流索引编号 "codec_name": "h264", # 编码器名称 "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", # 编码器详细名称 "profile": "High", # 视频编码档位 "codec_type": "video", # 编码器类型 "codec_tag_string": "avc1", # 编码标签名称 "codec_tag": "0x31637661", # 编码标签 "width": 1280, # 视频宽度,单位px "height": 720, # 视频高度,单位px "sample_aspect_ratio": "1:1", # 采样宽高比 "display_aspect_ratio": "16:9", # 显示宽高比 "pix_fmt": "yuv420p", # 像素格式 "level": 31, # 视频编码等级 "r_frame_rate": "24/1", # 帧率 "avg_frame_rate": "24/1", # 平均帧率 "time_base": "1/24000", # 编码时基 "start_time": "0.000000", # 视频开始时间 "duration": "596.458333", # 视频时长 "bit_rate": "1991287", # 比特率 "nb_frames": "14315", # 总帧数 } ], "format": { "nb_streams": 2, # 流数量 "nb_programs": 0, # 节目数量 "format_name": "mov,mp4,m4a,3gp,3g2,mj2", # 容器格式名称 "format_long_name": "QuickTime / MOV", # 容器格式全称 "start_time": "0.000000", # 首帧时间 "duration": "596.473333", # 时长 "size": "158008374", # 文件大小 "bit_rate": "2119234", # 码率 } }
原视频示例:https://tos-tools.tos-cn-beijing.volces.com/misc/video.mp4
获取视频元信息示例 URL 如下:
https://tos-tools.tos-cn-beijing.volces.com/misc/video.mp4?x-tos-process=video/info
预期返回以下结果:
{ "streams": [ { "index": 0, "codec_name": "h264", "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", "profile": "High", "codec_type": "video", "codec_tag_string": "avc1", "codec_tag": "0x31637661", "width": 1920, "height": 1080, "coded_width": 1920, "coded_height": 1088, "sample_aspect_ratio":"1:1", "display_aspect_ratio":"16:9", "pix_fmt":"yuv420p", "level":40, "chroma_location":"left", "refs":1,"is_avc":"true", "nal_length_size":"4", "r_frame_rate":"30/1", "avg_frame_rate":"30/1", "time_base":"1/1000000", "start_pts":0, "start_time":"0.000000", "duration_ts":51200000, "duration":"51.200000", "bit_rate":"2597036", "bits_per_raw_sample":"8", "nb_frames":"1536", "extradata_size":0, "disposition": { "default":1, "dub":0, "original":0, "comment":0, "lyrics":0, "karaoke":0, "forced":0, "hearing_impaired":0, "visual_impaired":0, "clean_effects":0, "attached_pic":0, "timed_thumbnails":0, "captions":0, "descriptions":0, "metadata":0, "dependent":0, "still_image":0 }, "tags": { "language": "und", "handler_name": "VideoHandler", "vendor_id": "" } }, { "index":1, "codec_name":"aac", "codec_long_name":"AAC (Advanced Audio Coding)", "profile":"LC", "codec_type":"audio", "codec_tag_string":"mp4a", "codec_tag":"0x6134706d", "sample_fmt":"fltp", "sample_rate":"44100", "channels":2, "channel_layout":"stereo", "r_frame_rate":"0/0", "avg_frame_rate":"0/0", "time_base":"1/44100", "start_pts":0, "start_time":"0.000000", "duration_ts":2257920, "duration":"51.200000", "bit_rate":"192755", "nb_frames":"2206", "extradata_size":0, "disposition": { "default":1, "dub":0, "original":0, "comment":0, "lyrics":0, "karaoke":0, "forced":0, "hearing_impaired":0, "visual_impaired":0, "clean_effects":0, "attached_pic":0, "timed_thumbnails":0, "captions":0, "descriptions":0, "metadata":0, "dependent":0, "still_image":0 }, "tags": { "language": "und", "handler_name": "SoundHandler", "vendor_id": "" } } ], "format": { "nb_streams":2, "nb_programs":0, "format_name":"mov,mp4,m4a,3gp,3g2,mj2", "format_long_name":"QuickTime / MOV", "start_time":"0.000000", "duration":"51.200000", "size":"17899516", "bit_rate":"2796799", "probe_score":100, "tags": { "major_brand": "isom", "minor_version": "512", "compatible_brands": "isomiso2avc1mp41", "encoder":"Lavf58.76.100" } } }