Trim the start and end of a video to create a shortened clip
Trim a video by cutting off the start, end or both. This demo application shows you a how you can upload or fetch a video from a URL, set a start and end time and render a new trimmed video clip. A simple form allows you to see the total clip length and select the in and out points.
The original video file and time settings are posted to a backend script that creates a JSON payload with the edit parameters. The JSON is posted to the Shotstack video editing API and after a few seconds the video is rendered to the new length and the URL is sent back to be displayed on the web page.
This is a simple example of what can be done with the API. You might adapt this functionality as part of a simple workflow to trim an hour long stream in to shorter segments for social media, or it might be a component of a broader online video editing application.
This demo is available as an open source project built using basic HTML, Bootstrap and a simple jQuery script. The backend uses Node.js and Express and can be one-click installed as a Serverless application.
curl --request POST 'https://api.shotstack.io/v1/render' \
--header 'x-api-key: YOUR_API_KEY' \
--data-raw '{
"timeline": {
"tracks": [
{
"clips": [
{
"asset": {
"type": "video",
"src": "https://shotstack-assets.s3.amazonaws.com/footage/beach-overhead.mp4"
},
"start": 0,
"length": "auto"
}
]
}
]
},
"output": {
"format": "mp4",
"size": {
"width": 1280,
"height": 720
}
}
}'