Video trimming involves cutting an existing video into shorter fragments. A purpose of this is to make a clip that can be easily shared on social media from a longer video recording. Here is an example of how to trim a video using an API:
curl -s -X POST https://api.creatomate.com/v1/renders \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
--data-binary @- << EOF
{
"source": {
"output_format": "mp4",
"elements": [
{
"type": "video",
"source": "https://cdn.creatomate.com/demo/mountains.mp4",
"trim_start": 1,
"trim_duration": 3
}
]
}
}
EOF
How it works: In this example, we're using Creatomate's video editing API. This REST API works by running video operations that are defined as JSON. All the operations are done in the cloud, and once the video is created, it's returned as an MP4 file.
As shown in the JSON code, we are defining a simple composition using a single video element with the "trim_start" and "trim_duration" attributes. This trims the video clip at 1 second from the beginning and for a duration of 3 seconds.
If you want to perform more advanced video editing tasks, try out the video editor below. Aside from trimming videos by API, this online tool also simplifies other video editing tasks, such as adding watermarks, captions, and merging videos, all of which can be performed through a RESTful API.