SmartVideo supports captions and subtitles in two ways: auto-imported from Vimeo, or manually added via WebVTT files.
Vimeo captions (auto-import)
If your video source is Vimeo, SmartVideo imports the captions that exist on the source when it first processes the video. Have all caption languages ready on Vimeo before then, so you don’t need a later caption fetch or a fresh source copy. Turn on caption import so the player shows the imported English track.
To enable caption import:
- WordPress plugin: Open SmartVideo in your WordPress admin sidebar. On the Settings tab, under Auto-conversions, turn on Import captions (it saves automatically).
- JavaScript snippet: Add
youtubecaptions: trueinside the existingswarmoptions.autoreplaceobject. Keep the other options already in that object.
The setting is named after YouTube for historical reasons. For Vimeo videos the option works as described; whether captions come across for a YouTube video that did convert is not something we can promise today.
Already converted the video, or added captions afterward? If no English captions are available and you have not supplied manual <track> elements, enable caption import and load a page with the video to request a captions-only fetch. The fetch is requested even if other caption languages were imported earlier. It runs asynchronously. After the captions have been fetched, reload the page so SmartVideo can attach the imported English track and show the CC control. If the video has captions only in other languages, add them with the captionsUrl helper and <track> elements below. This automatic fetch does not run for some videos whose captions were imported by an older version of SmartVideo. If the CC control still does not appear after a reload, add your captions with <track> elements (below), or put a fresh copy of the video on Vimeo and swap your embed to it.
Adding more languages when English captions were already imported: SmartVideo’s automatic caption check finds the existing English track and does not request another import. To import newly added languages, put a fresh copy of the video on Vimeo with all caption languages ready, then swap your site’s embed to that new video’s URL. Alternatively, add caption files manually with <track> elements.
SmartVideo imports every caption language available on the source Vimeo video. With caption import enabled and no manual <track> elements, the player adds the English track automatically. Use <track> elements to display other imported languages.
To display one of the additional imported languages, get its caption URL with the captionsUrl helper (run this in your browser console on any page with SmartVideo loaded):
swarmify.captionsUrl("https://player.vimeo.com/video/123456789", "es")
The first argument is the original video URL, the second is the language code. Paste the returned URL into a <track> element’s src (see below), and the language shows up in the player’s captions menu.
Adding any <track> element stops SmartVideo from adding the English track automatically. To keep English available alongside other languages, include an English <track> too. Get its URL with swarmify.captionsUrl("https://player.vimeo.com/video/123456789", "en"), using your original video URL.
Manual captions with WebVTT files
For full control over your captions, use the standard <track> element inside your SmartVideo tag with a WebVTT (.vtt) caption file.
<smartvideo src="https://your-video.example.com/file.mp4" width="1280" height="720" controls>
<track default kind="captions" srclang="en" label="English" src="captions.vtt">
</smartvideo>
Multiple languages
You can add captions in multiple languages by including additional <track> elements. The one marked with default will be shown first, and viewers can switch between languages from the captions menu in the player controls.
<smartvideo src="https://your-video.example.com/file.mp4" width="1280" height="720" controls>
<track default kind="captions" srclang="en" label="English" src="captions-en.vtt">
<track kind="captions" srclang="es" label="Español" src="captions-es.vtt">
<track kind="captions" srclang="fr" label="Français" src="captions-fr.vtt">
</smartvideo>
Where to host your caption files
Your .vtt files can live on your own website or on any other server you control. Where you put them decides whether there’s one extra step.
- If the caption file is on exactly the same domain as the page the video plays on, for example a file uploaded to your WordPress media library, there’s nothing extra to set up. (If a plugin offloads your media library to a CDN, the files are on that CDN’s domain instead.)
- If the caption file is on a different domain, such as an Amazon S3 bucket, another CDN, or a separate file host, that server has to allow cross-origin (CORS) requests. Without that, browsers won’t load the file and the captions don’t show up in the player. A subdomain counts as a different domain too, so a file on
cdn.example.comused onwww.example.comneeds this step. - Caption files imported from Vimeo, including the URLs you get from
swarmify.captionsUrl, are served from our network and already allow this, so there’s nothing to set up for them.
This matters most if your site runs on a hosted platform, like an online course or membership platform, that lets you paste embed code but doesn’t let you upload your own files. In that case your caption files will live somewhere else, so turn on CORS there.
To allow it, the server needs to send an Access-Control-Allow-Origin header with your caption files, set to your site’s address exactly as it appears in the browser, with no trailing slash or path (for example https://www.example.com), or to * to allow any site. Your storage provider’s docs cover how to turn this on. On Amazon S3, open the bucket’s Permissions tab and edit the Cross-origin resource sharing (CORS) section; Amazon’s CORS configuration guide has the steps and example rules.
Not sure if it’s working? Open your browser’s developer console on the page with the video. If a caption file is being blocked, you’ll see a CORS error that names the .vtt URL.
How captions show up in the player
- One caption track: the player shows a single CC toggle on the control bar (or inside the three-dot overflow menu on narrow players). Tap it once to turn captions on, tap again to turn them off.
- Multiple caption tracks: the CC button opens a submenu so viewers can pick a language or turn captions off.
- No caption files: the CC option is hidden entirely — you won’t see a stray “Captions” entry on videos that don’t have any.
Quick reference
| Method | Languages | Setup |
|---|---|---|
| Vimeo auto-import | All languages on the source video (English added automatically when enabled and no manual tracks are supplied) | Have captions on Vimeo before first processing; enable swarmoptions.autoreplace.youtubecaptions to show English |
| Manual WebVTT | Any language | Add <track> elements to your SmartVideo tag |
For more details on the <track> element, see Mozilla’s reference documentation.
Keywords: captions, subtitles, WebVTT, VTT, track, YouTube captions, youtubecaptions, multiple languages, accessibility, CORS, cross-origin, Access-Control-Allow-Origin, host caption files, vtt not loading, captions not showing, S3 captions