How to Automate Video Generation with Ruby

20 May 2025 | 8 min read
Laura van Sinderen

In this tutorial, you'll learn how to create videos programmatically using Ruby and Creatomate's video generation API.

As a Ruby developer exploring video creation, you've likely used tools like FFmpeg – either directly from the command line or through gems like streamio-ffmpeg – to handle basic editing tasks. For more advanced needs, such as custom animations or frame-by-frame rendering, it's common to pair RMagick with FFmpeg to generate slide-based videos. While these approaches work well for smaller projects, they can quickly become complex when scaling – especially for personalized video generation, social media content, or integration with AI tools like ChatGPT, DALL·E, or ElevenLabs.

That's where Creatomate comes in. It simplifies the entire process by offering a cloud-based API for rendering dynamic videos. Whether you're building automated content pipelines, backend tools, or AI-driven video apps, Creatomate helps you go from raw data to fully-rendered videos in just a few lines of code. Since it integrates smoothly with Ruby, it's a great choice for scripting environments or web applications built with frameworks like Rails or Sinatra.

In this tutorial, you'll learn the fundamentals of video automation using Ruby and Creatomate – a strong foundation for building your own automated video workflows. By the end, I'll also point you to follow-up tutorials that cover more advanced techniques, including how to integrate generative AI into your video pipeline.

The example we'll build is just a starting point. Whether you're creating simple slideshows or complex, dynamic videos at scale, Creatomate gives you the flexibility to automate nearly anything. Its online template editor offers full creative control, letting you fine-tune every element to match your brand or message.

Prerequisites

Before getting started, make sure you have the following in place:

  • Ruby installed. If you don't have it yet, you can download it from the official Ruby website.
  • A Creatomate account. If you haven't signed up already, you can create a free account here.
  • A terminal or code editor. Any environment where you can write and run Ruby scripts will work just fine.

How to create videos using Ruby?

There are two main ways to generate videos with Ruby and Creatomate.

The easiest method is to use a template. You design the video layout once, then use your Ruby script to insert dynamic content – creating a unique video each time. This is the approach we'll focus on in this tutorial.

The second option is to build videos entirely with code, without relying on a predefined template. This gives you complete control over every aspect of the video – from layout and animations to timing. By writing a bit of JSON, you can define the entire structure of each video. This approach is perfect for fully dynamic, data-driven video generation. If you're curious, take a look at the JSON to Video documentation.

Let's begin by setting up a new Ruby project.

1. Set up your Ruby project

Start by creating a new folder for your project. In your terminal, run:

$ mkdir video_creation_project

Then navigate into the project directory:

$ cd video_creation_project

Next, create a Ruby file where you'll write your code. We'll call it generate_video.rb

On macOS or Linux:

$ touch generate_video.rb

On Windows:

$ echo. > generate_video.rb

Your Ruby project is now set up and ready to go. In the next step, we'll create a video template in Creatomate to use for video generation.

2. Create a video template in Creatomate

Log in to your Creatomate account. If you don't have one yet, you can sign up for free.

Once you're logged in, go to the Templates page and click New to open the template gallery. From here, you can either start from scratch if you have a specific design in mind, or choose a ready-made template for faster setup. To keep things simple for this tutorial, select the Quick Promo template from the Featured category. Then, choose the 9:16 Vertical format and click Create Template to open it in the editor:

Let's take a closer look at the video template and how it will be used in your Ruby script.

On the left side of the editor, you'll find all the elements that make up the template. Some of these elements are marked as dynamic, such as Video, Text-1, and Text-2 in this example. This means their content can be customized for each video you generate — allowing you to insert different text or media programmatically through your script.

You can fully customize the template to suit your exact needs. The editor offers a wide range of options and should feel familiar if you've used other video editing tools. If you'd like a quick overview of how it works, check out this short guide.

Once you're happy with your video design, let's move on to the next step.

3. Generate the Ruby script

Now that your template is ready, it's time to turn it into an API request.

Click the Use Template button in the top-right corner of the template editor, then select API Integration:

Creatomate will generate ready-to-use code snippets in several programming languages. Select Ruby, then copy the code that's provided:

Next, paste the code into the generate_video.rb file you created earlier.

4. Insert video content

Now, let's customize the content of your video using the “modifications” parameter.

This is where you define the text, media, and other dynamic elements for each video render. In a real application, this data could come from an API, a database, or user input – but for now, we'll use some predefined test values to keep things simple.

Go ahead and copy the following snippet into your Ruby script:

 data = {
  "template_id": "your_template_id",
  "modifications": {
    "Video.source": "https://cdn.creatomate.com/demo/video5.mp4",
    "Text-1.text": "Hello Ruby users 👋",
    "Text-2.text": "It's easy to create videos from your own scripts!"
  }
}

Note: Make sure to replace "your_template_id" with the actual ID of the template you created in step 2. This tells the API exactly which video design to use for rendering.

5. Run the script to create a video

Now that your script is ready, you can run it from the terminal:

$ ruby generate_video.rb

Once the API call is made, Creatomate will respond with a JSON object confirming that your request was received. It should look something like this:

1[
2  {
3    "id": "3ff72894-0aaf-4aec-8f55-9e265073af4f",
4    "status": "planned",
5    "url": "https://f002.backblazeb2.com/file/creatomate-c8xg3hsxdu/3ff72894-0aaf-4aec-8f55-9e265073af4f.mp4",
6    "snapshot_url": "https://f002.backblazeb2.com/file/creatomate-c8xg3hsxdu/3ff72894-0aaf-4aec-8f55-9e265073af4f-snapshot.jpg",
7    ...
8  }
9]

At this point, the video is being rendered in the background.

There are two ways to wait for your video to finish rendering.

One option is to write a small Ruby script that checks the video's status by making a separate GET request to the API, looking for the "status" to change to "succeeded".

The second, and recommended, method is to use a webhook. With webhooks, Creatomate will automatically notify your application as soon as the video is ready, eliminating the need to repeatedly check the status.

For now, simply wait about a minute after running your script, then visit the video URL returned in the API response. If you see a “Not Found” message, the video is still being processed – just wait a little longer and refresh.

Once rendering is complete, the URL will display your finished video:

Now that you have the video URL, you can download it, embed it, or integrate it directly into your automation workflow – whatever best fits your needs.

Tip: You can track all your API requests on the API Log page in your Creatomate dashboard. If a video fails to render, the log will show error messages and suggested solutions to help with troubleshooting.

What's next for video creation with Ruby

And that's how you can create videos using Ruby and Creatomate. Now that you've learned the basics, you can tailor this workflow to fit your own use cases and projects.

Interested in building AI-generated videos? Think of the faceless, short-form content you see on platforms like YouTube, TikTok, and Instagram. With Ruby, you can create a fully automated pipeline by integrating AI tools. For example, use ChatGPT to generate a script from a topic or keyword. Then, convert that script into voiceover audio with a text-to-speech API like ElevenLabs. Next, use Creatomate to add animated captions – automatically synced word-by-word using its auto-transcription feature, just like the trending styles you've seen online. For visuals, generate images using tools like DALL·E or Stable Diffusion. If you want to simplify social media publishing, use ChatGPT again to write captions and hashtags.

Here are some helpful tutorials and examples to explore. While they aren't Ruby-specific, the ideas are easy to adapt to your Ruby setup.

👉 How to Create AI Voice Over Videos using an API
👉 Using ChatGPT's API to Auto-Create Social Media Videos by Code
👉 How to Automate AI-Generated Shorts, Stories, and Reels

Start automating today

Start with a full-featured trial with 50 credits, no credit card required.
Get started for free