文档首页/ 视频点播 VOD/ API参考/ 应用示例/ 示例3:获取媒资详情
更新时间:2024-12-04 GMT+08:00
分享

示例3:获取媒资详情

场景描述

若您需要查询一个或多个媒资的基本信息、转码文件生成信息、截图信息及审核信息,您可以调用VOD API进行查询。

本章节指导用户如何使用API调用的方式获取存储在VOD中的媒资的详情信息。

前提条件

  • 已明确需要查询的媒资所在区域信息,详见使用前必读
  • 已获取需要查询的媒资所在区域的项目ID,具体获取方法请参见获取项目ID

操作步骤

  1. 获取用户Token,用于调用点播接口时进行认证鉴权。

    详细信息请参见构造请求。以“华北-北京四”为示例,若您需要调用其它区域的点播接口,请替换成对应区域的IAM终端节点

    POST https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens
    Content-Type: application/json
    
    {
      "auth": {
        "identity": {
          "methods": [
            "password"
          ],
          "password": {
            "user": {
              "name": "username", 
              "password": "password", 
              "domain": {
                "name": "domainname"   
              }
            }
          }
        },
        "scope": {
          "project": {
             "name": "projectname"
          }
        }
      }
    }
    图1所示,红框中的信息为获取用户Token。
    图1 获取用户Token

  2. 调用查询媒资信息接口,查询媒资详情信息。

    1. 选择GET请求方法并输入URI。
      https://{endpoint}/v1.0/{project_id}/asset/details?asset_id=41cff636d5b12a51e7eb2838bbf45201&categories=base_info,transcode_info&thumbnail_info,review_info
      “categories”为查询媒资信息的类型,您可以选择一个或者多个类型进行查询,具体取值如下所示:
      • base_info:查询媒资基本信息,包含媒资标题、分类、描述、文件类型、原始文件地址等。
      • transcode_info:查询媒资转码文件信息,包含使用的转码模板、转码后的媒资信息等。
      • thumbnail_info:查询截图信息,包含截图状态、截图存储地址等。
      • review_info:审核信息,包含审核是否通过,文本审核结果、封面审核结果和视频审核结果等。

      仅转码、截图或审核成功时,才可查询到对应的转码信息、截图信息和审核信息。

    2. 请求消息头中增加“X-Auth-Token”,值设置为步骤1中获取的用户Token。
    3. 请求响应成功后,返回媒资详情信息。
      {
        "asset_info_array" : [ {
          "asset_id" : "652c1e4085afeb22fdc256c6757d751b",
          "status" : "PUBLISHED",
          "description" : "Asset meta is published",
          "base_info" : {
            "title" : "okFLV.flv",
            "video_name" : "okFLV.flv",
            "description" : null,
            "category_id" : -1,
            "category_name" : "其他",
            "create_time" : "20190704144303",
            "last_modified" : "20190704144303",
            "video_type" : "FLV",
            "tags" : null,
            "meta_data" : {
              "pack_type" : null,
              "codec" : "H.264",
              "duration" : 244,
              "video_size" : 13682041,
              "width" : 512,
              "hight" : 288,
              "bit_rate" : 448,
              "frame_rate" : 30,
              "quality" : null
            },
            "video_url" : "https://651.cdn-vod.huaweicloud.com/asset/652c1e4085afeb22fdc256c6757d751b/45c2493abe68de3dac7e98b0dadcf8ce.flv",
            "sign_url" : "",
            "cover_info_array" : [ {
              "cover_url" : "https://651.cdn-vod.huaweicloud.com/asset/652c1e4085afeb22fdc256c6757d751b/cover/Cover0.jpg"
            } ],
            "subtitle_info" : [ ],
            "source_path" : {
              "bucket" : "obs-host",
              "location" : "cn-north-4",
              "object" : "1/okFLV.flv"
            },
            "output_path" : {
              "bucket" : "obs-host",
              "location" : "cn-north-4",
              "object" : "output/652c1e4085afeb22fdc256c6757d751b/"
            }
          },
          "play_info_array" : [ {
            "play_type" : "hls",
            "url" : "https://651.cdn-vod.huaweicloud.com/asset/652c1e4085afeb22fdc256c6757d751b/play_video/index.m3u8",
            "encrypted" : 0,
            "meta_data" : {
              "pack_type" : null,
              "codec" : "H.264",
              "duration" : 0,
              "video_size" : 0,
              "width" : 0,
              "hight" : 0,
              "bit_rate" : 0,
              "frame_rate" : 0,
              "quality" : null
            }
          }, {
            "play_type" : "hls",
            "url" : "https://651.cdn-vod.huaweicloud.com/asset/652c1e4085afeb22fdc256c6757d751b/play_video/b5d498082bbcff7a2055041d803ae2f9_1.m3u8",
            "encrypted" : 0,
            "meta_data" : {
              "pack_type" : null,
              "codec" : "H.264",
              "duration" : 205,
              "video_size" : 14669824,
              "width" : 512,
              "hight" : 288,
              "bit_rate" : 534,
              "frame_rate" : 0,
              "quality" : null
            }
          } ]
        } ],
        "is_truncated" : 0,
        "total" : 1
      }
      {
        "asset_info_array" : [ {
          "asset_id" : "652c1e4085afeb22fdc256c6757d751b",
          "status" : "PUBLISHED",
          "description" : "Asset meta is published",
          "base_info" : {
            "title" : "okFLV.flv",
            "video_name" : "okFLV.flv",
            "description" : null,
            "category_id" : -1,
            "category_name" : "其他",
            "create_time" : "20190704144303",
            "last_modified" : "20190704144303",
            "video_type" : "FLV",
            "tags" : null,
            "meta_data" : {
              "pack_type" : null,
              "codec" : "H.264",
              "duration" : 244,
              "video_size" : 13682041,
              "width" : 512,
              "hight" : 288,
              "bit_rate" : 448,
              "frame_rate" : 30,
              "quality" : null
            },
            "video_url" : "https://651.cdn-vod.huaweicloud.com/asset/652c1e4085afeb22fdc256c6757d751b/45c2493abe68de3dac7e98b0dadcf8ce.flv",
            "sign_url" : "",
            "cover_info_array" : [ {
              "cover_url" : "https://651.cdn-vod.huaweicloud.com/asset/652c1e4085afeb22fdc256c6757d751b/cover/Cover0.jpg"
            } ],
            "subtitle_info" : [ ],
            "source_path" : {
              "bucket" : "obs-host",
              "location" : "cn-north-4",
              "object" : "1/okFLV.flv"
            },
            "output_path" : {
              "bucket" : "obs-host",
              "location" : "cn-north-4",
              "object" : "output/652c1e4085afeb22fdc256c6757d751b/"
            }
          },
          "play_info_array" : [ {
            "play_type" : "hls",
            "url" : "https://651.cdn-vod.huaweicloud.com/asset/652c1e4085afeb22fdc256c6757d751b/play_video/index.m3u8",
            "encrypted" : 0,
            "meta_data" : {
              "pack_type" : null,
              "codec" : "H.264",
              "duration" : 0,
              "video_size" : 0,
              "width" : 0,
              "hight" : 0,
              "bit_rate" : 0,
              "frame_rate" : 0,
              "quality" : null
            }
          }, {
            "play_type" : "hls",
            "url" : "https://651.cdn-vod.huaweicloud.com/asset/652c1e4085afeb22fdc256c6757d751b/play_video/b5d498082bbcff7a2055041d803ae2f9_1.m3u8",
            "encrypted" : 0,
            "meta_data" : {
              "pack_type" : null,
              "codec" : "H.264",
              "duration" : 205,
              "video_size" : 14669824,
              "width" : 512,
              "hight" : 288,
              "bit_rate" : 534,
              "frame_rate" : 0,
              "quality" : null
            }
          } ]
        } ],
        "is_truncated" : 0,
        "total" : 1
      }

相关文档