convertVideoToGif(params: Object)

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

Description

Convert video to GIF

Parameters

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