Learn · No-Code

How to add subtitles to a video automatically with n8n

Contents

Drop a video into a Google Drive folder. A copy with subtitles appears in another folder. That is the whole routine once this n8n workflow is running.

Shotstack listens to the speech, writes the subtitles and burns them into the picture in one render. There is no transcription tool to connect and no subtitle file to make or upload.

This guide shows how to add subtitles to a video automatically with n8n, using a free workflow template made by Shotstack. You connect two accounts and choose how the subtitles look. This is the result:

At a glance

QuestionShort answer
What goes in?Any video with speech, dropped into a Google Drive folder you choose
What comes out?An MP4 with the subtitles burned in, saved to a second Drive folder
What do you choose?The look: font, size, colors, position and how the spoken word is marked
What do you need?n8n (Cloud or self-hosted), a Shotstack account and a Google account
Is there code to write?No. You paste one block of settings to pick a look

Burned-in subtitles are part of the picture, so every viewer gets them, on every platform and on muted autoplay. That matters to more people than you might expect: in a 2023 Preply survey of 1,503 Americans, 51% said they watch content with subtitles most of the time.

Our guide to open captions vs closed captions explains when a separate caption file is the better choice.

What happens to each video

The n8n subtitle workflow on the canvas in three parts: watch Drive and send the video, wait for the render, save the captioned copy

  1. n8n notices the new file. The workflow checks your folder every minute.
  2. The file is shared by link so Shotstack can read it.
  3. Shotstack makes the subtitles. It transcribes the speech, times every word and renders a new MP4 with the subtitles on top.
  4. The copy is saved to Drive. Your original video is not changed.

Set up the workflow

1. Install the Shotstack node

In n8n, open the nodes panel with the plus button and type “Shotstack”. Select the node under More from the community and click Install. You need to be an owner or admin of the n8n instance.

n8n nodes panel with Shotstack typed in the search box and the verified Shotstack node in the results

Our n8n video automation guide covers everything else the node can do.

2. Add the template

Open the subtitle template on n8n and click Use for free. The workflow opens on your canvas with every step connected.

3. Connect Google Drive and pick the folder to watch

Create two folders in Drive first, for example To subtitle and Subtitled. Then open New video in the folder, the first step:

  1. Click Connect to Google Drive and sign in. On self-hosted n8n, create a Google OAuth client first.
  2. In Folder, pick To subtitle from the list.

The New video in the folder step: Connect to Google Drive, Poll Times set to Every Minute, Trigger On set to Changes Involving a Specific Folder, Folder, and Watch For set to File Created

Open Let Shotstack read the file and pick the same Google account. Nothing else changes in that step.

4. Connect Shotstack

Open Shotstack: burn in the captions. In the credential dropdown choose Create new credential, paste your production API key, set Environment to Production and save.

Shotstack API credential in n8n with Environment set to Production and a green Connection tested successfully banner

The key is under API Keys in the Shotstack dashboard. Create a free account if you don’t have one; new accounts include credits. Renders use credits, and rates are on the pricing page.

Pick the same credential in Check the render.

5. Paste a subtitle look

Stay in Shotstack: burn in the captions. The Edit field holds the settings for the video: where the file comes from and how the subtitles are drawn.

The Shotstack: burn in the captions step with Resource set to Render, Operation set to Render Asset, and the Edit field

Select everything in Edit and paste this in its place. It is the look from the video at the top: bold white text with the spoken word in yellow.

JSON
{
  "timeline": {
    "fonts": [
      {"src": "https://fonts.gstatic.com/s/inter/v20/UcCo3FwrK3iLTfvlaQc78lA2.ttf"}
    ],
    "tracks": [
      {
        "clips": [
          {
            "asset": {
              "type": "rich-caption",
              "src": "alias://source",
              "font": {"family": "UcCo3FwrK3iLTfvlaQc78lA2", "size": 38, "weight": 700, "color": "#ffffff"},
              "stroke": {"width": 2, "color": "#000000"},
              "shadow": {"offsetX": 0, "offsetY": 2, "blur": 6, "color": "#000000", "opacity": 0.6},
              "active": {"font": {"color": "#ffd60a"}},
              "animation": {"style": "highlight"},
              "align": {"vertical": "bottom"}
            },
            "start": 0,
            "length": "end",
            "width": 1000,
            "height": 130,
            "fit": "none",
            "position": "bottom",
            "offset": {"y": 0.06}
          }
        ]
      },
      {
        "clips": [
          {
            "alias": "source",
            "asset": {
              "type": "video",
              "src": "https://drive.usercontent.google.com/download?export=download&confirm=t&id={{ $('New video in the folder').item.json.id }}"
            },
            "start": 0,
            "length": "auto"
          }
        ]
      }
    ]
  },
  "output": {"format": "mp4", "resolution": "hd"}
}

Leave the line that starts with "src": "https://drive.usercontent.google.com exactly as it is. That line points Shotstack at the Drive file. There are three more looks further down.

