Go to file
DJ Chase 696e737c3a Switch to semantic versioning 2024-01-22 08:35:05 -05:00
.page-end.html Calm down about self hosting in stock instances 2024-01-22 08:32:14 -05:00
.page-start.html Add frontend 2024-01-18 16:42:51 -05:00
AUTHORS.md Add contributing information 2024-01-18 17:48:12 -05:00
CONTRIBUTING.md Add Sourcehut repo 2024-01-20 16:51:53 -05:00
LICENSE License project 2024-01-12 14:09:04 -05:00
README.md Switch to semantic versioning 2024-01-22 08:35:05 -05:00
vtt-embed.sh Add frontend 2024-01-18 16:42:51 -05:00

README.md

VTT Embed

Add captions to embedded YouTube videos (and others)

VTT Embed allows you to embed videos from external sources and add your own caption tracks. Its all CGI — so theres no need for your users to run JavaScript — and theres already a hosted instance if you dont want to set up your own (please do if you can though). It was also designed to avoid violating copyright so it should be safe to include this on your site.

VTT Embed also has many more features. Below are examples of some of the ways you can use it. There is also a demo if youd like to see it in action.

Usage

VTT Embed works by being a source in an HTML <video> or <audio> element. You select the source video — and optionally the format — you want via URL parameters. This makes it extremely easy to set up and allows you to use it in many different ways.

What follows is a more advanced description of how to use it. If you just go to the scripts address (see the hosted instance link above) there is a nice UI which will generate the embed code for you. Skip this section


There are two parameters you can use: url and format. url is the percent-encoded URL of to the page with the video youd like to embed; it is the only required parameter. format is the youtube-dl format youd like to use. It defaults to format=best if you do not specify it. (VTT Embed also uses Semantic Versioning 2...

Basic usage

The most basic way to use it is in the src attribute of the <video> tag:

<video controls src="https://dj-chase.com/cgi-bin/vtt-embed.sh?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dvv208qmcVeo">
  It looks like your browser cant display videos inline. You can still
  <a href="https://dj-chase.com/cgi-bin/vtt-embed.sh?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dvv208qmcVeo">download
  the video directly</a> or
  <a href="https://www.youtube.com/watch?v=vv208qmcVeo">watch it on YouTube</a>.
</video>
<p>You can also <a href="https://www.youtube.com/watch?v=vv208qmcVeo">watch this
  video on YouTube</a>.</p>

To keep these examples clean, Im going to omit the fallback text from now on. You should still include it in practice, though.

Adding captions

Captions are added just like you would for any other HTML <video> element:

<video controls src="https://dj-chase.com/cgi-bin/vtt-embed.sh?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dvv208qmcVeo">
  <track src="captions.vtt" kind="captions" srclang="en" label="English">
</video>
<p>You can also <a href="https://www.youtube.com/watch?v=vv208qmcVeo">watch this
  video on YouTube (no captions)</a>.</p>

Adding Audio Description

WebVTT can also be used for providing Audio Description:

<video controls src="https://dj-chase.com/cgi-bin/vtt-embed.sh?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dvv208qmcVeo">
  <track src="captions.vtt" kind="captions" srclang="en" label="English">
  <track src="description.vtt" kind="descriptions" srclang="en" label="English">
</video>
<p>You can also <a href="https://www.youtube.com/watch?v=vv208qmcVeo">watch this
  video on YouTube (no captions or Audio Description)</a>.</p>

Multiple resolutions

Itd be kind if you included a lower resolution option for people with slow connections (method from Adrian Roselli):

<video controls>
  <source media="(prefers-reduced-data: reduce)"
    src="https://dj-chase.com/cgi-bin/vtt-embed.sh?format=worst&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dvv208qmcVeo">
  <source src="https://dj-chase.com/cgi-bin/vtt-embed.sh?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dvv208qmcVeo">
  <track src="captions.vtt" kind="captions" srclang="en" label="English">
  <track src="description.vtt" kind="descriptions" srclang="en" label="English">
</video>
<p>You can also <a href="https://www.youtube.com/watch?v=vv208qmcVeo">watch this
  video on YouTube (no captions or Audio Description)</a>.</p>

Audio only

Sometimes podcasts are distributed as a video. If youd like, VTT Embed can also be used to embed a videos audio only:

<audio controls>
  <source media="(prefers-reduced-data: reduce)"
    src="https://dj-chase.com/cgi-bin/vtt-embed.sh?format=worstaudio&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dvv208qmcVeo">
  <source src="https://dj-chase.com/cgi-bin/vtt-embed.sh?format=bestaudio&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dvv208qmcVeo">
  <source src="https://dj-chase.com/cgi-bin/vtt-embed.sh?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dvv208qmcVeo">
  <track src="captions.vtt" kind="captions" srclang="en" label="English">
</audio>
<p>You can also <a href="https://www.youtube.com/watch?v=vv208qmcVeo">watch this
  as a video on YouTube (no captions)</a>.</p>

Support

The fastest way to get support would be to join the VTT Embed room on Matrix.

You can also email the mailing list if youd prefer, but it will definately be slower.

VTT Embed is designed not to get you a DMCA request as long as you are allowed to embed the video in the first place. This section details how it does this. I am not a lawyer, however, and this is not legal advice. By embedding someone elses video you of course assume responsibility.

VTT Embed does not host, stream, or copy videos. Instead, it merely locates the direct link on the provided page and redirects clients to it. Its similar to Invidious, except even more hands-off. Using it to embed a video is therefore as safe or safer than embedding a video from Invidious. It should also be as safe as embedding a video directly from YouTube, as long as you are allowed to embed the video from YouTube in the first place.