Description

This endpoint allows users to trim a video from a specified URL based on start and end timestamps. The trimmed video is then uploaded to R2 storage, and the URL of the trimmed video is returned.

Endpoint

POST /api/v1/video-trim

Headers

  • Content-Type: application/json
  • Authorization: Bearer <API_KEY> (required)

Request Body

{
  "videoUrl": "string", // Required. The URL of the video to trim. Only MP4 videos are supported.
  "startTimestamp": "string", // Required. The start time of the trim in HH:MM:SS format.
  "endTimestamp": "string" // Required. The end time of the trim in HH:MM:SS format.
}

Responses

Success (200)

Returns the URL of the trimmed video and the number of credits used.

{
  "trimmedVideoUrl": "string", // URL of the trimmed video
  "creditsUsed": "number" // Number of credits used for this operation
}
  • X-RateLimit-Limit: The rate limit for the user.
  • X-RateLimit-Remaining: The remaining number of requests for the user.

Bad Request (400)

Returned if the request is invalid or missing required parameters.

{
  "error": "Error message describing the issue"
}

Internal Server Error (500)

Returned if there’s an error during the video trimming process.

{
  "error": "Failed to trim video"
}

Example Request

curl -X POST https://app.dumplingai.com/api/v1/video-trim \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
  "videoUrl": "https://example.com/video.mp4",
  "startTimestamp": "00:00:10",
  "endTimestamp": "00:00:30"
}'

Example Response

{
  "trimmedVideoUrl": "https://storage.example.com/trimmed-videos/abcdef123456.mp4",
  "creditsUsed": 5
}

Notes

  • The timestamp format should be HH:MM:SS (e.g., 00:01:15 for 1 minute and 15 seconds).
  • Credits used are calculated based on the duration of the output video (20 credits per minute, rounded up).
  • Output videos are limited to 200MB in size. You can reduce the size of the output video by trimming a smaller portion of the input video.
  • The trimmed video is temporarily stored (~24 hours).

Rate Limiting

Rate limit headers (X-RateLimit-Limit and X-RateLimit-Remaining) are included in the response to indicate the user’s current rate limit status.