Ruby Video Editor

Add video, image and audio editing functionality to your Ruby applications and workflows using the Shotstack Ruby video editor SDK..

Edit video using Ruby

LOVED BY DEVELOPERS

Used every day by developers at businesses large and small

Twitter
McDonalds
Nike
Coca Cola
IKEA
Randstad

The Shotstack SDK for Ruby will get your video editing application up and running in days, not months.

The Ruby video editing SDK is available as a Ruby gem or directly from the Shotstack Github repo. The SDK works directly with Shotstack, the fully managed cloud based video editor, meaning you don't need to spend time or money on the infrastructure and can focus on creativity.

The Ruby gem simplifies the process of working with the Shotstack API, unlocking all the video editing features you need, including cut and trim, stitching clips, transitions, filters and effects.

Installation

The Shotstack Ruby video editing library is available as a gem and can be installed directly from Ruby Gems or downloaded from GitHub.

gem install shotstack

Usage

1. Require the gem

Add the library to your script.

require "shotstack"
2. Authentication and configuration

Use your own API key and point the base path to stage or v1. In production, make sure you pass the key via environment variables to keep it secure.

Shotstack.configure do |config|
config.api_key['x-api-key'] = "H7jKyj90kd09lbLOF7J900jNbSWS67X87xs9j0cD"
config.host = "api.shotstack.io"
config.base_path = "stage"
end
3. Trim a video

One of the many features the video editing API can do is trim a video. For this example we trim the start and end of a video clip. Setting the video asset trim to 3 will remove the first 3 seconds from the start. Setting the length to 8 will play the next 8 seconds. A start value of 0 makes the video play straight away, at second 0.

video_asset = Shotstack::VideoAsset.new(
src: "https://s3-ap-southeast-2.amazonaws.com/shotstack-assets/footage/skater.hd.mp4",
trim: 3
)

video_clip = Shotstack::Clip.new(
asset: video_asset,
start: 0,
length: 8
)
4. Add the clip to a track

Tracks are layers composed of titles, images, audio, html or video segments added on top of each other. This edit has a single clip added to a track.

track = Shotstack::Track.new(clips: [video_clip])
5. Add the track to the timeline

The timeline represents all the content (video, audio, images) of the edit over time, made up of one or more tracks.

timeline = Shotstack::Timeline.new(
background: "#000000",
tracks: [track]
)
6. Set the video output specification

Set the output format and resolution. For this edit, the output format is set to mp4 and the resolution to SD.

output = Shotstack::Output.new(
format: "mp4",
resolution: "sd"
)
7. Create the video edit

Add the timeline and the output format to the final edit.

edit = Shotstack::Edit.new(
timeline: timeline,
output: output
)
8. POST the edit to the API

The SDK will generate the JSON payload based on your config and will post it to the API, returning a response object, containing the ID.

api_client = Shotstack::EditApi.new
response = api_client.post_render(edit).response
9. Get the rendered video URL

Finally, query the render status and output the video URL when the render is done.

api_client = Shotstack::EditApi.new
response = api_client.get_render(id, { data: false, merged: true }).response
if response.status == "done"
puts ">> Asset URL: #{response.url}"
end

Output

The Ruby code above prepares a JSON payload, describing the video editing parameters to trim a video clip, POST's it to the Shotstack API and generate this video.

EXPLORE

Check our Ruby video editing examples and demos on GitHub

DISCOVER

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, Gunslinger.dev
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, thebeam.fm

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