---
name: "getVideoInfo"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.5.0" }
  - { name: "@ray-js/ray", version: "0.5.9" }
platform:
  - "iOS"
  - "Android"
async: true
---

## getVideoInfo

> [VERSION] BaseKit >= 2.5.0 | @ray-js/ray >= 0.5.9

> [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 | - | - | Completion callback (executed on both success and failure) |
| `success` | `(params: Object) => void` ↓see below | No | - | - | Callback on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### success callback parameters

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `width` | `number` | `3.2.6` | Original video width in px, ignoring rotation |
| `height` | `number` | `3.2.6` | Original video height in px, ignoring rotation |
| `orientation` | `string` | `3.2.6` | Frame orientation Valid values	Description up	Default orientation (phone held horizontally), corresponds to 1 in Exif; or no orientation info. up-mirrored	Same as up, but mirrored; corresponds to 2 in Exif down	Rotated 180°, corresponds to 3 in Exif down-mirrored	Same as down, but mirrored; corresponds to 4 in Exif left-mirrored	Same as left, but mirrored; corresponds to 5 in Exif right	Rotated 90° clockwise, corresponds to 6 in Exif right-mirrored	Same as right, but mirrored; corresponds to 7 in Exif left	Rotated 90° counterclockwise, corresponds to 8 in Exif |
| `type` | `string` | `3.2.6` | Video format, taken from media parsing results, 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` | Error extension code |
| `errorMsg` | `string` | Error extension message |


### Examples

#### Demo

```tsx
import { downloadFile, getVideoInfo } from '@ray-js/ray'

// Get video info: download the video first, then call using the returned scheme path tempFilePath
downloadFile({
  url: "https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/ttttestfile/test_video.mp4",
  success: ({ tempFilePath }) => {
    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),
});
```
