Image coding control method, device, equipment and storage medium
By calculating the average network delay during the image encoding process and determining the number of dropped frames based on the difference, the problem of extended image encoding time and waste of CPU resources is solved, and the effects of shortening the encoding delay and reducing network pressure are achieved.
Patent Information
- Application Number
- CN202010771812.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-04
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2040-08-04
AI Technical Summary
During the image encoding process, the image encoding delay is long, resulting in a waste of CPU resources and network pressure, and increasing the delay of image transmission.
After the current frame image transmission is completed, the average network delay within the preset time period is calculated to determine whether it is greater than the preset threshold. If it is greater, the number of lost frames is determined based on the difference between the average network delay and the preset threshold. And discard the continuous image frames that have not started encoding.
By determining the number of dropped frames before encoding, network pressure is relieved, image encoding delay is shortened, CPU load is reduced, and video playback freezes are avoided.
Smart Images

Figure CN112087627B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to an image encoding control method, device, equipment and storage medium. Background Art
[0002] At present, in the process of encoding and decoding graphics images, images are usually collected at a fixed frame rate, and after the collected images are encoded, they are stored in the cache waiting for transmission. During the transmission process, it is determined whether the encoded images in the cache need to be discarded based on the network delay.
[0003] For all images, since it is determined whether to discard them after encoding is completed, the image encoding delay is increased and the encoding resources of the CPU (Central Processing Unit) are wasted. Summary of the invention
[0004] The embodiments of the present application provide an image coding control method, device, equipment and storage medium, which can solve the problem of long image coding delay. The technical solution is as follows:
[0005] According to a first aspect of an embodiment of the present application, a method for controlling encoding of an image is provided, the method comprising:
[0006] After the current frame image is transmitted, the average network delay of all images transmitted within a preset time period is calculated, where the preset time period is the time interval between the current time point and a target time point before the current time point;
[0007] Determine whether the average network delay is greater than a preset threshold;
[0008] When the average network delay value is greater than the preset threshold, the number of lost frames M is determined according to a preset rule, where M is an integer;
[0009] The continuous M frames of images that have not yet started to be encoded are discarded.
[0010] In one embodiment, determining the number of lost frames M according to a preset rule includes:
[0011] The number of lost frames M is determined according to the difference between the average network delay value and the preset threshold.
[0012] In one embodiment, determining the number of lost frames M according to the difference between the average value of the network delay and the preset threshold value includes:
[0013] The number of lost frames M is determined according to a first formula, wherein the first formula is: M=[(T 平均 -A) / (t 采集 +t 编码)];
[0014] Among them, the T 平均 is the average network delay, A is the preset threshold, and t 采集 is the average time required to collect one frame of image, t 编码 The average time required to encode a frame of image.
[0015] In one embodiment, determining the number of lost frames M according to the difference between the average value of the network delay and the preset threshold value includes:
[0016] The number of lost frames M is determined according to a second formula, where the second formula is:
[0017] M=[(T 平均 -A) / (t 采集 +t 编码 )]+1;
[0018] Among them, the T 平均 is the average network delay, A is the preset threshold, and t 采集 is the average time required to collect one frame of image, t 编码 The average time required to encode a frame of image.
[0019] In one embodiment, when it is determined that the average network delay is greater than the preset threshold, the method further includes:
[0020] Update the time value of the target time point to the time value of the current time point.
[0021] The image encoding control method provided by the embodiment of the present application calculates the average network delay of all images transmitted within a preset time period after the current frame image is transmitted, determines whether the average network delay is greater than a preset threshold, and when the average network delay is greater than the preset threshold, determines the number of lost frames M according to a preset rule, and then discards the M consecutive frames of images that are not currently encoded. The number of lost frames can be determined once each frame of the image is transmitted, and the number of lost frames can be determined before the image is encoded and the corresponding number of images can be discarded before encoding, thereby alleviating network pressure, shortening image encoding delay, and reducing the encoding load of the CPU.
[0022] According to a second aspect of an embodiment of the present application, there is provided an image encoding control device, including:
[0023] A calculation module, used to calculate the average network delay of all images transmitted within a preset time period after the current frame image is transmitted, where the preset time period is the time interval between the current time point and a target time point before the current time point;
[0024] A determination module, configured to determine whether the average network delay is greater than a preset threshold value, and when the average network delay is greater than the preset threshold value, determine the number of lost frames M according to a preset rule, where M is an integer;
[0025] The frame discarding module is used to discard the continuous M frames of images that have not yet started to be encoded.
[0026] In one embodiment, the determination module is specifically configured to determine the number of lost frames M according to a difference between the average network delay value and the preset threshold.
[0027] In one embodiment, the apparatus further comprises:
[0028] The updating module is used to update the time value of the target time point to the time value of the current time point when it is determined that the average network delay is greater than the preset threshold.
[0029] The image encoding control device provided by the embodiment of the present application calculates the average network delay of all images transmitted within a preset time period after the current frame image is transmitted through a calculation module; the determination module determines whether the average network delay is greater than a preset threshold value, and when the average network delay is greater than the preset threshold value, determines the number of lost frames M according to a preset rule; and the frame discarding module discards the M consecutive frames of images that have not yet started to be encoded. The number of lost frames can be determined once after each frame of the image is transmitted, and the number of lost frames can be determined before the image is encoded and the corresponding number of images can be discarded before encoding, thereby alleviating network pressure, shortening image encoding delay, and reducing the encoding load of the CPU.
[0030] According to a third aspect of an embodiment of the present application, a device for controlling an encoding of an image is provided, the device comprising a processor and a memory, the memory storing at least one computer instruction, the instruction being loaded and executed by the processor to implement the steps performed in the method for controlling an encoding of an image as described above.
[0031] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, wherein at least one computer instruction is stored in the storage medium, and the instruction is loaded and executed by a processor to implement the steps performed in the image encoding control method as described above.
[0032] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0034] Figure 1 is a flow chart of an image encoding control method provided by an embodiment of the present application;
[0035] Figure 2 is a flowchart of a specific image encoding control method provided in an embodiment of the present application;
[0036] Figure 3 This is a schematic diagram of calculating the average network delay of all images transmitted between a target time point and a current time point provided by an embodiment of the present application;
[0037] Figure 4 It is a structural schematic diagram of an image encoding control device provided in an embodiment of the present application;
[0038] Figure 5 is a structural schematic diagram of another image encoding control device provided in an embodiment of the present application;
[0039] Figure 6 It is a structural diagram of an image encoding control device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0040] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0041] The present application embodiment provides a method for controlling image encoding, such as Figure 1 As shown, the image encoding control method includes the following steps:
[0042] Step 101: Calculate the average network delay of all images transmitted within a preset time period.
[0043] During the encoding and transmission of an image, after the current frame image is transmitted, the average network delay of all images transmitted within a preset time period is calculated. The preset time period is the time interval between the current time point and the target time point before the current time point, wherein the target time point is a time point before the current time point. In one embodiment, the target time point refers to the time node when the network delay average value was calculated last time and a frame loss process was performed based on the calculation result.
[0044] Specifically, the network delay of a frame of image is equal to the difference between the timestamp of the image received by the receiving end and the timestamp of the image sent by the sending end. The network delay of each frame of image transmitted within a preset time period can be counted, and then the average network delay is calculated based on the statistically obtained network delay.
[0045] Step 102: Determine whether the average network delay value is greater than a preset threshold.
[0046] After calculating the average network delay of all images transmitted within the preset time period, it is determined whether the average network delay is greater than a preset threshold. If so, step 103 is executed, otherwise, the process goes to step 101 to continue statistical calculation.
[0047] Step 103: Determine the number of lost frames M according to a preset rule.
[0048] When the average network delay of all images transmitted within a preset time period is greater than a preset threshold, the number of lost frames M is determined according to a preset rule, where M is an integer. For example, the number of lost frames M can be determined according to the difference between the average network delay and the preset threshold. In one embodiment, the number of lost frames M can be obtained by using the difference and the ratio of the average time required to capture one frame of image to the sum of the average time required to encode one frame of image.
[0049] Step 104: discard the M consecutive image frames that have not yet started to be encoded.
[0050] After determining the number of lost frames M, the M consecutive frames of images that have not yet started to be encoded are directly discarded, and then the process goes to step 101 to continue calculating the average value of the network delay. In this step, the images that have already started to be transmitted or encoded will not be discarded, and subsequent processing will still be performed normally. Only the M consecutive frames of images that have not yet started to be encoded are discarded.
[0051] The image encoding control method provided by the embodiment of the present application calculates the average network delay of all images transmitted within a preset time period after the current frame image is transmitted, determines whether the average network delay is greater than a preset threshold, and when the average network delay is greater than the preset threshold, determines the number of lost frames M according to a preset rule, and then discards the M consecutive frames of images that have not yet started encoding. The number of lost frames can be determined once each frame of the image is transmitted, and the number of lost frames can be determined before the image is encoded and the corresponding number of images can be discarded before encoding, thereby alleviating network pressure, shortening image encoding delay, reducing CPU encoding load, and avoiding freezes when users watch videos.
[0052] Based on the above Figure 1Corresponding to the image encoding control method provided in the embodiment, another embodiment of the present application provides a specific image encoding control method, which can be applied to a video image encoding terminal device, for example, the video image encoding terminal device can be a terminal device or a network server, etc. Figure 2 As shown, the image encoding control method provided by this embodiment may include the following steps:
[0053] Step 201: Calculate the average network delay of all images transmitted within a preset time period.
[0054] During the encoding and transmission of an image, after the current frame image is transmitted, the average network delay of all images transmitted within a preset time period is calculated, where the preset time period is the time interval between the current time point and a target time point before the current time point.
[0055] The target time point is a time point before the current time point. In one embodiment, the target time point may refer to the time point when the network delay average value calculation was performed last time and a frame loss process was performed based on the calculation result.
[0056] Reference Figure 3 , is a schematic diagram of calculating the average network delay of all images transmitted between the target time point and the current time point. Figure 3 In the figure, time point t0 is the target time point. After the marked target time point t0, image frames A1, A2, A3, and so on are transmitted in sequence. For example, the current transmission has completed image frame A1. After the transmission of image frame A1 is completed, the average network delay of all images transmitted between the current time point t1 and the target time point t0 can be calculated, that is, the network delay of image frame A1 transmission is calculated. For another example, assuming that the current transmission has completed image frame A3, after the transmission of image frame A3 is completed, the average network delay of all images transmitted between the current time point t2 and the target time point t0 is calculated, that is, the average network delay of image frames A1, image frames A2, and image frames A3 is calculated.
[0057] Specifically, the network delay of a frame of image is equal to the difference between the timestamp of the image received by the receiving end and the timestamp of the image sent by the sending end. For example, if N frames of image are transmitted continuously within a preset time period, the network delay of each frame of image can be obtained by counting, and then the average network delay T of these N frames of image can be calculated using the following calculation formula: 平均 :
[0058]
[0059] in, is the network delay of the x-th frame image, x is an integer greater than 0 and less than or equal to N, Among them, Rtx Indicates the timestamp of the x-th frame image transmitted to the receiving end, St x Indicates the timestamp when the x-th frame of image is sent from the sender. In this way, the average network delay of all images transmitted within the preset time period can be obtained.
[0060] Step 202: Determine whether the average network delay value is greater than a preset threshold.
[0061] After calculating the average network delay of all images transmitted within the preset time period, determine whether the average network delay is greater than a preset threshold. If so, execute steps 203 and 205 respectively; otherwise, go to step 101 to continue statistical calculation.
[0062] In this step, the calculated average value of the network delay is compared with a preset threshold, where the preset threshold is a preset value that can be set based on experience in actual applications, such as 100ms, 90ms, 80ms, etc., or other values. The higher the preset threshold is set, the higher the tolerance for delay is, so the setting of the preset threshold can be determined according to the usage scenario.
[0063] In one embodiment, a preset threshold setting function may be provided, which may be implemented by the following method: detecting a setting operation for setting the preset threshold; and determining the preset threshold according to the setting operation. For example, a setting interface for setting the preset threshold may be provided to the user, and the user may input the preset threshold according to the interface prompt, such as setting it to 100ms, 90ms, 80ms, etc.; or, the preset threshold may be set by using a shortcut key for the preset threshold.
[0064] Step 203: Determine the number of lost frames M according to the difference between the average network delay value and a preset threshold.
[0065] Assume that the calculated average network delay is T 平均 , then the number of lost frames M can be calculated by the following first formula or the following second formula.
[0066] The first formula is: M = [(T 平均 -A) / (t 采集 +t 编码 )];
[0067] The second formula is: M = [(T 平均 -A) / (t 采集 +t 编码 )]+1;
[0068] In the above formula, T 平均represents the average value of network delay, A represents the preset threshold, t 采集 is the average time required to collect one frame of image, t 编码 is the average time required to encode a frame of image, t 采集 and t 编码 All of them can be set according to the empirical value. The symbol [] indicates the rounding symbol, that is, [(T 平均 -A) / (t 采集 +t 编码 )] is equal to (T 平均 -A) / (t 采集 +t 编码 ) is the integer part of the result.
[0069] Step 204: discard the M consecutive image frames that have not yet started to be encoded.
[0070] After determining the number of lost frames M, the continuous M frames of images that are not currently encoded are directly discarded, and then the process goes to step 101 to continue counting the network delay.
[0071] In this step, the continuous M frames of images that have not yet started to be encoded are directly discarded. At the same time, the images that have already started to be transmitted or encoded will not be discarded and will still be processed normally. The discarded images are the continuous M frames of images that have not yet started to be encoded.
[0072] Step 205: Update the time value of the target time point to the time value of the current time point.
[0073] When it is determined that the average value of the network delay is greater than the preset threshold, the time value of the target time point is updated to the time value of the current time point, that is, the current time point is used as the new target time point.
[0074] In the embodiment of the present application, the target time point will be continuously updated and adjusted. Figure 3 For example, assuming that the calculated average network delay is greater than the preset threshold value during the preset time period from the target time point t0 to the current time point t2, the number of lost frames M is determined based on the difference between the average network delay and the preset threshold value, and the continuous M frames of images that have not yet started to be encoded are discarded. At the same time, the target time point is adjusted to t2, that is, starting from time point t2, the average network delay is recalculated, and whether frame loss is needed is determined based on the calculation result.
[0075] The image encoding control method provided by the embodiment of the present application, during the image encoding transmission process, after the current frame image transmission is completed, the average network delay of all images transmitted within the preset time period is calculated. When the average value is greater than the preset threshold, on the one hand, the number of lost frames M is determined according to the difference between the average value of the network delay and the preset threshold, and the continuous M frames of images that have not yet started encoding are discarded. On the other hand, the time value of the target time point is updated to the time value of the current time point, and the target time point is continuously updated and adjusted. The number of lost frames can be determined before encoding and the corresponding number of images can be discarded before encoding, thereby alleviating network pressure, shortening image encoding delay, avoiding the freeze phenomenon that occurs when users watch videos, and reducing the encoding load of the CPU.
[0076] Based on the above Figure 1 and Figure 2 The image encoding control method described in the corresponding embodiment is as follows: an embodiment of the device of the present application, which can be used to execute the method embodiment of the present application.
[0077] The present application embodiment provides an image encoding control device, such as Figure 4 As shown, the image encoding control device 40 includes: a calculation module 401, a determination module 402 and a frame discarding module 403;
[0078] The calculation module 401 is used to calculate the average network delay of all images transmitted within a preset time period after the current frame image is transmitted, wherein the preset time period is the time interval between the current time point and the target time point before the current time point;
[0079] The determination module 402 is used to determine whether the average network delay obtained by the calculation module 401 is greater than a preset threshold value. When the average network delay is greater than the preset threshold value, the number of lost frames M is determined according to a preset rule, where M is an integer;
[0080] The frame discarding module 403 is used to discard the continuous M frames of images that have not yet started to be encoded.
[0081] In one embodiment, the determination module 402 is specifically configured to determine the number of lost frames M according to a difference between an average value of the network delay and a preset threshold.
[0082] In one embodiment, the determination module 402 is specifically configured to determine the number of lost frames M according to a first formula, wherein the first formula is: M=[(T 平均 -A) / (t 采集 +t 编码 )];
[0083] Among them, T 平均 is the average network delay, A is the preset threshold, t 采集is the average time required to collect one frame of image, t 编码 The average time required to encode a frame of image.
[0084] In one embodiment, the determination module 402 is specifically configured to determine the number of lost frames M according to a second formula, wherein the second formula is:
[0085] M=[(T 平均 -A) / (t 采集 +t 编码 )]+1;
[0086] Among them, T 平均 is the average network delay, A is the preset threshold, t 采集 is the average time required to collect one frame of image, t 编码 The average time required to encode a frame of image.
[0087] In one embodiment, Figure 5 As shown, the image encoding control device 40 further includes an updating module 404, which is used to update the time value of the target time point to the time value of the current time point when the determining module 402 determines that the network delay average value reaches the preset threshold.
[0088] The image encoding control device provided by the embodiment of the present application calculates the average network delay of all images transmitted within a preset time period after the current frame image is transmitted through a calculation module; the determination module determines whether the average network delay is greater than a preset threshold value, and when the average network delay is greater than the preset threshold value, determines the number of lost frames M according to a preset rule; and the frame discarding module discards the M consecutive frames of images that have not yet started encoding. The number of lost frames can be determined once after each frame of the image is transmitted, and the number of lost frames can be determined before the image is encoded and the corresponding number of images can be discarded before encoding, thereby alleviating network pressure, shortening image encoding delay, avoiding the freeze phenomenon that occurs when users watch videos, and reducing the encoding load of the CPU.
[0089] refer to Figure 6 As shown, the embodiment of the present application further provides an image encoding control device 60, the image encoding control device comprises a processor 601 and a memory 602, wherein the memory 602 stores at least one computer instruction, the computer instruction is loaded and executed by the processor 601 to implement the above Figure 1 or Figure 2 The image encoding control method described in the corresponding embodiment.
[0090] Based on the above Figure 1 and Figure 2In accordance with the image encoding control method described in the corresponding embodiment, the present application embodiment also provides a computer-readable storage medium, for example, the non-temporary computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device. The storage medium stores computer instructions for executing the above Figure 1 and Figure 2 The image encoding control method described in the corresponding embodiment will not be repeated here.
[0091] Those skilled in the art will readily appreciate other embodiments of the present application after considering the description and practicing the contents disclosed herein. The present application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The description and embodiments are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the appended claims.
[0092] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for controlling image encoding, characterized in that: The method comprises: After the current frame image is transmitted, the average network delay of all images transmitted within a preset time period is calculated, where the preset time period is the time interval between the current time point and a target time point before the current time point, and the target time point refers to the time node when the network delay average value calculation was performed last time and a frame loss process was performed based on the calculation result; Determine whether the average network delay is greater than a preset threshold; When the average network delay value is greater than the preset threshold, the number of lost frames M is determined according to a preset rule, where M is an integer; Discard the M consecutive frames of images that have not yet started to be encoded; Determining the number of lost frames M according to a preset rule includes: The number of lost frames M is determined according to the difference between the average network delay value and the preset threshold.
2. The method according to claim 1, characterized in that: The determining the number of lost frames M according to the difference between the average network delay value and the preset threshold value comprises: The number of lost frames M is determined according to a first formula, wherein the first formula is: M=[(T 平均 -A) / (t 采集 +t 编码 )]; Among them, the T 平均 is the average network delay, A is the preset threshold, and t 采集 is the average time required to collect one frame of image, t 编码 The average time required to encode a frame of image.
3. The method according to claim 1, characterized in that: The determining the number of lost frames M according to the difference between the average network delay value and the preset threshold value comprises: The number of lost frames M is determined according to a second formula, where the second formula is: M=[(T 平均 -A) / (t 采集 +t 编码 )]+1; Among them, the T 平均 is the average network delay, A is the preset threshold, and t 采集 is the average time required to collect one frame of image, t 编码 The average time required to encode a frame of image.
4. The method according to claim 1, characterized in that: When it is determined that the average network delay is greater than the preset threshold, the method further includes: Update the time value of the target time point to the time value of the current time point.
5. An image encoding control device, characterized in that: The device comprises: A calculation module, used to calculate the average network delay of all images transmitted within a preset time period after the current frame image is transmitted, wherein the preset time period is the time interval between the current time point and a target time point before the current time point, and the target time point refers to the time node when the network delay average value calculation was performed last time and a frame loss process was performed based on the calculation result; A determination module, configured to determine whether the average network delay is greater than a preset threshold value, and when the average network delay is greater than the preset threshold value, determine the number of lost frames M according to a preset rule, where M is an integer; A frame discarding module is used to discard the M consecutive frames of images that have not yet started to be encoded; The determination module is specifically configured to determine the number of lost frames M according to a difference between the average network delay value and the preset threshold.
6. The device according to claim 5, characterized in that Also includes: The updating module is used to update the time value of the target time point to the time value of the current time point when it is determined that the average network delay is greater than the preset threshold.
7. An image encoding control device, characterized in that: The image encoding control device includes a processor and a memory, wherein the memory stores at least one computer instruction, and the instruction is loaded and executed by the processor to implement the steps performed in the image encoding control method according to any one of claims 1 to 4.
8. A computer-readable storage medium, characterized in that: The storage medium stores at least one computer instruction, which is loaded and executed by the processor to implement the steps performed in the image encoding control method according to any one of claims 1 to 4.