6. Choose where the copy goes and what it is called

Open Save the captioned copy:

  1. Pick your Google account.
  2. In Parent Folder, pick Subtitled.
  3. Replace the text in File Name with this:
Text
{{ $('New video in the folder').item.json.name.replace(/\.[^.]+$/, '') }} (captioned).mp4

The Save the captioned copy step: Operation set to Upload, File Name, Parent Drive and Parent Folder

A video named team-update.mp4 is saved as team-update (captioned).mp4.

The two folders must be different. If the copy is saved into the folder the workflow watches, the copy counts as a new video and gets subtitled again, in a loop.

7. Publish it and drop in a video

Click Publish in the top right. Then upload a short video with clear speech to To subtitle.

What you should see: a new run appears under Executions. When it finishes, your-file (captioned).mp4 is in the Subtitled folder.

More subtitle looks

Each look is a full replacement for the Edit field. Paste it over what is there.

Classic subtitles

White text with a black outline at the bottom of the frame, the way films do it. No animation.

JSON
{
  "timeline": {
    "fonts": [
      {"src": "https://fonts.gstatic.com/s/opensans/v44/mem8YaGs126MiZpBA-U1UpcaXcl0Aw.ttf"}
    ],
    "tracks": [
      {
        "clips": [
          {
            "asset": {
              "type": "rich-caption",
              "src": "alias://source",
              "font": {"family": "mem8YaGs126MiZpBA-U1UpcaXcl0Aw", "size": 34, "weight": 600, "color": "#ffffff"},
              "stroke": {"width": 3, "color": "#000000"},
              "animation": {"style": "none"},
              "align": {"vertical": "bottom"}
            },
            "start": 0,
            "length": "end",
            "width": 1000,
            "height": 120,
            "fit": "none",
            "position": "bottom",
            "offset": {"y": 0.06}
          }
        ]
      },
      {
        "clips": [
          {
            "alias": "source",
            "asset": {
              "type": "video",
              "src": "https://drive.usercontent.google.com/download?export=download&confirm=t&id={{ $('New video in the folder').item.json.id }}"
            },
            "start": 0,
            "length": "auto"
          }
        ]
      }
    ]
  },
  "output": {"format": "mp4", "resolution": "hd"}
}

White box

Dark text on a white rounded box, with the spoken word in blue. It stays readable over any background.

JSON
{
  "timeline": {
    "fonts": [
      {"src": "https://fonts.gstatic.com/s/inter/v20/UcCo3FwrK3iLTfvlaQc78lA2.ttf"}
    ],
    "tracks": [
      {
        "clips": [
          {
            "asset": {
              "type": "rich-caption",
              "src": "alias://source",
              "font": {"family": "UcCo3FwrK3iLTfvlaQc78lA2", "size": 30, "weight": 700, "color": "#111111"},
              "background": {"color": "#ffffff", "opacity": 1, "borderRadius": 12, "wrap": true, "padding": 16},
              "active": {"font": {"color": "#2563eb"}},
              "animation": {"style": "highlight"}
            },
            "start": 0,
            "length": "end",
            "width": 860,
            "height": 150,
            "fit": "none",
            "position": "bottom",
            "offset": {"y": 0.06}
          }
        ]
      },
      {
        "clips": [
          {
            "alias": "source",
            "asset": {
              "type": "video",
              "src": "https://drive.usercontent.google.com/download?export=download&confirm=t&id={{ $('New video in the folder').item.json.id }}"
            },
            "start": 0,
            "length": "auto"
          }
        ]
      }
    ]
  },
  "output": {"format": "mp4", "resolution": "hd"}
}

Change one thing

You can edit any look by hand. These are the lines people change most:

To changeEdit this line
Text size"size" inside "font"
Text color"color" inside "font", as a hex color such as #ffffff
Outline"width" and "color" inside "stroke"
Color of the spoken word"color" inside "active"
How the spoken word is marked"style" inside "animation": highlight, karaoke, pop, fade, slide, bounce, typewriter or none
How high the subtitles sit"y" inside "offset". A bigger number moves them up
How wide a line can be"width" on the caption clip, in pixels
All capitalsAdd "style": {"textTransform": "uppercase"} next to "font"

The font is set in two places. "fonts" at the top loads the font file, and "family" is that file’s name without .ttf. The rich captions page in the docs lists every option, with a short video of each animation.

Vertical videos for Reels, Shorts and TikTok

The three looks above render a landscape video, 1280 x 720. A vertical video needs a vertical output, or it is cropped to fit the landscape frame.

This look sets the output to 1080 x 1920. The text is large and in capitals, it sits in the lower third, and each word pops as it is spoken:

