Skip to main content

Animations

Shotstack provides a comprehensive system for creating smooth transitions (known as tweening) between keyframes in your video clips.

Tweening with Shotstack​

Shotstack's tweening framework allows developers to create animations by specifying how properties change over time. The core of this system is the use of arrays to define animation keyframes.

Instead of using a single start and end point, developers can create complex animations by defining multiple keyframe segments for a given property. Each segment specifies a start value (the initial state), end value (the final state), start time (when the animation starts), duration (how long the animation lasts), and interpolation method (how the values transition from start to end).

This approach enables the creation of nuanced, multi-stage animations for properties such as position and scale, all within a straightforward, array-based structure.

We currently support tweening for the following properties:

  • Opacity: Animate the transparency of a clip.
  • Offset: Control the x and y position of a clip.
  • Rotation: Animate the rotation of a clip
  • Skew: Control the horizontal and vertical shearing effect
  • Volume: Animate the audio volume of a clip.
  • Speed: Change the playback speed of a video asset over time. See speed ramps.

Animating a single property​

You can animate movement by adding an array with tweening properties to the property you wish to animate.

Animate position​

{
"timeline": {
"tracks": [
{
"clips": [
{
"asset": {
"type": "image",
"src": "https://shotstack-assets.s3.amazonaws.com/logos/shotstack/small/icon.png"
},
"start": 0,
"length": 5,
"fit": "none",
"offset": {
"x": [
{
"from": -1,
"to": 0,
"start": 0,
"length": 2.5
}
],
"y": [
{
"from": 0,
"to": 1,
"start": 2.5,
"length": 2.5
}
]
}
}
]
}
]
},
"output": {
"format": "mp4",
"size": {
"width": 1280,
"height": 720
}
}
}

Animate multiple properties​

You can add multiple tweening combinations to create complex animations.

{
"timeline": {
"tracks": [
{
"clips": [
{
"asset": {
"type": "image",
"src": "https://shotstack-assets.s3.amazonaws.com/logos/shotstack/small/icon.png"
},
"start": 0,
"length": 5,
"fit": "none",
"opacity": [
{
"from": 0,
"to": 1,
"start": 0,
"length": 5
}
],
"offset": {
"x": [
{
"from": -1,
"to": 0,
"start": 0,
"length": 2.5
}
],
"y": [
{
"from": 0,
"to": 1,
"start": 2.5,
"length": 2.5
}
]
},
"transform": {
"rotate": {
"angle": [
{
"from": 0,
"to": 360,
"start": 0,
"length": 2.5
},
{
"from": 360,
"to": 0,
"start": 2.5,
"length": 2.5
}
]
}
}
}
]
}
]
},
"output": {
"format": "mp4",
"size": {
"width": 1280,
"height": 720
}
}
}

Interpolation methods​

The default interpolation method is linear, producing a constant rate of change. For more complex effects, you can use a bezier curve with easings.

{
"output": {
"format": "mp4",
"fps": 60,
"size": {
"width": 1280,
"height": 720
}
},
"timeline": {
"tracks": [
{
"clips": [
{
"start": 0,
"length": 5,
"fit": "none",
"asset": {
"type": "image",
"src": "https://shotstack-assets.s3.amazonaws.com/logos/shotstack/small/icon.png"
},
"offset": {
"x": [
{
"start": 0,
"length": 2.5,
"from": -1,
"interpolation": "bezier",
"to": 0,
"easing": "easeInOutQuart"
}
],
"y": [
{
"start": 2.5,
"length": 2.5,
"from": 0,
"interpolation": "bezier",
"to": 1,
"easing": "easeInOutQuart"
}
]
}
}
]
}
]
}
}

Easings​

The easings available are:

