Disclosure of Invention
The embodiment of the application aims to provide a bandwidth statistics method, a system, a computer device and a computer readable storage medium for live video, which do not need to split logs, so as to achieve the purposes of saving log storage space, accelerating calculation speed and enhancing log readability.
An aspect of the embodiment of the present application provides a method for counting bandwidth of live video, including:
acquiring at least one log of live video;
calculating the mapping time length of each obtained log in at least one time node corresponding to the log;
according to the calculated time length, calculating the bandwidth mapped by each log at the at least one time node;
and adding the bandwidths of the logs mapped to the same time node to obtain the bandwidth of the live video counted by the time node.
Optionally, the calculating the time length of mapping each log to at least one time node corresponding to the log specifically includes:
for a currently acquired log, determining at least one time node related to the log according to a start time stamp and an end time stamp of the log; and is combined with
For each time node to which the log relates, a length of time that the log maps to the time node is calculated.
Optionally, the calculating the time length of mapping the log to the time node specifically includes:
for a time node that satisfies a first condition, the length of time that the log maps to the time node is equal to the sum of the time node and a set time granularity minus a start timestamp of the log;
wherein, the time node satisfying the first condition is: a time node that is equal to or greater than a difference between a start time stamp of the log and a set time granularity, and is equal to or less than a start time stamp of the log, and is equal to or less than a difference between an end time stamp of the log and a set time granularity.
Optionally, the calculating the time length of mapping the log to the time node specifically includes:
for a time node meeting the second condition, the length of time the log maps to the time node is equal to a set time granularity;
wherein the time nodes satisfying the second condition are: a time node that is equal to or greater than a start time stamp of the log and equal to or less than a difference between an end time stamp of the log and a set time granularity.
Optionally, the calculating the time length of mapping the log to the time node specifically includes:
for a time node that satisfies a third condition, a length of time the log maps to the time node is equal to a difference between an end timestamp of the log and the time node;
wherein the time nodes satisfying the third condition are: a time node that is equal to or greater than a start time stamp of the log and equal to or less than an end time stamp of the log.
Optionally, the calculating the time length of mapping the log to the time node specifically includes:
for a time node that satisfies the fourth condition, the length of time that the log maps to the time node is equal to the difference between the end timestamp and the start timestamp of the log;
wherein the time nodes satisfying the fourth condition are: a time node that is equal to or greater than a difference between an end time stamp of the log and a set time granularity and is equal to or less than a start time stamp of the log.
Optionally, the determining at least one time node related to the log according to the start timestamp and the end timestamp of the log specifically includes:
and determining a time node which is larger than the difference between the starting time stamp of the log and the set time granularity and smaller than the ending time stamp of the log as the time node related to the log.
An aspect of an embodiment of the present application further provides a bandwidth statistics system for live video, including:
the log acquisition module is used for acquiring at least one log of the live video;
the time length mapping module is used for calculating the time length of mapping of each obtained log on at least one time node corresponding to the log;
the bandwidth mapping module is used for calculating the bandwidth mapped by each log at the at least one time node according to the calculated time length;
and the bandwidth statistics module is used for adding the bandwidths of the logs mapped to the same time node to obtain the bandwidth of the live video counted by the time node.
An aspect of an embodiment of the present application further provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the method for bandwidth statistics of live video as described above when the computer program is executed.
An aspect of an embodiment of the present application further provides a computer readable storage medium including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the method for bandwidth statistics of live video as described above when the computer program is executed.
The method, the system, the equipment and the computer readable storage medium for counting the bandwidth of the live video provided by the embodiment of the application acquire the log of the live video; calculating the time length of each log mapped on the time node; according to the calculated time length, calculating the bandwidth mapped by each log at the time node; and adding the bandwidths of the logs mapped to the same time node to obtain the bandwidth of the live video counted by the time node. The whole calculation process does not need to split the log, namely the split sub-logs are not needed to be stored respectively, so that the purposes of saving log storage space, accelerating calculation speed and enhancing log readability are achieved.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
It should be noted that the descriptions of "first," "second," etc. in the embodiments of the present application are for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In addition, the technical solutions of the embodiments may be combined with each other, but it is necessary to base that the technical solutions can be realized by those skilled in the art, and when the technical solutions are contradictory or cannot be realized, the combination of the technical solutions should be considered to be absent and not within the scope of protection claimed in the present application.
In the description of the present application, it should be understood that the numerical references before the steps do not identify the order in which the steps are performed, but are merely used to facilitate description of the present application and to distinguish between each step, and thus should not be construed as limiting the present application.
Fig. 1 schematically shows an environmental application schematic according to an embodiment of the application. As shown in fig. 1:
the server 2 provided by the CDN service provider may be connected to a plurality of terminal devices 6 through the network 4.
The server 2 may provide content services for the terminal device 6. The content services may include content streaming services such as internet protocol video streaming services. The content streaming service may be configured to distribute content via various transmission techniques. The content service may be configured to provide content such as video, audio, text data, combinations thereof, and the like. The content may include content streams (e.g., video streams, audio streams, information streams), content files (e.g., video files, audio files, text files), and/or other data. For example, the server 2 may provide a playing service of the live video, and for the live video played by the server 2, bandwidth statistics may be performed by using the bandwidth statistics method of the live video in the embodiment of the present application.
The server 2 may be the following devices such as: rack servers, blade servers, tower servers, or rack servers (including stand-alone servers, or a server cluster made up of multiple servers), and the like.
The server 2 may be located in a data center such as a single venue or distributed among different geographic locations (e.g., among multiple venues). The server 2 may provide services via one or more networks 4. The network 4 includes various network devices such as routers, switches, multiplexers, hubs, modems, bridges, repeaters, firewalls, proxy devices, and/or the like. The network 4 may include physical links such as coaxial cable links, twisted pair cable links, fiber optic links, combinations thereof, and the like. The network 4 may include wireless links, such as cellular links, satellite links, wi-Fi links, and the like.
The terminal device 6 may be configured to access the server 2. The terminal device 6 may comprise any type of terminal device 6, such as: mobile devices, tablet devices, laptop computers, smart devices (e.g., smartwatches, smart glasses), virtual reality headphones, gaming devices, set-top boxes, digital streaming devices, robots, vehicle terminals, smart televisions, electronic book readers, MP4 (moving picture experts group audio layer IV) players, and the like.
The terminal device 6 can run Windows system, android (AndroidTM ) And operating systems such as a system. The user alsoVarious application installation packages can be installed as needed to obtain applications that implement various specific functions.
The bandwidth statistics scheme for live video will be described below in terms of various embodiments. The solution may be implemented by a computer device 1300, which computer device 1300 may be the server 2 or a computing node thereof.
Example 1
Fig. 2 schematically shows a flowchart of a method for bandwidth statistics of live video according to a first embodiment of the present application.
As shown in fig. 2, the bandwidth statistics method of the live video may include the following steps S201 to S204, in which:
step S201: and acquiring a log of the live video.
In this step, the computer device 1300 may obtain at least one log of live video with respect to the live video with bandwidth to be counted; that is, the live video of the bandwidth to be counted may be one or a plurality of live videos; for example, the log of live video obtained by the computer device 1300 is a log of all live video played by the platform over a period of time (e.g., a month).
Step S202: and calculating the time length of each obtained log mapped on the time node.
In this step, the computer apparatus 1300 determines, for a currently acquired log, at least one time node to which the log relates according to a start timestamp and an end timestamp of the log; and for each time node to which the log relates, calculating the length of time the log maps to the time node.
The specific method for calculating the mapping time length of each obtained log at least one time node corresponding to the log may be shown in fig. 3a, and the flow may include the following substeps S301 to S307:
substep S301: for a currently acquired log, a start timestamp and an end timestamp of the log are determined.
In this substep, the computer apparatus 1300 determines, for the currently acquired log, a start time stamp and an end time stamp of the log.
In an exemplary embodiment, the computer device 1300 may obtain the start_time, end_time fields from the currently obtained log to determine the start timestamp and end timestamp of the log.
Substep S302: and determining the time node related to the log according to the starting time stamp and the ending time stamp of the log.
In this substep, the computer apparatus 1300 will satisfy the following condition of the time node (time_node): time_node > start_time-t, and time_node < end_time, as the time nodes involved in the log, the set of these time nodes is denoted as set { time_node }; wherein t is a set time granularity, time_node represents the time node, and start_time and end_time are respectively a start time stamp and an end time stamp of the log. That is, a time node that is greater than the difference between the start time stamp of the log and the set time granularity and less than the end time stamp of the log is determined as the time node to which the log relates.
For example, the time granularity may be set to 5 minutes, and then the time nodes that are spaced at the time granularity may be in order: 00:00, 00:05, 00:10,.. 23:55, for ease of calculation, can convert the time nodes into millisecond form, let T be the time stamp of log day 00:00, e.g. the date of log is 2021-01-01, then t= 1609430400000 (2021-01-01 00:00 time stamp), time node (time_node) is: t+0, t+300000, t+600000.
In an exemplary embodiment, a schematic diagram of the time nodes involved in a long-span log is shown in FIG. 3 b. The time span of the log in fig. 3b exceeds 3 time granularities; the time nodes involved in the log determined by the computer device 1300 include 5 time nodes labeled with sequence numbers 1-5, respectively.
A schematic diagram of the time nodes involved in the logging of another time span is shown in fig. 3 c. The time span of the log in fig. 3c is one time node; the time node to which the log determined by the computer device 1300 relates includes 2 time nodes labeled with sequence numbers 1, 2, respectively.
A schematic diagram of the time nodes involved in the logging of a further time span is shown in fig. 3 d. The time span of the log in fig. 3d is within one time granularity; the log of the time nodes determined by the computer device 1300 includes 1 time node with a marked sequence number of 1.
Substep S303: judging the node type of each time node related to the log; if the node type of the time node is type a, performing the following substep S304 to calculate the time length of the time node mapped to type a; if the node type of the time node is type B, performing the following substep S305 to calculate the time length of the time node mapped to type B; if the node type of the time node is type C, executing the following substep S306 to calculate the time length of the time node mapped to type C; if the node type of the time node is type D, the following substep S307 is performed to calculate the time length of the time node mapped to type D.
In this substep, the computer apparatus 1300 determines, for a time node (time_node) satisfying the first condition, that the node type of the time node is type a;
wherein, the first condition is: time_node > = start_time-t, and time_node < = start_time, and time_node < = end_time-t;
that is, the time node satisfying the first condition is: a time node that is equal to or greater than a difference between a start time stamp of the log and a set time granularity, and is equal to or less than a start time stamp of the log, and is equal to or less than a difference between an end time stamp of the log and a set time granularity.
The computer apparatus 1300 determines, for a time node (time_node) that satisfies the second condition, that the node type of the time node is type B;
wherein the second condition is: time_node > = start_time, and time_node < = end_time-t;
that is, the time node satisfying the second condition is: a time node that is equal to or greater than a start time stamp of the log and equal to or less than a difference between an end time stamp of the log and a set time granularity;
the computer apparatus 1300 determines, for a time node (time_node) that satisfies the third condition, that the node type of the time node is type C;
wherein the third condition is: time_node > = start_time, and time_node < = end_time;
that is, the time node satisfying the third condition is: a time node that is equal to or greater than a start time stamp of the log and equal to or less than an end time stamp of the log.
The computer apparatus 1300 determines, for a time node (time_node) that satisfies the fourth condition, that the node type of the time node is type D;
wherein the fourth condition is: time_node > = end_time-t, and time_node < = start_time;
that is, the time node satisfying the fourth condition is: a time node that is equal to or greater than a difference between an end time stamp of the log and a set time granularity and is equal to or less than a start time stamp of the log.
In an exemplary embodiment, the computer device 1300 determines, for the time nodes involved in the log of the long time span as shown in fig. 3B, that the 1 st time node is type a, the 5 th time node is type C, and the other time nodes are type B;
in an exemplary embodiment, the computer device 1300 determines, for the time nodes involved in the log of one time span as shown in fig. 3C, that the 1 st time node is type a and the 2 nd time node is type C;
in an exemplary embodiment, the computer device 1300 is type D for the time node involved in the log of yet another time span as shown in fig. 3D.
Substep S304: calculating the time length of the time node mapped to the type A;
in this substep, the computer apparatus 1300 calculates a time length time_length=time_node+t-start_time mapped to the time node (time_node) of the type a;
that is, the length of time that the log maps to a time node that satisfies the first condition is equal to the sum of the time node and the set time granularity minus the start timestamp of the log.
Substep S305: calculating the time length of the time node mapped to the type B;
in this substep, the computer apparatus 1300 calculates a time length time_length=t of the time node (time_node) mapped to the type B;
that is, the length of time that the log maps to the time node that satisfies the second condition is equal to the set time granularity.
Substep S306: calculating the time length of the time node mapped to the type C;
in this substep, the computer apparatus 1300 calculates a time length time_length=end_time_time_node of the time node (time_node) mapped to the type C;
that is, the length of time that the log maps to a time node that satisfies the third condition is equal to the difference between the end timestamp of the log and the time node.
Substep S307: the length of time mapped to the time node of type D is calculated.
In this substep, the computer apparatus 1300 calculates a time length time_length=end_time-start_time mapped to the time node (time_node) of the type D;
that is, the length of time that the log maps to a time node that satisfies the fourth condition is equal to the difference between the end timestamp of the log and the time node.
Step S203: and calculating the bandwidth mapped by each log at the at least one time node according to the calculated time length.
In this step, for each time node involved in the currently acquired log, the computer device 1300 may calculate, according to the time length mapped by the log at the time node, the number of transmission bytes and the connection establishment duration of the log record, the bandwidth mapped by the log at the time node, where the specific method flow is as shown in fig. 4, and includes the following sub-steps S401 to S402:
substep S401: and for one time node related to the log, calculating the data transmission size of the log mapped at the time node according to the time length of the log mapped at the time node.
In this substep, the computer device 1300 calculates, for a time node involved in the log, a data transmission size mapped by the log at the time node according to a time length mapped by the log at the time node, a number of transmission bytes and a connection establishment duration of the log record.
In an exemplary embodiment, the log calculated by the computer apparatus 1300 maps to a data transmission size of one time node, size=bytes_send×time_length/session_time; where bytes_send and session_time are two fields recorded in the log, representing the number of bytes transferred (unit Byte) and the length of the connection (unit millisecond), respectively, and time_length is the length of time the log maps to the time node.
Substep S402: and calculating the bandwidth mapped by the log at the time node according to the data transmission size mapped by the log at the time node.
In an exemplary embodiment, the computer device 1300 may convert the size in bytes to a bandwidth value in Mbps: size_mbps=size 8/1024/1024/t/1000.
Step S204: and adding the bandwidths of the logs mapped to the same time node to obtain the bandwidth of the live video counted by the time node.
Specifically, the computer device 1300 may add bandwidths of the logs mapped to the same time node to obtain the bandwidth of the live video counted by the time node; therefore, the bandwidth value counted by all logs of the live video at each time node can be obtained; the whole calculation process does not need to split the log, namely the split sub-logs are not needed to be stored respectively, so that the purposes of saving log storage space, accelerating calculation speed and enhancing log readability are achieved.
Example two
Fig. 5 schematically illustrates a block diagram of a live video bandwidth statistics system according to a second embodiment of the present application, which may be divided into one or more program modules, stored in a storage medium and executed by one or more processors, to complete the embodiment of the present application. Program modules in the embodiments of the present application may be referred to as a series of computer program instruction segments capable of performing particular functions, and the following description may be presented in terms of their respective functions.
As shown in fig. 5, an internal structure of the bandwidth statistics system of the live video may include: a log acquisition module 501, a time length mapping module 502, a bandwidth mapping module 503, and a bandwidth statistics module 504, wherein:
the log obtaining module 501 is configured to obtain at least one log of live video;
the time length mapping module 502 is configured to calculate a time length of mapping of each log obtained at least one time node corresponding to the log; specifically, for a currently acquired log, the time length mapping module 502 determines a time node related to the log according to a start timestamp and an end timestamp of the log; and for each time node to which the log relates, calculating the length of time the log maps to the time node.
The time length mapping module 502 calculates the time length of the log mapped to the time node, and for the time node time_node satisfying the following first condition, the time length of the log mapped to the time node is time_length=time_node+t-start_time; for a time node time_node satisfying the following second condition, the length of time the log maps to the time node is time_length=t; for a time node time_node satisfying the following third condition, the length of time the log maps to the time node is time_length=end_time_time_node; for a time node time_node that satisfies the fourth condition, the length of time that the log maps to the time node is time_node > = end_time-t, and time_node < = start_time;
wherein, the first condition is: time_node > = start_time-t, and time_node < = start_time, and time_node < = end_time-t;
the second condition is: time_node > = start_time, and time_node < = end_time-t;
the third condition is: time_node > = start_time, and time_node < = end_time;
the fourth condition is: time_node > = end_time-t, and time_node < = start_time;
the bandwidth mapping module 503 is configured to calculate, according to the calculated time length, a bandwidth mapped by each log at the at least one time node; specifically, for each time node involved in the currently acquired log, the bandwidth mapping module 503 calculates, according to the time length mapped by the log at the time node, the number of transmission bytes and the connection establishment duration of the log record, the bandwidth mapped by the log at the time node.
The bandwidth statistics module 504 is configured to sum bandwidths of the logs mapped to the same time node to obtain a bandwidth of the live video counted by the time node.
The bandwidth statistics system for live video provided by the embodiment II of the application can realize statistics of the bandwidth value of the live video at each time node on the premise that the log is not split and the sub-logs after splitting are not stored respectively, thereby achieving the purposes of saving the log storage space in the process of calculating the bandwidth value, accelerating the calculation speed and enhancing the log readability.
Example III
Fig. 6 schematically illustrates a hardware architecture diagram of a computer device 1300 adapted to implement a method for bandwidth statistics of live video according to a third embodiment of the present application. In this embodiment, the computer apparatus 1300 is an apparatus capable of automatically performing numerical calculation and/or information processing in accordance with an instruction set or stored in advance. For example, it may be a smart phone, a tablet computer, a notebook computer, a desktop computer, a rack server, a blade server, a tower server, or a rack server (including a stand-alone server or a server cluster composed of a plurality of servers), etc. As shown in fig. 6, computer device 1300 includes at least, but is not limited to: memory 1310, processor 1320, and network interface 1330 may be communicatively linked to each other by a system bus. Wherein:
memory 1310 includes at least one type of computer-readable storage medium including flash memory, hard disk, multimedia card, card memory (e.g., SD or DX memory, etc.), random Access Memory (RAM), static Random Access Memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 1310 may be an internal storage module of the computer device 1300, such as a hard disk or memory of the computer device 1300. In other embodiments, the memory 1310 may also be an external storage device of the computer device 1300, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card) or the like. Of course, memory 1310 may also include both internal memory modules of computer device 1300 and external memory devices. In this embodiment, the memory 1310 is typically used for storing an operating system installed in the computer device 1300 and various application software, such as program codes of a bandwidth statistics method of live video. Furthermore, the memory 1310 may also be used to temporarily store various types of data that have been output or are to be output.
Processor 1320 may be a central processing unit (Central Processing Unit, simply CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments. The processor 1320 is generally configured to control overall operation of the computer device 1300, such as performing control and processing related to data interaction or communication with the computer device 1300, and the like. In this embodiment, processor 1320 is used to execute program code or process data stored in memory 1310.
The network interface 1330 may include a wireless network interface or a wired network interface, the network interface 1330 typically being used to establish communication links between the computer device 1300 and other computer devices. For example, the network interface 1330 is used to connect the computer device 1300 to an external terminal through a network, establish a data transmission channel and a communication link between the computer device 1300 and the external terminal, and the like. The network may be a wireless or wired network such as an Intranet (Intranet), the Internet (Internet), a global system for mobile communications (Global System of Mobile communication, abbreviated as GSM), wideband code division multiple access (Wideband Code Division Multiple Access, abbreviated as WCDMA), a 4G network, a 5G network, bluetooth (Bluetooth), wi-Fi, etc.
It should be noted that fig. 6 only shows a computer device having components 1310-1330, but it should be understood that not all of the illustrated components are required to be implemented, and that more or fewer components may be implemented instead.
In this embodiment, the overdraw test method based on color feature recognition stored in the memory 1310 may also be divided into one or more program modules and executed by one or more processors (the processor 1320 in this embodiment) to complete the embodiment of the present application.
Example IV
The embodiment of the application also provides a computer readable storage medium, and the computer readable storage medium stores a computer program thereon, and the computer program when executed by a processor realizes the steps of the bandwidth statistics method of the live video in the embodiment.
In this embodiment, the computer-readable storage medium includes a flash memory, a hard disk, a multimedia card, a card memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the computer readable storage medium may be an internal storage unit of a computer device, such as a hard disk or a memory of the computer device. In other embodiments, the computer readable storage medium may also be an external storage device of a computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card), etc. that are provided on the computer device. Of course, the computer-readable storage medium may also include both internal storage units of a computer device and external storage devices. In this embodiment, the computer readable storage medium is typically used to store an operating system and various application software installed on the computer device, such as program code of the bandwidth statistics method of live video in the embodiment. Furthermore, the computer-readable storage medium may also be used to temporarily store various types of data that have been output or are to be output.
It will be apparent to those skilled in the art that the modules or steps of the embodiments of the application described above may be implemented in a general purpose computing device, they may be concentrated on a single computing device, or distributed across a network of computing devices, they may alternatively be implemented in program code executable by computing devices, so that they may be stored in a storage device for execution by computing devices, and in some cases, the steps shown or described may be performed in a different order than what is shown or described, or they may be separately fabricated into individual integrated circuit modules, or a plurality of modules or steps in them may be fabricated into a single integrated circuit module. Thus, embodiments of the application are not limited to any specific combination of hardware and software.
The foregoing description is only of the preferred embodiments of the present application, and is not intended to limit the scope of the application, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.