When viewers seek to a specific position in an on-demand video or audio file after enabling video seeking, the client sends a URL request to the server. This topic describes how to enable video seeking in the CDN console.
After video seeking is enabled, the time to first byte (TTFB) increases by about 30 ms, which may slightly affect user experience.
Introduction
After video seeking is enabled, the client sends a URL request to the server whenever viewers adjust the playback position. CDN identifies the nearest preceding keyframe of the playback position to load the video clip that viewers want to play, providing a seamless playback experience.
Prerequisites
The origin server supports HTTP Range requests.
The Ignore parameters feature is disabled.
Supported file formats
For example: For an FLV file with the URL request www.aliyun.com/test.flv?start=10
, the server responds with data from the keyframe preceding the 10th byte. The following table describes the supported file formats for video seeking and sample URLs.
File format | Metadata | Start parameter | Example |
MP4 | The metadata of a video file on the origin server must be included in the file header and not included in the file tail. | The start parameter specifies the time in seconds and the value can be rounded up to three decimal places. For example,
| URL request |
FLV | Video files on the origin server must contain metadata. | The start parameter specifies the position in bytes. Decimals are not supported. Although the parameter can include decimals, the seeking module rounds down the value to the nearest positive integer. If you turn on Time-based FLV Seeking, the unit of the start and end parameters is second. Note Seeking by bytes is suitable for precise data processing or raw video data processing. Seeking by seconds provides a user-friendly experience by directly jumping to the exact second requested.
| URL request |
Procedure
Log on to the Alibaba Cloud CDN console.
In the left-side navigation pane, click Domain Names.
On the Domain Names page, find the domain name that you want to manage and click Manage in the Actions column.
In the left-side navigation tree of the domain name, click Video.
In the Video Seeking section, turn on the Video Seeking switch.
Optional. Turn on Time-based FLV Seeking and modify Custom Parameters.
Processing logics of video seeking parameters
Seeking by time is used as an example. The default start and end parameters are used. The following tables describe the processing logics of parameter values in different scenarios:
Requests for MP4 file
start/end values | Example | Processing logic |
Invalid values of the |
| Ignores video seeking parameters and responds with the complete video. |
Valid value of the |
| Processes video seeking from |
Invalid value of the |
| Processes video seeking from |
Valid values of the |
| Processes video seeking from |
Both the |
| Ignores video seeking parameters and responds with the complete video. |
The value of the |
| Processes video seeking from |
The value of the |
| Processes video seeking from |
The value of the | The value of the | Returns response with a HTTP status code |
Requests for FLV file
start/end values | Example | Processing logic |
Invalid values of the |
| Ignores video seeking parameters and responds with the complete video. |
Valid value of the |
| Processes video seeking from |
Invalid value of the |
| Processes video seeking from |
Valid values of the |
| Processes video seeking from |
Both the |
| Ignores video seeking parameters and responds with the complete video. |
The value of the |
| Processes video seeking from |
The value of the |
| Processes video seeking from |
The value of the | The value of the | Returns the complete video. |