Goal
Create a finished video clip or poster and obtain the exact output file.Prerequisites
- Node.js 20+ for the examples; no SDK package is required
- A server-side token with assets:read, assets:process and assets:write; an authorized Assets space ID
- A clean, ready video with an authorized current native video package; sufficient processing allowance and advanced-transform entitlement
Workflow
1
Upload a video and prepare its current version for native processing.
2
Render the trim or poster recipe below.
3
Wait for completed status and use the derivative ID returned by that job.
4
Download the output or mint its short-lived URL immediately before external processing.
Before you render
For Cloudinary users: start/end offsets map to the trim operation; a poster offset maps to timestamp. These are JSON recipes submitted to the API, not Cloudinary transformation strings appended to a CDN URL. Check GET /assets/capabilities and your plan before integrating. Native video packaging and Studio editing are separate operations. After upload, use POST /assets/{assetID}/versions/{versionID}/video when processing is needed, then GET /assets/{assetID}/video until the current package is ready and review permits use. Follow the native video guide for package states; a completed upload alone is not an editable video. Management requests use /api/v1 and return a success/data envelope. X-Asset-Space-ID selects your authorized space. The examples assume an existing video ID in that space. Do not put the permanent token in browser JavaScript.Shared request and job-polling helper
Run this helper first, then the recipe you need. Export STACKSHIFT_ASSETS_TOKEN and STACKSHIFT_ASSET_SPACE_ID in your server environment. A 202 response is acceptance, not a finished file. The ten-minute polling budget is an example client timeout, not a processing guarantee. Resume the same job after that timeout rather than resubmitting it. The transform service derives an idempotency key from the asset, source checksum and normalized recipe when you omit one. If you supply Idempotency-Key yourself, use a different key when the source or recipe changes.Trim from 5 seconds to 20 seconds, keeping audio
This produces a 15-second MP4. Start is inclusive of the selected range; end must be greater than start and within source duration. Leave muted false to retain the first audio track when present. Video is encoded as H.264 and audio as AAC stereo; this is not lossless stream copying or preservation of every audio track.Create a JPEG poster at 12.5 seconds
Timestamp is relative to the original source video. To take a poster relative to an edited clip, first save that clip as an asset and use the new asset as the source after it is ready. Use format jpeg in the API even when your downloaded filename ends in .jpg. Choose a timestamp before the last frame.Download the exact rendered file
The completed job result is the derivative record, including id, output_kind, mime_type, size and status. It is not the original asset ID. GET /assets/{assetID}/derivatives also lists results, but do not select its first row: another recipe or source version can have produced it. Set ASSET_ID to the source video and OUTPUT_ID to clipId or posterId. Change the output filename to poster.jpg when downloading the poster. This authenticated endpoint returns file bytes, not JSON. Use ?info=true separately to inspect output metadata.Give an external AI service a download URL
The signed derivative URL expires in 15 minutes and is bound to the issuer access, source version and output. Mint it shortly before the provider fetches the file. Send the returned URL to that provider using its own documented media-input field; never send your StackShift API token. For a provider that queues retrieval beyond the expiry, download and upload the bytes using its file API, or mint a fresh URL when retrieval begins. Do not treat an expiring signed URL as a permanent database reference. Keep the asset and derivative IDs. Replacing the source or revoking access can invalidate the URL.Keep the edited video as a separate asset
POST /assets/{assetID}/derivatives/{outputID}/save copies a video-source Studio output into a new private asset in the default bucket. The response data is the new asset. Store its ID and wait for its own scan/processing readiness before delivery. This separates the saved output from the original source lifecycle; it does not make it public.Expected result
Create a finished video clip or poster and obtain the exact output file.
Common failures
Related guides
Edit videos in Video Studio
Trim, crop, resize, overlay, extract audio and create poster frames before packaging video for delivery.
Native video processing and secure playback
Version-pinned video packages, scan and review gates, replacement behavior, playback sessions, API routes, and failure recovery.
Deterministic image, video, and audio transforms
Define ordered v2 transforms for images, video renditions, audio extraction, and timestamp thumbnails; store eager presets or materialize durable derivatives.
Import generated videos from an external URL
Copy an AI-generated MP4 into permanent Assets storage using a constrained remote-URL capability, then track readiness and deliver it safely.
Blur images and create a 1200×630 social preview
Build an exact-size JPEG social card with ordered crop and blur operations, then choose durable public delivery or private access.