Video files primarily come in two types: with a file header, and without a file header. The file header records global information of the video file, for example, size and duration of each frame, position of a key frame, and so on. A video file without a file header is composed of many video file packages. Although there is no dedicated header for storing the global information of the file, information such as the position of the key frame and a timestamp is stored in specific video file packages.
Video dragging is a common operation performed when a user watches a video. In the process of watching the video, the user can drag a progress bar to locate the current playing position of the video quickly so as to find a segment of interest quickly. Because a client has to start decoding and playing from the position of the key frame of the video, a player needs to locate the key frame of the video in the process of dragging the video.
In the prior art, the video dragging operation depends on the file header of the video file. By parsing the file header, the position information of all key frames of the video file stored in the file header is obtained, and video data that begins with a key frame is sent to the client, where the key frame is the closest to a position from which the video is requested to be dragged, and the client decodes and plays the video data, thereby completing the video dragging operation. However, if the video file of a specific format has no file header, the video file cannot be played after being dragged, so the video file can only be played sequentially.
In addition, in the prior art, a server generally uses a fragmented buffer architecture for storing video files. Under this architecture, for a video, the server only stores a part of segments of the video. In the process of dragging the video, if a target position of dragging goes beyond the range of the video segments stored on the server, the dragging operation cannot be completed, which deteriorates user experience.