# 查询视频信息

### 接口描述

```
1、通过子账号id和视频id，查询视频的详细信息
2、接口支持https协议
```

### 接口URL

```
http://api.polyv.net/v3/video/get-video-info
```

[在线API调用](https://git.polyv.net/help-center/document-center/-/blob/master/req.html?api=http:/api.polyv.net/v3/video/get-video-info/README.md)

### 请求方式

```
GET
```

### 接口约束

1、接口同时支持HTTP 、HTTPS ，建议使用HTTPS 确保接口安全，接口调用有频率限制，[详细请查看](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/limit/README.md)

### 请求参数描述

| 参数名       | 必选    | 类型     | 说明                                                                                                                                                                                                                                                                   |
| --------- | ----- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| appId     | true  | String | 保利威点播子账户appId，获取路径：保利威点播后台->设置->账号管理                                                                                                                                                                                                                                 |
| timestamp | true  | Long   | 当前时间的毫秒级时间戳，3分钟内有效                                                                                                                                                                                                                                                   |
| sign      | true  | String | 签名，32位大写MD5值【详见[MD5签名生成规则](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/buildSignMd5/README.md)】                                                                                                                                          |
| vids      | true  | String | <p>视频id，多个视频id用英文逗号分隔，例如：<br>"1b448be32370f4822ac40fd926112a66_1,1b448be323d66f3dae8db5af9f1fdce6_1"；<br>获取路径：保利威点播后台->视频列表；<br>也可以获取自【<a href="https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/video_upload/upload_video.md">上传视频</a>】；</p> |
| filter    | false | String | <p>选择需要返回的视频信息，多个以英文逗号分隔，默认为基础信息<br>basicInfo：基础信息<br>metaData：元数据<br>transcodeInfo：转码信息<br>snapshotInfo：截图信息<br>例如："basicInfo,metaData,transcodeInfo,snapshotInfo"</p>                                                                                              |

### 示例

```requestUrl
http://api.polyv.net/v3/video/get-video-info?filter=basicInfo%2CmetaData%2CtranscodeInfo%2CsnapshotInfo&vids=1b448be32370f4822ac40fd926112a66_1%2C1b448be323d66f3dae8db5af9f1fdce6_1&appId=a0Wmol5EwX&sign=A840DFCB355E7B3D23AC85EAD6089B18&timestamp=1617939194034

```

### 响应参数描述

| 参数名       | 类型      | 说明                                                                                                                                                                                             |
| --------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| code      | Integer | 响应状态码，200为成功返回，非200为失败【详见[全局错误说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/errorInfo/README.md)】                                                                |
| status    | String  | 响应状态文本信息                                                                                                                                                                                       |
| requestId | String  | 本次请求的业务流水号，便于客户端/服务器端排查问题                                                                                                                                                                      |
| error     | Object  | 响应失败时返回错误的详细信息【详见[error字段说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/sub_account/sub_get_video_info.md?id=error%E5%AD%97%E6%AE%B5%E8%AF%B4%E6%98%8E)】，响应成功时返回空 |
| data      | Array   | 响应成功时返回视频信息列表【详见[data字段说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/sub_account/sub_get_video_info.md?id=data%E5%AD%97%E6%AE%B5%E8%AF%B4%E6%98%8E)】，响应失败时返回空    |

#### error字段说明

| 字段   | 类型      | 说明                                                                                                            |
| ---- | ------- | ------------------------------------------------------------------------------------------------------------- |
| code | Integer | 错误码                                                                                                           |
| desc | String  | 错误描述【详见[全局错误说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/errorInfo/README.md)】 |

#### data字段说明

| 字段             | 类型     | 说明                                                                                                                                                                                                  |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| vid            | String | 视频id                                                                                                                                                                                                |
| basicInfo      | Object | 视频的基础信息 【详见[basicInfo字段说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/sub_account/sub_get_video_info.md?id=basicInfo%E5%AD%97%E6%AE%B5%E8%AF%B4%E6%98%8E)】             |
| metaData       | Object | 视频的元数据 【详见[metaData字段说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/sub_account/sub_get_video_info.md?id=metaData%E5%AD%97%E6%AE%B5%E8%AF%B4%E6%98%8E)】                |
| transcodeInfos | Array  | 视频的转码信息列表 【详见[transcodeInfos字段说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/sub_account/sub_get_video_info.md?id=transcodeInfos%E5%AD%97%E6%AE%B5%E8%AF%B4%E6%98%8E)】 |
| snapshotInfo   | Object | 视频的截图信息 【详见[snapshotInfo字段说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/sub_account/sub_get_video_info.md?id=snapshotInfo%E5%AD%97%E6%AE%B5%E8%AF%B4%E6%98%8E)】       |

#### basicInfo字段说明

| 字段            | 类型      | 说明                                                                                                                                                                                |
| ------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| title         | String  | 视频标题                                                                                                                                                                              |
| description   | String  | 视频描述                                                                                                                                                                              |
| duration      | Long    | 源视频时长，单位：秒                                                                                                                                                                        |
| coverURL      | String  | 首图地址，大图                                                                                                                                                                           |
| miniCoverURL  | String  | 首图地址，小图                                                                                                                                                                           |
| largeCoverURL | String  | 首图地址，大图，同coverURL                                                                                                                                                                 |
| creationTime  | String  | 创建时间                                                                                                                                                                              |
| updateTime    | String  | 更新时间                                                                                                                                                                              |
| size          | Long    | 源文件大小，单位：Bytes                                                                                                                                                                    |
| status        | Integer | 视频状态码，可以参考【[status字段说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/sub_account/sub_get_video_info.md?id=status%E5%AD%97%E6%AE%B5%E8%AF%B4%E6%98%8E)】 |
| cateId        | Long    | 分类id；其中1为根目录，即"默认分类"                                                                                                                                                              |
| cateName      | String  | 分类名称                                                                                                                                                                              |
| tags          | String  | 标签                                                                                                                                                                                |
| uploader      | String  | 上传者                                                                                                                                                                               |

#### metaData字段说明

| 字段       | 类型      | 说明                 |
| -------- | ------- | ------------------ |
| size     | Long    | 源文件大小，单位：Bytes     |
| format   | String  | 视频容器类型，如mp4、flv等   |
| duration | Long    | 源视频时长，单位：秒         |
| bitrate  | Integer | 视频码率，单位：bps        |
| fps      | Integer | 视频帧率               |
| height   | Integer | 分辨率高，单位：px         |
| width    | Integer | 分辨率宽，单位：px         |
| codec    | String  | 编码格式，例如：h264、h265等 |

#### transcodeInfos字段说明

| 字段         | 类型      | 说明                                                   |
| ---------- | ------- | ---------------------------------------------------- |
| playUrl    | String  | 播放地址                                                 |
| definition | String  | <p>清晰度<br>SOURCE：原清晰度<br>LD：普清<br>SD：标清<br>HD：高清</p> |
| bitrate    | Integer | 码率kbps                                               |
| duration   | Long    | 时长，秒                                                 |
| encrypt    | Boolean | <p>是否加密<br>1：加密视频<br>0：非加密</p>                       |
| format     | String  | 转码格式，如mp4、flv、pdx、hls                                |
| fps        | Integer | 视频帧率                                                 |
| height     | Integer | 分辨率高，单位：px                                           |
| width      | Integer | 分辨率宽，单位：px                                           |
| status     | String  | <p>视频状态<br>normal：可以正常播放<br>unavailable：不能正常播放</p>   |

#### snapshotInfo字段说明

| 字段       | 类型        | 说明      |
| -------- | --------- | ------- |
| imageUrl | String\[] | 截图url数组 |

#### status字段说明

| 视频状态码 | 说明    |
| ----- | ----- |
| 60/61 | 已发布   |
| 10    | 等待编码  |
| 20    | 正在编码  |
| 50    | 等待审核  |
| 51    | 审核不通过 |
| -1    | 已删除   |

### Java请求示例

快速接入基础代码请下载相关依赖源码， [点击下载源代码](https://git.polyv.net/help-center/document-center/-/blob/master/third_res/util.zip) ,下载后加入到自己的源码工程中即可。测试用例中的**HttpUtil.java 和 VodSignUtil.java** 都包含在下载文件中。

> 强烈建议您使用[点播Java SDK](https://git.polyv.net/help-center/document-center/-/blob/master/vod/java/README.md)完成API的功能对接，点播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。

```java
private static final Logger log = LoggerFactory.getLogger(VodSubAccountTest.class);

/**
 * 查询视频信息
 * @throws Exception
 * @throws NoSuchAlgorithmException
 */
@Test
public void testGetSubVideoInfo() throws Exception, NoSuchAlgorithmException {
        //公共参数,填写自己的实际参数
        String appId = super.appId;
        String appSecret = super.appSecret;
        String timestamp = String.valueOf(System.currentTimeMillis());

        //业务参数
        String url = "http://api.polyv.net/v3/video/get-video-info";
        String vids = "1b448be32370f4822ac40fd926112a66_1,1b448be323d66f3dae8db5af9f1fdce6_1";
        String filter = "basicInfo,metaData,transcodeInfo,snapshotInfo";

        Map<String, String> requestMap = new HashMap<>();
        requestMap.put("appId", appId);
        requestMap.put("timestamp", timestamp);
        requestMap.put("vids", vids);
        requestMap.put("filter", filter);

        //用md5进行签名，使用子账号的secretKey签名
        requestMap.put("sign", VodSignUtil.getSignMd5(requestMap, appSecret));
        String response = HttpUtil.get(url, requestMap);
        log.debug("测试查询视频信息,{}", response);
        //do somethings
}

```

### 响应示例

系统全局错误说明详见[全局错误说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/errorInfo/README.md)

成功示例

```json
{
  "requestId": "2a8a4861-5ab3-40b3-8855-1f9007347580",
  "code": 200,
  "status": "success",
  "error": null,
  "data": [
    {
      "vid": "1b448be32370f4822ac40fd926112a66_1",
      "basicInfo": {
        "title": "b",
        "description": "",
        "duration": 45,
        "coverURL": "https://img.videocc.net/uimage/1/http://img.videocc.net/uimage/1/1b448be323/6/1b448be32370f4822ac40fd926112a66_1_b.jpg",
        "creationTime": "2021-04-08 10:16:07",
        "updateTime": "2021-04-08 14:03:21",
        "size": 46573287,
        "status": 61,
        "cateId": 1617173363572,
        "cateName": "分类名称2222",
        "tags": "",
        "uploader": "主账号"
      },
      "metaData": {
        "size": 46573287,
        "format": "mp4",
        "duration": 45,
        "bitrate": 7871,
        "fps": 25,
        "height": 720,
        "width": 1280,
        "codec": "h264"
      },
      "transcodeInfos": [
        {
          "playUrl": null,
          "definition": "LD",
          "bitrate": 171,
          "duration": 45,
          "encrypt": true,
          "format": "pdx",
          "fps": 25,
          "height": 720,
          "width": 1280,
          "status": "normal"
        },
        {
          "playUrl": "https://hls.videocc.net/1b448be323/6/1b448be32370f4822ac40fd926112a66_1.m3u8",
          "definition": "LD",
          "bitrate": 171,
          "duration": 45,
          "encrypt": true,
          "format": "hls",
          "fps": 25,
          "height": 720,
          "width": 1280,
          "status": "normal"
        },
        {
          "playUrl": null,
          "definition": "SD",
          "bitrate": 733,
          "duration": 45,
          "encrypt": true,
          "format": "pdx",
          "fps": 25,
          "height": 720,
          "width": 1280,
          "status": "normal"
        },
        {
          "playUrl": "https://hls.videocc.net/1b448be323/6/1b448be32370f4822ac40fd926112a66_2.m3u8",
          "definition": "SD",
          "bitrate": 733,
          "duration": 45,
          "encrypt": true,
          "format": "hls",
          "fps": 25,
          "height": 720,
          "width": 1280,
          "status": "normal"
        },
        {
          "playUrl": null,
          "definition": "HD",
          "bitrate": 958,
          "duration": 45,
          "encrypt": true,
          "format": "pdx",
          "fps": 25,
          "height": 720,
          "width": 1280,
          "status": "normal"
        },
        {
          "playUrl": "https://hls.videocc.net/1b448be323/6/1b448be32370f4822ac40fd926112a66_3.m3u8",
          "definition": "HD",
          "bitrate": 958,
          "duration": 45,
          "encrypt": true,
          "format": "hls",
          "fps": 25,
          "height": 720,
          "width": 1280,
          "status": "normal"
        }
      ],
      "snapshotInfo": {
        "imageUrl": [
          "https://img.videocc.net/uimage/1/1b448be323/6/1b448be32370f4822ac40fd926112a66_0.jpg",
          "https://img.videocc.net/uimage/1/1b448be323/6/1b448be32370f4822ac40fd926112a66_1.jpg",
          "https://img.videocc.net/uimage/1/1b448be323/6/1b448be32370f4822ac40fd926112a66_2.jpg",
          "https://img.videocc.net/uimage/1/1b448be323/6/1b448be32370f4822ac40fd926112a66_3.jpg",
          "https://img.videocc.net/uimage/1/1b448be323/6/1b448be32370f4822ac40fd926112a66_4.jpg",
          "https://img.videocc.net/uimage/1/1b448be323/6/1b448be32370f4822ac40fd926112a66_5.jpg"
        ]
      }
    },
    {
      "vid": "1b448be323d66f3dae8db5af9f1fdce6_1",
      "basicInfo": {
        "title": "a",
        "description": "",
        "duration": 44,
        "coverURL": "https://img.videocc.net/uimage/1/1b448be323/6/1b448be323d66f3dae8db5af9f1fdce6_0_b.jpg",
        "creationTime": "2021-04-08 10:15:49",
        "updateTime": "2021-04-08 10:20:06",
        "size": 43721963,
        "status": 61,
        "cateId": 1617173363572,
        "cateName": "分类名称2222",
        "tags": "",
        "uploader": "主账号"
      },
      "metaData": {
        "size": 43721963,
        "format": "mp4",
        "duration": 44,
        "bitrate": 7577,
        "fps": 25,
        "height": 720,
        "width": 1280,
        "codec": "h264"
      },
      "transcodeInfos": [
        {
          "playUrl": null,
          "definition": "LD",
          "bitrate": 168,
          "duration": 44,
          "encrypt": true,
          "format": "pdx",
          "fps": 25,
          "height": 720,
          "width": 1280,
          "status": "normal"
        },
        {
          "playUrl": "https://hls.videocc.net/1b448be323/6/1b448be323d66f3dae8db5af9f1fdce6_1.m3u8",
          "definition": "LD",
          "bitrate": 168,
          "duration": 44,
          "encrypt": true,
          "format": "hls",
          "fps": 25,
          "height": 720,
          "width": 1280,
          "status": "normal"
        },
        {
          "playUrl": null,
          "definition": "SD",
          "bitrate": 669,
          "duration": 44,
          "encrypt": true,
          "format": "pdx",
          "fps": 25,
          "height": 720,
          "width": 1280,
          "status": "normal"
        },
        {
          "playUrl": "https://hls.videocc.net/1b448be323/6/1b448be323d66f3dae8db5af9f1fdce6_2.m3u8",
          "definition": "SD",
          "bitrate": 669,
          "duration": 44,
          "encrypt": true,
          "format": "hls",
          "fps": 25,
          "height": 720,
          "width": 1280,
          "status": "normal"
        },
        {
          "playUrl": null,
          "definition": "HD",
          "bitrate": 982,
          "duration": 44,
          "encrypt": true,
          "format": "pdx",
          "fps": 25,
          "height": 720,
          "width": 1280,
          "status": "normal"
        },
        {
          "playUrl": "https://hls.videocc.net/1b448be323/6/1b448be323d66f3dae8db5af9f1fdce6_3.m3u8",
          "definition": "HD",
          "bitrate": 982,
          "duration": 44,
          "encrypt": true,
          "format": "hls",
          "fps": 25,
          "height": 720,
          "width": 1280,
          "status": "normal"
        }
      ],
      "snapshotInfo": {
        "imageUrl": [
          "https://img.videocc.net/uimage/1/1b448be323/6/1b448be323d66f3dae8db5af9f1fdce6_0.jpg",
          "https://img.videocc.net/uimage/1/1b448be323/6/1b448be323d66f3dae8db5af9f1fdce6_1.jpg",
          "https://img.videocc.net/uimage/1/1b448be323/6/1b448be323d66f3dae8db5af9f1fdce6_2.jpg",
          "https://img.videocc.net/uimage/1/1b448be323/6/1b448be323d66f3dae8db5af9f1fdce6_3.jpg",
          "https://img.videocc.net/uimage/1/1b448be323/6/1b448be323d66f3dae8db5af9f1fdce6_4.jpg",
          "https://img.videocc.net/uimage/1/1b448be323/6/1b448be323d66f3dae8db5af9f1fdce6_5.jpg"
        ]
      }
    }
  ]
}

```

异常示例

```json
{
    "requestId": "89733cbd-85fd-480b-bbad-23d51c2197f6", 
    "code": 403, 
    "status": "error", 
    "error": {
        "code": 104, 
        "desc": "invalid signature"
    }, 
    "data": null
}

```
