convertVideoToGif

版本要求:
BizKit≥4.25.0@ray-js/ray≥1.7.76
支持平台:
iOSAndroid
import { convertVideoToGif } from '@ray-js/ray';

// Promise 调用
try {
  const res = await convertVideoToGif({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

方法签名
convertVideoToGif(params: )
SDK 最低版本
iOSThingSmartBizKitBizBundle
≥ 7.5.0
Androidcom.thingclips.smart:thingsmart-bizbundle-bizkit
≥ 7.5.0

描述

Video转Gif

参数

属性类型必填说明SDK 最低版本
videoFilePathstring是path Video文件路径—
widthnumber否width 宽度—
heightnumber否height 高度—
frameRatenumber是frameRate 帧率(每秒提取多少帧)—
startTimenumber否startTime 开始时间,单位秒—
durationTimenumber否duration 持续时间,单位秒—
complete() => void否接口调用结束的回调函数(调用成功、失败都会执行)—
success(params: Object) => void否接口调用成功的回调函数—
fail(params: Object) => void否接口调用失败的回调函数—
success 回调参数
属性类型说明SDK 最低版本
pathstringVideo转Gif输出 Gif文件路径—
fail 回调参数
属性类型说明
errorMsgstring错误信息
errorCodestring | number错误码
错误扩展

返回值

无

示例代码

import { downloadFile, convertVideoToGif } from '@ray-js/ray'

// Download a real video to a local path first, then convert it to a gif.
downloadFile({
  url:
    "https://images.tuyacn.com/rms-static/05b751a0-3596-11ed-acd5-2f6ea556a3fd-1663315397562.mp4",
  success: res => {
    const videoFilePath = res.tempFilePath || res.filePath || res.apFilePath;
    console.log("downloaded", videoFilePath);
    convertVideoToGif({
      videoFilePath: videoFilePath,
      frameRate: 5,
      startTime: 0,
      durationTime: 2,
      success: data => {
        console.log(data);
      },
      fail: error => {
        console.error(error);
      },
    });
  },
  fail: error => {
    console.error(error);
  },
});