Key Frame Collision Detection Method, Data Transmission Method and Related Devices for Video Equipment
By performing packet management of video devices and hashing timestamps to time slots, the problem of keyframe collision of video devices is solved, and higher accuracy detection and stable data transmission are achieved.
Patent Information
- Application Number
- CN202011280028.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-16
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2040-11-16
AI Technical Summary
When a video device is connected to the server, multiple devices send keyframes in a short time, causing collisions, affecting the real-time and stability of transmission, especially when the number of devices increases, the problem is more significant.
The video equipment is grouped and hashed the timestamp of the keyframe to the corresponding time slot. The collision is determined by detecting whether there are keyframes with the first threshold or above in the same time slot, and the time slots of the current keyframe and the previous keyframe are corrected, and the time slots of the keyframe are adjusted to reduce collisions.
Improve the precision and accuracy of keyframe collision detection, ensure the stability of keyframe transmission, adjust the encoding through peak stagger management to reduce collisions, and improve the stability of data transmission.
Smart Images

Figure CN114513651B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data communication technologies, and particularly to a method for detecting key frame collisions of video devices, a data transmission method, and related devices. Background Art
[0002] Video devices such as IP cameras (IPCs) have been widely used in the security field. In the current application environment, multiple video devices are connected to a server and upload video data to the server. Among them, a group of pictures (GOP) of video data includes a key frame (I-frame). The key frame retains the complete image of one frame of the picture, so the data volume is large. If multiple video devices send key frames to the server within a short time interval, key frame collisions will occur during a certain period of time, affecting the real-time performance and stability of key frame transmission. Moreover, as the number of video devices connected to the server increases, the situation of key frame collisions will become more obvious. Therefore, it is necessary to detect key frame collisions. Summary of the Invention
[0003] The main technical problem to be solved by the present application is to provide a method for detecting key frame collisions of video devices, a data transmission method, and related devices, which can group and manage video devices and hash the timestamps of key frames of video devices within a group to corresponding time slots, and then detect whether there are key frame collisions within the same time slot.
[0004] To solve the above technical problem, a technical solution adopted by the present application is: to provide a method for detecting key frame collisions of video devices, the method including: in response to a video device accessing the server, setting video devices accessing the server in the same access mode in the same group, and the server obtaining parameter information of all the video devices within the same group currently accessing and the timestamps of key frames; hashing the timestamps of the key frames to corresponding time slots according to the parameter information, where the time slot includes at least one frame interval time; in response to there being key frames of the video devices above a first threshold within the same time slot, determining that there is a key frame collision within the current time slot.
[0005] Wherein, each video device corresponds to multiple key frames. Before the step of determining that there is a key frame collision within the current time slot in response to there being key frames of the video devices above a first threshold within the same time slot, the method further includes: for each key frame of each video device, correcting the time slot corresponding to the current key frame by using the time slot corresponding to the current key frame and the time slots corresponding to other key frames before the current key frame.
[0006] Among them, the step of correcting the time slot corresponding to the current key frame by using the time slot corresponding to the current key frame and the time slots corresponding to other key frames before the current key frame includes: numbering all the key frames of the current video device in chronological order; obtaining a first time slot corresponding to the current key frame and a second time slot corresponding to the previous key frame before the current key frame; when the number of the key frame corresponding to the current video device is less than a second threshold, taking the average value of the first time slot and the second time slot as the corrected time slot corresponding to the current key frame; when the number of the key frame corresponding to the current video device is greater than or equal to the second threshold, taking the average value obtained by dividing the sum of the first time slot and the second time slot multiplied by a first value by the second threshold as the corrected time slot corresponding to the current key frame, where the first value is the difference between the second threshold and 1.
[0007] Among them, after the step of correcting the time slot corresponding to the current key frame by using the time slot corresponding to the current key frame and the time slots corresponding to other key frames before the current key frame, it further includes: obtaining a third time slot corresponding to the first key frame after the current key frame, and determining whether the difference between the third time slot and the corrected time slot of the current key frame is greater than or equal to a third threshold; if so, taking the first key frame as a starting point and renumbering the first key frame and the key frames after it.
[0008] Among them, the parameter information at least includes the group of pictures time; the step of hashing the time stamp of the key frame to the corresponding time slot according to the parameter information includes: obtaining a hashing range, a hashing interval, and a hashing number corresponding to the time slot, where the hashing range is equal to the group of pictures time, the hashing interval is the time interval corresponding to the time slot, and the first integer value obtained by dividing the hashing range by the hashing interval is the hashing number; obtaining a first remainder value obtained by dividing the time stamp by the hashing range; obtaining a second integer value obtained by dividing the first remainder value by the hashing interval; taking the time slot at the second integer value as the specific time slot where the time stamp is located among the hashing numbers.
[0009] Among them, the parameter information further includes the number of video devices and the frame interval time; the method further includes: determining the hashing interval by using the number of video devices, the group of pictures time, and the frame interval time.
[0010] Among them, after the step of obtaining the second integer value obtained by dividing the first remainder value by the hashing interval, it further includes: obtaining a second remainder value obtained by dividing the second integer value by the hashing number; comparing whether the second integer value and the second remainder value are equal, if they are equal, determining that the second integer value is valid, and if they are not equal, determining that the second integer value is invalid.
[0011] To solve the above technical problems, another technical solution adopted by this application is: to provide a method for data transmission of a video device, the method comprising: in response to a video device accessing a server, setting the video devices accessing the server in the same group according to the same access method, and the server obtaining parameter information and timestamps of key frames of all the video devices in the currently accessed same group; hashing the timestamps of the key frames to corresponding time slots according to the parameter information, wherein the time slots include at least one frame interval time; in response to there being key frames of a first threshold or more of the video devices in the same time slot, determining that there is a key frame collision in the current time slot; performing peak shifting management on the video devices having key frame collisions in the same time slot within the same group, so that the number of key frames in the same time slot is less than or equal to a fourth threshold.
[0012] To solve the above technical problems, another technical solution adopted by this application is: to provide an electronic device, the electronic device comprising a memory and a processor coupled to each other, wherein the memory stores program data, and the processor calls the program data to execute the above key frame collision detection method or data transmission method.
[0013] To solve the above technical problems, another technical solution adopted by this application is: to provide a computer storage medium, on which program data is stored, and when the program data is executed by a processor, the above key frame collision detection method or data transmission method is implemented.
[0014] The beneficial effect of this application is: this application groups the video devices accessing the server in different ways according to the access method, obtains the parameter information and timestamps of key frames of all the video devices in the same group, and hashes the timestamps to corresponding time slots according to the above data to determine whether there is a key frame collision in the same time slot. Among them, after grouping and managing the video devices, the video devices perform key frame collision detection in units of groups, improving the fineness and accuracy of key frame collision detection, and further improving the accuracy of key frame collision by hashing the timestamps into time slots and then performing collision judgment, thereby facilitating the adjustment of the encoding of the video devices having key frame collisions. Description of the Drawings
[0015] To more clearly illustrate the technical solutions in the embodiments of this application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of this application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts. Among them:
[0016] Figure 1It is a schematic flowchart of an embodiment of the key frame collision detection method for a video device provided by this application;
[0017] Figure 2 It is a schematic flowchart of another embodiment of the key frame collision detection method for a video device provided by this application;
[0018] Figure 3 is Figure 2 a schematic flowchart of an embodiment corresponding to step S203 in
[0019] Figure 4 It is a schematic flowchart of an embodiment of the video device data transmission method provided by this application;
[0020] Figure 5 It is a schematic structural diagram of an embodiment of an electronic device provided by this application;
[0021] Figure 6 It is a schematic structural diagram of an embodiment of a computer storage medium provided by this application. Specific Embodiments
[0022] Next, the technical solutions in the embodiments of this application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts shall fall within the protection scope of this application.
[0023] The terms "system" and "network" are often used interchangeably in this article. The term " / and" in this article only describes the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this article generally represents an "or" relationship between the associated objects before and after. In addition, "multiple" in this article means two or more than two.
[0024] Please refer to Figure 1 , Figure 1 is a schematic flowchart of an embodiment of the key frame collision detection method for a video device provided by this application, and the method includes:
[0025] Step S101: In response to the video device accessing the server, set the video devices accessing the server in the same group according to the same access method, and the server obtains the parameter information and the time stamps of the key frames of all the video devices in the currently accessed same group.
[0026] Specifically, the server can be a network platform or a Network Video Recorder (NVR), and the video devices can be various front-end video devices, including but not limited to IP cameras (IPCs). The video devices can obtain network access through base stations / wireless networks / wired networks, etc., and then connect to the server. Therefore, setting video devices with the same access method into the same group is beneficial for information interaction among video devices within the group and for refined management.
[0027] Specifically, video devices accessing the same base station belong to the same group, and video devices accessing different base stations belong to different groups. Each base station corresponds to one group. Similarly, video devices accessing the same wireless network belong to the same group, and each wireless network corresponds to one group. Video devices accessing the same local area network through wired connections belong to the same group, and each local area network corresponds to one group.
[0028] Further, after the video device actively connects to the server, it sends registration information including the device ID and channel number of the video device to the server. The server obtains the registration information and then initiates real-time video streaming to all the video devices that have already been connected within the group to play back the video data captured by all the video devices within the group. Then, the server can obtain parameter information from the video data of all the video devices within the group. The parameter information includes stream type, bit rate, frame rate, and group of pictures (GOP) time. The frame interval time corresponding to each frame can be obtained by converting the frame rate. Also, the server can obtain the timestamp corresponding to the key frame from the video stream corresponding to the video data.
[0029] Step S102: Hash the timestamp of the key frame to the corresponding time slot, where the time slot contains at least one frame interval time.
[0030] Specifically, in this step, the parameter information includes at least the GOP time, that is, the time interval of a group of GOPs.
[0031] In one application mode, the step of hashing the timestamp of the key frame to the corresponding time slot according to the parameter information specifically includes: obtaining the hash range, hash interval, and number of hashes corresponding to the time slot; obtaining the first remainder value obtained by dividing the timestamp by the hash range; obtaining the second integer value obtained by dividing the first remainder value by the hash interval; and taking the time slot at the second integer value as the specific time slot where the timestamp is located among the number of hashes.
[0032] Specifically, the hash range is equal to the GOP time, the hash interval is the time interval corresponding to the time slot, and the first integer value obtained by dividing the hash range by the hash interval is the number of hashes.
[0033] Preferably, the shooting parameters of video devices in the same group are set the same. Among them, the shooting parameters include the initial group of pictures time, frame rate, and bit rate. Furthermore, when hashing the timestamps of the key frames of video devices in the same group, the group of pictures time can be uniformly used as a reference.
[0034] Specifically, the hashing interval can be preset by the user. The hashing interval is at least one frame interval time. For example, the user can set the hashing interval to 2 frame interval times.
[0035] Optionally, the hashing range is denoted as HashTimeGop, the hashing interval is denoted as HashTimeInterval, and the number of hashes is denoted as HashArrayCnt, and the number of hashes starts from 0.
[0036] Furthermore, HashArrayCnt = [HashTimeGop / HashTimeInterval]. The specific steps to obtain the specific time slot in the number of hashes for the timestamp are specifically represented by the following formula:
[0037] slots = [(time % HashTimeGop) / HashTimeInterval];
[0038] Among them, time represents the timestamp, and slots represents the specific time slot corresponding to the timestamp.
[0039] In a specific application scenario, the group of pictures time of video devices in the same group is 2 seconds (s), the frame rate is 25 frames per second, then the frame interval time is 40 milliseconds (ms). Therefore, the hashing range is 2000 milliseconds (ms), the hashing interval is 80 milliseconds (ms), and the number of hashes is 25. When the timestamp of the video device is 7s, first obtain the first remainder value as [7000ms % 2000ms], that is, 1000ms; then obtain the second integer value as [1000ms / 80ms], that is, 12; finally, the current timestamp is in time slot 12. The timestamps of the key frames of other video devices in the same group can all be hashed, and the time slots corresponding to the hashed key frames of the video devices can be obtained.
[0040] It can be understood that through the above method, the specific value of the time slot corresponding to any timestamp in the same group can be accurately obtained, which is accurate and simple when calculating the hash of any timestamp to the corresponding time slot.
[0041] In another application method, after obtaining the second integer value obtained by dividing the first remainder value by the hashing interval, it further includes: obtaining the second remainder value obtained by dividing the second integer value by the number of hashes; comparing whether the second integer value and the second remainder value are equal. If they are equal, it is determined that the second integer value is valid. If they are not equal, it is determined that the second integer value is invalid.
[0042] Specifically, after obtaining the second integer value, theoretically, the second integer value should not be greater than the number of hashes. Then, the second integer value is the result of hashing the timestamp to the corresponding time slot. However, to improve the accuracy of the calculation result and prevent abnormal calculation results, the second remainder value obtained by taking the remainder of the second integer value divided by the number of hashes is used. If the calculation result is normal, the second integer value and the second remainder value are theoretically equal. Therefore, by determining whether the second integer value and the second remainder value are equal, only when they are equal is the second integer value determined to be valid, which can avoid abnormal results being used as the time sequence corresponding to the timestamp and improve the accuracy of the calculation result.
[0043] Step S103: In response to the existence of key frames of video devices equal to or above the first threshold within the same time slot, it is determined that there is a key frame collision within the current time slot.
[0044] Specifically, when the video data of the video device is transmitted normally, if the time of a group of pictures is the same, the time slots corresponding to the hashed key frames of the same video device have been determined. When the time slot includes at least one frame interval time, the key frames can be fully hashed and dispersed, and then determining whether there is a key frame collision within the time slot can make the determination result more accurate. Among them, the first threshold can be preset according to the peak value of the data volume received by the server. For example, the first threshold can be set to 2 or 3. In other embodiments, after obtaining the parameter information, the data volume of the key frames can also be analyzed through the bit rate and the time of the picture group in the parameter information, and then the integer value obtained by dividing the peak value of the data volume received by the server by the data volume of the key frames is used as the first threshold.
[0045] Furthermore, after determining which time slot has a key frame conflict, the encoding of the video device can be adjusted for management to improve the stability of data transmission.
[0046] In this embodiment, the video devices connected to the server in different ways are grouped according to the connection method, the parameter information of all video devices in the same group and the timestamps of the key frames are obtained, and the timestamps are hashed to the corresponding time slots according to the above data. It is determined whether there is a key frame collision within the same time slot. Among them, after grouping and managing the video devices, the video devices perform key frame collision detection in groups, which improves the fineness and accuracy of key frame collision detection. And hashing the timestamps into the time slots and then performing collision judgment can further improve the accuracy of key frame collision, and then facilitate the adjustment of the encoding of the video devices with key frame collisions.
[0047] Please refer to Figure 2 , Figure 2 which is a schematic flowchart of another implementation manner of the method for detecting key frame collision of video devices provided by this application. The method includes:
[0048] Step S201: In response to the access of a video device to the server, the video devices accessing the server in the same access mode are set in the same group, and the server obtains the parameter information of all the video devices in the same group that are currently accessing and the timestamps of the key frames.
[0049] Specifically, the server provides a management service. When a video device accesses the server, it sends registration information to the server. The server sets the video devices accessing the server in the same access mode in the same group and provides a management service for the video devices. This management service initiates real-time stream pulling for the video devices that have already accessed the group. During the stream pulling process, the server obtains the parameter information of all the video devices in the group and records the registration information, parameter information, and the timestamps of the key frames of any video device after detecting its key frame. In other embodiments, real-time stream pulling can also be initiated through a network node between the server and the video device.
[0050] Furthermore, when the server cannot identify the access mode of a video device, the video device with an unidentifiable access mode is manually configured into a group or set in the default group.
[0051] Step S202: Hash the timestamps of the key frames to the corresponding time slots according to the parameter information, where the time slot includes at least one frame interval time.
[0052] Specifically, the server provides a detection service. The detection service obtains the parameter information of the video device and the timestamps of the key frames transmitted by the management service, and hashes the timestamps to the corresponding time slots according to the parameter information. The specific process can refer to the corresponding content in the above Step S102.
[0053] It should be noted that in addition to the group of pictures time, the parameter information of the video device also includes the number of video devices and the frame interval time. Furthermore, when determining the hash interval, it also includes: determining the hash interval by using the number of video devices, the group of pictures time, and the frame interval time.
[0054] Specifically, when the ratio of the group of pictures time to the number of video devices is less than or equal to the frame interval time, the hash interval is the frame interval time; when the ratio of the group of pictures time to the number of video devices is greater than the frame interval time and less than the second numerical multiple of the frame interval time, the hash interval is obtained by taking the integer of the ratio of the group of pictures time to the number of video devices; when the ratio of the group of pictures time to the number of video devices is greater than or equal to the second numerical multiple of the frame interval time, the hash interval is the second numerical multiple of the frame interval time. Here, the second numerical value is an integer and is related to the frame interval time. The longer the frame interval time, the smaller the second numerical value.
[0055] Specifically, when the number of video devices in the same group is large, the hash interval is at least one frame interval time to ensure that the timestamps can be hashed within the frame interval time. When the number of video devices in the same group is moderate, the group of pictures time is evenly divided and rounded according to the number of video devices to obtain a better hash interval. When the number of video devices in the same group is small, the upper limit of the hash interval is set so that the key frames can be hashed to the corresponding time sequence to achieve a better hash result, and the probability of key frame collision within the same time slot will not be increased due to too large a hash interval, affecting the accuracy of key frame collision analysis. Therefore, dynamically adjusting the hash interval according to the number of video devices, the group of pictures time, and the frame interval time is beneficial to improving the accuracy of key frame collision detection results.
[0056] In a specific application scenario, the group of pictures time of the video devices in the same group is 2s, the frame rate is 25 frames per second, then the frame interval time is 40ms, and the second value is 3. Then, when the number of video devices is greater than or equal to 50, the hash interval is 40ms. When the number of video devices is between 17 and 50, the hash interval is the integer value obtained by dividing the group of pictures time by the number of video devices. When the number of video devices is less than 17, the hash interval is 120ms.
[0057] Step S203: For each key frame of each video device, use the time slot corresponding to the current key frame and the time slots corresponding to other key frames before the current key frame to correct the time slot corresponding to the current key frame.
[0058] Specifically, due to the volatility of network transmission, the time when the key frames arrive at the server is fluctuating. Therefore, there may be a certain error in the time slot obtained by hashing a key frame of a video device. For video devices hashed to adjacent time slots, key frame collision will occur due to the volatility of network transmission during the actual upload of key frames to the server. Therefore, using the time slot corresponding to the current key frame and the time slots corresponding to other key frames before the current key frame to correct the time slot corresponding to the current key frame can reduce the error caused by the volatility of network transmission.
[0059] Specifically, please refer to Figure 3 , Figure 3 is Figure 2 a schematic flowchart of an implementation manner corresponding to step S203 in
[0060] Step S301: Number all the key frames of the current video device in chronological order.
[0061] Specifically, the server records the key frames of the same video device during the pulling process and numbers the key frames in the order of the timestamps.
[0062] Step S302: Obtain the first time slot corresponding to the current key frame and the second time slot corresponding to the previous key frame before the current key frame.
[0063] Specifically, the time slot corresponding to the hash result of the previous key frame before the current key frame can be temporarily stored in the buffer of the server. When performing successive hashing according to the numbers of the key frames of the current video device, the first time slot corresponding to the current key frame can be obtained according to the above Steps S201 - S202, and the second time slot corresponding to the previous key frame can be obtained from the buffer.
[0064] Step S303: Determine whether the number of the key frame corresponding to the current video device is less than the second threshold.
[0065] Specifically, when the number of the key frame corresponding to the current video device is less than the second threshold, Step S304 is executed; when the number of the key frame corresponding to the current video device is greater than or equal to the second threshold, Step S305 is executed. Among them, the second threshold can be 10, and the second threshold is used to perform arithmetic mean processing on the data when the number of samples is small, and perform moving average processing on the data when the number of samples is greater than the second threshold.
[0066] Step S304: Take the average value of the first time slot and the second time slot as the time slot corresponding to the corrected current key frame.
[0067] Specifically, assume that the uncorrected time slot after hashing of the i-th key frame is S i , the corrected time slot of the i-th key frame is M i , and the second threshold is 10. When i < 10, the time slot M i corresponding to the corrected current key frame = [M (i-1) + S i ] / 2. M (i-1) is the corrected time slot of the previous key frame before the current key frame, that is, the second time slot. Take the integer of the average value of the first time slot and the second time slot as the time slot corresponding to the corrected current key frame.
[0068] Step S305: Take the average value obtained by dividing the sum of the first time slot and the second time slot multiplied by the first value by the second threshold as the time slot corresponding to the corrected current key frame, where the first value is the difference between the second threshold and 1.
[0069] Specifically, assume that the uncorrected time slot after hashing of the i-th key frame is S i , the corrected time slot of the i-th key frame is M i , and the second threshold is 10. When i ≥ 10, the time slot M i corresponding to the corrected current key frame = [9 * M (i-1) + S i / 10. The average value obtained by dividing the sum of the first time slot and the second time slot multiplied by the first value by the second threshold is rounded to be used as the time slot corresponding to the current key frame.
[0070] It can be understood that in other embodiments, the second threshold may not be set, and only the arithmetic mean processing in step S304 or the moving average processing in step S305 is performed. No matter which correction method is adopted, after correcting the time slot corresponding to the current key frame by using the time slot corresponding to the current key frame and the time slots corresponding to other key frames before the current key frame, the error of the time sequence of the current key frame can be effectively reduced, and the impact caused by the volatility of network transmission can be reduced.
[0071] Further, after step S203, it further includes: obtaining the third time slot corresponding to the first key frame after the current key frame, and determining whether the difference between the third time slot and the time slot after the current key frame is corrected is greater than or equal to the third threshold; if so, using the first key frame as the starting point, re-numbering the first key frame and the key frames after it.
[0072] Specifically, assume that the uncorrected time slot of the i-th key frame after hashing is S i , and the corrected time slot of the i-th key frame is M i . The third threshold is 2. When the difference between the uncorrected time slot S (i+1) of the first key frame and M i is greater than 2, then starting from the first key frame after the current key frame, re-number the first key frame and the key frames after it.
[0073] Specifically, when the difference between the time slot of the first key frame before correction and the corrected time slot of the key frame before the first key frame is greater than the third threshold, it is very likely that the first key frame has caused re-streaming due to a newly connected video device or the user has performed manual streaming. Therefore, it is necessary to re-number starting from the position of the first key frame, and repeat steps S302 - S305 to correct the time slot corresponding to the key frame of the current video device in a timely manner, improving the reliability of time slot correction.
[0074] Step S204: In response to the existence of key frames of video devices with the first threshold or more within the same time slot, it is determined that there is a key frame collision within the current time slot.
[0075] Specifically, when there are key frames of video devices with the first threshold or more within the hash interval corresponding to the same time slot, it is considered that the number of key frames uploaded within this time slot exceeds the limit that the server can bear.
[0076] The key frame collision detection method provided in this embodiment further corrects the time slots after timestamp hashing to reduce the impact caused by network transmission volatility, making the time slots after timestamp hashing of key frames more accurate, and thus improving the accuracy of key frame collision detection results.
[0077] It can be understood that for all video devices in different groups connected to the same server, the method in any of the above embodiments can be used to perform key frame collision detection within the same group.
[0078] Please refer to Figure 4 , Figure 4 which is a schematic flowchart of an implementation manner of the video device data transmission method provided in this application. The data transmission method includes:
[0079] Step S401: In response to a video device accessing the server, the video devices accessing the server in the same access manner are set in the same group, and the server obtains the parameter information of all video devices in the current accessed group and the timestamps of key frames.
[0080] Step S402: Hash the timestamps of key frames to the corresponding time slots according to the parameter information, where the time slots include at least one frame interval time.
[0081] Step S403: In response to there being key frames of a first threshold or more video devices in the same time slot, it is determined that there is a key frame collision in the current time slot.
[0082] Specifically, for parts of the above steps S401 - S403, please refer to any of the above embodiments and will not be elaborated here.
[0083] Step S404: Perform peak staggering management on the video devices in the same group where key frame collisions occur in the same time slot, so that the number of key frames in the same time slot is less than or equal to the fourth threshold.
[0084] Specifically, the above fourth threshold can be a positive integer such as 1.
[0085] In a specific application scenario, the time slot of the key frame of one video device in the video devices where key frame collisions occur within the same time slot is kept unchanged. If there are idle time slots, the time slots of the key frames of the remaining video devices where key frame collisions occur within the same time slot are preferentially adjusted to the idle time slots respectively to obtain the target time slot. If there are no idle time slots, the time slots of the key frames of the remaining video devices where key frame collisions occur within the same time slot are adjusted to the time slot with the least number of key frames to obtain the target time slot. Among them, the above-mentioned idle time slot refers to a time slot in which there is no key frame, and the idle time slot is also included in the hash number. The above method for adjusting the target time slot of the key frame is relatively simple and has a low computational complexity. Of course, in other application scenarios, the target time slots of the key frames of all video devices can also be adjusted, and the present application does not limit this.
[0086] The video device data transmission method provided in this embodiment, after detecting that the key frames of the video device will collide, performs staggering management on the key frames of the video device so that the number of key frames within the same time slot is less than the fourth threshold, thereby improving the stability of the video device transmitting data to the server.
[0087] Please refer to Figure 5 , Figure 5 FIG. is a schematic structural diagram of an embodiment of an electronic device provided by the present application. The electronic device 50 includes a memory 501 and a processor 502 that are coupled to each other. Among them, the memory 501 stores program data (not shown in the figure), and the processor 502 calls the program data to implement the video device key frame collision detection method or the video device data transmission method in any of the above embodiments. For the description of related content, please refer to the detailed description of the above method embodiments, and details will not be repeated here.
[0088] Please refer to Figure 6 , Figure 6 FIG. is a schematic structural diagram of an embodiment of a computer storage medium provided by the present application. The computer storage medium 60 stores program data 600, and when the program data 600 is executed by a processor, it implements the video device key frame collision detection method or the video device data transmission method in any of the above embodiments. For the description of related content, please refer to the detailed description of the above method embodiments, and details will not be repeated here.
[0089] It should be noted that the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0090] In addition, in each embodiment of the present application, each functional unit may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit.
[0091] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, may be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods in various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0092] The above are only the embodiments of the present application, and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present application.
Claims
1. A method for detecting key frame collisions in a video device, characterized in that, The method includes: In response to a video device accessing the server, video devices accessing the server in the same access mode are set in the same group, and the server obtains parameter information of all the video devices in the same group that are currently accessed and timestamps of key frames; each of the video devices corresponds to multiple key frames. Hash the timestamps of the key frames to corresponding time slots according to the parameter information, where each time slot includes at least one frame interval time. For each key frame of each video device, use the time slot corresponding to the current key frame and time slots corresponding to other key frames before the current key frame to correct the time slot corresponding to the current key frame; specifically including: numbering all the key frames of the current video device in chronological order; obtaining a first time slot corresponding to the current key frame and a second time slot corresponding to the previous key frame before the current key frame; when the number of the key frame corresponding to the current video device is less than a second threshold, use the average value of the first time slot and the second time slot as the corrected time slot corresponding to the current key frame; when the number of the key frame corresponding to the current video device is greater than or equal to the second threshold, use the average value obtained by dividing the sum of the first time slot and the first numerical multiple of the second time slot by the second threshold as the corrected time slot corresponding to the current key frame, where the first numerical value is the difference between the second threshold and 1. In response to there being key frames of the video devices above a first threshold in the same time slot, it is determined that there is a key frame collision in the current time slot.
2. The method according to claim 1, wherein After the step of using the time slot corresponding to the current key frame and time slots corresponding to other key frames before the current key frame to correct the time slot corresponding to the current key frame, it further includes: Obtain a third time slot corresponding to a first key frame after the current key frame, and determine whether the difference between the third time slot and the time slot after correction of the current key frame is greater than or equal to a third threshold. If so, use the first key frame as a starting point to re-number the first key frame and key frames after it.
3. The method according to claim 1, wherein the parameter information at least includes group of pictures time. The step of hashing the timestamps of the key frames to corresponding time slots according to the parameter information includes: Obtain a hash range, a hash interval, and a hash number corresponding to the time slot, where the hash range is equal to the group of pictures time, the hash interval is the time interval corresponding to the time slot, and the first integer value obtained by dividing the hash range by the hash interval is the hash number. Obtain a first remainder value obtained by dividing the timestamp by the hash range. Obtain a second integer value obtained by dividing the first remainder value by the hash interval. Use the time slot at the second integer value as the specific time slot where the timestamp is located among the hash number.
4. The method according to claim 3, characterized in that The parameter information further includes the number of video devices and the frame interval time, and the method further includes: Determine the hash interval using the number of video devices, the group of pictures time, and the frame interval time.
5. The method according to claim 3, characterized in that, After the step of obtaining the second integer value obtained by dividing the first remainder value by the hash interval, the method further includes: obtaining a second remainder value obtained by dividing the second integer value by the number of hashes; comparing whether the second integer value is equal to the second remainder value, if they are equal, determining that the second integer value is valid, and if they are not equal, determining that the second integer value is invalid.
6. A method for transmitting video device data, characterized in that, The method includes: in response to a video device accessing the server, setting video devices accessing the server in the same group according to the same access method, and the server obtaining parameter information and timestamps of key frames of all the video devices in the same group currently accessed; each of the video devices corresponds to a plurality of key frames; hashing the timestamps of the key frames to corresponding time slots according to the parameter information, where the time slots include at least one frame interval time; for each key frame of each video device, using the time slot corresponding to the current key frame and the time slots corresponding to other key frames before the current key frame to correct the time slot corresponding to the current key frame; specifically including: numbering all the key frames of the current video device in chronological order; obtaining a first time slot corresponding to the current key frame and a second time slot corresponding to the previous key frame before the current key frame; when the number of the key frames corresponding to the current video device is less than a second threshold, taking the average value of the first time slot and the second time slot as the time slot corresponding to the corrected current key frame; when the number of the key frames corresponding to the current video device is greater than or equal to the second threshold, taking the average value obtained by dividing the sum of the first time slot and the second time slot multiplied by a first value by the second threshold as the time slot corresponding to the corrected current key frame, where the first value is the difference between the second threshold and 1; in response to there being key frames of the first threshold or more video devices in the same time slot, determining that there is a key frame collision in the current time slot; performing staggering management on the video devices in the same group where key frame collisions occur in the same time slot, so that the number of key frames in the same time slot is less than or equal to a fourth threshold.
7. An electronic device, characterized in that, including: a memory and a processor coupled to each other, where the memory stores program data, and the processor calls the program data to execute the method according to any one of claims 1-5 or execute the method according to claim 6.
8. A computer storage medium, on which program data is stored, characterized in that, When the program data is executed by the processor, it implements the method according to any one of claims 1-5 or implements the method according to claim 6.
Citation Information
Patent Citations
Data transmission method based on multiple network cameras and related device
CN111787292A