Python Video Editor

Build video applications and workflows using a Python video editing library and the Shotstack API. Python video processing made easy.

Python video editing library


Used every day by developers at businesses large and small

Coca Cola

Edit videos using the Shotstack Python video editing library. The fully managed API makes it quick and easy to build video based applications in days, not months.

Available as an open source Python package on PyPI or from GitHub. The demo repository is also available that shows you how to get started generating video using Python. The SDK and demo projects connect to the Shotstack video editing API - a cloud hosted, fully managed video editing platform.

Using Shotstack and Python you can cut and trim videos, stitch clips, add transitions, filters and effects. Merge videos, images and audio files using Python, the language you are familiar with.


The Shotstack Python video editing library is available for Python version 3 and can be installed from PyPI.

pip install shotstack_sdk


1. Import the library

Import the library in to your script.

import shotstack_sdk as shotstack
2. Import features

Import the editing features needed for your video edit.

from shotstack_sdk.api import edit_api
from shotstack_sdk.model.video_asset import VideoAsset
from shotstack_sdk.model.clip import Clip
from shotstack_sdk.model.track import Track
from shotstack_sdk.model.timeline import Timeline
from shotstack_sdk.model.output import Output
from shotstack_sdk.model.edit import Edit
3. Configure the API client

Configure the API client to use either the free developer sandbox or the v1 production API.

configuration = shotstack.Configuration(host = '')
4. Authenticate

Copy your API key for the sandbox or v1 environment from the dashboard and set the `DeveloperKey`. You should load the key using environment variables in a production environment.

configuration.api_key['DeveloperKey'] = 'H7jKyj90kd09lbLOF7J900jNbSWS67X87xs9j0cD'
5. Trim a video clip

A simple use case for Shotstack is trim a video. In the example below the first 3 seconds are trimmed from the start of the skater.hd.mp4 video. The video then plays for 8 seconds. The start point of 0 plays the click form the start of the timeline, i.e. immediately.

video_asset = VideoAsset(
src = "",
trim = 3.0

video_clip = Clip(
asset = video_asset,
start = 0.0,
length = 8.0
6. Add the clip to a track

Videos, images and text can be layered on top of each other using tracks. In this example there is only one video added to a single track.

track = Track(clips=[video_clip])
7. Add the track to the timeline

Tracks are added to the timeline. The timeline accepts an array of tracks as well as a background color.

timeline = Timeline(
background = "#000000",
tracks = [track]
8. Set the video output specification

The video output specification is defined including the resolution and format, such as an mp4 SD video.

output = Output(
format = "mp4",
resolution = "sd"
9. Create the video edit

Finally everything is put together as an edit, including the timeline and output format.

edit = Edit(
timeline = timeline,
output = output
10. POST the edit to the API

The SDK post_render method prepares the edit to the Shotstack JSON specification and posts it to the API. The response includes a render ID of the video which renders in the background.

api_response = api_instance.post_render(edit)
id = api_response['response']['id']
print(f">> python examples/ {id}")
10. Get the rendered video URL

Videos render in the background and can take a few seconds to minutes depending on the length. The status can be polled using the id returned in step 9.

api_response = api_instance.get_render(id)
status = api_response['response']['status']

if status == "done":
url = api_response['response']['url']
print(f">> Asset URL: {url}")


After a few seconds the render will complete and the status request will return the URL of a video file.


Check our Python video editing examples and demos on GitHub


See what else the Shotstack API can do

This application is the perfect example of a well executed and documented API. In less than 10 mins, set up, web hook done, and first render! Mike Maberry,
There are a couple of other options out there that attempt to provide the same or similar solution, but none of them come close in terms of quality, ease of use, and speed. Adam Chubbuck, Software Engineer
Shotstack was EXACTLY what I was looking for, and incredibly easy to get started with. You guys are killing it. Colin Plamondon,

Experience Shotstack for yourself, with no risk, and generate your first video in 15 minutes.