Overview
Creating a media player that is engaging and accessible is key to growing and retaining an audience. Learn how to add subtitles, a thumbnail track, and chapters to your media player using Ittybit's Tracks API
.
Step-by-step guide
-
Locate the media file you want to add
Tracks
to. You will need themedia id
as an input as well as anAPI Key
. You can find themedia id
in the Media object. -
Use the following code snippets to add
Tracks
to your media player:
const API_KEY = "YOUR API KEY HERE" // Your Ittybit API key const response = await fetch("https://api.ittybit.com/tasks", { headers: { Method: "POST", Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", body: JSON.stringify({ input: "med_abcdefgh1234", // Required parameter: media id or file URL output: { kind: "subtitles", // Required parameter: desired output kind }, }), }, });
const API_KEY = "YOUR API KEY HERE" // Your Ittybit API key const response = await fetch("https://api.ittybit.com/tasks", { headers: { Method: "POST", Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", body: JSON.stringify({ input: "med_abcdefgh1234", // Required parameter: media id or file URL output: { kind: "chapters", // Required parameter: desired output kind }, }), }, });
const API_KEY = "YOUR API KEY HERE" // Your Ittybit API key const response = await fetch("https://api.ittybit.com/tasks", { headers: { Method: "POST", Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", body: JSON.stringify({ input: "med_abcdefgh1234", // Required parameter: media id or file URL output: { kind: "thumbnail", // Required parameter: desired output kind }, }), }, });
About the API
Endpoint
POST https://api.ittybit.com/tasks
Body parameters
{ "input": "MEDIA_ID", // Required parameter: media id or file URL "output": { "kind": "subtitles" // or "chapters" or "thumbnail" } }
Required
Note: Generating Subtitles
and Chapters
requires that the Media item already has a Speech Intelligence object. You can create this using the Intelligence API.
-
input string
The ID of the media to use as the input for the task. You may use a
media_id
: theid
from a Media object, or afile_id
: theid
from a File object or a URL to the media file. -
output object
Defines the output for the task. The
output
object must include akind
and may include additional options that are specific to thekind
of task.
Next: Combine with Automations API
You can use the Automations API to automatically add subtitles, a thumbnail track, and chapters to all uploaded media files. This is useful for large media libraries or social networks with user-generated content.
See the guide here: Automations
Or see Tracks in action within an Automations API request:
const response = await fetch("https://api.ittybit.com/automations", { headers: { Method: "POST", Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", body: JSON.stringify({ "name": "All video uploads", "trigger": { "event": "media.created", "conditions": [ {"prop": "kind", "value": "video"} ] }, "tasks": [ { "kind": "image", "start": 0 }, { "kind": "video", "width": 600, "format": "mp4", "filename": "600.mp4", "next": [ { "kind": "speech", "next": [ { "kind": "subtitles" } ] }, { "kind": "thumbnails" } ] } ] }), }, });
Considerations
This guide is being updated. Please check back soon for more information.