Video seeking lets viewers jump to any point in an on-demand video or audio file without downloading the entire file first. This topic describes how to enable video seeking in the Alibaba Cloud CDN console.
Enabling video seeking increases time to first byte (TTFB) by approximately 30 ms.
How it works
When a viewer drags the playback bar to a new position, the player sends a URL request with a start parameter to CDN. CDN identifies the nearest preceding keyframe at or before that position and streams the video clip from there, delivering a seamless playback experience.
When the start value does not land on a keyframe, CDN seeks back to the last keyframe before that position. The actual playback starts slightly earlier than the requested timestamp. If your application requires frame-accurate seeking, account for this offset on the client side.Prerequisites
Before you begin, ensure that:
The origin server supports HTTP Range requests
The Ignore parameters feature is disabled on the accelerated domain name
Video seeking usesstartandendquery parameters to identify the playback segment. If Ignore parameters is enabled, CDN strips these parameters before forwarding requests to the origin, which breaks seeking behavior.
Supported file formats
Video seeking supports MP4 and FLV files. Each format has different metadata requirements and parameter units.
MP4
MP4 files store metadata in a structure called the moov atom, which holds the index information for the entire file. The player must read this metadata before it can seek to any position.
The moov atom must be in the file header. If it is at the file tail, the origin server must transmit the entire file before the player can begin seeking, which defeats the purpose of video seeking.
| Attribute | Details |
|---|---|
| Metadata location | File header (not file tail) |
| `start` parameter unit | Seconds, up to three decimal places (for example, start=1.01) |
| Example URL | domain/video.mp4?start=10 — plays from the 10th second |
FLV
For FLV files, the video must contain metadata. By default, the start parameter specifies a byte offset. Enable Time-based FLV Seeking to use seconds instead.
| Attribute | Details |
|---|---|
| Metadata requirement | File must contain metadata |
| Default `start` unit | Bytes (decimals rounded down to the nearest positive integer) |
| `start` unit with Time-based FLV Seeking | Seconds |
| Example URL (bytes) | domain/video.flv?start=10 — plays from the keyframe preceding byte 10 |
Choosing a seek mode for FLV:
Byte-based seeking — suited for precise data processing or raw video workflows
Time-based seeking — suited for end-user playback; jumps directly to the requested second
Enable video seeking
Log on to the Alibaba Cloud CDN console.
In the left-side navigation pane, click Domain Names.
Find the accelerated domain name to configure, then click Manage in the Actions column.
In the left-side navigation tree, click Video.
In the Video Seeking section, turn on the Video Seeking switch.
(Optional) To use time-based seeking for FLV files, turn on Time-based FLV Seeking.
(Optional) Modify Custom Parameters as needed.
Parameter processing logic
The following tables show how CDN handles different combinations of start and end values. These examples use time-based seeking with the default start and end parameters.
MP4
| Condition | Example | Result |
|---|---|---|
Both start and end are invalid | start=foo&end=bar | Returns the complete video |
start is valid; end is invalid | start=10 | Seeks from second 10 to the end |
start is invalid; end is valid | end=10 | Seeks from 0 to second 10 |
Both start and end are valid | start=0&end=10 | Seeks from 0 to second 10 |
Both start and end are 0 | start=0&end=0 | Returns the complete video |
start > end | start=10&end=0 | Seeks from second 10 to the end |
start = end | start=10&end=10 | Seeks from second 10 to the end |
start exceeds video duration | — | Returns HTTP 400 |
FLV
| Condition | Example | Result |
|---|---|---|
Both start and end are invalid | start=foo&end=bar | Returns the complete video |
start is valid; end is invalid | start=10 | Seeks from position 10 to the end |
start is invalid; end is valid | end=10 | Seeks from 0 to position 10 |
Both start and end are valid | start=0&end=10 | Seeks from 0 to position 10 |
Both start and end are 0 | start=0&end=0 | Returns the complete video |
start > end | start=10&end=0 | Seeks from position 10 to the end |
start = end | start=10&end=10 | Seeks from position 10 to the end |
start exceeds video duration | — | Returns the complete video |
When start exceeds the video duration, MP4 returns HTTP 400 but FLV returns the complete video.What's next
To configure video seeking through the API, call BatchSetCdnDomainConfig. For a full list of configurable parameters, see Feature settings for domain names.