Skip to main content

Video Clipping and Trimming Guide for Teyuto API

Video clipping and trimming are essential features for content creators and editors. This guide will explore how these operations might be performed using the Teyuto API. Please note that the exact implementation may vary, and you should always refer to the most up-to-date Teyuto API documentation for specific details.

Understanding Video Clipping and Trimming

  • Clipping: Creating a new, shorter video from a portion of an existing video.
  • Trimming: Removing portions from the beginning or end of a video.

Hypothetical API Endpoints

While the current API specification doesn't explicitly mention these operations, here's how they might be implemented:

  1. POST /videos/{id}/clip: Create a new video by clipping a portion of an existing video.
  2. PATCH /videos/{id}/trim: Trim an existing video by removing portions from the start or end.

Video Clipping

Creating a Clip

To create a new video clip:

  1. Use the hypothetical POST /videos/{id}/clip endpoint
  2. Set up your request headers:
    Content-Type: application/json
    Accept: application/json
    Authorization: YOUR_API_KEY
  3. In the request body, include:
    • start_time: The starting point of the clip (in seconds or timecode format)
    • end_time: The ending point of the clip
    • new_title: Title for the new clipped video

Example cURL request:

curl -X POST "https://api.teyuto.tv/v2/videos/12345/clip" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d '{
"start_time": "00:01:30",
"end_time": "00:02:45",
"new_title": "Highlight Clip"
}'

Video Trimming

Trimming a Video

To trim an existing video:

  1. Use the hypothetical PATCH /videos/{id}/trim endpoint
  2. Set up your request headers as before
  3. In the request body, include:
    • trim_start: Time to trim from the start (optional)
    • trim_end: Time to trim from the end (optional)

Example cURL request:

curl -X PATCH "https://api.teyuto.tv/v2/videos/12345/trim" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: YOUR_API_KEY" \
-d '{
"trim_start": "00:00:10",
"trim_end": "00:00:05"
}'

This request would remove the first 10 seconds and the last 5 seconds of the video.

Best Practices

  1. Precision: Always use precise timecodes or second values to ensure accurate clipping and trimming.

  2. Original Preservation: When possible, keep the original video intact and create new versions through clipping rather than trimming the original.

  3. Testing: Always test the clipped or trimmed video to ensure the desired portion has been captured or removed.

  4. Metadata: Update metadata (like duration, description) for clipped or trimmed videos to reflect the new content accurately.

  5. Error Handling: Implement proper error handling to manage cases where the specified time ranges are invalid or outside the video duration.

  6. User Permissions: Ensure that users have the necessary permissions to perform clipping and trimming operations on videos.

Considerations

  • Processing Time: Video clipping and trimming operations may not be instantaneous. The API might return a job ID that you can use to check the status of the operation.

  • Storage: Consider how clipped videos will be stored and managed within your Teyuto account.

  • Quality: Be aware of any potential quality loss that might occur during the clipping or trimming process.

Conclusion

While the current Teyuto API specification doesn't explicitly cover video clipping and trimming, these are common operations in video management. If these features are important for your use case, we recommend reaching out to Teyuto's support team or checking their latest documentation for the most up-to-date information on how to perform these operations.

Remember, the exact implementation may differ from what's described here, but the general principles of specifying time ranges for clipping and trimming should apply across most video processing APIs.

Tus Client is available for JavaScript, React Native, Flutter, PHP, .NET, and many other platforms. View the full list here.

Use this method to get TUS' session parameters: the hostname of the server to upload to, and a secure token.

The general sequence of actions for a direct upload of a video is as follows:

  1. Create a video entity via the POST method.
  2. Get TUS' session parameters (you are here now): https://api.teyuto.tv/v2/videos/{idVideo}/signed/upload
    API Documentation
  3. Upload the file via the TUS client. Choose your implementation from the list of available clients.

The final endpoint for uploading is constructed using the following template: https://{hostname}/upload/. You also need to provide the token, client_id, and video_id as metadata.

A short JavaScript example is shown below, based on tus-js-client. The variable data below is the result of this API request.

Please note that we support only version 2.x of tus-js-client.

<script src="https://cdn.jsdelivr.net/npm/tus-js-client@latest/dist/tus.min.js"></script>
uploads[data.video.id] = new tus.Upload(file, {
endpoint: `https://${data.hostname}/upload/`,
autoRetry: true, // optional
retryDelays: [0, 3000, 5000, 10000, 20000], // optional
chunkSize: 10000000, // mandatory if uploading files greater than 10 GB
metadata: {
filename: data.video_name,
token: data.token,
video_id: data.video_id,
client_id: data.client_id
},
onSuccess: function() {
// Handle success
}
});
uploads[data.video.id].start();