跳转到主要内容
POST
/
clip
TypeScript
import { Livepeer } from "livepeer";

const livepeer = new Livepeer({
  apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await livepeer.stream.createClip({
    playbackId: "eaw4nk06ts2d0mzb",
    startTime: 1587667174725,
    endTime: 1587667174725,
    name: "My Clip",
    sessionId: "de7818e7-610a-4057-8f6f-b785dc1e6f88",
  });

  // Handle the result
  console.log(result);
}

run();
{
  "asset": {
    "id": "09F8B46C-61A0-4254-9875-F71F4C605BC7",
    "source": {
      "type": "url",
      "url": "<string>",
      "gatewayUrl": "<string>",
      "encryption": "<unknown>"
    },
    "name": "filename.mp4",
    "type": "video",
    "playbackId": "eaw4nk06ts2d0mzb",
    "userId": "66E2161C-7670-4D05-B71D-DA2D6979556F",
    "playbackUrl": "https://livepeercdn.com/asset/ea03f37e-f861-4cdd-b495-0e60b6d753ad/index.m3u8",
    "downloadUrl": "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video/download.mp4",
    "playbackPolicy": {
      "type": "webhook",
      "webhookId": "1bde4o2i6xycudoy",
      "webhookContext": {
        "streamerId": "my-custom-id"
      },
      "refreshInterval": 600,
      "allowedOrigins": [
        "<string>"
      ]
    },
    "creatorId": {
      "type": "unverified",
      "value": "user123"
    },
    "profiles": [
      {
        "bitrate": 3000000,
        "width": 1280,
        "name": "720p",
        "height": 720,
        "quality": 23,
        "fps": 30,
        "fpsDen": 1,
        "gop": 2,
        "profile": "H264Baseline",
        "encoder": "H.264"
      }
    ],
    "storage": {
      "ipfs": {
        "spec": {},
        "nftMetadata": {
          "cid": "<string>",
          "url": "<string>",
          "gatewayUrl": "<string>"
        },
        "updatedAt": 1587667174725
      },
      "status": {
        "phase": "ready",
        "tasks": {
          "pending": "09F8B46C-61A0-4254-9875-F71F4C605BC7",
          "last": "09F8B46C-61A0-4254-9875-F71F4C605BC7",
          "failed": "09F8B46C-61A0-4254-9875-F71F4C605BC7"
        },
        "progress": 0.5,
        "errorMessage": "Failed to update storage"
      }
    },
    "status": {
      "phase": "uploading",
      "updatedAt": 1587667174725,
      "progress": 123,
      "errorMessage": "<string>"
    },
    "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9",
    "createdAt": 1587667174725,
    "createdByTokenName": "<string>",
    "size": 84934509,
    "hash": [
      {
        "hash": "9b560b28b85378a5004117539196ab24e21bbd75b0e9eb1a8bc7c5fd80dc5b57",
        "algorithm": "sha256"
      }
    ],
    "videoSpec": {
      "format": "mp4",
      "duration": 23.8328,
      "bitrate": 1000000,
      "tracks": [
        {
          "type": "video",
          "codec": "aac",
          "startTime": 23.8238,
          "duration": 23.8238,
          "bitrate": 1000000,
          "width": 1920,
          "height": 1080,
          "pixelFormat": "yuv420p",
          "fps": 30,
          "channels": 2,
          "sampleRate": 44100,
          "bitDepth": 16
        }
      ]
    }
  },
  "task": {
    "id": "34d7618e-fd42-4798-acf5-19504616a11e"
  }
}

创建剪辑

授权

Authorization
string
header
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求体

application/json
playbackId
string
必填

The playback ID of the stream or stream recording to clip. Asset playback IDs are not supported yet.

示例:

"eaw4nk06ts2d0mzb"

startTime
number
必填

The start timestamp of the clip in Unix milliseconds. See the ClipTrigger in the UI Kit for an example of how this is calculated (for HLS, it uses Program Date-Time tags, and for WebRTC, it uses the latency from server to client at stream startup).

示例:

1587667174725

endTime
number

The end timestamp of the clip in Unix milliseconds. See the ClipTrigger in the UI Kit for an example of how this is calculated (for HLS, it uses Program Date-Time tags, and for WebRTC, it uses the latency from server to client at stream startup).

示例:

1587667174725

name
string

The optional friendly name of the clip to create.

示例:

"My Clip"

sessionId
string

The optional session ID of the stream to clip. This can be used to clip recordings - if it is not specified, it will clip the ongoing livestream.

示例:

"de7818e7-610a-4057-8f6f-b785dc1e6f88"

响应

Success

asset
object
必填
task
object
必填
Last modified on March 3, 2026