getVideoInfo(params: Object)

Requires:
BaseKit≥2.5.0@ray-js/ray≥0.5.9
Platforms:
iOSAndroid
import { getVideoInfo } from '@ray-js/ray';

// Promise usage
try {
  const res = await getVideoInfo({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Description

Get video information

Parameters

PropertyTypeRequiredDescription
srcstringYesVideo file path; can be a temporary or permanent file path
complete() => voidNoCompletion callback (executed on both success and failure)
success(params: Object) => voidNoCallback on successful API call
fail(params: Object) => voidNoFailure callback
success callback parameters
PropertyTypeDescriptionBaseKit Since
widthnumberOriginal video width in px, ignoring rotationv3.2.6
heightnumberOriginal video height in px, ignoring rotationv3.2.6
orientationstringFrame 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 Exifv3.2.6
typestringVideo format, taken from media parsing results, e.g., mp4v3.2.6
durationnumberVideo duration in secondsv3.2.6
sizenumberVideo size, in kBv3.2.6
fpsnumberVideo frame ratev3.2.6
bitratenumberVideo bitrate, in kbpsv3.2.6
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

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),
});