A video playback method and system
By pre-creating the frame data information of the video start part on the server and transmitting it in image frames, and mixing the video stream data with the client's asynchronous threads, the problems of slow video playback speed and poor user experience in the prior art are solved, and the rapid start-up and optimized user experience are achieved.
Patent Information
- Application Number
- CN202411700443.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-04-01
AI Technical Summary
When playing videos, existing video platforms need to pull video stream data in sequence, which takes a long time to cache video stream data, affecting the video playback speed and user experience.
The server pre-creates the frame data information of the first preset time of the start part of each video, and sends it to the client in the form of image frame transmission. The client receives and plays the frame data information, and at the same time loads the cached video stream data through an asynchronous thread.
By pre-framed data information and asynchronous thread cache video streaming data, the video playback speed is improved, the user wait time is shortened, and the user experience is optimized.
Smart Images

Figure CN119743631A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a video playing method and system. Background Art
[0002] In order to allow users to quickly view video content after clicking on a video, current video platforms usually use a cache method. Specifically, when a user clicks on a video, the video stream data will be quickly pulled for direct display. At the same time, an asynchronous thread is used to load the cache to provide fast access to subsequent videos. However, since the video stream data needs to be pulled in sequence, and the user needs to wait for a long time when caching the video stream data, it affects the video playback speed and the user experience. Summary of the invention
[0003] The technical problem to be solved by the present invention is: the present invention provides a method and system for video playback, which improves the video playback speed, shortens the user waiting time, and optimizes the user experience.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0005] In a first aspect, the present invention provides a method for playing a video, comprising:
[0006] The server pre-generates frame data information of a first preset time for the beginning part of each video, and when receiving a start play instruction from the client, sends the corresponding frame data information to the client in the form of image frame transmission according to the start play instruction;
[0007] The client receives and plays the frame data information, and at the same time loads and caches the video stream data after the first preset time through an asynchronous thread, and plays the video stream data.
[0008] The beneficial effect of the present invention is that the server will pre-generate frame data information of the first preset time for the beginning part of each video. When the start playback instruction is received, the frame data information is sent to the client for playback in the form of image frame transmission, that is, the video stream transmission method is replaced by the image frame transmission method. The image frame transmission is carried out using frame data information as data packets. Compared with the traditional video stream transmission in which video clips are transmitted as data packets, the capacity is smaller. Therefore, the client can quickly obtain and play the corresponding frame data information, which improves the start speed of video playback. Moreover, the frame data information is pre-generated on the server, thereby further shortening the user's waiting time. When the client plays the frame data information, an asynchronous thread is used to cache the video stream data, which provides convenience for subsequent video playback and optimizes the user experience.
[0009] Optionally, the server pre-generates frame data information of a first preset time for the beginning portion of each video, including:
[0010] The server obtains the number of accesses of each video, and determines whether the number of accesses exceeds the access threshold. If so, the server pre-generates frame data information of a first preset time for the beginning portion of the video whose number of accesses exceeds the access threshold.
[0011] According to the above description, the server does not pre-generate frame data information for all videos, but pre-generates frame data information for videos whose access times exceed a threshold, that is, pre-generates frame data information for videos that are more likely to be accessed by users, thereby saving storage space and improving the availability of the generated frame data information.
[0012] Optionally, it also includes:
[0013] When the server receives the drag-and-play instruction from the client, it obtains the drag position point from the drag-and-play instruction, obtains the key data frame of the second preset time after the drag position point by using the frame extraction method, and sends the key data frame of the second preset time to the client;
[0014] The client receives a key data frame at a second preset time, and plays the key data frame at the second preset time with a first definition, and at the same time loads and caches video stream data after the second preset time through an asynchronous thread, and when the video stream data after the second preset time exceeds a cache threshold, adjusts the first definition to a second definition to play the video stream data after the second preset time;
[0015] The clarity value of the second clarity is higher than the clarity value of the first clarity.
[0016] According to the above description, when a user drag-and-drop play instruction is received, that is, when the user pulls the video progress and does not play it from the starting position, the key data frame will be obtained by obtaining the drag position point and the key data frame will be played with the first clarity. At the same time, the cached video stream data is loaded through an asynchronous thread. When the video stream data exceeds the cache threshold, the clarity of the video playback is adjusted and the second clarity is used for playback. Although the first clarity during initial playback is not as good as the second clarity, it allows users to watch the video as soon as possible, shortens the user's waiting time, and can dynamically adjust the clarity. The flexible adjustment mechanism optimizes the user experience.
[0017] Optionally, the first preset time is [8, 12] seconds.
[0018] In a second aspect, the present invention provides a system for video playback, comprising:
[0019] The server is used to pre-generate frame data information of a first preset time for the beginning part of each video, and when receiving a start play instruction from the client, send the corresponding frame data information to the client in the form of image frame transmission according to the start play instruction;
[0020] The client is used to receive and play the frame data information, and at the same time load and cache the video stream data after the first preset time through an asynchronous thread, and play the video stream data.
[0021] The beneficial effect of the present invention is that the server will pre-generate frame data information of the first preset time for the beginning part of each video. When the start playback instruction is received, the frame data information is sent to the client for playback in the form of image frame transmission, that is, the video stream transmission method is replaced by the image frame transmission method. The image frame transmission is carried out using frame data information as data packets. Compared with the traditional video stream transmission in which video clips are transmitted as data packets, the capacity is smaller. Therefore, the client can quickly obtain and play the corresponding frame data information, which improves the start speed of video playback. Moreover, the frame data information is pre-generated on the server, thereby further shortening the user's waiting time. When the client plays the frame data information, an asynchronous thread is used to cache the video stream data, which provides convenience for subsequent video playback and optimizes the user experience.
[0022] Optionally, the server is specifically:
[0023] The server obtains the number of accesses of each video, and determines whether the number of accesses exceeds the access threshold. If so, the server pre-generates frame data information of a first preset time for the beginning portion of the video whose number of accesses exceeds the access threshold.
[0024] According to the above description, the server does not pre-generate frame data information for all videos, but pre-generates frame data information for videos whose access times exceed a threshold, that is, pre-generates frame data information for videos that are more likely to be accessed by users, thereby saving storage space and improving the availability of the generated frame data information.
[0025] Optionally, the server is further configured to, when receiving a drag-and-play instruction from the client, obtain a drag position point from the drag-and-play instruction, and obtain a key data frame at a second preset time after the drag position point by using a frame extraction method, and send the key data frame at the second preset time to the client;
[0026] The client is further configured to receive a key data frame at a second preset time, and to play the key data frame at the second preset time with the first definition, and to load and cache the video stream data after the second preset time through an asynchronous thread, and when the video stream data after the second preset time exceeds a cache threshold, to adjust the first definition to the second definition to play the video stream data after the second preset time;
[0027] The clarity value of the second clarity is higher than the clarity value of the first clarity.
[0028] According to the above description, when a user drag-and-drop play instruction is received, that is, when the user pulls the video progress and does not play it from the starting position, the key data frame will be obtained by obtaining the drag position point and the key data frame will be played with the first clarity. At the same time, the cached video stream data is loaded through an asynchronous thread. When the video stream data exceeds the cache threshold, the clarity of the video playback is adjusted and the second clarity is used for playback. Although the first clarity during initial playback is not as good as the second clarity, it allows users to watch the video as soon as possible, shortens the user's waiting time, and can dynamically adjust the clarity. The flexible adjustment mechanism optimizes the user experience.
[0029] Optionally, the first preset time is [8, 12] seconds. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 A flowchart of a video playback method provided by an embodiment of the present invention;
[0031] Figure 2 A schematic diagram of the overall flow of a video playback method provided by an embodiment of the present invention;
[0032] Figure 3 The present invention provides a schematic diagram of the structure of a video playback system.
[0033] [Description of Reference Numerals]
[0034] 1. Server side;
[0035] 2. Client. DETAILED DESCRIPTION
[0036] In order to better understand the above technical solution, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to enable a clearer and more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.
[0037] Embodiment 1
[0038] Please refer to Figure 1 to Figure 2 The present invention provides a method for video playback, comprising the steps of:
[0039] S1. The server pre-generates frame data information of a first preset time for the beginning part of each video, and when receiving a start playback instruction from the client, sends the corresponding frame data information to the client in the form of image frame transmission according to the start playback instruction;
[0040] In this embodiment, if Figure 2 As shown, the server will pre-generate frame data information of the first preset time for the beginning of each video, wherein the first preset time is [8,12] seconds, and preferably, the first preset time is 10 seconds, that is, 10 seconds of frame data information is pre-generated for the beginning of each video. When the start playback instruction of the client is received, the corresponding frame data information is sent to the client according to the start playback instruction. At this time, the frame data information is sent to the client in the form of image frame transmission, that is, the frame data information is sent as a data packet.
[0041] At this time, the server in step S1 pre-generates frame data information of the first preset time for the beginning part of each video, including:
[0042] S11. The server obtains the number of accesses of each video and determines whether the number of accesses exceeds the access threshold. If so, the server pre-generates frame data information of a first preset time for the beginning portion of the video whose number of accesses exceeds the access threshold.
[0043] In this embodiment, if Figure 2 As shown, the server does not pre-generate frame data information for all videos, but obtains the number of visits to each video and makes a judgment based on the number of visits. When the number of visits exceeds the access threshold, it means that the video is more likely to be visited and clicked by users. Therefore, the server pre-generates frame data information of the first preset time for the beginning part of the video whose number of visits exceeds the access threshold.
[0044] S2. The client receives and plays the frame data information, and at the same time loads and caches the video stream data after the first preset time through an asynchronous thread, and plays the video stream data.
[0045] In this embodiment, if Figure 2 As shown, the client receives the frame data information sent by the server in step S1 and plays it, and at the same time loads and caches the video stream data after the first preset time through an asynchronous thread, that is, the video stream data after 10 seconds, and plays the video stream data.
[0046] In this embodiment, considering that there is a situation where the user drags the video playback progress, the video playback in this situation is described, and the specific steps are as follows:
[0047] When the server receives the drag-and-play instruction from the client, it obtains the drag position point from the drag-and-play instruction, obtains the key data frame of the second preset time after the drag position point by using the frame extraction method, and sends the key data frame of the second preset time to the client;
[0048] The client receives a key data frame at a second preset time, and plays the key data frame at the second preset time with a first definition, and at the same time loads and caches video stream data after the second preset time through an asynchronous thread, and when the video stream data after the second preset time exceeds a cache threshold, adjusts the first definition to a second definition to play the video stream data after the second preset time;
[0049] The clarity value of the second clarity is higher than the clarity value of the first clarity.
[0050] In this embodiment, if Figure 2 As shown, when the server receives the drag-and-play instruction from the client, that is, when the user drags and plays the video playback progress, the server obtains the drag position point from the drag-and-play instruction, and uses the frame extraction method to obtain the key data frame of the second preset time after the drag position point. The first preset time at this time can be the same as the first preset time, or it can be different. For example, if the second preset time is 10 seconds, that is, the key data frame 10 seconds after the drag position point is obtained by the frame extraction method, and the key data frame of the second preset time is sent to the client. The client receives the key data frame of the second preset time and plays it with the first clarity. At this time, playing with the first clarity is actually for fuzzy display processing. At the same time, the video stream data after the second preset time, that is, the video stream data after 10 seconds, is loaded and cached through an asynchronous thread. When the cached video stream data exceeds the cache threshold, the clarity of the video playback is adjusted, that is, the first clarity is adjusted to the second clarity, and the video stream data is played with the second clarity.
[0051] Embodiment 2
[0052] Please refer to Figure 3 The present invention provides a video playback system 1, including: a server 2 and a client 3.
[0053] The server 2 is used to pre-generate frame data information of a first preset time for the beginning part of each video, and when receiving a start play instruction from the client 3, send the corresponding frame data information to the client 3 in the form of image frame transmission according to the start play instruction;
[0054] The client 3 is used to receive and play the frame data information, and at the same time load and cache the video stream data after the first preset time through an asynchronous thread, and play the video stream data.
[0055] Specifically, the server 2 is:
[0056] The server 2 obtains the number of accesses of each video, and determines whether the number of accesses exceeds the access threshold. If so, it pre-generates frame data information of a first preset time for the beginning portion of the video whose number of accesses exceeds the access threshold.
[0057] Specifically, the server 2 is further used to, when receiving the drag-and-play instruction from the client 3, obtain the drag position point from the drag-and-play instruction, and obtain the key data frame of the second preset time after the drag position point by using the frame extraction method, and send the key data frame of the second preset time to the client 3;
[0058] The client 3 is further used to receive the key data frame of the second preset time, and use the first definition to play the key data frame of the second preset time, and at the same time load and cache the video stream data after the second preset time through an asynchronous thread, and when the video stream data after the second preset time exceeds the cache threshold, adjust the first definition to the second definition to play the video stream data after the second preset time;
[0059] The clarity value of the second clarity is higher than the clarity value of the first clarity.
[0060] Specifically, the first preset time is [8, 12] seconds.
[0061] Since the system / device described in the above embodiments of the present invention is a system / device used to implement the method of the above embodiments of the present invention, a person skilled in the art can understand the specific structure and deformation of the system / device based on the method described in the above embodiments of the present invention, and thus will not be described in detail here. All systems / devices used in the method of the above embodiments of the present invention belong to the scope of protection of the present invention.
[0062] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0063] The present invention is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present invention. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions.
[0064] It should be noted that in the claims, any reference numerals placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention may be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In the claims enumerating several means, several of these means may be embodied by the same hardware. The use of the words first, second, third, etc., is for convenience of expression only and does not indicate any order. These words may be understood as part of the component name.
[0065] In addition, it should be noted that, in the description of this specification, the description of the terms "one embodiment", "some embodiments", "embodiment", "example", "specific example" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0066] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments after knowing the basic creative concept. Therefore, the claims should be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present invention.
[0067] Obviously, those skilled in the art can make various modifications and variations to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention should also include these modifications and variations.
Claims
1. A method for video playback, characterized in that: include: The server pre-generates frame data information of a first preset time for the beginning part of each video, and when receiving a start play instruction from the client, sends the corresponding frame data information to the client in the form of image frame transmission according to the start play instruction; The client receives and plays the frame data information, and at the same time loads and caches the video stream data after the first preset time through an asynchronous thread, and plays the video stream data.
2. A video playback method as claimed in claim 1, characterized in that: The server pre-generates frame data information of a first preset time for the beginning part of each video, including: The server obtains the number of accesses of each video, and determines whether the number of accesses exceeds the access threshold. If so, the server pre-generates frame data information of a first preset time for the beginning portion of the video whose number of accesses exceeds the access threshold.
3. A video playback method as claimed in claim 1, characterized in that: Also includes: When the server receives the drag-and-play instruction from the client, it obtains the drag position point from the drag-and-play instruction, obtains the key data frame of the second preset time after the drag position point by using the frame extraction method, and sends the key data frame of the second preset time to the client; The client receives a key data frame at a second preset time, and plays the key data frame at the second preset time with a first definition, and at the same time loads and caches video stream data after the second preset time through an asynchronous thread, and when the video stream data after the second preset time exceeds a cache threshold, adjusts the first definition to a second definition to play the video stream data after the second preset time; The clarity value of the second clarity is higher than the clarity value of the first clarity.
4. A video playback method as claimed in claim 1, characterized in that: The first preset time is [8, 12] seconds.
5. A video playback system, characterized in that: include: The server is used to pre-generate frame data information of a first preset time for the beginning part of each video, and when receiving a start play instruction from the client, send the corresponding frame data information to the client in the form of image frame transmission according to the start play instruction; The client is used to receive and play the frame data information, and at the same time load and cache the video stream data after the first preset time through an asynchronous thread, and play the video stream data.
6. A video playback system as claimed in claim 5, characterized in that: The server is specifically: The server obtains the number of accesses of each video, and determines whether the number of accesses exceeds the access threshold. If so, the server pre-generates frame data information of a first preset time for the beginning portion of the video whose number of accesses exceeds the access threshold.
7. A video playback system as claimed in claim 5, characterized in that: The server is further configured to, when receiving a drag-and-play instruction from the client, obtain a drag position point from the drag-and-play instruction, and obtain a key data frame at a second preset time after the drag position point by using a frame extraction method, and send the key data frame at the second preset time to the client; The client is further configured to receive a key data frame at a second preset time, and to play the key data frame at the second preset time with the first definition, and to load and cache the video stream data after the second preset time through an asynchronous thread, and when the video stream data after the second preset time exceeds a cache threshold, to adjust the first definition to the second definition to play the video stream data after the second preset time; The clarity value of the second clarity is higher than the clarity value of the first clarity.
8. A video playback system as claimed in claim 1, characterized in that: The first preset time is [8, 12] seconds.