Skip to content
Start here

Clip videos given a start and end time

client.stream.clip.create(ClipCreateParams { account_id, clippedFromVideoUID, endTimeSeconds, 7 more } params, RequestOptionsoptions?): Clip { allowedOrigins, clippedFromVideoUID, created, 12 more }
POST/accounts/{account_id}/stream/clip

Clips a video based on the specified start and end times provided in seconds.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Stream Write
ParametersExpand Collapse
params: ClipCreateParams { account_id, clippedFromVideoUID, endTimeSeconds, 7 more }
account_id: string

Path param: The account identifier tag.

maxLength32
clippedFromVideoUID: string

Body param: The unique video identifier (UID).

maxLength32
endTimeSeconds: number

Body param: Specifies the end time for the video clip in seconds.

startTimeSeconds: number

Body param: Specifies the start time for the video clip in seconds.

allowedOrigins?: Array<AllowedOrigins>

Body param: Lists the origins allowed to display the video. Enter allowed origin domains in an array and use * for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.

creator?: string

Body param: A user-defined identifier for the media creator.

maxLength64
maxDurationSeconds?: number

Body param: The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of -1 means the value is unknown.

maximum36000
minimum1
requireSignedURLs?: boolean

Body param: Indicates whether the video can be a accessed using the UID. When set to true, a signed token must be generated with a signing key to view the video.

thumbnailTimestampPct?: number

Body param: The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.

maximum1
minimum0
watermark?: Watermark

Body param

uid?: string

The unique identifier for the watermark profile.

maxLength32
ReturnsExpand Collapse
Clip { allowedOrigins, clippedFromVideoUID, created, 12 more }
allowedOrigins?: Array<AllowedOrigins>

Lists the origins allowed to display the video. Enter allowed origin domains in an array and use * for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.

clippedFromVideoUID?: string

The unique video identifier (UID).

maxLength32
created?: string

The date and time the clip was created.

formatdate-time
creator?: string

A user-defined identifier for the media creator.

maxLength64
endTimeSeconds?: number

Specifies the end time for the video clip in seconds.

maxDurationSeconds?: number

The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of -1 means the value is unknown.

maximum36000
minimum1
meta?: unknown

A user modifiable key-value store used to reference other systems of record for managing videos.

modified?: string

The date and time the live input was last modified.

formatdate-time
playback?: Playback { dash, hls }
dash?: string

DASH Media Presentation Description for the video.

hls?: string

The HLS manifest for the video.

preview?: string

The video's preview page URI. This field is omitted until encoding is complete.

formaturi
requireSignedURLs?: boolean

Indicates whether the video can be a accessed using the UID. When set to true, a signed token must be generated with a signing key to view the video.

startTimeSeconds?: number

Specifies the start time for the video clip in seconds.

status?: "pendingupload" | "downloading" | "queued" | 4 more

Specifies the processing status for all quality levels for a video.

One of the following:
"pendingupload"
"downloading"
"queued"
"inprogress"
"ready"
"error"
"live-inprogress"
thumbnailTimestampPct?: number

The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.

maximum1
minimum0
watermark?: Watermark { uid }
uid?: string

The unique identifier for the watermark profile.

maxLength32

Clip videos given a start and end time

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const clip = await client.stream.clip.create({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  clippedFromVideoUID: '023e105f4ecef8ad9ca31a8372d0c353',
  endTimeSeconds: 0,
  startTimeSeconds: 0,
});

console.log(clip.clippedFromVideoUID);
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "allowedOrigins": [
      "example.com"
    ],
    "clippedFromVideoUID": "023e105f4ecef8ad9ca31a8372d0c353",
    "created": "2014-01-02T02:20:00Z",
    "creator": "creator-id_abcde12345",
    "endTimeSeconds": 0,
    "maxDurationSeconds": 1,
    "meta": {
      "name": "video12345.mp4"
    },
    "modified": "2014-01-02T02:20:00Z",
    "playback": {
      "dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd",
      "hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8"
    },
    "preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch",
    "requireSignedURLs": true,
    "startTimeSeconds": 0,
    "status": "inprogress",
    "thumbnailTimestampPct": 0.529241,
    "watermark": {
      "uid": "ea95132c15732412d22c1476fa83f27a"
    }
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "allowedOrigins": [
      "example.com"
    ],
    "clippedFromVideoUID": "023e105f4ecef8ad9ca31a8372d0c353",
    "created": "2014-01-02T02:20:00Z",
    "creator": "creator-id_abcde12345",
    "endTimeSeconds": 0,
    "maxDurationSeconds": 1,
    "meta": {
      "name": "video12345.mp4"
    },
    "modified": "2014-01-02T02:20:00Z",
    "playback": {
      "dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd",
      "hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8"
    },
    "preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch",
    "requireSignedURLs": true,
    "startTimeSeconds": 0,
    "status": "inprogress",
    "thumbnailTimestampPct": 0.529241,
    "watermark": {
      "uid": "ea95132c15732412d22c1476fa83f27a"
    }
  }
}