PyPI or can be downloaded directly from GitHub.
pip install shotstack-sdk
Import the Shotstack SDK and required classes.
import shotstack_sdk as shotstack
from shotstack_sdk.api import edit_api
from shotstack_sdk.model.edit import Edit
Set the host and API key for your environment.
configuration = shotstack.Configuration(
host="https://api.shotstack.io/stage"
)
configuration.api_key['DeveloperKey'] = "YOUR_API_KEY"
Define the video asset with source URL and trim settings.
video_asset = shotstack.VideoAsset(
src="https://shotstack-assets.s3.amazonaws.com/footage/skater.mp4",
trim=3
)
Create clips, tracks, timeline and output configuration.
clip = shotstack.Clip(
asset=video_asset,
start=0,
length=8
)
track = shotstack.Track(clips=[clip])
timeline = shotstack.Timeline(tracks=[track])
output = shotstack.Output(
format="mp4",
resolution="sd"
)
edit = Edit(
timeline=timeline,
output=output
)
Send the edit to the API for rendering.
with shotstack.ApiClient(configuration) as api_client:
api_instance = edit_api.EditApi(api_client)
try:
response = api_instance.post_render(edit)
render_id = response['response']['id']
print(f"Render ID: {render_id}")
except Exception as e:
print(f"Exception: {e}")
The Python code above creates a JSON specification for trimming a video, sends it to the Shotstack API, and produces the edited video output.
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!
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.
Shotstack was EXACTLY what I was looking for, and incredibly easy to get started with. You guys are killing it.
Unlimited developer sandbox
No credit card required