Captioning

AMP supports the following captioning formats by default:

  • VTT
  • TTML
  • 608
  • 708
  • embedded

To include caption tracks in media playback, provide a track array to the media object. Each item in the array should have the following properties:

  • src: The path to the caption file
  • type: The mime type of the file
  • kind: The kind of text track. For captions, use the string "captions".
var config = {
	media: {
		src: "http://video.xyz.com/master.m3u8",
		type: "application/x-mpegURL",
		track: [{
			kind : "captions",
			type: "application/ttml+xml",
			src: "captioning.xml"
		}]
	}
};

Additionally, tracks for individual languages can be setting the srclang property of the track items with an ISO 639-1 language code. The player will choose the track based on the player's language setting (see Localization for more details):

var config = {
	media : {
		src : "http://video.xyz.com/master.m3u8",
		type : "application/x-mpegURL",
		track : [{
			kind : "captions",
			type : "text/vtt",
			src : "captioning-en.vtt",
			srclang : "en"
		}, {
			kind : "captions",
			type : "application/ttml+xml",
			src : "captioning-es.xml",
			srclang : "es"
		}]
	}
};

For 608, 708, or embedded captions, the src property is not needed. Just provide the proper mime type:

  • 608: "text/cea-608"
  • 708: "text/cea-708"
  • Embedded: "text/embedded"

Example

var config = {
 media : {
	 src : "http://video.xyz.com/master.m3u8",
	 type : "application/x-mpegURL",
	 track : [{
		 kind : "captions",
		 type : "text/cea-608"
	 }]
 }
};