clipVideo(params: Object)

Requires:
BaseKit≥3.14.2@ray-js/ray≥1.5.33
Platforms:
iOSAndroid
import { clipVideo } from '@ray-js/ray';

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

Description

Trim video

Parameters

PropertyTypeRequiredDescription
filePathstringYesVideo file path; can be a temporary file path or a permanent file path (local path)
startTimenumberYesStart time, in milliseconds
endTimenumberYesEnd time, in milliseconds
levelnumberYesTarget compressed resolution 1 - 480x854 Bitrate: 1572x1000 2 - 540x960 Bitrate: 2128x1000 3 - 720x1280 Bitrate: 3145x1000 4 - 1080x1920 Bitrate: 3500x1000
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
videoClipPathstringTrimmed video path
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

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

// Trim video: download the video first, then call with the protocol path tempFilePath; level 1–4 corresponds to resolution presets (1=480×854)
downloadFile({
  url: "https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/ttttestfile/test_video.mp4",
  success: ({ tempFilePath }) => {
    clipVideo({
      filePath: tempFilePath,
      startTime: 0,
      endTime: 3000,
      level: 1,
      success: data => console.log("Trimmed video path:", data.videoClipPath),
      fail: error => console.error("Trim failed:", JSON.stringify(error)),
    });
  },
  fail: error => console.error("Download failed:", JSON.stringify(error)),
});