---
layout: article
title: Timeline
description: Learn how Appwrite Videos generates sprite sheets and a WebVTT index for scrubbing thumbnails, and how to load them in your player.
---

The **timeline** gives a [video](/docs/products/videos/videos) scrubbing thumbnails: viewers see a preview frame while they drag across the progress bar. It is made of **sprite sheets**, images that pack many thumbnails into a grid, plus a **WebVTT index** that maps each time range to a thumbnail inside a sprite.

# Why sprite sheets

A one-hour video could need hundreds of thumbnails. Loading each as its own image would mean hundreds of requests the moment a viewer starts scrubbing. A sprite sheet packs many thumbnails into one image, so the player downloads a handful of files and crops the right thumbnail out of each with CSS or a canvas. Scrubbing stays instant, even on slow connections.

# Generation

Appwrite queues timeline generation when you create a video. The job downloads its own copy of the source, probes it if needed, and writes the sprites and index. There is nothing to configure.

Open the video and select **Timeline** to browse the generated thumbnails. From there you can copy the timeline URL, download the timeline file, or download every sprite with a matching `timeline.vtt` as a `.tar.gz` archive.

![Timeline tab with sprite thumbnails, the thumbnail interval and size, and the timeline file URL](/images/docs/videos/timeline.avif)

The video's `timelineStatus` shows how far the job has got:

| Status | Meaning |
|--------|---------|
| `pending` | Waiting for a worker |
| `started` | Generating the sprites and index |
| `ready` | The index and sprites are available |
| `skipped` | The source has no picture, such as an audio-only file |
| `error` | Generation failed. `timelineError` says why |

The timeline is generated once per video and is not retried if it fails.

# WebVTT index

Load the index from `/v1/videos/<VIDEO_ID>/timeline?project=<PROJECT_ID>`. In every SDK, `videos.getTimeline({ videoId })` returns that URL; fetch it to read the WebVTT text. Each cue points at a sprite and the region of one thumbnail inside it, using a `#xywh=x,y,width,height` media fragment. For a short 16:9 clip:

```text
WEBVTT

00:00:00.000 --> 00:00:02.000
thumbnails/<THUMBNAIL_ID>?project=<PROJECT_ID>#xywh=0,0,480,270

00:00:02.000 --> 00:00:04.000
thumbnails/<THUMBNAIL_ID>?project=<PROJECT_ID>#xywh=480,0,480,270
```

Each thumbnail is 480 pixels wide, and each sprite holds a grid of up to 4 × 4 thumbnails. Cue paths are relative to the timeline URL. Resolve them against it to get the full image URL.

The time between thumbnails depends on the video's length:

| Duration | One thumbnail every |
|----------|---------------------|
| Under 2 minutes | 2 seconds |
| 2 to 10 minutes | 5 seconds |
| 10 to 30 minutes | 10 seconds |
| 30 to 60 minutes | 20 seconds |
| 1 hour or more | 30 seconds |

Many players can show thumbnails from a WebVTT thumbnail track, either built in or with a plugin. Until the timeline is generated, and always for audio-only videos, the request returns `404` with the `video_timelines_not_found` error. Since generation runs in the background, check `timelineStatus` every few seconds after creating a video if you need the timeline right away.

# Use thumbnails in a custom player

If your player has no thumbnail support, parse the index yourself and show the matching region as a CSS background while the pointer hovers the progress bar:

```js
function parseTimeline(vtt, timelineUrl) {
    const toSeconds = (t) => t.split(':').reduce((sum, part) => sum * 60 + Number(part), 0);

    return vtt.split(/\n{2,}/).flatMap((block) => {
        const lines = block.trim().split('\n');
        const timing = lines.findIndex((line) => line.includes('-->'));
        if (timing < 0 || !lines[timing + 1]) return [];

        const [start, end] = lines[timing].split('-->').map((t) => toSeconds(t.trim()));
        const [path, fragment] = lines[timing + 1].split('#xywh=');
        const [x, y, w, h] = fragment.split(',').map(Number);

        return [{ start, end, url: new URL(path, timelineUrl).toString(), x, y, w, h }];
    });
}

function showThumbnail(element, cues, seconds) {
    const cue = cues.find((c) => seconds >= c.start && seconds < c.end);
    if (!cue) return;
    element.style.width = `${cue.w}px`;
    element.style.height = `${cue.h}px`;
    element.style.backgroundImage = `url("${cue.url}")`;
    element.style.backgroundPosition = `-${cue.x}px -${cue.y}px`;
}
```

Load the sprite images once when the player opens, so the first hover does not wait on the network.

# Sprite images

Each sprite is served as a **thumbnail**. Fetch one from the URL in the index, or with `videos.getThumbnail({ videoId, thumbnailId })`. Pass `output` (`jpg`, `jpeg`, `png`, `gif`, or `webp`) to convert it. Without `output`, browsers that accept WebP get WebP, and others get JPEG.

A thumbnail is a whole sprite, not a single frame. `width` and `height` resize and crop the whole sprite, so the `#xywh` regions in the index no longer line up. Keep the original size when you use sprites for scrubbing.

# Posters

Videos does not set a poster image. To show one before playback starts, use your own image, for example a file in [Storage](/docs/products/storage) whose ID you keep next to the video ID in your database.
