shotstack 0.1.8 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1099 -11
  3. data/lib/shotstack/api/edit_api.rb +80 -8
  4. data/lib/shotstack/api/serve_api.rb +7 -7
  5. data/lib/shotstack/api_client.rb +3 -3
  6. data/lib/shotstack/api_error.rb +1 -1
  7. data/lib/shotstack/configuration.rb +8 -5
  8. data/lib/shotstack/models/asset_render_response.rb +1 -1
  9. data/lib/shotstack/models/asset_response.rb +1 -1
  10. data/lib/shotstack/models/asset_response_attributes.rb +1 -1
  11. data/lib/shotstack/models/asset_response_data.rb +1 -1
  12. data/lib/shotstack/models/audio_asset.rb +1 -1
  13. data/lib/shotstack/models/clip.rb +15 -6
  14. data/lib/shotstack/models/crop.rb +1 -1
  15. data/lib/shotstack/models/edit.rb +14 -2
  16. data/lib/shotstack/models/flip_transformation.rb +234 -0
  17. data/lib/shotstack/models/font.rb +1 -1
  18. data/lib/shotstack/models/html_asset.rb +1 -1
  19. data/lib/shotstack/models/image_asset.rb +2 -2
  20. data/lib/shotstack/models/luma_asset.rb +1 -1
  21. data/lib/shotstack/models/merge_field.rb +236 -0
  22. data/lib/shotstack/models/offset.rb +1 -1
  23. data/lib/shotstack/models/output.rb +18 -8
  24. data/lib/shotstack/models/poster.rb +1 -1
  25. data/lib/shotstack/models/probe_response.rb +255 -0
  26. data/lib/shotstack/models/queued_response.rb +1 -1
  27. data/lib/shotstack/models/queued_response_data.rb +1 -1
  28. data/lib/shotstack/models/range.rb +1 -1
  29. data/lib/shotstack/models/render_response.rb +1 -1
  30. data/lib/shotstack/models/render_response_data.rb +1 -1
  31. data/lib/shotstack/models/rotate_transformation.rb +222 -0
  32. data/lib/shotstack/models/shotstack_destination.rb +1 -1
  33. data/lib/shotstack/models/size.rb +1 -1
  34. data/lib/shotstack/models/skew_transformation.rb +234 -0
  35. data/lib/shotstack/models/soundtrack.rb +1 -1
  36. data/lib/shotstack/models/thumbnail.rb +1 -1
  37. data/lib/shotstack/models/timeline.rb +1 -1
  38. data/lib/shotstack/models/title_asset.rb +1 -1
  39. data/lib/shotstack/models/track.rb +1 -1
  40. data/lib/shotstack/models/transformation.rb +237 -0
  41. data/lib/shotstack/models/transition.rb +1 -1
  42. data/lib/shotstack/models/video_asset.rb +1 -1
  43. data/lib/shotstack/version.rb +2 -2
  44. data/lib/shotstack.rb +7 -1
  45. data/shotstack.gemspec +1 -1
  46. metadata +15 -10
data/README.md CHANGED
@@ -1,26 +1,1114 @@
1
- # Shotstack Ruby SDK
1
+ # Shotstack Ruby SDK <!-- omit in toc -->
2
2
 
