convertVideoToGif

Requires:
BizKit≥4.25.0@ray-js/ray≥1.7.76
Platforms:
iOSAndroid
import { convertVideoToGif } from '@ray-js/ray';

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

Method signature
convertVideoToGif(params: )
Minimum SDK versions
iOSThingSmartBizKitBizBundle
≥ 7.5.0
Androidcom.thingclips.smart:thingsmart-bizbundle-bizkit
≥ 7.5.0

Description

Convert video to GIF

Parameters

PropertyTypeRequiredDescriptionMinimum SDK versions
videoFilePathstringYespath Path to the video file—
widthnumberNowidth Width—
heightnumberNoheight Height—
frameRatenumberYesframeRate Frame rate (frames extracted per second)—
startTimenumberNostartTime Start time in seconds—
durationTimenumberNoduration Duration in seconds—
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
PropertyTypeDescriptionMinimum SDK versions
pathstringVideo-to-GIF output GIF file path—
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

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