Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures. In addition, the embodiments and features of the embodiments in the present invention may be combined with each other without conflict.
Example one
Fig. 1A is a flowchart of a video downloading method according to an embodiment of the present invention, which is applicable to a situation where multiple videos are sequentially played in any service scene. The method for downloading video provided by this embodiment may be performed by a device for downloading video provided by the embodiment of the present invention, where the device may be implemented in a software and/or hardware manner, and is integrated in a server for performing the method, where the server may be a background server participating in downloading video data.
Specifically, referring to fig. 1A, the method may include the steps of:
and S110, responding to the fact that the current network state of the video to be played does not support smooth playing of the video to be played at the pre-download code rate, and selecting a corresponding target code rate gear when the video to be played simultaneously meets the playing index requirement and the playing performance requirement from the code rate gears matched with the current network state.
Optionally, at present, in order to ensure fast playing of a video, part of contents of several videos to be played after the current video (not all downloading is completed) are usually downloaded in advance in the playing process of the current video, so that a certain delay always exists between the actual playing time point and the pre-downloading time point of each video, at this time, because the network shakes in real time, if the network bandwidth of the video to be played during actual playing is suddenly reduced relative to the network bandwidth during pre-downloading, when the remaining contents in the video to be played are downloaded in the current network state, the remaining downloading speed is far from the playing speed of the video to be played, and thus the video to be played is blocked. Meanwhile, for the video which is not subjected to the pre-downloading, when the video is played at the current moment, the code rate gear matched with the current network state is directly selected for complete downloading, and the problem of playing pause caused by delay between the actual playing time point and the pre-downloading time point is not considered, so that the video to be played in the embodiment mainly can be the video which is indicated to be played at present and is subjected to the pre-downloading, and the pre-downloading code rate is the code rate gear actually adopted by the video to be played during the pre-downloading.
At this time, in order to avoid the playing jam of the video to be played in the playing process, when a playing instruction of the video to be played which has been downloaded in advance is received, and a client indicates that the video to be played needs to be played at the current time, because the pre-download code rate of the video to be played is matched with the network state at the pre-download time, and the network state changes in real time, the current network state of the video to be played needs to be determined, and then whether the current network state supports the smooth playing of the video to be played at the pre-download code rate is judged, and the smooth playing of the video to be played at the pre-download code rate can require that the video content which needs to be played at each playing time of the video to be played is downloaded by using the pre-download code rate at the network state at a certain previous time, that is, when the remaining content of the video to be played except the pre-download content is downloaded by using the pre-download code rate at the current network state of the video to be played, the residual downloading time length of the residual content is less than or equal to the playing time length of the video to be played; meanwhile, if the pre-download code rate of the video to be played is the lowest code rate gear in the code rate gear list corresponding to the video to be played, even if playing is stopped, the video to be played cannot be converted to be downloaded at a lower code rate gear; therefore, referring to the above two descriptions, it can be understood that, in this embodiment, the case that the current network state of the video to be played does not support smooth playing of the video to be played at the pre-download bitrate may be: and under the current network state of the video to be played, the residual downloading time length when the residual content except the pre-downloaded content in the video to be played is downloaded by adopting the pre-downloading code rate is greater than the playing time length of the video to be played, and the pre-downloading code rate is greater than the lowest code rate gear corresponding to the video to be played.
Further, if the current network state of the video to be played does not support smooth playing of the video to be played at the pre-download bitrate, a new target bitrate gear matched with the current network state needs to be reselected from a bitrate gear list corresponding to the video to be played, as shown in fig. 1B, to re-download the video to be played completely, and meanwhile, in order to improve the performance requirements of the video to be played at the playing stage and the playing stage, when the video to be played is also required to be downloaded by adopting the reselected target bitrate gear, the video to be played can simultaneously meet the playing index requirement and the playing performance requirement, the playing index requirement can be that when the video to be played is downloaded at the target bitrate gear, the video to be played can be guaranteed to be played successfully within the playing duration acceptable by the user, and the playing performance requirement can be that when the video to be played is required to be downloaded at the target bitrate gear, the video to be played can be guaranteed not exist in the actual playing process The playing is blocked, and playing characteristics preset according to actual playing requirements can be achieved, for example, the playing quality of the video to be played at the target code rate gear is required to be optimal, or the downloading rate of the video to be played at the target code rate gear is required to be fastest, so that code rate reselection when the video to be played cannot be played smoothly at the pre-downloading code rate is achieved, the video to be played at the target code rate gear can be downloaded and played simultaneously according to the playing index requirement and the playing performance requirement, rapid playing of the video to be played is guaranteed on the basis of avoiding the video to be played from being blocked, and the playing smoothness of the video to be played is improved.
It should be noted that, in order to avoid that the video to be played is played in a jammed state, in this embodiment, a code rate gear matched with the current network state may be a code rate gear of which a code rate value in the code rate gear list of the video to be played is smaller than or equal to a code rate gear of a network bandwidth in the current network state, so that the video to be played can be guaranteed to be downloaded quickly in the current network state.
In addition, referring to the determination condition in this embodiment for determining whether the current network state of the video to be played supports the smooth playing of the video to be played at the pre-download code rate, before determining whether the current network state of the video to be played supports the smooth playing of the video to be played at the pre-download code rate, the method may further include: and calculating the residual downloading time length of the video to be played in the current network state according to the playing time length of the video to be played, the pre-downloading code rate and the residual occupation ratio of the residual content except the pre-downloading content in the video to be played.
Specifically, by searching for the video characteristics corresponding to the video to be played and the pre-download condition of the video to be played, it can be determined that the playing time of the video to be played is l, the pre-download code rate is br, and the pre-download ratio of the pre-download content in the video to be played is p, and then the remaining download time of the video to be played in the current network state can be calculated as
Wherein l
reFor the remaining download duration bwe is the current network status of the video to be played. At this time, it can be determined that the judgment condition that the current network state of the video to be played does not support smooth playing of the video to be played at the pre-download code rate is as follows:
wherein br
0The lowest bit rate gear corresponding to the video to be played.
And S120, downloading the video to be played by adopting the target code rate gear.
Optionally, after the current network state of the video to be played does not support smooth playing of the video to be played at the pre-download code rate, and the corresponding target code rate gear which enables the video to be played to simultaneously meet the playing index requirement and the playing performance requirement is selected from the code rate gears matched with the current network state, the target code rate gear can be directly adopted to completely download the video to be played again in the current network state, and the video to be played is played synchronously, so that the playing smoothness of the video to be played is ensured.
In the technical scheme provided by this embodiment, for the video to be played after the pre-downloading is completed, it needs to be determined whether the current network state of the video to be played supports the smooth playing of the video to be played at the pre-downloading bitrate, and if the current network state does not support the smooth playing of the video to be played at the pre-downloading bitrate, it indicates that if the pre-downloading bitrate is still used to continue downloading the remaining content in the video to be played, the playing of the video to be played is stuck, so that the corresponding target bitrate is selected again from the bitrate gears matched with the current network state to re-download the video to be played, thereby realizing the bitrate reselection when the video to be played cannot be played smoothly at the pre-downloading bitrate, so that the video to be played is downloaded and played at the target bitrate gears, and can meet the requirements of the start playing index and the playing performance simultaneously, thereby avoiding the occurrence of playing stuck of the video to be played, the fast playing of the video to be played is ensured, and the playing smoothness of the video to be played is improved.
Example two
Fig. 2A is a flowchart of a video downloading method according to a second embodiment of the present invention, and fig. 2B is a schematic diagram of a video downloading process according to the second embodiment of the present invention. The embodiment is optimized on the basis of the embodiment. Specifically, as shown in fig. 2A, this embodiment explains in detail a specific process of selecting a target code rate step from code rate steps matched with a current network state.
Optionally, as shown in fig. 2A, the present embodiment may include the following steps:
s210, estimating the current network state of the video to be played according to the change of the corresponding historical network state of the historical video played forward when the historical video is actually downloaded.
Optionally, since when the video to be played is played at the current time, the plurality of historical videos played before the video to be played have already finished downloading and playing, and the real-time change of the network state has a certain change rule, so the embodiment firstly carries out forward search on the video to be played, further searching a plurality of historical videos which are played forward by the video to be played, taking the actual downloading speed of each historical video during actual downloading as the corresponding historical network state of the historical video during actual downloading, then analyzing the change condition of the corresponding historical network state of each historical video when the historical video is actually played so as to judge the change trend of the network state at the current moment, and then, the current network state of the video to be played is estimated so as to judge whether the current network state supports smooth playing of the video to be played at the pre-download code rate or not in the subsequent process, and the problem of pause in playing in the video playing process is avoided.
Exemplarily, if in video v0In the playing process, the video v can be finished according to the preset video playing sequence1To video vnIn the process of pre-downloading each video, the video to be played v is played at the momentkWhen k is less than or equal to n, the video v to be played can be determinedkThe history video played in the forward direction is video v1To video vk-1In between, at this time can be based on respective historical videos vi(i ═ {1, 2 …, k-1}) to determine each historical video viActual download rate siAt this time, the calculation formula of the current network state of the video to be played is as follows: bwek=fewma(si) i ═ 1, …, k-1. Wherein, bwekFor video v to be playedkCurrent network state of siFor video v to be playedkPrevious ith historical video viActual download rate of fewma(si) The method comprises the steps of carrying out mean processing on the actual downloading rate of the historical video by adopting an exponential weighted moving average algorithm, and estimating the video v to be playedkCurrent network state bwek。
S220, responding to the fact that the current network state of the video to be played does not support smooth playing of the video to be played under the pre-download code rate, selecting a corresponding initial code rate gear from code rate gears matched with the current network state, wherein the initial code rate gear supports successful playing of the video to be played within the playing duration required by the playing index.
Optionally, after estimating the current network state of the video to be played, first of all, it is determined whether the current network state supports the smooth playing of the video to be played at the pre-download code rate, and the determination condition for whether the current network state supports the smooth playing of the video to be played at the pre-download code rate has been described in detail in the foregoing embodiment one.
Further, if the current network state of the video to be played does not support smooth playing of the video to be played at the pre-download code rate, it is described that if the pre-download code rate is used to continue downloading the remaining content in the video to be played except the pre-download content and playing the content, the playing is stuck, so in this embodiment, a new code rate gear needs to be selected from the code rate gear list of the video to be played again, the pre-download content of the video to be played at the pre-download code rate is discarded, and the newly selected code rate gear needs to be used to completely download the video to be played again. At this time, in order to avoid the pause problem of playing after the video to be played is continuously downloaded by adopting the pre-download code rate in the current network state, firstly, according to the network bandwidth corresponding to the current network state, a code rate gear matched with the current network state is selected from a code rate gear list of the video to be played, as shown in fig. 2B, that is, each code rate gear with a code rate value smaller than or equal to the network bandwidth in the current network state is selected from the code rate gear list of the video to be played as a code rate gear matched with the current network state, then, the play-on duration defined by the preset play-on index requirement is determined, the play-on duration represents the duration that a user can receive the video successfully play, that is, the video to be played is required to be successfully played within the play-on duration, so that the corresponding initial code rate gear needs to be continuously selected from the code rate gears matched with the current network state, the initial code rate gear can ensure that the video to be played is successfully played within the playing duration required by the playing index, namely when the video to be played is downloaded by adopting each initial code rate gear, the video to be played is ensured to be successfully played within the playing duration, so that the video to be played is ensured to be rapidly played on the basis of avoiding playing pause of the video to be played.
It can be understood that, in order to accurately select the corresponding initial code rate gear, the embodiment may calculate, for each code rate gear in the code rate gears matched with the current network state, a pre-download duration when the pre-download content in the video to be played is downloaded by using the code rate gear; and if the pre-download duration is less than or equal to the broadcasting duration required by the broadcasting index, taking the code rate gear as an initial code rate gear.
For example, the selection condition for selecting the initial code rate step from the code rate steps matched with the current network state may be:
wherein br
jFor the selected initial bitrate level, bwe is the network bandwidth of the video to be played in the current network state, l is the playing time of the video to be played, p is the pre-download proportion of the pre-downloaded content in the video to be played, and epsilon is the playing time required by the playing index, so bwe is not less than br
jRepresenting the code rate gear matching the current network state.
And S230, selecting a corresponding target code rate gear from the initial code rate gears, wherein the playing condition of the video to be played after the video to be played is downloaded by adopting the target code rate gear meets the requirement of playing performance.
Optionally, after the corresponding initial bitrate gear is selected from the bitrate gears matched with the current network state, because multiple bitrate gears may exist in the bitrate gears matched with the current network state, the video to be played can be successfully played within the playing duration required by the playing index, so that a corresponding target bitrate gear needs to be further selected from the initial bitrate gears, the target bitrate gear can enable the video to be played to meet the playing performance requirement, the playing performance requirement can be that the playing image quality of the video to be played at the target bitrate gear is optimal, or the downloading rate of the video to be played at the target bitrate gear is required to be fastest, and the like.
For example, in this embodiment, the corresponding target code rate gear is selected from the initial code rate gearsThe selection conditions can be as follows: brtar={arg maxbrg (br) | br ∈ Γ }; wherein brtarFor the selected target bitrate gear, Γ is a selection result of the initial bitrate gear, br is any one of the initial bitrate gears in Γ, and g (br) is a bitrate gear selection algorithm required by the playing performance, so that a parameter br meeting the playing performance requirement can be obtained from g (br) by adopting an arg max function and is used as the target bitrate gear br in the embodiment.
And S240, downloading the video to be played by adopting the target code rate gear.
The technical solution provided in this embodiment estimates, for a video to be played after completing pre-downloading, a current network state of the video to be played by analyzing a change of a corresponding historical network state of a historical video played forward of the video to be played during actual downloading, so as to ensure accuracy of the current network state, and further determine whether the current network state of the video to be played supports smooth playing of the video to be played at a pre-downloading bitrate, if the current network state does not support smooth playing of the video to be played at the pre-downloading bitrate, a corresponding target bitrate gear is selected again from bitrate gears matched with the current network state to re-download the video to be played, so as to achieve bitrate reselection when the video to be played cannot be played smoothly at the pre-downloading bitrate gear, so that the video to be played can be downloaded and played at the target bitrate gear, and can simultaneously meet requirements of a play index and play performance, therefore, on the basis of avoiding the playing jam of the video to be played, the fast playing of the video to be played is ensured, and the playing smoothness of the video to be played is improved.
EXAMPLE III
Fig. 3 is a schematic structural diagram of a video downloading apparatus according to a third embodiment of the present invention, specifically, as shown in fig. 3, the apparatus may include:
a code rategear reselection module 310, configured to select, in response to that a current network state of a video to be played does not support smooth playing of the video to be played at a pre-download code rate, a corresponding target code rate gear from code rate gears matched with the current network state, where the target code rate gear makes the video to be played meet a playing index requirement and a playing performance requirement at the same time;
and avideo downloading module 320, configured to download the video to be played by using the target bitrate gear.
In the technical scheme provided by this embodiment, for the video to be played after the pre-downloading is completed, it needs to be determined whether the current network state of the video to be played supports the smooth playing of the video to be played at the pre-downloading bitrate, and if the current network state does not support the smooth playing of the video to be played at the pre-downloading bitrate, it indicates that if the pre-downloading bitrate is still used to continue downloading the remaining content in the video to be played, the playing of the video to be played is stuck, so that the corresponding target bitrate is selected again from the bitrate gears matched with the current network state to re-download the video to be played, thereby realizing the bitrate reselection when the video to be played cannot be played smoothly at the pre-downloading bitrate, so that the video to be played is downloaded and played at the target bitrate gears, and can meet the requirements of the start playing index and the playing performance simultaneously, thereby avoiding the occurrence of playing stuck of the video to be played, the fast playing of the video to be played is ensured, and the playing smoothness of the video to be played is improved.
The video downloading device provided by the embodiment can be applied to the video downloading method provided by any embodiment, and has corresponding functions and beneficial effects.
Example four
Fig. 4 is a schematic structural diagram of a server according to a fourth embodiment of the present invention, as shown in fig. 4, the server includes aprocessor 40, astorage device 41, and acommunication device 42; the number of theprocessors 40 in the server may be one or more, and oneprocessor 40 is taken as an example in fig. 4; theprocessor 40, thestorage device 41 and thecommunication device 42 in the server may be connected by a bus or other means, and the bus connection is taken as an example in fig. 4.
The server provided by this embodiment can be used to execute the video downloading method provided by any of the above embodiments, and has corresponding functions and advantages.
EXAMPLE five
Fifth, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, can implement the method for downloading video in any of the above embodiments. The method specifically comprises the following steps:
responding to the situation that the current network state of a video to be played does not support smooth playing of the video to be played at a pre-download code rate, and selecting a corresponding target code rate gear when the video to be played simultaneously meets the playing index requirement and the playing performance requirement from code rate gears matched with the current network state;
and downloading the video to be played by adopting the target code rate gear.
Of course, the storage medium provided by the embodiment of the present invention contains computer-executable instructions, and the computer-executable instructions are not limited to the method operations described above, and may also perform related operations in the method for downloading video provided by any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
It should be noted that, in the embodiment of the video downloading apparatus, the units and modules included in the apparatus are only divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.