To add captions to your videos using query parameters, follow these steps:

  1. Determine the URLs of the caption files you want to use for different languages. These caption files should be in the WebVTT format (files with a .vtt extension).
  2. Use the tracks query parameter to specify the captions. It should be an array of JSON objects, each representing a caption track. Here’s the structure of each object:

    {“kind”:”captions”, “src”:”URL_TO_CAPTION_FILE.vtt”, “srclang”:”LANGUAGE_CODE”, “label”:”LABEL_FOR_LANGUAGE”, “default”:”1″}
  • “kind”: Set this to “captions” to indicate it’s a caption track.
  • “src”: Replace URL_TO_CAPTION_FILE.vtt with the URL of the caption file for the specific language.
  • “srclang”: Specify the language code for the captions (e.g., “en” for English, “de” for German, “es” for Spanish).
  • “label”: Provide a label for the language (e.g., “English”, “German”, “Spanish”).
  • “default” (optional): If you want one language to be the default, set this to “1”. Only one caption track should have this set to “1”.