---
name: "getVideoInfo"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.5.0" }
platform:
  - "iOS"
  - "Android"
async: true
title: "getVideoInfo - 获取视频信息"
---

## getVideoInfo

> [VERSION] BaseKit >= 2.5.0

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Get video information

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `src` | `string` | Yes | - | `2.5.0` | Video file path; can be a temporary or permanent file path |
| `complete` | `() => void` | No | - | - | Callback invoked when the API call completes (runs on both success and failure) |
| `success` | `(params: Object) => void` ↓see below | No | - | - | Callback function on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Callback function on API call failure |

#### success callback parameters

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `width` | `number` | `3.2.6` | Original video width in px. Rotation not considered. |
| `height` | `number` | `3.2.6` | Original video height in px. Rotation not considered. |
| `orientation` | `string` | `3.2.6` | Orientation Valid values	Description up	Default orientation (phone held in landscape), corresponds to Exif 1, or no orientation information. up-mirrored	Same as up, but mirrored; corresponds to Exif 2 down	Rotated 180°, corresponds to Exif 3 down-mirrored	Same as down, but mirrored; corresponds to Exif 4 left-mirrored	Same as left, but mirrored; corresponds to Exif 5 right	Rotated 90° clockwise, corresponds to Exif 6 right-mirrored	Same as right, but mirrored; corresponds to Exif 7 left	Rotated 90° counterclockwise, corresponds to Exif 8 |
| `type` | `string` | `3.2.6` | Video format, from media parsing, e.g., mp4 |
| `duration` | `number` | `3.2.6` | Video duration, in seconds |
| `size` | `number` | `3.2.6` | Video size, in kB |
| `fps` | `number` | `3.2.6` | Video frame rate |
| `bitrate` | `number` | `3.2.6` | Video bitrate, in kbps |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Extended error code |
| `errorMsg` | `string` | Extended error information |


### Examples

```tsx
// Get video info: download the video first, then call with the protocol path tempFilePath returned in the callback
ty.downloadFile({
  url: "https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/ttttestfile/test_video.mp4",
  success: ({ tempFilePath }) => {
    ty.getVideoInfo({
      src: tempFilePath,
      success: data => console.log("Width/Height/Duration/Format:", data.width, data.height, data.duration, data.type),
      fail: error => console.error(error),
    });
  },
  fail: error => console.error(error),
});
```