Easing TypeDescription
easeSmooth transition with a gradual acceleration and deceleration.
easeInStarts slowly, then speeds up.
easeOutStarts quickly, then slows down.
easeInOutStarts and ends slowly, with a faster middle section.
easeInQuadSpeeds up at a steady rate from the start.
easeOutQuadSlows down steadily towards the end.
easeInOutQuadGradual speed up, then gradual slow down.
easeInCubicAccelerates faster than easeInQuad, for a stronger start.
easeOutCubicDecelerates faster than easeOutQuad, for a stronger finish.
easeInOutCubicStrong acceleration at the start, smooth middle, strong deceleration at the end.
easeInQuartEven stronger acceleration at the start, for a very quick takeoff.
easeOutQuartEven stronger deceleration at the end, for a very smooth stop.
easeInOutQuartQuick start, steady middle, smooth stop.
easeInQuintExtremely fast start, used for dramatic effects.
easeOutQuintExtremely smooth stop, used for dramatic effects.
easeInOutQuintVery fast start and very smooth stop.
easeInSineGentle acceleration, like easing into a swing.
easeOutSineGentle deceleration, like easing out of a swing.
easeInOutSineGentle start and end, like a smooth pendulum swing.
easeInExpoStarts slowly but speeds up dramatically, like an explosion.
easeOutExpoStarts fast then slows down dramatically, like something settling.
easeInOutExpoStarts and ends dramatically, for a very dynamic effect.
easeInCircStarts slow and curves quickly into motion, like rolling a ball.
easeOutCircStarts quickly and slows down in a circular motion, like a ball stopping.
easeInOutCircCurves into motion, speeds up, then curves to a stop.
easeInBackStarts by pulling back slightly before speeding up.
easeOutBackOvershoots the end slightly, then settles back.
easeInOutBackPulls back at the start, speeds up, overshoots the end, then settles back.

Speed ramps​

A video asset's speed takes the same tween array, so playback can speed up and slow down within a single clip. from and to are playback rates: 1 is normal speed, 2 is twice as fast and 0.5 is half speed. An eased tween gives the gradual change editors call a speed ramp; a linear one changes speed at a constant rate.

This drone flyover plays at normal speed, eases up to 8x, drops into 0.5x slow motion, speeds up to 6x and settles back to normal speed:

{
"timeline": {
"tracks": [
{
"clips": [
{
"asset": {
"type": "video",
"src": "https://shotstack-assets.s3.amazonaws.com/footage/drone-city-flyover.mp4",
"speed": [
{ "from": 1, "to": 1, "start": 0, "length": 2 },
{ "from": 1, "to": 8, "start": 2, "length": 1, "interpolation": "bezier", "easing": "easeInOut" },
{ "from": 8, "to": 8, "start": 3, "length": 5 },
{ "from": 8, "to": 0.5, "start": 8, "length": 1.5, "interpolation": "bezier", "easing": "easeInOut" },
{ "from": 0.5, "to": 0.5, "start": 9.5, "length": 5 },
{ "from": 0.5, "to": 6, "start": 14.5, "length": 1, "interpolation": "bezier", "easing": "easeInOut" },
{ "from": 6, "to": 6, "start": 15.5, "length": 4 },
{ "from": 6, "to": 1, "start": 19.5, "length": 1, "interpolation": "bezier", "easing": "easeInOut" },
{ "from": 1, "to": 1, "start": 20.5, "length": 2.5 }
]
},
"start": 0,
"length": 23
}
]
}
]
},
"output": {
"format": "mp4",
"fps": 60,
"size": {
"width": 1280,
"height": 720
}
}
}

How the speed is applied:

  • The clip keeps the length you set. Speed decides how much of the source plays in that time, starting from trim.
  • Before the first tween the video plays at its from speed, and after the last tween it holds the last to speed. Between two tweens the speed changes linearly from one to the next.
  • A speed of 0 freezes the current frame and a negative speed plays the video backwards.
  • If the speed runs past the end of the source, the last frame holds for the rest of the clip.
  • Audio follows the speed, so its pitch rises when the video speeds up and drops when it slows down.

Slow motion can only show the frames the source has. At 0.5x, 24fps footage shows 12 new frames each second, which looks jerky. For smooth slow motion use 60fps footage and set the output fps to 60, as in the example above.