Disclosure of Invention
The technical problem to be solved by the present invention is to provide a video bitrate matching method, a storage medium, and a terminal device, aiming at the defects of the prior art.
In order to solve the technical problems, the technical scheme adopted by the invention is as follows:
a method for matching video bitrate, the method comprising:
when a cache server receives a downloading request sent by a playing end, acquiring a playing state corresponding to the playing end and a link state of an origin server corresponding to the cache server;
and matching the downloading mode of the video block to be downloaded corresponding to the downloading request according to the playing state and the link state, wherein the downloading mode comprises the step of forwarding the downloading request to a source server or selecting the video block to be downloaded with the selected code rate in a cache server.
The video code rate matching method comprises the steps that the downloading request comprises a target request code rate of a video block to be downloaded; the step of, when the cache server receives a download request sent by a play end, acquiring a play state corresponding to the play end and a link state of an origin server corresponding to the cache server specifically includes:
when a cache server receives a downloading request sent by a playing end, locally searching a video block to be downloaded with the target request code rate in the cache server;
and if the video block to be downloaded with the target request code rate is not found, acquiring a playing state corresponding to the playing end and a link state of a source server corresponding to the cache server.
The video code rate matching method, wherein the obtaining of the playing state corresponding to the playing end and the link state of the source server corresponding to the cache server when the cache server receives the download request sent by the playing end includes:
and if the video block to be downloaded with the target request code rate is found, completing video code rate matching, and sending the video block to be downloaded with the target request code rate to a playing end.
The video code rate matching method, wherein the matching of the downloading mode of the video block to be downloaded corresponding to the downloading request according to the playing state and the link state specifically includes:
inputting the playing state and the link state into a pre-trained reinforcement learning model;
outputting a probability set through the reinforcement learning model, wherein the probability set comprises the selected probability of each preset code rate and the downloading probability of the source server;
and determining a downloading mode corresponding to the downloading request according to the probability set.
The method for matching the video code rate, wherein the determining the downloading mode corresponding to the downloading request according to the probability set specifically comprises:
and selecting the maximum probability in the probability set, and taking the downloading mode corresponding to the maximum probability as the downloading mode corresponding to the downloading request.
The video code rate matching method, wherein after the video block code rate matching method to be downloaded is sent to the playing end according to the downloading mode, the method further comprises the following steps:
and obtaining QoE corresponding to a playing end, and reacting on the reinforcement learning model according to the QoE so as to correct the reinforcement learning model.
The video rate matching method further comprises the following steps:
acquiring all the downloading requests received in the preset time length every interval of the preset time length, and acquiring the probability value of the code rate corresponding to each downloading request and the video cache cost;
and determining income values corresponding to the code rates according to the obtained probability values of all the code rates and the video caching cost, and caching the video according to the income values from large to small.
The video code rate matching method comprises the step of matching the video code rate, wherein the playing state comprises a target request code rate, a previous request code rate, video time cached by a playing end, cache hit throughput of a previous video block of a video block to be downloaded and cache miss throughput of a previous video block of the video block to be downloaded.
A computer readable storage medium storing one or more programs, the one or more programs being executable by one or more processors to implement the steps in the video bitrate matching method as described in any one of the above.
A terminal device, comprising: a processor, a memory, and a communication bus; the memory has stored thereon a computer readable program executable by the processor;
the communication bus realizes connection communication between the processor and the memory;
the processor, when executing the computer readable program, implements the steps in the method for matching video bitrate as described in any one of the above.
Has the advantages that: compared with the prior art, the invention provides a video code rate matching method, when a cache server receives a downloading request sent by a playing end, a playing state corresponding to the playing end and a link state of an origin server corresponding to the cache server are obtained; and matching the downloading mode of the video block to be downloaded corresponding to the downloading request according to the playing state and the link state, wherein the downloading mode comprises the step of forwarding the downloading request to a source server or selecting the video block to be downloaded with the selected code rate in a cache server. When receiving the downloading request, the invention can match the corresponding code rate file for the video block to be downloaded or download the video block from the source server according to the playing state and the link state, thereby improving the cache hit rate and bringing convenience to the use of users.
Detailed Description
The invention provides a video code rate matching method, a storage medium and a terminal device, and in order to make the purpose, technical scheme and effect of the invention clearer and clearer, the invention is further described in detail below by referring to the attached drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
The invention will be further explained by the description of the embodiments with reference to the drawings.
The embodiment provides a video code rate matching method. The method can be executed by a matching device, and the device can be realized by software or hardware, so that the device receives a downloading request sent by a playing end at a cache server, and obtains a playing state corresponding to the playing end and a link state of an origin server corresponding to the cache server; and matching the downloading mode of the video block to be downloaded corresponding to the downloading request according to the playing state and the link state, wherein the downloading mode comprises the step of forwarding the downloading request to a source server or selecting the video block to be downloaded with the selected code rate in a cache server. The matching device can be applied to intelligent terminals such as PCs, servers and the like which can be used as cache servers. Referring to fig. 1, the method for matching video bitrate provided in this embodiment specifically includes:
and S10, when the cache server receives the download request sent by the playing end, acquiring the playing state corresponding to the playing end and the link state of the source server corresponding to the cache server.
Specifically, the playing end is used for running a video playing program and sending a video downloading request to the cache server, wherein the playing end can be a terminal device which can be connected with the internet and has an image display function, such as a smart phone, a tablet computer, a desktop computer, and the like. The cache server has cache capacity, partial video files can be stored in the cache server, and all the video files are stored in the source server cluster. The cache server is geographically closer to the playing end than the source server, when the playing end requests a video file, the playing end sends the request to the cache server first, and when the cache server cannot respond to the request of the playing end, the cache server forwards the request to the source server.
Further, in an implementation manner of this embodiment, the download request includes a target request code rate of a video block to be downloaded; the step of, when the cache server receives a download request sent by a play end, acquiring a play state corresponding to the play end and a link state of an origin server corresponding to the cache server specifically includes:
s11, when the cache server receives a downloading request sent by a playing end, locally searching the video block to be downloaded with the target request code rate in the cache server;
s12, if the video block to be downloaded with the target request code rate is not found, acquiring a playing state corresponding to the playing end and a link state of a source server corresponding to the cache server;
and S13, if the video block to be downloaded with the target request code rate is found, completing video code rate matching, and sending the video block to be downloaded with the target request code rate to a playing end.
Specifically, the downloading request is a request for acquiring a video file, which is sent by a playing terminal to a cache server, and the downloading request is used for requesting a video block to be downloaded with a target request code rate in the cache server. And the video block to be downloaded with the target requested code rate can be stored in the cache server or not stored in the cache server. When the video block to be downloaded with the target request code rate is stored in the cache server, the cache server can directly respond to the downloading request so as to feed back the video block to be downloaded with the target request code rate to the playing end; when a video block to be downloaded with a target request code rate is not stored in the cache server, the cache server needs to acquire a playing state corresponding to a playing end and a link state of the source server corresponding to the cache server, so as to determine whether to use a video file with other code rates corresponding to the video block to be downloaded stored in the cache server or acquire the file to be downloaded with the target request code rate from the source server according to the playing state and the link state.
Further, the playing state includes a target request code rate, a previous request code rate, a video duration cached by the playing end, a cache hit throughput of a previous video block of the video block to be downloaded, and a cache miss throughput of the previous video block of the video block to be downloaded. The target request code rate is a code rate carried by the downloading request, namely the target request code rate is a video request sent by the playing end for the code rate, but a video file is not received yet. The previous request code rate refers to a request code rate of a video block file which is located before the video block to be downloaded corresponding to the download request and adjacent to the video block to be downloaded according to the playing sequence, and the previous request code rate corresponds to the fact that the video file is downloaded to the playing end. The video time length cached by the playing end refers to the video time length cached at the moment of sending the downloading request in the buffer area of the playing end. The cache hit means that the video file is stored in the cache server, and the video file is sent to the playing end from the cache server. The cache miss means that the video file is not stored in the cache server, and the video file is sent from the source server to the playing end, wherein the difference between the cache hit and the cache miss is that a link through which data passes is different.
Further, in an implementation manner of this embodiment, as shown in fig. 2, the cache server may be provided with a playing state collection module 100, a throughput regression module 200, an origin server direction network state collection module 300, a reinforcement learning agent module 400, and a cache management module 500. The playing end state collection module 100 is configured to parse a download request sent by a playing end and extract playing end state data, where the playing end state data needs to be carried by the download request sent by the playing end and is sent to a cache server through the download request, where the playing end state data may include a target request code rate, a previous request code rate, a video duration cached by the playing end, and a throughput of a previous video block of a video block to be downloaded.
The throughput regression module 200 is configured to calculate a cache hit throughput of a previous video of the video block to be downloaded or a cache miss throughput of a previous video of the video block to be downloaded, where the throughput regression module may determine to be arranged at the playing end or the cache server according to the computation of the playing end and the computation of the cache server, and it may be understood that the throughput regression module may be arranged at the playing end or the server end; when the throughput regression module is deployed at the client, the download request carries the cache hit throughput of the previous video block of the video block to be downloaded and the cache miss throughput of the previous video block of the video block to be downloaded; when the throughput regression module is deployed on the cache server, the download request only needs to carry one of the cache hit throughput of the previous video block of the video block to be downloaded and the cache miss throughput of the previous video block of the video block to be downloaded, and meanwhile the download request needs to carry state information used for calculating the cache hit throughput or the cache miss throughput, wherein the state information may include RTT transmitted between the source server and the cache server, data volume transmitted, and link bandwidth between the source server and the cache server.
The source server side needs to continuously and periodically collect the network status of the data transmitted from the source server to the cache server to the network status collection module 300. The network status can be measured by sending probe packets, which are more accurate but occupy part of the network bandwidth, or directly using the amount of miss request data, which is easily available but not accurate enough. The reinforcement learning agent module 400 stores a reinforcement learning module, and outputs a downloading mode of the video block to be downloaded corresponding to the downloading request through the reinforcement learning module. The cache management module 500 is configured to manage video files stored in a cache server.
Further, in an implementation manner of this embodiment, the cache hit throughput and the cache miss throughput are obtained to obtain the cache hit throughput or the cache miss throughput, and when the cache hit throughput is obtained, the cache miss throughput needs to be calculated according to the cache hit throughput; when the cache miss throughput is obtained, the cache hit throughput needs to be calculated according to the cache miss throughput. Under the same condition, the cache hit throughput is higher than the cache miss throughput, because the physical distance of video data transmission is short and the delay is small when the cache hit occurs, and the difference between the cache hit and the cache miss mainly lies in that the cache miss requires that a cache server video file is obtained from an origin server and then the video file is transmitted to a playing end through the cache server. Therefore, when the cache miss throughput is calculated according to the cache hit throughput or the cache hit throughput is calculated according to the cache miss throughput, the miss throughput can be obtained according to the hit throughput only by considering the influence of a link between the source server and the cache server on the throughput, and vice versa.
Further, in this embodiment, when calculating the cache miss throughput according to the cache hit throughput, or when calculating the cache hit throughput according to the cache miss throughput, the corresponding calculation may be performed according to the known throughput data, the RTT transmitted between the source server and the cache server, the amount of the transmitted data, and the link bandwidth between the source server and the cache server. For example, a regression tree based regression algorithm is used to calculate the cache hit throughput or cache miss throughput. Certainly, in the process of obtaining the regression tree model, in order to obtain the cache hit throughput and the cache miss throughput at the same time, a throughput tag may be added to the video request header, so that the cache server sequentially and respectively transmits the video in a cache hit mode and a cache miss mode according to the throughput tag, and then sequentially receives the video files twice at the playing end to respectively calculate the cache hit throughput and the cache miss throughput.
And S20, matching the downloading mode of the video block to be downloaded corresponding to the downloading request according to the playing state and the link state.
Specifically, the downloading mode includes forwarding the downloading request to the source server or selecting the video block to be downloaded with the selected code rate in the cache server. The step of forwarding the downloading request to the source server refers to acquiring a video block to be downloaded with a target request code rate through the source server; the step of selecting the video block to be downloaded with the selected code rate in the cache server refers to taking the video block to be downloaded with the selected code rate in the cache server as a video file corresponding to the downloading request, and directly sending the video block to be downloaded with the selected code rate to the playing end. The video block to be downloaded with the selected code rate and the video block to be downloaded with the target request code rate are in different code rate formats of the same video, namely, the video contents of the video block to be downloaded with the selected code rate and the video block to be downloaded with the target request code rate are only different in code rate acquired by the two videos.
Further, in an implementation manner of this embodiment, as shown in fig. 2, a reinforcement learning agent module may be configured in the cache server, and the reinforcement learning agent module may be inserted into an existing network cache process, and when a download request of a playing end is received and a video block to be downloaded with a target request code rate is searched in the cache server, the playing state and the link state may be input to the reinforcement learning agent module, so as to determine a download mode corresponding to the download request through the reinforcement learning agent module. In addition, the reinforcement learning agent module can determine the downloading mode through a reinforcement learning mode, that is, a reinforcement learning model can be configured in the reinforcement learning agent module, and the downloading mode is determined through the reinforcement learning model. Correspondingly, in an implementation manner of this embodiment, the matching, according to the play state and the link state, a downloading manner of the video block to be downloaded corresponding to the download request specifically includes:
inputting the playing state and the link state into a pre-trained reinforcement learning model;
outputting a probability set through the reinforcement learning model, wherein the probability set comprises the selected probability of each preset code rate and the downloading probability of the source server;
and determining a downloading mode corresponding to the downloading request according to the probability set.
Specifically, the reinforcement learning model is obtained by training based on preset training samples, the preset training samples include multiple groups of training sample groups, and each group of training sample group includes a playing state and a link state. The output items of the reinforcement learning are probability sets, wherein the probability sets comprise code stream probabilities and source server downloading probabilities corresponding to a plurality of code rates, and the code rates comprise all code rates which can be stored in the video file by the cache server. In the training process, after the probability set is obtained, the playing state and the downloading mode corresponding to the link state are determined according to the probability set, the QoE generated after downloading according to the downloading mode is determined, and the network is updated to the direction of maximizing the accumulated QoE through the QoE updating model parameters by reinforcement learning. It can be understood that the output items of the reinforcement learning model are probability sets, and when the reinforcement learning model is trained, the QoE generated by determining the downloading mode according to the probability sets corrects the model parameters of the reinforcement learning model.
Further, as can be seen from the training process of the reinforcement learning model, as shown in fig. 3, when the playing status and the link status are input to the reinforcement learning model trained in advance, the reinforcement learning model outputs a probability set corresponding to the playing status and the link status. The probability set comprises the probability of selecting the code rate in the cache and the downloading probability of the source server, the sum of the probability of selecting the code rate in the cache and the downloading probability of the source server is 1, in addition, because the cache server only possibly caches the video files with partial code rates, the output layer of the reinforcement learning model is provided with a mask, and the probability of not storing the code rate in the cache server is set to be 0 through the mask, so that when the downloading mode is determined according to the probability set, the code rate which is selected to be not existed in the cache server cannot be output.
Further, in an implementation manner of this embodiment, the determining, according to the probability set, the downloading manner corresponding to the downloading request refers to selecting a maximum value in the probability set, and if the maximum value corresponds to a code rate in the cache server, taking the code rate as a selected code rate, and sending a video block to be downloaded with the selected code rate to the playing end; and if the maximum value corresponds to the source server for downloading, forwarding the downloading request to the source server, acquiring the video block to be downloaded with the target request code rate through the source server, and sending the acquired video block to be downloaded with the target request code rate to a playing end. In addition, in order to improve the accuracy of the reinforcement learning model, after the reinforcement learning model determines the downloading method corresponding to the downloading request, the reinforcement learning model may be modified by using the QoE corresponding to the downloading method. Correspondingly, after the matching of the code rate to be downloaded to the playing end according to the downloading mode, the method further includes: and obtaining QoE corresponding to a playing end, and reacting on the reinforcement learning model according to the QoE so as to correct the reinforcement learning model.
Further, in an implementation manner of this embodiment, in order to improve the hit rate of the cache server, the cache server may cache the video file with the corresponding bitrate according to the revenue of the video file corresponding to the download request received by the cache server, so as to improve the QoE of the user. Correspondingly, in an implementation manner of this embodiment, after the matching of the code rate to be downloaded to the playing end according to the downloading manner, the method further includes:
acquiring all downloading requests received in a preset time length every interval of the preset time length, and acquiring a probability value of a code rate corresponding to each downloading request and video cache cost, wherein the probability value is determined by a probability set obtained when a downloading mode is determined according to the downloading request;
and determining income values corresponding to the code rates according to the obtained probability values of all the code rates and the video caching cost, and caching the video according to the income values from large to small.
Specifically, after a probability set is input through a reinforcement learning module, a probability value of each code rate output by reinforcement learning is recorded, wherein the probability value is recorded in one record entry in a file list corresponding to a video block to be downloaded, the file list corresponds to a video file, and the record entries of all code rates corresponding to the video file are stored in the file list. The entry identifier of the record entry is a video identifier of a video block to be downloaded and the code rate, and the value of the record entry is a probability and a video cache cost, wherein the video cache cost can be the size of a video file. Of course, it is worth explaining that when a plurality of probability values of a video file with a code rate are recorded within a preset time, a plurality of probability values are stored in a recording entry corresponding to the code rate.
In addition, after the preset time length is set at intervals, all the downloading requests received in the preset time length are obtained, the corresponding video identification and code rate can be determined according to the downloading requests, and the probability value and the video cache cost can be determined according to the video identification and the code rate. And when the probability value and the video caching cost are obtained, for the video files with the same code rate, calculating the profit value according to all the probability values corresponding to the video files with the code rate, and caching the video according to the profit value in descending order. In this embodiment, the profit value may be equal to the quotient of the sum of all probability values of the video file with the same bitrate and the video caching cost. Certainly, when video caching is performed according to the ascending order of the profit values, the storage space of the cache server needs to be determined, and if the storage space cannot download the video files with the large profit values, the video files which can be cached are sequentially determined according to the profit value order.
In summary, the present invention provides a method for matching video bitrate, when a cache server receives a download request sent by a play end, acquiring a play state corresponding to the play end and a link state of an origin server corresponding to the cache server; and matching the downloading mode of the video block to be downloaded corresponding to the downloading request according to the playing state and the link state, wherein the downloading mode comprises the step of forwarding the downloading request to a source server or selecting the video block to be downloaded with the selected code rate in a cache server. When receiving the downloading request, the invention can match the corresponding code rate file for the video block to be downloaded or download the video block from the source server according to the playing state and the link state, thereby improving the cache hit rate and bringing convenience to the use of users.
Based on the above matching method for video bitrate, the present embodiment provides a computer-readable storage medium, where one or more programs are stored, and the one or more programs are executable by one or more processors to implement the steps in the matching method for video bitrate according to the above embodiment.
Based on the above matching method of video bitrate, the present invention further provides a terminal device, as shown in fig. 4, which includes at least one processor (processor) 20; a display screen 21; and a memory (memory)22, and may further include a communication Interface (Communications Interface)23 and a bus 24. The processor 20, the display 21, the memory 22 and the communication interface 23 can communicate with each other through the bus 24. The display screen 21 is configured to display a user guidance interface preset in the initial setting mode. The communication interface 23 may transmit information. The processor 20 may call logic instructions in the memory 22 to perform the methods in the embodiments described above.
Furthermore, the logic instructions in the memory 22 may be implemented in software functional units and stored in a computer readable storage medium when sold or used as a stand-alone product.
The memory 22, which is a computer-readable storage medium, may be configured to store a software program, a computer-executable program, such as program instructions or modules corresponding to the methods in the embodiments of the present disclosure. The processor 20 executes the functional application and data processing, i.e. implements the method in the above-described embodiments, by executing the software program, instructions or modules stored in the memory 22.
The memory 22 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal device, and the like. Further, the memory 22 may include a high speed random access memory and may also include a non-volatile memory. For example, a variety of media that can store program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk, may also be transient storage media.
In addition, the specific processes loaded and executed by the storage medium and the instruction processors in the terminal device are described in detail in the method, and are not stated herein.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.