3
- Ruby SDK for [Shotstack](http://shotstack.io), the cloud video editing API.
3
+ Ruby SDK for the Shotstack [Ruby video editor](https://shotstack.io/product/sdk/ruby/) and cloud video editing API.
4
4
 
5
5
  Shotstack is a cloud based video editing platform that enables the editing of videos using code.
6
6
 
7
- The platform uses an API and a JSON format for specifying how videos should be edited and what assets and titles should be used.
7
+ The platform uses an API and a JSON format for specifying how videos should be edited and what asset and titles should be used.
8
8
 
9
9
  A server based render farm takes care of rendering the videos allowing multiple videos to be created simultaneously.
10
10
 
11
11
  For examples of how to use the SDK to create videos using code checkout the Ruby demo repo: https://github.com/shotstack/ruby-demos
12
12
 
13
- ## Installation
13
+ ## Contents <!-- omit in toc -->
14
+ - [Using the Ruby SDK](#using-the-ruby-sdk)
15
+ - [Installation](#installation)
16
+ - [Video Editing](#video-editing)
17
+ - [Video Editing Example](#video-editing-example)
18
+ - [Status Check Example](#status-check-example)
19
+ - [Video Editing Schemas](#video-editing-schemas)
20
+ - [Edit](#edit)
21
+ - [Timeline](#timeline)
22
+ - [Soundtrack](#soundtrack)
23
+ - [Font](#font)
24
+ - [Track](#track)
25
+ - [Clip](#clip)
26
+ - [VideoAsset](#videoasset)
27
+ - [ImageAsset](#imageasset)
28
+ - [TitleAsset](#titleasset)
29
+ - [HtmlAsset](#htmlasset)
30
+ - [AudioAsset](#audioasset)
31
+ - [LumaAsset](#lumaasset)
32
+ - [Transition](#transition)
33
+ - [Offset](#offset)
34
+ - [Crop](#crop)
35
+ - [Transformation](#transformation)
36
+ - [RotateTransformation](#rotatetransformation)
37
+ - [SkewTransformation](#skewtransformation)
38
+ - [FlipTransformation](#fliptransformation)
39
+ - [MergeField](#mergefield)
40
+ - [Output Schemas](#output-schemas)
41
+ - [Output](#output)
42
+ - [Size](#size)
43
+ - [Range](#range)
44
+ - [Poster](#poster)
45
+ - [Thumbnail](#thumbnail)
46
+ - [ShotstackDestination](#shotstackdestination)
47
+ - [Render Response Schemas](#render-response-schemas)
48
+ - [QueuedResponse](#queuedresponse)
49
+ - [QueuedResponseData](#queuedresponsedata)
50
+ - [RenderResponse](#renderresponse)
51
+ - [RenderResponseData](#renderresponsedata)
52
+ - [Inspecting Media](#inspecting-media)
53
+ - [Probe Example](#probe-example)
54
+ - [Probe Schemas](#probe-schemas)
55
+ - [ProbeResponse](#proberesponse)
56
+ - [Managing Assets](#managing-assets)
57
+ - [Assets by Render ID Example](#assets-by-render-id-example)
58
+ - [Assets by Asset ID Example](#assets-by-asset-id-example)
59
+ - [Asset Schemas](#asset-schemas)
60
+ - [AssetResponse](#assetresponse)
61
+ - [AssetRenderResponse](#assetrenderresponse)
62
+ - [AssetResponseData](#assetresponsedata)
63
+ - [AssetResponseAttributes](#assetresponseattributes)
64
+ - [API Documentation and Guides](#api-documentation-and-guides)
14
65
 
66
+ # Using the Ruby SDK
67
+ ### Installation
68
+
69
+ ```bash
70
+ gem install shotstack
15
71
  ```
16
- bundle install
72
+
73
+ ## Video Editing
74
+
75
+ The Shotstack SDK enables programmatic video editing via the Edit API `render` endpoint. Prepare JSON edits using the
76
+ provided schema classes and `POST` to the API for rendering.
77
+ ### Video Editing Example
78
+
79
+ The example below trims the start of a video clip and plays it for 8 seconds. The edit is prepared using the SDK models
80
+ and then sent to the API for rendering.
81
+
82
+ ```ruby
83
+ require "shotstack"
84
+
85
+ Shotstack.configure do |config|
86
+ config.api_key['x-api-key'] = "H7jKyj90kd09lbLOF7J900jNbSWS67X87xs9j0cD"
87
+ config.host = "api.shotstack.io"
88
+ config.base_path = "stage"
89
+ end
90
+
91
+ api_client = Shotstack::EditApi.new
92
+
93
+ video_asset = Shotstack::VideoAsset.new(
94
+ src: "https://s3-ap-southeast-2.amazonaws.com/shotstack-assets/footage/skater.hd.mp4",
95
+ trim: 3
96
+ )
97
+
98
+ video_clip = Shotstack::Clip.new(
99
+ asset: video_asset,
100
+ start: 0,
101
+ length: 8
102
+ )
103
+
104
+ track = Shotstack::Track.new(clips: [video_clip])
105
+
106
+ timeline = Shotstack::Timeline.new(
107
+ background: "#000000",
108
+ tracks: [track])
109
+
110
+ output = Shotstack::Output.new(
111
+ format: "mp4",
112
+ resolution: "sd")
113
+
114
+ edit = Shotstack::Edit.new(
115
+ timeline: timeline,
116
+ output: output)
117
+
118
+ response = api_client.post_render(edit).response
119
+
120
+ puts response.id
17
121
  ```
18
122
 
19
- ## Documentation
123
+ ### Status Check Example
20
124
 
21
- - [Getting Started Guide](https://shotstack.gitbook.io/docs/guides/getting-started)
22
- - [API Reference](https://shotstack.restlet.io/)
23
- - [Examples](https://github.com/shotstack/ruby-demos)
24
- - [Shotstack Website](http://shotstack.io)
125
+ The example request below can be called a few seconds after the render above is posted. It will return the status of
126
+ the render, which can take several seconds to process.
127
+
128
+ ```ruby
129
+ require "shotstack"
130
+
131
+ Shotstack.configure do |config|
132
+ config.api_key['x-api-key'] = "H7jKyj90kd09lbLOF7J900jNbSWS67X87xs9j0cD"
133
+ config.host = "api.shotstack.io"
134
+ config.base_path = "stage"
135
+ end
136
+
137
+ id = "75143ec6-4b72-46f8-a67a-fd7284546935"
138
+ api_client = Shotstack::EditApi.new
139
+
140
+ response = api_client.get_render(id, { data: false, merged: true }).response
141
+
142
+ if response.status === "done"
143
+ puts response.url
144
+ ```
145
+
146
+ ## Video Editing Schemas
147
+
148
+ The following schemas are used to prepare a video edit.
149
+
150
+ ### Edit
151
+
152
+ An **Edit** defines the arrangement of a video on a timeline, an audio edit or an image design and the output format.
153
+
154
+ #### Example:
155
+
156
+ ```ruby
157
+ require "shotstack"
158
+
159
+ edit = Shotstack::Edit.new(
160
+ timeline: timeline,
161
+ output: output,
162
+ merge: merge,
163
+ callback: "https://my-server.com/callback.php",
164
+ disk: "local"
165
+ )
166
+ ```
167
+
168
+ #### Arguments:
169
+
170
+ Argument | Type | Description | Required
171
+ :--- | :--- | :--- | :---:
172
+ timeline | [Shotstack::Timeline](#timeline) | A timeline represents the contents of a video edit over time, an audio edit over time, in seconds, or an image layout. A timeline consists of layers called tracks. Tracks are composed of titles, images, audio, html or video segments referred to as clips which are placed along the track at specific starting point and lasting for a specific amount of time. | -
173
+ output | [Shotstack::Output](#output) | The output format, render range and type of media to generate. | Y
174
+ merge | [Shotstack::MergeField[]](#mergefield) | An array of key/value pairs that provides an easy way to create templates with placeholders. The placeholders can be used to find and replace keys with values. For example you can search for the placeholder `{{NAME}}` and replace it with the value `Jane`. | -
175
+ callback | string | An optional webhook callback URL used to receive status notifications when a render completes or fails. See [webhooks](https://shotstack.io/docs/guide/architecting-an-application/webhooks/) for more details. | -
176
+ disk | string | The disk type to use for storing footage and asset for each render. See [disk types](https://shotstack.io/docs/guide/architecting-an-application/disk-types/) for more details. [default to `local`] <ul><li>`local` - optimized for high speed rendering with up to 512MB storage</li><li>`mount` - optimized for larger file sizes and longer videos with 5GB for source footage and 512MB for output render</li></ul> | -
177
+
178
+ -----
179
+
180
+ ### Timeline
181
+
182
+ A **Timeline** represents the contents of a video edit over time, an audio edit over time, in seconds, or an image layout. A timeline consists of layers called tracks. Tracks are composed of titles, images, audio, html or video segments referred to as clips which are placed along the track at specific starting point and lasting for a specific amount of time.
183
+
184
+ #### Example:
185
+
186
+ ```ruby
187
+ require "shotstack"
188
+
189
+ timeline = Shotstack::Timeline.new(
190
+ soundtrack: soundtrack,
191
+ background: '#000000',
192
+ fonts: fonts,
193
+ tracks: tracks,
194
+ cache: true
195
+ )
196
+ ```
197
+
198
+ #### Arguments:
199
+
200
+ Argument | Type | Description | Required
201
+ :--- | :--- | :--- | :---:
202
+ soundtrack | [Shotstack::Soundtrack](#soundtrack) | A music or audio soundtrack file in mp3 format. | -
203
+ background | string | A hexadecimal value for the timeline background colour. Defaults to `#000000` (black). | -
204
+ fonts | [Shotstack::Font[]](#font) | An array of custom fonts to be downloaded for use by the HTML assets. | -
205
+ tracks | [Shotstack::Track[]](#track) | A timeline consists of an array of tracks, each track containing clips. Tracks are layered on top of each other in the same order they are added to the array with the top most track layered over the top of those below it. Ensure that a track containing titles is the top most track so that it is displayed above videos and images. | Y
206
+ cache | bool | Disable the caching of ingested source footage and assets. See [caching](https://shotstack.io/docs/guide/architecting-an-application/caching) for more details. [default to `true`] | -
207
+
208
+ ---
209
+
210
+ ### Soundtrack
211
+
212
+ A music or audio file in mp3 format that plays for the duration of the rendered video or the length of the audio file, which ever is shortest.
213
+
214
+ #### Example:
215
+
216
+ ```ruby
217
+ require "shotstack"
218
+
219
+ soundtrack = Shotstack::Soundtrack.new(
220
+ src: 'https://s3-ap-southeast-2.amazonaws.com/shotstack-assets/music/disco.mp3',
221
+ effect: 'fadeIn',
222
+ volume: 1
223
+ )
224
+ ```
225
+
226
+ #### Arguments:
227
+
228
+ Argument | Type | Description | Required
229
+ :--- | :--- | :--- | :---:
230
+ src | string | The URL of the mp3 audio file. The URL must be publicly accessible or include credentials. | Y
231
+ effect | string | The effect to apply to the audio file <ul><li>`fadeIn` - fade volume in only</li><li>`fadeOut` - fade volume out only</li><li>`fadeInFadeOut` - fade volume in and out</li></ul> | -
232
+ volume | float | Set the volume for the soundtrack between 0 and 1 where 0 is muted and 1 is full volume (defaults to `1`). | -
233
+
234
+ ---
235
+
236
+ ### Font
237
+
238
+ Download a custom font to use with the HTML asset type, using the font name in the CSS or font tag. See our [custom fonts](https://shotstack.io/learn/html-custom-fonts/) getting started guide for more details.
239
+
240
+ #### Example:
241
+
242
+ ```ruby
243
+ require "shotstack"
244
+
245
+ font = Shotstack::Font.new(
246
+ src: 'https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/fonts/OpenSans-Regular.ttf'
247
+ )
248
+ ```
249
+
250
+ #### Arguments:
251
+
252
+ Argument | Type | Description | Required
253
+ :--- | :--- | :--- | :---:
254
+ src | string | The URL of the font file. The URL must be publicly accessible or include credentials. | Y
255
+
256
+ ---
257
+
258
+ ### Track
259
+
260
+ A track contains an array of clips. Tracks are layered on top of each other in the order in the array. The top most track will render on top of those below it.
261
+
262
+ #### Example:
263
+
264
+ ```ruby
265
+ require "shotstack"
266
+
267
+ track = Shotstack::Track(
268
+ clips: clips
269
+ )
270
+ ```
271
+
272
+ #### Arguments:
273
+
274
+ Argument | Type | Description | Required
275
+ :--- | :--- | :--- | :---:
276
+ clips | [Shotstack::Clip[]](#clip) | An array of Clips comprising of TitleClip, ImageClip or VideoClip. | Y
277
+
278
+ ---
279
+
280
+ ### Clip
281
+
282
+ A **Clip** is a container for a specific type of asset, i.e. a title, image, video, audio or html. You use a Clip to define when an asset will display on the timeline, how long it will play for and transitions, filters and effects to apply to it.
283
+
284
+ #### Example:
285
+
286
+ ```ruby
287
+ require "shotstack"
288
+
289
+ clip = Shotstack::Clip.new(
290
+ asset: asset,
291
+ start: 2,
292
+ length: 5,
293
+ fit: 'crop',
294
+ scale: 0,
295
+ position: 'center',
296
+ offset: offset,
297
+ transition: transition,
298
+ effect: 'zoomIn',
299
+ filter: 'greyscale',
300
+ opacity: 1,
301
+ transform: transform
302
+ )
303
+ ```
304
+
305
+ #### Arguments:
306
+
307
+ Argument | Type | Description | Required
308
+ :--- | :--- | :--- | :---:
309
+ asset | asset | The type of asset to display for the duration of this Clip. Value must be one of: <ul><li>[Shotstack::VideoAsset](#videoasset)</li><li>[Shotstack::ImageAsset](#imageasset)</li><li>[Shotstack::TitleAsset](#titleasset)</li><li>[Shotstack::HtmlAsset](#htmlasset)</li><li>[Shotstack::AudioAsset](#audioasset)</li><li>[Shotstack::LumaAsset](#lumaasset)</li></ul> | Y
310
+ start | float | The start position of the Clip on the timeline, in seconds. | Y
311
+ length | float | The length, in seconds, the Clip should play for. | Y
312
+ fit | string fit | Set how the asset should be scaled to fit the viewport using one of the following options [default to `crop`]: <ul><li>`cover` - stretch the asset to fill the viewport without maintaining the aspect ratio.</li><li>`contain` - fit the entire asset within the viewport while maintaining the original aspect ratio.</li><li>`crop` - scale the asset to fill the viewport while maintaining the aspect ratio. The asset will be cropped if it exceeds the bounds of the viewport.</li><li>`none` - preserves the original asset dimensions and does not apply any scaling.</li></ul>| -
313
+ scale | float | Scale the asset to a fraction of the viewport size - i.e. ting the scale to 0.5 will scale asset to half the size of the viewport. This is useful for picture-in-picture video and scaling images such as logos and watermarks. | -
314
+ position | string | Place the asset in one of nine predefined positions of the viewport. This is most effective for when the asset is scaled and you want to position the element to a specific position [default to `center`].<ul><li>`top` - top (center)</li><li>`topRight` - top right</li><li>`right` - right (center)</li><li>`bottomRight` - bottom right</li><li>`bottom` - bottom (center)</li><li>`bottomLeft` - bottom left</li><li>`left` - left (center)</li><li>`topLeft` - top left</li><li>`center` - center</li></ul> | -
315
+ offset | [Shotstack::Offset](#offset) | Offset the location of the asset relative to its position on the viewport. The offset distance is relative to the width of the viewport - for example an x offset of 0.5 will move the asset half the viewport width to the right. | -
316
+ transition | [Shotstack::Transition](#transition) | In and out transitions for a clip - i.e. fade in and fade out | -
317
+ effect | string | A motion effect to apply to the Clip. <ul><li>`zoomIn` - slow zoom in</li><li>`zoomOut` - slow zoom out</li><li>`slideLeft` - slow slide (pan) left</li><li>`slideRight` - slow slide (pan) right</li><li>`slideUp` - slow slide (pan) up</li><li>`slideDown` - slow slide (pan) down</li></ul>| -
318
+ filter | string | A filter effect to apply to the Clip. <ul><li>`boost` - boost contrast and saturation</li><li>`contrast` - increase contrast</li><li>`darken` - darken the scene</li><li>`greyscale` - remove colour</li><li>`lighten` - lighten the scene</li><li>`muted` - reduce saturation and contrast</li><li>`invert` - invert colors</li></ul> | -
319
+ opacity | float | s the opacity of the Clip where 1 is opaque and 0 is transparent. [default to `1`] | -
320
+ transform | [Shotstack::Transformation](#transformation) | A transformation lets you modify the visual properties of a clip. Available transformations are [Shotstack::RotateTransformation](#rotatetransformation), [Shotstack::SkewTransformation](#skewtransformation) and [Shotstack::FlipTransformation](#fliptransformation). Transformations can be combined to create interesting new shapes and effects. | -
321
+
322
+ ---
323
+
324
+ ### VideoAsset
325
+
326
+ The **VideoAsset** is used to create video sequences from video files. The src must be a publicly accessible URL to a video
327
+ resource such as an mp4 file.
328
+
329
+ #### Example:
330
+
331
+ ```ruby
332
+ require "shotstack"
333
+
334
+ videoAsset = Shotstack::VideoAsset.new(
335
+ src: 'https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/footage/table-mountain.mp4',
336
+ trim: 5,
337
+ volume: 0.5,
338
+ crop: crop
339
+ )
340
+ ```
341
+
342
+ #### Arguments:
343
+
344
+ Argument | Type | Description | Required
345
+ :--- | :--- | :--- | :---:
346
+ src | string | The video source URL. The URL must be publicly accessible or include credentials. | Y
347
+ trim | float | The start trim point of the video clip, in seconds (defaults to 0). Videos will start from the in trim point. The video will play until the file ends or the Clip length is reached. | -
348
+ volume | float | Set the volume for the video clip between 0 and 1 where 0 is muted and 1 is full volume (defaults to 0). | -
349
+ crop | [Shotstack::Crop](#crop) | Crop the sides of an asset by a relative amount. The size of the crop is specified using a scale between 0 and 1, relative to the screen width - i.e. a left crop of 0.5 will crop half of the asset from the left, a top crop of 0.25 will crop the top by quarter of the asset. | -
350
+
351
+ ---
352
+
353
+ ### ImageAsset
354
+
355
+ The **ImageAsset** is used to create video from images to compose an image. The src must be a publicly accessible URL to an image resource such as a jpg or png file.
356
+
357
+ #### Example:
358
+
359
+ ```ruby
360
+ require "shotstack"
361
+
362
+ imageAsset = Shotstack::ImageAsset.new(
363
+ src: 'https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/images/earth.jpg',
364
+ crop: crop
365
+ )
366
+ ```
367
+
368
+ #### Arguments:
369
+
370
+ Argument | Type | Description | Required
371
+ :--- | :--- | :--- | :---:
372
+ src | string | The image source URL. The URL must be publicly accessible or include credentials. | Y
373
+ crop | [Shotstack::Crop](#crop) | Crop the sides of an asset by a relative amount. The size of the crop is specified using a scale between 0 and 1, relative to the screen width - i.e. a left crop of 0.5 will crop half of the asset from the left, a top crop of 0.25 will crop the top by quarter of the asset. | -
374
+
375
+ ---
376
+
377
+ ### TitleAsset
378
+
379
+ The **TitleAsset** clip type lets you create video titles from a text string and apply styling and positioning.
380
+
381
+ #### Example:
382
+
383
+ ```ruby
384
+ require "shotstack"
385
+
386
+ titleAsset = Shotstack::TitleAsset.new(
387
+ text: 'My Title',
388
+ style: 'minimal',
389
+ color: '#ffffff',
390
+ size: 'medium',
391
+ background: '#000000',
392
+ position: 'center',
393
+ offset: offset
394
+ )
395
+ ```
396
+
397
+ #### Arguments:
398
+
399
+ Argument | Type | Description | Required
400
+ :--- | :--- | :--- | :---:
401
+ text | string | The title text string. | Y
402
+ style | string | Uses a preset to apply font properties and styling to the title. <ul><li>`minimal`</li><li>`blockbuster`</li><li>`vogue`</li><li>`sketchy`</li><li>`skinny`</li><li>`chunk`</li><li>`chunkLight`</li><li>`marker`</li><li>`future`</li><li>`subtitle`</li></ul> | -
403
+ color | string | Set the text color using hexadecimal color notation. Transparency is supported by ting the first two characters of the hex string (opposite to HTML), i.e. #80ffffff will be white with 50% transparency [default to `#ffffff`]. | -
404
+ size | string | Set the relative size of the text using predefined sizes from xx-small to xx-large [default to 'medium']. <ul><li>`xx-small`</li><li>`x-small`</li><li>`small`</li><li>`medium`</li><li>`large`</li><li>`x-large`</li><li>`xx-large`</li></ul> | -
405
+ background | string | Apply a background color behind the text. Set the text color using hexadecimal color notation. Transparency is supported by ting the first two characters of the hex string (opposite to HTML), i.e. #80ffffff will be white with 50% transparency. Omit to use transparent background. | -
406
+ position | string | Place the title in one of nine predefined positions of the viewport [default to `center`. <ul><li>`top` - top (center)</li><li>`topRight` - top right</li><li>`right` - right (center)</li><li>`bottomRight` - bottom right</li><li>`bottom` - bottom (center)</li><li>`bottomLeft` - bottom left</li><li>`left` - left (center)</li><li>`topLeft` - top left</li><li>`center` - center</li></ul> | -
407
+ offset | [Shotstack::Offset](#offset) | Offset the location of the title relative to its position on the screen. | -
408
+
409
+ ---
410
+
411
+ ### HtmlAsset
412
+
413
+ The **HtmlAsset** clip type lets you create text based layout and formatting using HTML and CSS. You can also set the height and width of a bounding box for the HTML content to sit within. Text and elements will wrap within the bounding box.
414
+
415
+ #### Example:
416
+
417
+ ```ruby
418
+ require "shotstack"
419
+
420
+ htmlAsset = Shotstack::HtmlAsset.new(
421
+ html: '<p>Hello <b>World</b></p>',
422
+ css: 'p { color: #ffffff; } b { color: #ffff00; }',
423
+ width: 400,
424
+ height: 200,
425
+ background: 'transparent',
426
+ position: 'center'
427
+ )
428
+ ```
429
+
430
+ #### Arguments:
431
+
432
+ Argument | Type | Description | Required
433
+ :--- | :--- | :---:
434
+ html | string | The HTML text string. See list of [supported HTML tags](https://shotstack.io/docs/guide/architecting-an-application/html-support/#supported-html-tags). | Y
435
+ css | string | The CSS text string to apply styling to the HTML. See list of [support CSS properties](https://shotstack.io/docs/guide/architecting-an-application/html-support/#supported-css-properties). | -
436
+ width | int | Set the width of the HTML asset bounding box in pixels. Text will wrap to fill the bounding box. | -
437
+ height | int | Set the height of the HTML asset bounding box in pixels. Text and elements will be masked if they exceed the height of the bounding box. | -
438
+ background | string | Apply a background color behind the HTML bounding box using. Set the text color using hexadecimal color notation. Transparency is supported by ting the first two characters of the hex string (opposite to HTML), i.e. #80ffffff will be white with 80% transparency [default to `transparent`]. | -
439
+ position | string | Place the HTML in one of nine predefined positions within the HTML area [default to `center`]. <ul><li>`top` - top (center)</li><li>`topRight` - top right</li><li>`right` - right (center)</li><li>`bottomRight` - bottom right</li><li>`bottom` - bottom (center)</li><li>`bottomLeft` - bottom left</li><li>`left` - left (center)</li><li>`topLeft` - top left</li><li>`center` - center</li></ul> | -
440
+
441
+ ---
442
+
443
+ ### AudioAsset
444
+
445
+ The **AudioAsset** is used to add sound effects and audio at specific intervals on the timeline. The src must be a
446
+ publicly accessible URL to an audio resource such as an mp3 file.
447
+
448
+ #### Example:
449
+
450
+ ```ruby
451
+ require "shotstack"
452
+
453
+ audioAsset = Shotstack::AudioAsset.new(
454
+ src: 'https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/music/unminus/lit.mp3',
455
+ trim: 2,
456
+ volume: 0.5,
457
+ effect: 'fadeInFadeOut'
458
+ )
459
+ ```
460
+
461
+ #### Arguments:
462
+
463
+ Argument | Type | Description | Required
464
+ :--- | :--- | :--- | :---:
465
+ src | string | The audio source URL. The URL must be publicly accessible or include credentials. | Y
466
+ trim | float | The start trim point of the audio clip, in seconds (defaults to 0). Audio will start from the trim point. The audio will play until the file ends or the Clip length is reached. | -
467
+ volume | float | Set the volume for the audio clip between 0 and 1 where 0 is muted and 1 is full volume (defaults to 1). | -
468
+ effect | string | The effect to apply to the audio asset: <ul><li>`fadeIn` - fade volume in only</li><li>`fadeOut` - fade volume out only</li><li>`fadeInFadeOut` - fade volume in and out</li></ul> | -
469
+
470
+ ---
471
+
472
+ ### LumaAsset
473
+
474
+ The **LumaAsset** is used to create luma matte masks, transitions and effects between other assets. A luma matte is a grey scale image or animated video where the black areas are transparent and the white areas solid. The luma matte animation should be provided as an mp4 video file. The src must be a publicly accessible URL to the file.
475
+
476
+ #### Example:
477
+
478
+ ```ruby
479
+ require "shotstack"
480
+
481
+ lumaAsset = Shotstack::LumaAsset.new(
482
+ src: 'https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/examples/luma-mattes/paint-left.mp4',
483
+ trim: 5
484
+ )
485
+ ```
486
+
487
+ #### Arguments:
488
+
489
+ Argument | Type | Description | Required
490
+ :--- | :--- | :--- | :---:
491
+ src | string | The luma matte source URL. The URL must be publicly accessible or include credentials. | Y
492
+ trim | float | The start trim point of the luma matte clip, in seconds (defaults to 0). Videos will start from the in trim point. A luma matte video will play until the file ends or the Clip length is reached. | -
493
+
494
+ ---
495
+
496
+ ### Transition
497
+
498
+ The **Transition** clip type lets you define in and out transitions for a clip - i.e. fade in and fade out
499
+
500
+ #### Example:
501
+
502
+ ```ruby
503
+ require "shotstack"
504
+
505
+ transition = Shotstack::Transition.new(
506
+ in: 'fade',
507
+ out: 'fade'
508
+ )
509
+ ```
510
+
511
+ #### Arguments:
512
+
513
+ Argument | Type | Description | Required
514
+ :--- | :--- | :--- | :---:
515
+ in | string | The transition in. Available transitions are: <ul><li>`fade` - fade in</li><li>`reveal` - reveal from left to right</li><li>`wipeLeft` - fade across screen to the left</li><li>`wipeRight` - fade across screen to the right</li><li>`slideLeft` - move slightly left and fade in</li><li>`slideRight` - move slightly right and fade in</li><li>`slideUp` - move slightly up and fade in</li><li>`slideDown` - move slightly down and fade in</li><li>`carouselLeft` - slide in from right to left</li><li>`carouselRight` - slide in from left to right</li><li>`carouselUp` - slide in from bottom to top</li><li>`carouselDown` - slide in from top to bottom</li><li>`shuffleTopRight` - rotate in from top right</li><li>`shuffleRightTop` - rotate in from right top</li><li>`shuffleRightBottom` - rotate in from right bottom</li><li>`shuffleBottomRight` - rotate in from bottom right</li><li>`shuffleBottomLeft` - rotate in from bottom left</li><li>`shuffleLeftBottom` - rotate in from left bottom</li><li>`shuffleLeftTop` - rotate in from left top</li><li>`shuffleTopLeft` - rotate in from top left</li><li>`zoom` - fast zoom in</li></ul> The transition speed can also be controlled by appending `Fast` or `Slow` to the transition, e.g. `fadeFast` or `CarouselLeftSlow`. | -
516
+ out | string | The transition out. Available transitions are: <ul><li>`fade` - fade out</li><li>`reveal` - reveal from right to left</li><li>`wipeLeft` - fade across screen to the left</li><li>`wipeRight` - fade across screen to the right</li><li>`slideLeft` - move slightly left and fade out</li><li>`slideRight` - move slightly right and fade out</li><li>`slideUp` - move slightly up and fade out</li><li>`slideDown` - move slightly down and fade out</li><li>`carouselLeft` - slide out from right to left</li><li>`carouselRight` - slide out from left to right</li><li>`carouselUp` - slide out from bottom to top</li><li>`carouselDown` - slide out from top to bottom</li><li>`shuffleTopRight` - rotate out from top right</li><li>`shuffleRightTop` - rotate out from right top</li><li>`shuffleRightBottom` - rotate out from right bottom</li><li>`shuffleBottomRight` - rotate out from bottom right</li><li>`shuffleBottomLeft` - rotate out from bottom left</li><li>`shuffleLeftBottom` - rotate out from left bottom</li><li>`shuffleLeftTop` - rotate out from left top</li><li>`shuffleTopLeft` - rotate out from top left</li><li>`zoom` - fast zoom out</li></ul> The transition speed can also be controlled by appending `Fast` or `Slow` to the transition, e.g. `fadeFast` or `CarouselLeftSlow`. | -
517
+
518
+ ---
519
+
520
+ ### Offset
521
+
522
+ Offs the position of an asset horizontally or vertically by a relative distance.
523
+
524
+ #### Example:
525
+
526
+ ```ruby
527
+ require "shotstack"
528
+
529
+ offset = Shotstack::Offset.new(
530
+ x: 0.1,
531
+ y: -0.2
532
+ )
533
+ ```
534
+
535
+ #### Arguments:
536
+
537
+ Argument | Type | Description | Required
538
+ :--- | :--- | :--- | :---:
539
+ x | float | Offset an asset on the horizontal axis (left or right), range varies from -1 to 1. Positive numbers move the asset right, negative left. For all asset except titles the distance moved is relative to the width of the viewport - i.e. an X offset of 0.5 will move the asset half the screen width to the right. [default to `0`] | -
540
+ y | float | Offset an asset on the vertical axis (up or down), range varies from -1 to 1. Positive numbers move the asset up, negative down. For all asset except titles the distance moved is relative to the height of the viewport - i.e. an Y offset of 0.5 will move the asset up half the screen height. [default to `0`] | -
541
+
542
+ ---
543
+
544
+ ### Crop
545
+
546
+ Crop the sides of an asset by a relative amount. The size of the crop is specified using a scale between 0 and 1, relative to the screen width - i.e a left crop of 0.5 will crop half of the asset from the left, a top crop of 0.25 will crop the top by quarter of the asset.
547
+
548
+ #### Example:
549
+
550
+ ```ruby
551
+ require "shotstack"
552
+
553
+ crop = Shotstack::Crop.new(
554
+ top: 0.15,
555
+ bottom: 0.15,
556
+ left: 0,
557
+ right: 0
558
+ )
559
+ ```
560
+
561
+ #### Arguments:
562
+
563
+ Argument | Type | Description | Required
564
+ :--- | :--- | :--- | :---:
565
+ top | float | Crop from the top of the asset | -
566
+ bottom | float | Crop from the bottom of the asset | -
567
+ left | float | Crop from the left of the asset | -
568
+ right | float | Crop from the right of the asset | -
569
+
570
+ ---
571
+
572
+ ### Transformation
573
+
574
+ Apply one or more transformations to a clip. **Transformations** alter the visual properties of a clip and can be combined to create new shapes and effects.
575
+
576
+ #### Example:
577
+
578
+ ```ruby
579
+ require "shotstack"
580
+
581
+ transformation = Shotstack::Transformation.new(
582
+ rotate: rotate,
583
+ skew: skew,
584
+ flip: flip
585
+ )
586
+ ```
587
+
588
+ #### Arguments:
589
+
590
+ Argument | Type | Description | Required
591
+ :--- | :--- | :--- | :---:
592
+ rotate | [Shotstack::RotateTransformation](#rotatetransformation) | Rotate a clip by the specified angle in degrees. Rotation origin is set based on the clips `position`. | -
593
+ skew | [Shotstack::SkewTransformation](#skewtransformation) | Skew a clip so its edges are sheared at an angle. Use values between 0 and 3. Over 3 the clip will be skewed almost flat. | -
594
+ flip | [Shotstack::FlipTransformation](#fliptransformation) | Flip a clip vertically or horizontally. Acts as a mirror effect of the clip along the selected plane. | -
25
595
 
26
- ###
596
+ ---
597
+
598
+ ### RotateTransformation
599
+
600
+ Rotate a clip by the specified angle in degrees. Rotation origin is set based on the clips `position`.
601
+
602
+ #### Example:
603
+
604
+ ```ruby
605
+ require "shotstack"
606
+
607
+ rotateTransformation = Shotstack::RotateTransformation.new(
608
+ angle: 45
609
+ )
610
+ ```
611
+
612
+ #### Arguments:
613
+
614
+ Argument | Type | Description | Required
615
+ :--- | :--- | :--- | :---:
616
+ angle | int | The angle to rotate the clip. Can be 0 to 360, or 0 to -360. Using a positive number rotates the clip clockwise, negative numbers counter-clockwise. | -
617
+
618
+ ---
619
+
620
+ ### SkewTransformation
621
+
622
+ Skew a clip so its edges are sheared at an angle. Use values between 0 and 3. Over 3 the clip will be skewed almost flat.
623
+
624
+ #### Example:
625
+
626
+ ```ruby
627
+ require "shotstack"
628
+
629
+ skewTransformation = Shotstack::SkewTransformation.new(
630
+ x: 0.5,
631
+ y: 0.5
632
+ )
633
+ ```
634
+
635
+ #### Arguments:
636
+
637
+ Argument | Type | Description | Required
638
+ :--- | :--- | :--- | :---:
639
+ x | float | Skew the clip along it&#39;s x axis. [default to `0`] | -
640
+ y | float | Skew the clip along it&#39;s y axis. [default to `0`] | -
641
+
642
+ ---
643
+
644
+ ### FlipTransformation
645
+
646
+ Flip a clip vertically or horizontally. Acts as a mirror effect of the clip along the selected plane.
647
+
648
+ #### Example:
649
+
650
+ ```ruby
651
+ require "shotstack"
652
+
653
+ flipTransformation = Shotstack::FlipTransformation.new(
654
+ horizontal: true,
655
+ vertical: true
656
+ )
657
+ ```
658
+
659
+ #### Arguments:
660
+
661
+ Argument | Type | Description | Required
662
+ :--- | :--- | :--- | :---:
663
+ horizontal | bool | Flip a clip horizontally. [default to `false`] | -
664
+ vertical | bool | Flip a clip vertically. [default to `false`] | -
665
+
666
+ ---
667
+
668
+ ### MergeField
669
+
670
+ A merge field consists of a key; `find`, and a `value`; replace. Merge fields can be used to replace placeholders within the JSON edit to create re-usable templates. Placeholders should be a string with double brace delimiters, i.e. `"{{NAME}}"`. A placeholder can be used for any value within the JSON edit.
671
+
672
+ #### Example:
673
+
674
+ ```ruby
675
+ require "shotstack"
676
+
677
+ mergeField = Shotstack::MergeField.new(
678
+ find: 'NAME',
679
+ replace: 'Jane'
680
+ )
681
+ ```
682
+
683
+ #### Arguments:
684
+
685
+ Argument | Type | Description | Required
686
+ :--- | :--- | :--- | :---:
687
+ find | string | The string to find <u>without</u> delimiters. | Y
688
+ replace | replace | The replacement value. The replacement can be any valid JSON type - string, boolean, number, etc... | Y
689
+
690
+ ---
691
+
692
+ ## Output Schemas
693
+
694
+ The following schemas specify the output format and tings.
695
+ ### Output
696
+
697
+ The output format, render range and type of media to generate.
698
+
699
+ #### Example:
700
+
701
+ ```ruby
702
+ require "shotstack"
703
+
704
+ output = Shotstack::Output.new(
705
+ format: 'mp4',
706
+ resolution: 'sd',
707
+ aspectRatio: '16:9',
708
+ size: size,
709
+ fps: 25,
710
+ scaleTo: 'preview',
711
+ quality: 'medium',
712
+ repeat: true,
713
+ range: range,
714
+ poster: poster,
715
+ thumbnail: thumbnail,
716
+ destination: destination
717
+ )
718
+ ```
719
+
720
+ #### Arguments:
721
+
722
+ Argument | Type | Description | Required
723
+ :--- | :--- | :--- | :---:
724
+ format | string | The output format and type of media file to generate. <ul><li>`mp4` - mp4 video file</li><li>`gif` - animated gif</li><li>`jpg` - jpg image file</li><li>`png` - png image file</li><li>`bmp` - bmp image file</li><li>`mp3` - mp3 audio file (audio only)</li></ul> | Y
725
+ resolution | string | The output resolution of the video or image. <ul><li>`preview` - 512px x 288px @ 15fps</li><li>`mobile` - 640px x 360px @ 25fps</li><li>`sd` - 1024px x 576px @ 25fps</li><li>`hd` - 1280px x 720px @ 25fps</li><li>`1080` - 1920px x 1080px @ 25fps</li></ul> | -
726
+ aspectRatio | string | The aspect ratio (shape) of the video or image. Useful for social media output formats. Options are: <ul><li>`16:9` - regular landscape/horizontal aspect ratio (default)</li><li>`9:16` - vertical/portrait aspect ratio</li><li>`1:1` - square aspect ratio</li><li>`4:5` - short vertical/portrait aspect ratio</li><li>`4:3` - legacy TV aspect ratio</li></ul> | -
727
+ size | [Shotstack::Size](#size) | Set a custom size for a video or image. When using a custom size omit the `resolution` and `aspectRatio`. Custom sizes must be divisible by 2 based on the encoder specifications. | -
728
+ fps | float | Override the default frames per second. Useful for when the source footage is recorded at 30fps, i.e. on mobile devices. Lower frame rates can be used to add cinematic quality (24fps) or to create smaller file size/faster render times or animated gifs (12 or 15fps). Default is 25fps. <ul><li>`12` - 12fps</li><li>`15` - 15fps</li><li>`23.976` - 23.976fps</li><li>`24` - 24fps</li><li>`29.97` - 29.97fps</li><li>`25` - 25fps</li><li>`30` - 30fps</li></ul> | -
729
+ scaleTo | string | Override the resolution and scale the video or image to render at a different size. When using scaleTo the asset should be edited at the resolution dimensions, i.e. use font sizes that look best at HD, then use scaleTo to output the file at SD and the text will be scaled to the correct size. This is useful if you want to create multiple asset sizes. <ul><li>`preview` - 512px x 288px @ 15fps</li><li>`mobile` - 640px x 360px @ 25fps</li><li>`sd` - 1024px x 576px @25fps</li><li>`hd` - 1280px x 720px @25fps</li><li>`1080` - 1920px x 1080px @25fps</li></ul> | -
730
+ quality | string | Adjust the output quality of the video, image or audio. Adjusting quality affects render speed, download speeds and storage requirements due to file size. The default `medium` provides the most optimized choice for all three factors. <ul><li>`low` - slightly reduced quality, smaller file size</li><li>`medium` - optimized quality, render speeds and file size</li><li>`high` - slightly increased quality, larger file size</li></ul> | -
731
+ repeat | bool | Loop tings for gif files. Set to `true` to loop, `false` to play only once. [default to `true`] | -
732
+ range | [Shotstack::Range](#range) | Specify a time range to render, i.e. to render only a portion of a video or audio file. Omit this ting to export the entire video. Range can also be used to render a frame at a specific time point - ting a range and output format as `jpg` will output a single frame image at the range `start` point. | -
733
+ poster | [Shotstack::Poster](#poster) | Generate a poster image from a specific point on the timeline. | -
734
+ thumbnail | [Shotstack::Thumbnail](#thumbnail) | Generate a thumbnail image from a specific point on the timeline. | -
735
+ destinations | [AnyOfShotstackDestination[]](#shotstackdestination) | A destination is a location where output files can be sent to for serving or hosting. By default all rendered assets are automatically sent to the Shotstack hosting destination. [ShotstackDestination](#shotstackdestination) is currently the only option with plans to add more in the future such as S3, YouTube, Vimeo and Mux. If you do not require hosting you can opt-out using the `exclude` property. | -
736
+
737
+ ---
738
+
739
+ ### Size
740
+
741
+ Set a custom size for a video or image. When using a custom size omit the `resolution` and `aspectRatio`. Custom sizes must be divisible by 2 based on the encoder specifications.
742
+
743
+ #### Example:
744
+
745
+ ```ruby
746
+ require "shotstack"
747
+
748
+ size = Shotstack::Size.new(
749
+ width: 1200,
750
+ height: 800
751
+ )
752
+ ```
753
+
754
+ #### Arguments:
755
+
756
+ Argument | Type | Description | Required
757
+ :--- | :--- | :--- | :---:
758
+ width | int | Set a custom width for the video or image file. Value must be divisible by 2. Maximum video width is 1920px, maximum image width is 4096px. | -
759
+ height | int | Set a custom height for the video or image file. Value must be divisible by 2. Maximum video height is 1920px, maximum image height is 4096px. | -
760
+
761
+ ---
762
+
763
+ ### Range
764
+
765
+ Specify a time range to render, i.e. to render only a portion of a video or audio file. Omit this ting to export the entire video. Range can also be used to render a frame at a specific time point - ting a range and output format as `jpg` will output a single frame image at the range `start` point.
766
+
767
+ #### Example:
768
+
769
+ ```ruby
770
+ require "shotstack"
771
+
772
+ range = Shotstack::Range.new(
773
+ start: 3,
774
+ length: 6
775
+ )
776
+ ```
777
+
778
+ #### Arguments:
779
+
780
+ Argument | Type | Description | Required
781
+ :--- | :--- | :--- | :---:
782
+ start | float | The point on the timeline, in seconds, to start the render from - i.e. start at second 3. | -
783
+ length | float | The length of the portion of the video or audio to render - i.e. render 6 seconds of the video. | -
784
+
785
+ ---
786
+
787
+ ### Poster
788
+
789
+ Generate a **Poster** image for the video at a specific point from the timeline. The poster image size will match the size of the output video.
790
+
791
+ #### Example:
792
+
793
+ ```ruby
794
+ require "shotstack"
795
+
796
+ poster = Shotstack::Poster.new(
797
+ capture: 1
798
+ )
799
+ ```
800
+
801
+ #### Arguments:
802
+
803
+ Argument | Type | Description | Required
804
+ :--- | :--- | :--- | :---:
805
+ capture | float | The point on the timeline in seconds to capture a single frame to use as the poster image. | Y
806
+
807
+ ---
808
+
809
+ ### Thumbnail
810
+
811
+ Generate a thumbnail image for the video or image at a specific point from the timeline.
812
+
813
+ #### Example:
814
+
815
+ ```ruby
816
+ require "shotstack"
817
+
818
+ thumbnail = Shotstack::Thumbnail.new(
819
+ capture: 1,
820
+ scale: 0.3
821
+ )
822
+ ```
823
+
824
+ #### Arguments:
825
+
826
+ Argument | Type | Description | Required
827
+ :--- | :--- | :--- | :---:
828
+ capture | float | The point on the timeline in seconds to capture a single frame to use as the thumbnail image. | Y
829
+ scale | float | Scale the thumbnail size to a fraction of the viewport size - i.e. ting the scale to 0.5 will scale the thumbnail to half the size of the viewport. | Y
830
+
831
+ ---
832
+
833
+ ### ShotstackDestination
834
+
835
+ Send rendered asset to the Shotstack hosting and CDN service. This destination is enabled by default.
836
+
837
+ #### Example:
838
+
839
+ ```ruby
840
+ require "shotstack"
841
+
842
+ shotstackDestination = Shotstack::ShotstackDestination.new(
843
+ provider: 'shotstack',
844
+ exclude: false
845
+ )
846
+ ```
847
+
848
+ #### Arguments:
849
+
850
+ Argument | Type | Description | Required
851
+ :--- | :--- | :--- | :---:
852
+ provider | string | The destination to send rendered asset to - set to `shotstack` for Shotstack hosting and CDN. [default to `shotstack`] | Y
853
+ exclude | bool | Set to `true` to opt-out from the Shotstack hosting and CDN service. All files must be downloaded within 24 hours of rendering. [default to `false`] | -
854
+
855
+ ---
856
+
857
+ ## Render Response Schemas
858
+
859
+ The following schemas are returned by the render request and status request.
860
+
861
+ ### QueuedResponse
862
+
863
+ The response received after a [render request](https://shotstack.io/docs/api/#render-asset) is submitted. The render task is queued for rendering and a unique render id is returned.
864
+
865
+ #### Attributes:
866
+
867
+ Attribute | Type | Description | Required
868
+ :--- | :--- | :--- | :---:
869
+ success | bool | `true` if successfully queued, else `false`. | Y
870
+ message | string | `Created`, `Bad Request` or an error message. | Y
871
+ response | [Shotstack::QueuedResponseData](#queuedresponsedata) | `QueuedResponseData` or an error message. | Y
872
+
873
+ ---
874
+
875
+ ### QueuedResponseData
876
+
877
+ The **QueuedResponseData** is the response data returned with the [QueuedResponse](#queuedresponse).
878
+
879
+ #### Attributes:
880
+
881
+ Attribute | Type | Description | Required
882
+ :--- | :--- | :--- | :---:
883
+ message | string | Success response message or error details. | Y
884
+ id | string | The id of the render task in UUID format. | Y
885
+
886
+ ---
887
+
888
+ ### RenderResponse
889
+
890
+ The **RenderResponse** is the response received after a [render status request](https://shotstack.io/docs/api/#get-render-status) is submitted. The response includes details about status of a render and the output URL.
891
+
892
+ #### Attributes:
893
+
894
+ Attribute | Type | Description | Required
895
+ :--- | :--- | :--- | :---:
896
+ success | bool | `true` if status available, else `false`. | Y
897
+ message | string | `OK` or an error message. | Y
898
+ response | [Shotstack::RenderResponseData](#renderresponsedata) | `RenderResponse` or an error message. | Y
899
+
900
+ ---
901
+
902
+ ### RenderResponseData
903
+
904
+ The **RenderResponseData** is the response data returned with the [RenderResponse](https://shotstack.io/docs/api/#tocs_renderresponse) request including status and URL.
905
+
906
+ #### Arguments:
907
+
908
+ Argument | Type | Description | Required
909
+ :--- | :--- | :--- | :---:
910
+ id | string | The id of the render task in UUID format. | Y
911
+ owner | string | The owner id of the render task. | Y
912
+ plan | string | The customer subscription plan. | -
913
+ status | string | The status of the render task. <ul> <li>`queued` - render is queued waiting to be rendered</li><li>`fetching` - asset are being fetched</li><li>`rendering` - the asset is being rendered</li><li>`saving` - the final asset is being saved to storage</li><li>`done` - the asset is ready to be downloaded</li><li>`failed` - there was an error rendering the asset</li></ul> | Y
914
+ error | string | An error message, only displayed if an error occurred. | -
915
+ duration | float | The output video or audio length in seconds. | -
916
+ render_time | float | The time taken to render the asset in milliseconds. | -
917
+ url | string | The URL of the final asset. This will only be available if status is done. This is a temporary URL and will be deleted after 24 hours. By default all asset are copied to the Shotstack hosting and CDN destination. | -
918
+ poster | string | The URL of the poster image if requested. This will only be available if status is done. | -
919
+ thumbnail | string | The URL of the thumbnail image if requested. This will only be available if status is done. | -
920
+ data | [Shotstack::Edit](#edit) | The timeline and output data to be rendered. | Y
921
+ created | string | The time the render task was initially queued. | Y
922
+ updated | string | The time the render status was last updated. | Y
923
+
924
+ ---
925
+ ## Inspecting Media
926
+
927
+ The SDK `probe` endpoint can be used to inspect media hosted online. Simply pass the URL of an asset to inspect.
928
+ ### Probe Example
929
+
930
+ The example below inspects (probes) a video hosted on GitHub and returns metadata about the file.
931
+
932
+ ```ruby
933
+ require "shotstack"
934
+
935
+ Shotstack.configure do |config|
936
+ config.api_key['x-api-key'] = "H7jKyj90kd09lbLOF7J900jNbSWS67X87xs9j0cD"
937
+ config.host = "api.shotstack.io"
938
+ config.base_path = "stage"
939
+ end
940
+
941
+ url = "https://github.com/shotstack/test-media/raw/main/captioning/scott-ko.mp4"
942
+ api_client = Shotstack::EditApi.new
943
+
944
+ begin
945
+ response = api_client.probe(url).response
946
+ rescue => error
947
+ abort("Request failed: #{error.message}")
948
+ end
949
+
950
+ response[:metadata][:streams].each_with_index do |stream, index|
951
+ if stream[:codec_type] === 'video'
952
+ puts "Example settings for: #{response[:metadata][:format][:filename]}"
953
+ puts "Width: #{stream[:width]}px"
954
+ puts "Height: #{stream[:height]}px"
955
+ puts "Framerate: #{stream[:r_frame_rate]} fps"
956
+ puts "Duration: #{stream[:duration]} secs"
957
+ end
958
+ end
959
+ ```
960
+ ## Probe Schemas
961
+
962
+ The following schemas are returned by the probe request.
963
+ ### ProbeResponse
964
+
965
+ The **ProbeResponse** is the response returned after a [probe request](https://shotstack.io/docs/api/#inspect-media) is submitted. The probe requests returns data from FFprobe formatted as JSON.
966
+
967
+ #### Arguments:
968
+
969
+ Argument | Type | Description | Required
970
+ :--- | :--- | :--- | :---:
971
+ success | bool | `true` if media successfully read, else `false`. | Y
972
+ message | string | `Created`, `Bad Request` or an error message. | Y
973
+ response | object | The response from FFprobe in JSON format | Y
974
+
975
+ ---
976
+
977
+ ## Managing Assets
978
+
979
+ By default, all assets generated by the editing API are hosted by Shotstack and served via our CDN. The SDK provides
980
+ access to the Serve API to retrieve information about hosted files. Files can also be deleted.
981
+
982
+ ### Assets by Render ID Example
983
+
984
+ The example below uses a render ID to look up hosted assets associated with the render. Note that multiple assets can be
985
+ created for a render, i.e. video, thumb and poster. Each asset has a unique asset ID different to the render ID.
986
+
987
+ ```ruby
988
+ require "shotstack"
989
+
990
+ Shotstack.configure do |config|
991
+ config.api_key['x-api-key'] = "H7jKyj90kd09lbLOF7J900jNbSWS67X87xs9j0cD"
992
+ config.host = "api.shotstack.io"
993
+ config.base_path = "serve/stage"
994
+ end
995
+
996
+ id = "140924c6-077d-4334-a89f-94befcfc0155"
997
+ api_client = Shotstack::ServeApi.new
998
+
999
+ begin
1000
+ data = api_client.get_asset_by_render_id(id).data
1001
+ rescue => error
1002
+ abort("Request failed: #{error.message}")
1003
+ end
1004
+
1005
+ data.each do |asset|
1006
+ case asset.attributes.status
1007
+ when "failed"
1008
+ puts ">> Something went wrong, asset could not be copied."
1009
+ else
1010
+ puts "Status: #{asset.attributes.status}"
1011
+ puts ">> Asset CDN URL: #{asset.attributes.url}"
1012
+ puts ">> Asset ID: #{asset.attributes.id}"
1013
+ puts ">> Render ID: #{asset.attributes.render_id}"
1014
+ end
1015
+ end
1016
+ ```
1017
+
1018
+ ### Assets by Asset ID Example
1019
+
1020
+ Every asset has a unique asset ID, the example below looks up an asset by its asset ID.
1021
+
1022
+ ```ruby
1023
+ require "shotstack"
1024
+
1025
+ Shotstack.configure do |config|
1026
+ config.api_key['x-api-key'] = "H7jKyj90kd09lbLOF7J900jNbSWS67X87xs9j0cD"
1027
+ config.host = "api.shotstack.io"
1028
+ config.base_path = "serve/stage"
1029
+ end
1030
+
1031
+ id = "ed43eae3-4825-4c03-979d-f7dc47b9997c"
1032
+ api_client = Shotstack::ServeApi.new
1033
+
1034
+ begin
1035
+ asset = api_client.get_asset(id).data
1036
+ rescue => error
1037
+ abort("Request failed: #{error.message}")
1038
+ end
1039
+
1040
+ case asset.attributes.status
1041
+ when "failed"
1042
+ puts ">> Something went wrong, asset could not be copied."
1043
+ else
1044
+ puts "Status: #{asset.attributes.status}"
1045
+ puts ">> Asset CDN URL: #{asset.attributes.url}"
1046
+ puts ">> Asset ID: #{asset.attributes.id}"
1047
+ puts ">> Render ID: #{asset.attributes.render_id}"
1048
+ end
1049
+ ```
1050
+
1051
+ ## Asset Schemas
1052
+
1053
+ The following schemas are returned by requests to the Serve API.
1054
+ ### AssetResponse
1055
+
1056
+ The **AssetResponse** is the response returned by the Serve API [get asset](https://shotstack.io/docs/api/#get-asset) request. Includes details of a hosted video, image, audio file, thumbnail or poster image. The response follows the [json:api](https://jsonapi.org/) specification.
1057
+
1058
+ #### Arguments:
1059
+
1060
+ Argument | Type | Description | Required
1061
+ :--- | :--- | :--- | :---:
1062
+ data | [Shotstack::AssetResponseData](#assetresponsedata) | Returns an asset resource. | -
1063
+
1064
+ ---
1065
+
1066
+ ### AssetRenderResponse
1067
+
1068
+ The **AssetRenderResponse** is the response returned by the Serve API [get asset by render id](https://shotstack.io/docs/api/#get-asset-by-render-id) request. The response is an array of asset resources, including video, image, audio, thumbnail and poster image. The response follows the [json:api](https://jsonapi.org/) specification.
1069
+
1070
+ #### Arguments:
1071
+
1072
+ Argument | Type | Description | Required
1073
+ :--- | :--- | :--- | :---:
1074
+ data | [Shotstack::AssetResponseData[]](#assetresponsedata) | Returns an array of asset resources grouped by render id. | -
1075
+
1076
+ ---
1077
+
1078
+ ### AssetResponseData
1079
+
1080
+ The **AssetResponseData** contains the type of resource (an asset) and attributes of the asset.
1081
+
1082
+ #### Arguments:
1083
+
1084
+ Argument | Type | Description | Required
1085
+ :--- | :--- | :--- | :---:
1086
+ type | string | The type of resource, in this case it is an `asset`. | -
1087
+ attributes | [Shotstack::AssetResponseAttributes](#assetresponseattributes) | The asset attributes including render id, url, filename, file size, etc... | -
1088
+
1089
+ ---
1090
+
1091
+ ### AssetResponseAttributes
1092
+
1093
+ The **AssetResponseAttributes** contains the list of asset attributes and their values.
1094
+
1095
+ #### Arguments:
1096
+
1097
+ Argument | Type | Description | Required
1098
+ :--- | :--- | :--- | :---:
1099
+ id | string | The unique id of the hosted asset in UUID format. | -
1100
+ owner | string | The owner id of the render task. | -
1101
+ region | string | The region the asset is hosted, currently only `au` (Australia). | -
1102
+ renderId | string | The original render id that created the asset in UUID format. Multiple asset can share the same render id. | -
1103
+ filename | string | The asset file name. | -
1104
+ url | string | The asset file name. | -
1105
+ status | string | The status of the asset. <ul><li>`importing` - the asset is being copied to the hosting service</li><li>`ready` - the asset is ready to be served to users</li><li>`failed` - the asset failed to copy or delete</li><li>`deleted` - the asset has been deleted</li></ul> | -
1106
+ created | string | The time the asset was created. | -
1107
+ updated | string | The time the asset status was last updated. | -
1108
+
1109
+ # API Documentation and Guides
1110
+
1111
+ - [Getting Started Guide](https://shotstack.io/docs/guide/getting-started/core-concepts/)
1112
+ - [API Reference](https://shotstack.io/docs/api/)
1113
+ - [Examples](https://github.com/shotstack/ruby-demos)
1114
+ - [Shotstack Website](https://shotstack.io)