Video frame rate statistics method, system, medium, and electronic device
Patent Information
- Application Number
- CN202311873337.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2043-12-29
AI Technical Summary
[0004]发明人发现,弱网环境下,一些前端设备会根据某些策略调整自身的视频传输帧率,叠加网络波动,这给网络协议中通常为整数格式的帧率值的确定带来了挑战,帧率的统计误差通常会随时间的推移而扩大,影响以帧率为基准的后续计算与处理
[0034] This invention innovatively proposes a video frame rate statistics strategy. Through multiple anomaly detection and final compensation calculation, it eliminates accumulated errors and adjusts the current frame rate in real time to accurately reflect the number of frames per unit time, providing a more accurate basis for playback terminals and analysis services.
Smart Images

Figure CN117749976B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of real-time video frame rate statistics technology, and in particular to a video frame rate statistics method, system, medium, and electronic device. Background Technology
[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.
[0003] Frame rate is the frequency (rate) at which a bitmap image appears continuously on a display, measured in frames. Videos with higher frame rates are smoother and often provide a better viewing experience. Therefore, it is particularly important to track frame rates.
[0004] The inventors discovered that in weak network environments, some front-end devices adjust their own video transmission frame rates according to certain strategies, which, combined with network fluctuations, poses a challenge to the determination of frame rate values, which are usually in integer format in network protocols. The statistical error of the frame rate usually increases over time, affecting subsequent calculations and processing based on the frame rate. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a video frame rate statistics method, system, medium, and electronic device that eliminates accumulated errors and adjusts the current frame rate in real time to accurately reflect the number of frames per unit time, providing a more accurate basis for playback terminals and analysis services.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] In a first aspect, the present invention provides a video frame rate statistics method.
[0008] A video frame rate statistics method includes the following steps:
[0009] Step 1: When the difference between the input video timestamp and the start timestamp is less than the first set time threshold, it is determined that the sample is too small, the initial calibration value is output, and the calculation process ends. The initial calibration value is a value obtained from the media parameters of the front-end device or a custom default value.
[0010] Step 2: When the difference between the input video timestamp and the starting timestamp is greater than or equal to the first set time threshold, if the current video frame sequence number is less than or equal to the previous video frame sequence number, set the timestamp of the last calculated video frame to the timestamp of the current video frame, output the calculated frame rate value, and end the calculation process.
[0011] As a further limitation of the first aspect of the present invention, in step three: if the current video frame sequence number in step two is greater than the previous video frame sequence number, and the current video frame timestamp is less than or equal to the previously calculated video frame timestamp, then the previously calculated video frame timestamp is set as the current video frame timestamp, the previously calculated frame rate value is output, and the calculation process ends.
[0012] As a further limitation of the first aspect of the present invention, in step four: if the current video frame timestamp in step three is greater than the previously calculated video frame timestamp, and the difference between the current video frame timestamp and the previously calculated video frame timestamp is less than or equal to the second set time threshold, then the previously calculated video frame timestamp is set as the current video frame timestamp, the previously calculated frame rate value is output, and the calculation process ends.
[0013] As a further limitation of the first aspect of the present invention, step five: when the difference between the previous video frame timestamp in step four and the previously calculated video frame timestamp is greater than the second set time threshold, and no video frame is received within the time interval between the current video frame timestamp and the previously calculated video frame timestamp, the final frame rate value 1 is directly output, the previously calculated video frame timestamp is reset to the current video frame timestamp, and the calculation process ends.
[0014] As a further limitation of the first aspect of the present invention, step six: when a video frame is received within the time interval between the current video frame timestamp in step five and the last calculated video frame timestamp, the frame rate value with a decimal part is calculated. When the rounding value is not 0, the frame rate value with a decimal part is compensated. After updating the two compensation state variables, the final frame rate value after compensation calculation and rounding is output.
[0015] As a further limitation of the first aspect of the present invention, in step six, the frame rate value with a decimal part is the ratio of the number of video frames received within the current timestamp and the last calculated timestamp to the time interval between the current timestamp and the last calculated timestamp.
[0016] The frame rate value after compensation calculation is the sum of the frame rate value before compensation calculation and the compensation coefficient, where the compensation coefficient is the ratio of the compensation amount to the rounded value.
[0017] The updated rounded value is the integer value of the frame rate after compensation calculation;
[0018] The updated compensation amount is the difference between the frame rate value after compensation calculation and the rounded frame rate value after compensation calculation.
[0019] Secondly, the present invention provides a video frame rate statistics system.
[0020] A video frame rate statistics system, comprising:
[0021] The first anomaly detection module is configured to: when the difference between the input video timestamp and the start timestamp is less than a first set time threshold, determine that the sample is too small, output an initial calibration value, and end the calculation process. The initial calibration value is a value obtained from the media parameters of the front-end device or a custom default value.
[0022] The second anomaly detection module is configured to: when the difference between the input video timestamp and the starting timestamp is greater than or equal to the first set time threshold, if the current video frame sequence number is less than or equal to the previous video frame sequence number, set the timestamp of the last calculated video frame to the timestamp of the current video frame, output the calculated frame rate value, and end the calculation process.
[0023] As a further limitation of the second aspect of the present invention, the third anomaly judgment module is configured to: if the current video frame sequence number is greater than the previous video frame sequence number, and the current video frame timestamp is less than or equal to the last calculated video frame timestamp, set the last calculated video frame timestamp to the current video frame timestamp, output the last calculated frame rate value, and end the calculation process.
[0024] The fourth anomaly detection module is configured to: if the current video frame timestamp is greater than the last calculated video frame timestamp, and the difference between the current video frame timestamp and the last calculated video frame timestamp is less than or equal to the second set time threshold, set the last calculated video frame timestamp to the current video frame timestamp, output the last calculated frame rate value, and end the calculation process.
[0025] The fifth anomaly detection module is configured to: when the difference between the current video frame timestamp and the last calculated video frame timestamp is greater than the second set time threshold, and no video frame is received within the time interval between the current video frame timestamp and the last calculated video frame timestamp, directly output the final frame rate value of 1, reset the last calculated video frame timestamp to the current video frame timestamp, and end the calculation process.
[0026] The compensation calculation module is configured to: when a video frame is received within the time interval between the current video frame timestamp and the last calculated video frame timestamp, calculate the frame rate value with a decimal part; when the rounded value is not 0, perform compensation calculation on the frame rate value with a decimal part; after updating the two compensation status variables, output the final frame rate value after compensation calculation and rounding.
[0027] The frame rate value, with a decimal part, is calculated as the ratio of the number of video frames received between the current timestamp and the last calculated timestamp to the time interval between the current timestamp and the last calculated timestamp.
[0028] The frame rate value after compensation calculation is the sum of the frame rate value before compensation calculation and the compensation coefficient, where the compensation coefficient is the ratio of the compensation amount to the rounded value.
[0029] The updated rounded value is the integer value of the frame rate after compensation calculation;
[0030] The updated compensation amount is the difference between the frame rate value after compensation calculation and the rounded frame rate value after compensation calculation.
[0031] Thirdly, the present invention provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the steps in the video frame rate statistics method as described in the first aspect of the present invention.
[0032] Fourthly, the present invention provides an electronic device including a memory, a processor, and a program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps in the video frame rate statistics method as described in the first aspect of the present invention.
[0033] Compared with the prior art, the beneficial effects of the present invention are:
[0034] This invention innovatively proposes a video frame rate statistics strategy. Through multiple anomaly detection and final compensation calculation, it eliminates accumulated errors and adjusts the current frame rate in real time to accurately reflect the number of frames per unit time, providing a more accurate basis for playback terminals and analysis services. Attached Figure Description
[0035] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0036] Figure 1 This is a schematic diagram of the system structure provided in Embodiment 1 of the present invention;
[0037] Figure 2 This is a flowchart illustrating the video frame rate statistics method provided in Embodiment 1 of the present invention. Detailed Implementation
[0038] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0039] It should be noted that the following detailed description is illustrative and intended to provide further explanation of the invention. Unless otherwise specified, all 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 pertains.
[0040] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.
[0041] Example 1:
[0042] like Figure 1 and Figure 2As shown, Embodiment 1 of the present invention provides a video frame rate statistics method, including the following process:
[0043] Step 1: The system has an initial calibration value. When the difference between the input video timestamp and the starting timestamp is less than 1 second (i.e., the first set time threshold, which can be selected according to the specific working conditions, and will not be elaborated here), it is considered that the sample is too small, and the initial calibration value will be returned and the calculation process will end.
[0044] The initial calibration value can be obtained from the media parameters of the front-end device or a default value defined by the system itself.
[0045] Step 2: When the current video frame sequence number is less than or equal to the previous video frame sequence number, it is considered an abnormal state. The last calculated timestamp will be reset to the current timestamp, and the last calculated frame rate value will be returned to end the calculation process.
[0046] Step 3: When the current video frame sequence number is greater than the previous video frame sequence number, and the current video frame timestamp curPts is less than or equal to the last calculated timestamp lastPts, it is considered an abnormal state. The last calculated timestamp will be reset to the current timestamp, and the last calculated frame rate value will be returned to end the calculation process.
[0047] Step 4: When the current video frame timestamp curPts is greater than the last calculated timestamp lastPts, and the difference between the current video frame timestamp curPts and the last calculated timestamp lastPts is less than or equal to 1s (i.e., the second set time threshold, which can be selected according to the specific working conditions, and will not be elaborated here), it is considered an abnormal state. The last calculated timestamp will be reset to the current timestamp, and the last calculated frame rate value will be returned to end the calculation process.
[0048] Step 5: If the difference between the current video frame timestamp curPts and the last calculated timestamp lastPts is greater than 1 second, and no video frame is received within the time interval between the current timestamp curPts and the last calculated timestamp lastPts, the final frame rate value of 1 will be returned directly, the last calculated timestamp will be reset to the current timestamp, and the calculation process will end.
[0049] Step Six: Calculate the frame rate value with decimal parts:
[0050] curFrameRate = (curPts, lastPts) number of frames received within the time interval / (curPts, lastPts) time interval, and reset the last calculated timestamp to the current timestamp;
[0051] When the roundValue value is not 0, a compensation calculation will be performed on the current frame rate value curFrameRate:
[0052] curFrameRate=curFrameRate+curFrameRate*compensationValue / roundValue;
[0053] Update two compensation state variables:
[0054] roundValue=[curFrameRate];
[0055] compensationValue=curFrameRate-[curFrameRate].
[0056] The output frame rate value is rounded down to the nearest integer: [curFrameRate].
[0057] Example 2:
[0058] Embodiment 2 of the present invention provides a video frame rate statistics system, comprising:
[0059] The first anomaly detection module is configured to: when the difference between the input video timestamp and the start timestamp is less than a first set time threshold, determine that the sample is too small, output an initial calibration value, and end the calculation process. The initial calibration value is a value obtained from the media parameters of the front-end device or a custom default value. The specific working method of the first anomaly detection module is described in step one of embodiment 1, and will not be repeated here.
[0060] The second anomaly detection module is configured to: when the difference between the input video timestamp and the start timestamp is greater than or equal to the first set time threshold, if the current video frame sequence number is less than or equal to the previous video frame sequence number, set the timestamp of the last calculated video frame to the timestamp of the current video frame, output the calculated frame rate value, and end the calculation process. The specific working method of the second anomaly detection module is described in step two of embodiment 1, and will not be repeated here.
[0061] The third anomaly detection module is configured to: if the current video frame sequence number is greater than the previous video frame sequence number, and the current video frame timestamp is less than or equal to the last calculated video frame timestamp, set the last calculated video frame timestamp to the current video frame timestamp, output the last calculated frame rate value, and end the calculation process. The specific working method of the third anomaly detection module is described in step three of embodiment 1, and will not be repeated here.
[0062] The fourth anomaly detection module is configured to: if the current video frame timestamp is greater than the last calculated video frame timestamp, and the difference between the current video frame timestamp and the last calculated video frame timestamp is less than or equal to the second set time threshold, set the last calculated video frame timestamp to the current video frame timestamp, output the last calculated frame rate value, and end the calculation process. The specific working method of the fourth anomaly detection module is described in step four of embodiment 1, and will not be repeated here.
[0063] The fifth anomaly detection module is configured to: when the difference between the current video frame timestamp and the last calculated video frame timestamp is greater than the second set time threshold, and no video frame is received within the time interval between the current video frame timestamp and the last calculated video frame timestamp, directly output the final frame rate value of 1, reset the last calculated video frame timestamp to the current video frame timestamp, and end the calculation process. The specific working method of the fifth anomaly detection module is described in step five of embodiment 1, and will not be repeated here.
[0064] The compensation calculation module is configured to: when a video frame is received within the time interval between the current video frame timestamp and the last calculated video frame timestamp, calculate the frame rate value with a decimal part; when the rounding value is not 0, perform compensation calculation on the frame rate value with a decimal part; after updating the two compensation state variables, output the final frame rate value after compensation calculation and rounding. The specific working method of the compensation calculation module is described in step six of embodiment 1, and will not be repeated here.
[0065] Example 3:
[0066] Embodiment 3 of the present invention provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the steps in the video frame rate statistics method as described in Embodiment 1 of the present invention.
[0067] Example 4:
[0068] Embodiment 4 of the present invention provides an electronic device, including a memory, a processor, and a program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps in the video frame rate statistics method as described in Embodiment 1 of the present invention.
[0069] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.
[0070] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0071] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0072] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0073] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0074] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A video frame rate statistics method, characterized in that, The process includes the following: Step 1: When the difference between the input video timestamp and the start timestamp is less than the first set time threshold, it is determined that the sample is too small, the initial calibration value is output, and the calculation process ends. The initial calibration value is a value obtained from the media parameters of the front-end device or a custom default value. Step 2: When the difference between the input video timestamp and the starting timestamp is greater than or equal to the first set time threshold, if the current video frame sequence number is less than or equal to the previous video frame sequence number, set the timestamp of the last calculated video frame to the timestamp of the current video frame, output the calculated frame rate value, and end the calculation process. Step 3: If the current video frame sequence number in Step 2 is greater than the previous video frame sequence number, and the current video frame timestamp is less than or equal to the last calculated video frame timestamp, set the last calculated video frame timestamp to the current video frame timestamp, output the last calculated frame rate value, and end the calculation process. Step 4: If the current video frame timestamp in Step 3 is greater than the last calculated video frame timestamp, and the difference between the current video frame timestamp and the last calculated video frame timestamp is less than or equal to the second set time threshold, then set the last calculated video frame timestamp to the current video frame timestamp, output the last calculated frame rate value, and end the calculation process. Step 5: When the difference between the previous video frame timestamp in Step 4 and the last calculated video frame timestamp is greater than the second set time threshold, and no video frame is received within the time interval between the current video frame timestamp and the last calculated video frame timestamp, the final frame rate value of 1 is directly output, the last calculated video frame timestamp is reset to the current video frame timestamp, and the calculation process ends. Step 6: When a video frame is received within the time interval between the current video frame timestamp in Step 5 and the last calculated video frame timestamp, calculate the frame rate value with a decimal part. If the rounded value is not 0, perform compensation calculation on the frame rate value with a decimal part. After updating the two compensation state variables, output the final frame rate value after compensation calculation and rounding. In step six, the frame rate value with a decimal part is the ratio of the number of video frames received within the current timestamp and the last calculated timestamp to the time interval between the current timestamp and the last calculated timestamp. The frame rate value after compensation calculation is the sum of the frame rate value before compensation calculation and the compensation coefficient, where the compensation coefficient is the ratio of the compensation amount to the rounded value. The updated rounded value is the integer value of the frame rate after compensation calculation; The updated compensation amount is the difference between the frame rate value after compensation calculation and the rounded frame rate value after compensation calculation.
2. A video frame rate statistics system, characterized in that, include: The first anomaly detection module is configured to: when the difference between the input video timestamp and the start timestamp is less than a first set time threshold, determine that the sample is too small, output an initial calibration value, and end the calculation process. The initial calibration value is a value obtained from the media parameters of the front-end device or a custom default value. The second anomaly detection module is configured to: when the difference between the input video timestamp and the start timestamp is greater than or equal to the first set time threshold, if the current video frame sequence number is less than or equal to the previous video frame sequence number, set the timestamp of the last calculated video frame to the timestamp of the current video frame, output the calculated frame rate value, and end the calculation process. The third anomaly detection module is configured to: if the current video frame sequence number is greater than the previous video frame sequence number, and the current video frame timestamp is less than or equal to the last calculated video frame timestamp, set the last calculated video frame timestamp to the current video frame timestamp, output the last calculated frame rate value, and end the calculation process. The fourth anomaly detection module is configured to: if the current video frame timestamp is greater than the last calculated video frame timestamp, and the difference between the current video frame timestamp and the last calculated video frame timestamp is less than or equal to the second set time threshold, set the last calculated video frame timestamp to the current video frame timestamp, output the last calculated frame rate value, and end the calculation process. The fifth anomaly detection module is configured to: when the difference between the current video frame timestamp and the last calculated video frame timestamp is greater than the second set time threshold, and no video frame is received within the time interval between the current video frame timestamp and the last calculated video frame timestamp, directly output the final frame rate value of 1, reset the last calculated video frame timestamp to the current video frame timestamp, and end the calculation process. The compensation calculation module is configured to: when a video frame is received within the time interval between the current video frame timestamp and the last calculated video frame timestamp, calculate the frame rate value with a decimal part; when the rounded value is not 0, perform compensation calculation on the frame rate value with a decimal part; after updating the two compensation status variables, output the final frame rate value after compensation calculation and rounding. The frame rate value, with a decimal part, is calculated as the ratio of the number of video frames received between the current timestamp and the last calculated timestamp to the time interval between the current timestamp and the last calculated timestamp. The frame rate value after compensation calculation is the sum of the frame rate value before compensation calculation and the compensation coefficient, where the compensation coefficient is the ratio of the compensation amount to the rounded value. The updated rounded value is the integer value of the frame rate after compensation calculation; The updated compensation amount is the difference between the frame rate value after compensation calculation and the rounded frame rate value after compensation calculation.
3. A computer-readable storage medium having a program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps in the video frame rate statistics method as described in claim 1.
4. An electronic device comprising a memory, a processor, and a program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps in the video frame rate statistics method as described in claim 1.
Citation Information
Patent Citations
Method and device for calculating video frame rate
CN109413371A
Timestamp correction method and device and storage medium
CN115842923A