JSON
{
  "timeline": {
    "fonts": [
      {"src": "https://fonts.gstatic.com/s/montserrat/v31/JTUSjIg1_i6t8kCHKm45xW5rygbi49c.ttf"}
    ],
    "tracks": [
      {
        "clips": [
          {
            "asset": {
              "type": "rich-caption",
              "src": "alias://source",
              "font": {"family": "JTUSjIg1_i6t8kCHKm45xW5rygbi49c", "size": 72, "weight": 800, "color": "#ffffff"},
              "style": {"textTransform": "uppercase"},
              "stroke": {"width": 6, "color": "#000000"},
              "active": {"font": {"color": "#ffd60a"}},
              "animation": {"style": "pop"}
            },
            "start": 0,
            "length": "end",
            "width": 900,
            "height": 260,
            "fit": "none",
            "offset": {"y": -0.18}
          }
        ]
      },
      {
        "clips": [
          {
            "alias": "source",
            "asset": {
              "type": "video",
              "src": "https://drive.usercontent.google.com/download?export=download&confirm=t&id={{ $('New video in the folder').item.json.id }}"
            },
            "start": 0,
            "length": "auto"
          }
        ]
      }
    ]
  },
  "output": {"format": "mp4", "size": {"width": 1080, "height": 1920}}
}

A workflow has one output shape. If you make both kinds of video, duplicate the workflow, give each copy its own pair of folders, and paste a landscape look in one and the vertical look in the other.

Add subtitles to a batch of videos at once

You can drop a whole batch into the folder. Each video becomes its own render and its own captioned copy. This is one run that received three videos at the same time:

Two settings make that work, and you already have both. The looks in this guide read the file with .item, and so does the file name from step 6. .item means “the video this run is working on”, so each video keeps its own link and its own name.

Three things to know when you work in batches:

  • Videos that were already in the folder are not picked up. The workflow only sees files added after you publish it. To subtitle older videos, make a copy of each one in the folder. A copy counts as a new file.
  • Subfolders are not watched. Put the videos directly in the folder.
  • A failed video stops its run. Videos that arrived in the same check of the folder are in that run too. If one of them has no copy afterward, add it to the folder again. The next section shows how to read the reason.

The same job in code, for when the videos are not in Drive: burn subtitles into a video with the API.

If a video does not get its subtitles

Open the failed run under Executions. The Stop and say why step shows a message that starts with “Shotstack could not finish this render”, followed by the reason.

The reason saysWhat happenedWhat to do
declared as 'video' but source content type is 'image/jpeg' (or another file type)A file that is not a video was added to the folder.Keep only videos in the folder, or add the filter below.
declared as 'video' but source content type is 'text/html'Drive answered with a web page, not the video. Either the file is not shared by link, or the Edit field still has the template’s original link and the video is large.Paste a look from this guide. Its link also works for large videos, such as a 111 MB file.
Generation failed and Failed clip: timeline.tracks[0].clips[0]The video has no audio track, so there is nothing to transcribe.Use a video with audible speech.
The edit still contains an n8n expressionThe Edit field is in Fixed mode.Switch the field to Expression.

To skip files that are not videos, add an If step right after New video in the folder. Set the first value to {{ $json.mimeType }}, the condition to starts with, and the second value to video/. Connect its true output to Let Shotstack read the file. MP4 and MOV files pass. Images and PDFs don’t.

What the workflow changes in your Drive

  • Link sharing is turned on for each video you drop in. The second step sets it to “Anyone with the link” as a viewer, with search discovery off. Shotstack needs this to read the file.
  • The sharing stays on after the run. If a video should not stay reachable by link, turn sharing off in Drive when the copy is done.
  • Your original is never edited. The captioned video is a new file in the output folder.

More n8n video workflows

Shotstack has more n8n workflows that you can use as they are:

  • n8n video automation: the main guide to the Shotstack node. Install it, make your first render and build a review form that turns customer quotes into testimonial videos.
  • Real estate videos with n8n: a row in Google Sheets becomes a narrated listing tour made from the listing’s photos, with an approval email for the agent.

Let Shotstack subtitle every video you drop in Drive

Install the node, add the template, connect Drive and Shotstack, and paste a look. From then on, you add captions to a video by dragging it into a folder: the video goes into one folder and the captioned copy lands in the other, in your font and colors.

Create a free Shotstack account to get your API key and starter credits, then open the subtitle template on n8n.

Frequently asked questions (FAQs)

Which languages does it work with?

Shotstack detects the spoken language on its own and supports 99 languages. You don’t set the language anywhere in the workflow. The subtitles are in the language that is spoken.

Can I get an SRT file instead of burned-in subtitles?

Not from this workflow, which always burns the subtitles into the picture. To get a caption file you can upload to YouTube or a video player, follow our guide to generating SRT and VTT subtitles with the API.

Can I use my own subtitle file instead of the automatic transcript?

Yes. In the Edit field, replace alias://source with a public link to your .srt or .vtt file. Shotstack then uses your text and timings, and your look is applied the same way.

Do the videos have to be in Google Drive?

No. Shotstack reads any video that has a direct public link. Swap the first two steps for your storage tool’s steps, and put that tool’s file link where the Drive link is in the Edit field.

Keep reading

Start free

  • Unlimited developer sandbox
  • No credit card required