A video encoding control method, device and electronic equipment
By subdividing video images into regions and using differentiated coding parameters, the problem of unstable image quality in existing technologies is solved, and the stability of the buffer and the uniformity of image quality are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- LENOVO (BEIJING) LTD
- Filing Date
- 2023-03-31
- Publication Date
- 2026-04-10
AI Technical Summary
In existing technologies, the bitrate control of video encoders is adjusted based on image groups or images, which leads to unstable image quality under various display formats and cannot effectively smooth the bitstream fluctuations generated during the encoding process.
By subdividing each frame of an image into multiple target regions and using different encoding parameters for encoding, the number of encoded bits for different target regions is different, thereby achieving bit rate control and avoiding buffer overflow or underflow.
It achieves image quality stability under different display formats, avoids buffer overflow or insufficiency, and ensures data stream stability.
Smart Images

Figure CN116366850B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of information technology, and more particularly, to a video encoding control method and device and electronic equipment. BACKGROUND
[0002] In the process of video transmission, the video needs to be transmitted through a limited bandwidth transmission channel. The encoder may generate a variable bit stream when encoding a video sequence. Therefore, a video buffer is arranged between the encoder and the channel to smooth the bit stream fluctuation generated in the encoding process, and the encoder needs to output a stable encoding rate to the buffer to avoid buffer overflow or underflow.
[0003] In the prior art, the rate control of the encoder is based on the group of pictures or the image, but the granularity of the adjustment is large, and the image quality of various display formats cannot be guaranteed to be stable. SUMMARY
[0004] Therefore, the present application provides a video encoding control method and device as follows.
[0005] A video encoding control method comprises the following steps:
[0006] Obtaining a target stream media;
[0007] Encoding each frame of image in the image sequence based on the image sequence of the target stream media, wherein the target stream media meets a target display parameter;
[0008] At least one frame of image is encoded into different target regions, and the number of encoded bits of the at least one frame of image is different.
[0009] Optionally, the method described above, wherein the encoding each frame of image in the image sequence comprises:
[0010] Dividing each frame of image into at least two target regions based on a target number of preset encoding units;
[0011] Encoding the at least two target regions respectively;
[0012] The number of target regions of each frame of image in the image sequence of the stream media is the same.
[0013] Optionally, the method described above, wherein the encoding the at least two target regions respectively comprises:
[0014] Determining a compression factor of the i-th target region of the N-th frame of image based on the number of encoded bits of the i-th target region of the N-1-th frame of image, wherein N is an integer greater than 1, and i is a positive integer;
[0015] The compression factor of the i-th target region of the N-th frame image is encoded for the i-th target region of the N-th frame image to obtain the number of encoded bits of the i-th target region of the N-th frame image.
[0016] Optionally, the method, the number of encoded bits of the i-th target region of the N-th frame image is determined based on the number of encoded bits of the i-th target region of the N-1-th frame image, and the compression factor of the i-th target region of the N-th frame image is determined by:
[0017] If the number of encoded bits of the i-th target region of the N-1-th frame image is greater than the target number of bits, the compression factor of the i-th target region of the N-1-th frame image is increased by a target value to obtain the compression factor of the i-th target region of the N-th frame image;
[0018] If the number of encoded bits of the i-th target region of the N-1-th frame image is less than the target number of bits, the compression factor of the i-th target region of the N-1-th frame image is decreased by a target value to obtain the compression factor of the i-th target region of the N-th frame image;
[0019] If the number of encoded bits of the i-th target region of the N-1-th frame image is equal to the target number of bits, the compression factor of the i-th target region of the N-1-th frame image is determined as the compression factor of the i-th target region of the N-th frame image;
[0020] The value of the compression factor is inversely related to the number of encoded bits, and the number of encoded bits is positively related to the clarity after encoding.
[0021] Optionally, the method, the target number of bits of the i-th target region of the N-1-th frame image is a predicted value, and the method further comprises:
[0022] The target number of bits is predicted.
[0023] Optionally, the method, the target number of bits is predicted by:
[0024] A basic number of bits of each target region is determined based on a target code rate, a target frame rate, and the number of target regions in each frame image, and the target code rate is related to a transmission channel for transmitting the encoded target stream media.
[0025] Optionally, the method,
[0026] If the current frame is the first frame image, the target number of bits of the i-th target region of the first frame image is the basic number of bits.
[0027] If the current frame is the Nth frame image, the target bit number of the i-th target region of the Nth frame image comprises the sum of the target bit number of the i-th target region of the N-1th frame and the difference between the encoding bit number of the i-th target region of the N-1th frame and the base bit number.
[0028] Optionally, the method described above,
[0029] If the current frame is the Nth frame image, the target bit number of the i-th target region of the Nth frame image is determined according to the proportion of the complexity of the i-th target region of the N-1th frame to the complexity of the N-1th frame.
[0030] A video encoding control device comprises:
[0031] An obtaining module is configured to obtain a target stream media;
[0032] An encoding module is configured to encode each frame image in an image sequence of the target stream media based on the image sequence, wherein the target stream media satisfies a target display parameter.
[0033] At least one frame image has different encoding bit numbers after being encoded for different target regions.
[0034] An electronic device comprises an encoder and a buffer.
[0035] The encoder is configured to encode each frame image in an image sequence of a target stream media based on the image sequence, wherein the target stream media satisfies a target display parameter.
[0036] The buffer is configured to buffer data encoded by the encoder and then output the data through a transmission channel.
[0037] The encoder is configured to make at least one frame image have different encoding bit numbers after being encoded for different target regions based on the buffering result of the buffer.
[0038] The encoder is integrated in a processor of the electronic device, the buffer is part of a storage space in a memory of the electronic device, or the encoder and the buffer are integrated in a preset functional chip. BRIEF DESCRIPTION OF DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiment description. Obviously, the drawings in the following description are only embodiments of the present application, and those skilled in the art can obtain other drawings according to the provided drawings without any creative effort.
[0040] Figure 1is a flow chart of a video coding control method embodiment 1 provided by the present application;
[0041] Figure 2 is a structural schematic diagram of an electronic device in the video coding control method embodiment 1 provided by the present application;
[0042] Figure 3 is a flow chart of a video coding control method embodiment 2 provided by the present application;
[0043] Figure 4 is a target region schematic diagram of a frame image in the video coding control method embodiment 2 provided by the present application;
[0044] Figure 5 is a flow chart of a video coding control method embodiment 3 provided by the present application;
[0045] Figure 6 is a coding schematic diagram of a streaming media in the video coding control method embodiment 3 provided by the present application;
[0046] Figure 7 is a flow chart of a video coding control method embodiment 4 provided by the present application;
[0047] Figure 8 is a flow chart of a video coding control method embodiment 5 provided by the present application;
[0048] Figure 9 is a structural schematic diagram of a video coding control device embodiment provided by the present application. DETAILED DESCRIPTION
[0049] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0050] As shown in Figure 1 is a flow chart of a video coding control method embodiment 1 provided by the present application, which is applied to an electronic device. The method comprises the following steps:
[0051] Step S101: obtaining a target streaming media;
[0052] The electronic device to which the embodiment is applied can be an electronic device serving as a streaming media provider.
[0053] The target stream media is transmitted to other electronic devices through a transmission channel after being encoded in the electronic device.
[0054] Step S102: encoding each frame of image in the image sequence based on the target stream media, the target stream media meeting a target display parameter; wherein the encoding bit number of at least one frame of image after encoding for different target regions is different.
[0055] The target stream media is transmitted to other electronic devices through a transmission channel after being encoded in the electronic device.
[0056] Specifically, the target display parameter can be a preset resolution threshold.
[0057] For example, the target display parameter can be a resolution of 1080P, of course, the selection of the target display parameter is not limited thereto, and the value of the target display parameter can be set according to actual conditions in specific implementation.
[0058] The image is divided into a plurality of target regions, and different encoding parameters can be used for different target regions to achieve different encoding bit numbers of different target regions after encoding.
[0059] The bit number is the network bandwidth occupied by the encoded data corresponding to the target region, the larger the bit number, the more network bandwidth required for transmitting the encoded data; the smaller the bit number, the less network bandwidth required for transmitting the encoded data.
[0060] Specifically, in the present scheme, different encoding parameters are used for different encoding regions of an image, so that the encoding bit numbers of different target regions in the image after encoding are different, and the code rate control of different target regions is different, so that the quality of the encoded image can be ensured to be stable.
[0061] It should be noted that, due to the different encoding bit numbers of different target regions of a frame of image after encoding in the present scheme, the bit numbers of the data obtained after encoding of different regions are different.
[0062] If the target stream media does not meet the target display parameter, the same encoding parameter can be used for encoding of a frame of image, and the bit numbers of the data obtained after encoding of any target region are the same.
[0063] In the present application, the encoding parameter adjustment for image encoding is specifically parameter adjustment using a VBR (Variable Bit Rate, dynamic bit rate) encoding method.
[0064] For example,Figure 2 As shown in the structural schematic diagram of the electronic device, it comprises an encoder 201 and a buffer 202; wherein, after the stream media input encoder is encoded, the encoded data enters the buffer 202 to smooth the bit stream fluctuation generated in the encoding process, and is sent to other devices through a transmission channel. Wherein, the encoder realizes the code rate control based on the feedback of the buffer, to avoid the overflow or underflow of the buffer.
[0065] In the embodiment, the different target regions of each frame of image are encoded, and the number of encoded bits after encoding is different, so that the data stream entering the buffer is stable.
[0066] It should be noted that the encoding process of different target regions of each frame of image in the image sequence will be described in detail in subsequent embodiments, and will not be described in detail in this embodiment.
[0067] In summary, the video encoding control method provided in the embodiment comprises: obtaining a target stream media; encoding each frame of image in an image sequence based on the image sequence of the target stream media, wherein the target stream media satisfies a target display parameter; and the number of encoded bits after encoding different target regions of at least one frame of image is different. In the embodiment, based on the target stream media satisfying the target display parameter, each frame of image in the image sequence of the target stream media is encoded, wherein the number of encoded bits after encoding different target regions of at least one frame of image is different. Different encoding parameters are used to encode different target regions of a certain frame of image in the target stream media, so that the number of data bits after encoding different regions is different, the data stream entering the buffer is stable, and the overflow or underflow of the buffer is avoided.
[0068] As Figure 3 As shown in the flowchart of the video encoding control method embodiment 2 provided in the application, the method comprises the following steps:
[0069] Step S301: obtaining a target stream media;
[0070] Wherein, step S301 is consistent with the corresponding step in embodiment 1, and will not be described in detail in this embodiment.
[0071] Step S302: based on the image sequence of the target stream media, each frame of image is divided into at least two target regions based on the preset encoding unit of the target quantity;
[0072] Wherein, the preset encoding unit is the smallest encoding unit in a frame of image, such as a macroblock.
[0073] Specifically, a macroblock is composed of a 16x16 pixel matrix.
[0074] The target number of preset coding units is divided into a target region.
[0075] The target region can be expressed in a group of macroblocks (GOM).
[0076] Each target region contains preset coding units in whole units, and the sizes of the target regions except the last target region are equal.
[0077] The number of preset coding units contained in each target region is A, and the number of preset coding units in each frame of image is B. The number of divided target regions is as follows:
[0078] B / A=C
[0079] If C is an integer, a frame of image is divided into C target regions with equal sizes.
[0080] If C is a non-integer, there is a remainder D, and a frame of image is divided into C+1 target regions, wherein the first C target regions have equal sizes, and the C+1th target region is composed of the remaining coding units.
[0081] The selection condition of the number of preset coding units contained in each target region can be set according to actual conditions.
[0082] Specifically, an upper threshold value (H) and a lower threshold value (L) can be set, and a formula for calculating the number of preset coding units (A) contained in each target region is as follows:
[0083] A=H-round((H-L)*ratio)
[0084] Wherein, round represents rounding, and ratio is a configurable factor.
[0085] Specifically, different upper and lower threshold values can be set for different target display parameters, and the value of the configurable factor can be set according to actual conditions, which is irrelevant to the target display parameters.
[0086] For example, in a 1080P streaming media, the threshold values H and L are set to 8 and 4 respectively, and the ratio is set to 90%. The number of preset coding units contained in each target region is as follows:
[0087] A=8-round((8-4)*0.9)=4
[0088] It should be noted that the number of preset coding units contained in each target region in each frame of image is as follows:
[0089] S=A*D
[0090] Wherein, S is the preset encoding number contained by each target region, A is the preset encoding unit row number contained by each target region, and D is the preset encoding unit number contained by each row in the image.
[0091] Wherein, the D = the pixel number of each row in the image / 16
[0092] For example, in the 1080P stream media, the pixel number contained by each row in each image is 1080, in order to ensure the integrity of the macro block, in the embodiment, 8 filling pixels are supplemented to adopt 1088 for calculation.
[0093] Wherein, the pixel value adopted by the filling pixel is transmitted to the opposite equipment together with the encoded data through the transmission channel, so that the opposite equipment performs filling pixel processing on the received data based on the pixel value to obtain the output data.
[0094] Specifically, in the 1080P stream media, the preset encoding unit number contained by each row in each image is as follows:
[0095] D = 1088 / 16 = 68
[0096] Correspondingly, in the 1080P stream media, the target region contained by each image is 4*68 macro blocks.
[0097] For example, the target stream media is 1080P video, then one image is 1920*1088 (row*column) pixels, the one image can be divided into 120*68 macro blocks, if the preset encoding unit contained by one target region is 6 rows (6*68), then one image is divided into 20 target regions; if the preset encoding unit contained by one target region is 7 rows (7*68), then one image is divided into 18 target regions, the preset encoding unit contained by the 1st-17th target region is 7 rows (7*68), and the preset encoding unit contained by the 18th target region is 1 row (1*68).
[0098] As shown in the left drawing of FIG. 4, one image in one stream media is shown, the image is composed of 6*3 macro blocks, one target region contains 2*3 macro blocks, and the one image is divided into 3 target regions. Figure 4 As shown in the right drawing of FIG. 4, one image in another stream media is shown, the image is composed of 7*3 macro blocks, one target region contains 2*3 macro blocks, and the one image is divided into 4 target regions, wherein, the upper 3 target regions respectively contain 2*3 macro blocks, and the 4th target region contains the remaining 1*3 macro blocks.
[0099] Step S303: encode the at least two target regions respectively.
[0100] The number of target regions in each frame image of the image sequence of the stream media is the same.
[0101] It should be noted that since the target display parameters of one stream media are unique, the number of pixels in each frame image of one stream media is the same, so the number of target regions divided for each frame image in the same stream media is the same, and the sizes of the corresponding target regions in each frame image are the same.
[0102] Different encoding parameters can be used to encode different target regions in one frame image, and the number of encoded bits after encoding is different.
[0103] It should be noted that when the data amount of each frame image in one stream media is different, if the same encoding parameter is used for each region of one frame image, the number of encoded bits after encoding of different frame data with different data amounts will fluctuate greatly. In the present scheme, since different encoding parameters are used for different target regions in one frame image, the number of encoded bits after final encoding of the target regions is different, which can ensure that the number of encoded bits of each frame image in one stream media maintains a small fluctuation.
[0104] In summary, the video encoding control method provided in the present embodiment includes: dividing each frame image into at least two target regions based on a preset encoding unit of a target number; encoding the at least two target regions respectively; and the number of target regions divided for each frame image in the image sequence of the stream media is the same. In the present embodiment, each frame image is divided into at least two target regions based on a preset encoding unit of a target number, the number of target regions divided for each frame image in the image sequence of the stream media is the same, and each target region in one frame image is encoded respectively, so that the number of encoded bits after final encoding of different target regions in one frame image is different, which can ensure that the number of encoded bits of each frame image in one stream media maintains a small fluctuation.
[0105] As shown in FIG. 3, a flowchart of a video encoding control method embodiment 3 provided by the present application includes the following steps: Figure 5
[0106] Step S501: obtain a target stream media;
[0107] Step S502: based on the image sequence of the target stream media, divide each frame image into at least two target regions based on a preset encoding unit of a target number;
[0108] Steps S501-502 are the same as the corresponding steps in embodiment 2, and will not be described herein.
[0109] Step S503: Based on the number of encoded bits of the i-th target region in the (N-1)-th frame image, determine the compression factor of the i-th target region in the N-th frame image;
[0110] Wherein, N is an integer greater than 1, and i is a positive integer.
[0111] The compression factor for a target region in a frame is determined based on the encoding result of the target region at the corresponding position in the previous frame.
[0112] Specifically, starting from the second frame, the compression factor of a target region in each frame is determined based on the encoding result of the target region at the corresponding position in the previous frame.
[0113] Specifically, the compression factor can be the compression parameter required to compress the data in the target area.
[0114] The specific process of determining the compression factor of the i-th target region in the N-th frame image will be described in detail in subsequent embodiments, but will not be described in detail in this embodiment.
[0115] like Figure 6 The diagram illustrates the encoding process for streaming media, using three consecutive frames as an example: frames N-1, N, and N+1. Each frame contains three target regions (GOMs), designated GOM0-2. After encoding and compressing the three GOMs of frame N-1, the compression factor for the corresponding three GOMs of frame N is determined based on the number of encoded bits. This compression factor is then used to encode the three GOMs of frame N, and the compression factor for the three GOMs of frame N+1 is determined based on the number of encoded bits. This process is repeated for each frame in the streaming media, thus achieving compression.
[0116] Step S504: Encode the i-th target region of the N-th frame image based on the compression factor of the i-th target region to obtain the number of encoded bits of the i-th target region of the N-th frame image.
[0117] Based on a determined compression factor, the corresponding target region is encoded to obtain the number of encoded bits for that target region.
[0118] It should be noted that the compression factor adopted by different target regions in a frame of image is determined based on the encoding bit number of the corresponding target region in the previous frame of image. Since the image content in different target regions is different, the encoding bit number after encoding of different target regions in the same frame of image is different, therefore, the determined compression factor can be different, and the encoding bit number obtained after encoding of different compression factors and different image content can also be different.
[0119] In summary, the video encoding control method provided in this embodiment comprises: determining a compression factor of an i-th target region of an N-th frame of image based on the encoding bit number of the i-th target region of an N-1-th frame of image, wherein N is an integer greater than 1, and i is a positive integer; encoding the i-th target region of the N-th frame of image based on the compression factor of the i-th target region of the N-th frame of image, to obtain the encoding bit number of the i-th target region of the N-th frame of image. In this embodiment, the encoding factor of the target region at the corresponding position in the next frame is determined in combination with the encoding result of the target region in the previous frame. The encoding bit number of different target regions is different, and accordingly, the encoding factor adopted by different target regions in the next frame is different, so that the encoding bit number of different regions in the frame of image is different.
[0120] As shown in Figure 7 , it is a flow chart of embodiment 4 of the video encoding control method provided in this application, which comprises the following steps:
[0121] Step S701: obtaining a target stream media;
[0122] Step S702: based on the image sequence of the target stream media, dividing each frame of image into at least two target regions based on a preset encoding unit of target quantity;
[0123] Among them, steps S701-702 are consistent with the corresponding steps in embodiment 3, which will not be described in detail in this embodiment.
[0124] Step S703: if the encoding bit number of the i-th target region of the N-1-th frame of image is greater than the target bit number, increasing the target value based on the compression factor of the i-th target region of the N-1-th frame of image, to obtain the compression factor of the i-th target region of the N-th frame of image;
[0125] Among them, the encoding bit number of the i-th target region in the N-1-th frame of image is compared with the target bit number, to obtain the comparison result as follows: the encoding bit number is greater than the target bit number, the encoding bit number is less than the target bit number, and the encoding bit number is equal to the target bit number.
[0126] Among them, the target bit number represents the transmission bandwidth allocated to the target region.
[0127] In a specific implementation, the target bit number can be a preset fixed value or a value estimated in combination with a transmission process.
[0128] The setting process of the target bit number will be described in detail in subsequent embodiments, and will not be described in detail in this embodiment.
[0129] Specifically, if the encoding bit number is greater than the target bit number, it indicates that the bandwidth required to transmit the i-th target region of the N-1 frame image exceeds the transmission bandwidth allocated to the target region by the transmission channel, and in order to ensure the stability of the buffer, the compression degree needs to be increased, and the compression factor of the i-th target region of the N-1 frame is increased to obtain the compression factor of the i-th target region of the N frame.
[0130] The value of the compression factor is inversely related to the encoding bit number, and the encoding bit number is positively related to the encoding clarity.
[0131] Specifically, the larger the compression factor, the greater the compression degree, the smaller the encoding bit number obtained by encoding, and correspondingly, the lower the encoding clarity; the smaller the compression factor, the smaller the compression degree, the greater the encoding bit number obtained by encoding, and correspondingly, the higher the encoding clarity.
[0132] Specifically, the compression factor can be a QP (Quantizer Parameter, quantization parameter), which reflects the spatial detail compression situation. The smaller the value, the finer the quantization, the higher the image quality, and the longer the code stream generated. For example, if QP is small, most details will be preserved; if QP is large, some details are lost, the code rate is reduced, but the image distortion is increased and the quality is decreased.
[0133] The compression factor is increased based on a preset target value.
[0134] In a specific implementation, the target value can be a small value, such as 1 or 2, and the application does not limit the value of the target value.
[0135] It should be noted that in order to ensure that the distortion rate of the encoded and compressed image is within an acceptable range, an upper limit of the compression factor can be preset.
[0136] In a specific implementation, if the compression factor of the i-th target region of the N-1 frame image is greater than the preset upper limit of the compression factor after being increased by the target value, the i-th target region of the N frame image is encoded using the upper limit value of the compression factor.
[0137] Step S704: If the encoding bit number of the i-th target region of the N-1 frame image is less than the target bit number, the compression factor of the i-th target region of the N-1 frame image is reduced by a target value to obtain the compression factor of the i-th target region of the N frame image.
[0138] Specifically, if the encoding bit number is less than the target bit number, it indicates that the bandwidth required for transmitting the i-th target region of the N-th frame image is less than the transmission bandwidth allocated to the target region by the transmission channel, in order to ensure the stability of the buffer, it is necessary to reduce the compression degree, and the compression factor of the i-th target region of the N-th frame image is obtained based on the reduction of the compression factor of the i-th target region of the N-th frame.
[0139] The compression factor is reduced based on a preset target value.
[0140] It should be noted that, in order to ensure the compression effect of the image, a lower limit of the compression factor can be preset.
[0141] In a specific implementation, if the compression factor reduction target value of the i-th target region of the N-th frame image is less than the preset lower limit of the compression factor, the i-th target region of the N-th frame image is encoded using the lower limit value of the compression factor.
[0142] Step S705: If the encoding bit number of the i-th target region of the N-th frame image is equal to the target bit number, the compression factor of the i-th target region of the N-th frame image is determined as the compression factor of the i-th target region of the N-th frame image.
[0143] Specifically, if the encoding bit number is equal to the target bit number, it indicates that the bandwidth required for transmitting the i-th target region of the N-th frame image is equal to the transmission bandwidth allocated to the target region by the transmission channel, in order to ensure the stability of the buffer, it is not necessary to adjust the compression degree, and the compression factor of the i-th target region of the N-th frame image is taken as the compression factor of the i-th target region of the N-th frame.
[0144] Step S706: The i-th target region of the N-th frame image is encoded based on the compression factor of the i-th target region of the N-th frame image, and the encoding bit number of the i-th target region of the N-th frame image is obtained.
[0145] Wherein, step S706 is consistent with the corresponding step in embodiment 3, and this embodiment will not be repeated.
[0146] In summary, the video encoding control method provided in the embodiment includes: since the target bit number represents the transmission channel bandwidth allocated for the i-th target region, based on the relationship between the encoding bit number of the i-th target region of the N-1th frame and the target bit number, it can be determined whether the encoding data of the i-th target region of the N-1th frame exceeds the transmission channel bandwidth allocated for the i-th target region. If the encoding bit number is greater than the target bit number, it is represented that it exceeds, and the compression factor is increased as the compression factor of the i-th target region of the Nth frame. If the encoding bit number is less than the target bit number, it is represented that it does not exceed, and the compression factor is reduced as the compression factor of the i-th target region of the Nth frame. If the encoding bit number is equal to the target bit number, it is represented that it is equal, and the compression factor is directly used as the compression factor of the i-th target region of the Nth frame. The relationship between the encoding bit number and the target bit number of the corresponding target region of the last frame is combined to determine the compression factor of the target region of the current frame.
[0147] As shown in Figure 8 FIG. 5 is a flowchart of an embodiment 5 of the video encoding control method provided in the application. The method includes the following steps:
[0148] Step S801: obtaining a target stream media;
[0149] Step S802: based on the image sequence of the target stream media, each frame of image is divided into at least two target regions based on the preset encoding unit of the target number;
[0150] In the embodiment, steps S801-802 are consistent with the corresponding steps in the embodiment 4, and will not be described herein.
[0151] Step S803: estimating a target bit number;
[0152] The target bit number compared with the encoding bit number of the i-th target region of the N-1th frame is not a fixed value, but is estimated.
[0153] Specifically, the target bit number is estimated by:
[0154] The basic bit number of each target region is determined based on the target code rate, the target frame rate, and the number of target regions in each frame of image. The target code rate is related to the transmission channel of the encoded target stream media.
[0155] The target code rate and the target frame rate are set for the target stream media.
[0156] The target code rate is related to the transmission channel width of the target stream media.
[0157] The target frame rate is the number of frames of the picture in the target stream media transmitted by the transmission channel in one second, which can be set by the user.
[0158] In a specific implementation, in order to ensure the output effect of the encoded target stream media, the target frame rate is not less than 20, such as 30 frames per second, 60 frames per second, etc. The application does not limit the value of the target frame rate.
[0159] The target bit number of each frame of image is calculated based on the target frame rate and the target code rate.
[0160] The target bit number of each target region of each frame of image is obtained by dividing the target bit number of each frame of image by the number of target regions in each frame of image.
[0161] The target bit number of each target region of each frame of image is obtained by dividing the target bit number of each frame of image by the number of target regions in each frame of image.
[0162] If the current frame is the first frame of image, the target bit number of the i-th target region of the first frame of image is the basic bit number.
[0163] If the current frame is the N-th frame of image, the target bit number of the i-th target region of the N-th frame of image includes the sum of the difference between the target bit number of the i-th target region of the N-1-th frame and the encoding bit number of the i-th target region of the N-1-th frame and the basic bit number.
[0164] If the current frame is the first frame of image, the preset initial compression factor is used as the compression factor in the first frame of image, and the i-th target region in the defined frame of image is encoded and compressed to obtain the encoding bit number of the i-th target region of the first frame.
[0165] If the current frame is the second frame of image, the encoding bit number of the i-th target region of the first frame is compared with the target bit number obtained based on the basic bit number to obtain a comparison result, and the comparison result is used to determine whether to adjust the initial compression factor to obtain the compression factor of the i-th target region in the second frame of image.
[0166] If the current frame is the N-th frame of image, the target bit number of the i-th target region of the N-th frame of image is the sum of the residual bandwidth of the N-1-th frame of image and the preset basic bit number.
[0167] The residual bandwidth of the N-1-th frame of image is the difference between the target bit number of the i-th target region of the N-1-th frame of image and the encoding bit number of the i-th target region of the N-1-th frame of image.
[0168] wherein the difference value can be any number, if the difference value is positive, it means that there is remaining bandwidth after transmitting the i-th target region of the N-1-th image, in order to ensure that the buffer does not overflow, the number of encoding bits of the i-th target region of the N-th image needs to be increased; if the difference value is zero, it means that the bandwidth required for transmitting the i-th target region of the N-1-th image is the same as the allocated bandwidth of the transmission channel, and there is no bandwidth remaining; if the difference value is negative, it means that the bandwidth required for transmitting the i-th target region of the N-1-th image exceeds the allocated bandwidth of the transmission channel, in order to ensure that the buffer does not overflow, the number of encoding bits of the i-th target region of the N-th image needs to be reduced.
[0169] wherein if the current frame is the N-th image, the proportion of the complexity of the i-th target region of the N-1-th image to the complexity of the N-1-th image determines the target number of bits of the i-th target region of the N-th image.
[0170] wherein the complexity of the target region is calculated by summing the absolute values of the differences between the corresponding pixels in the same target region of the reconstructed frame of the N-1-th image after encoding and the original N-th image before encoding.
[0171] wherein the complexity of the target region represents the difference degree between the i-th target region of the N-th image and the i-th target region of the N-1-th image, the greater the difference degree, the more bandwidth is required for transmitting the i-th target region of the N-th image after encoding, and vice versa.
[0172] Specifically, the proportion of the complexity of the i-th target region of the N-1-th image to the overall complexity of the N-th image is taken as a calculation proportion parameter for determining the i-th target region of the N-th image, and the target number of bits of the i-th target region of the N-th image is calculated by combining the aforementioned method for determining the target number of bits.
[0173] wherein the complexity of the i-th target region of the N-1-th image is Complexity(i), and the complexity of the N-1-th image is SUM(Complexity)
[0174] Correspondingly, the target number of bits T Ni The calculation formula is as follows:
[0175] T Ni = (T (N-1)i -E (N-1)i +T0)*Complexity(i) / SUM(Complexity)
[0176] wherein T (N-1)iis the target bit number of the i-th target region of the N-th frame image, E (N-1)i is the encoding bit number of the i-th target region of the N-th frame image, T0is the basic bit number.
[0177] It should be noted that since the complexity of the target region represents the difference between the i-th target region of the N-th frame image and the i-th target region of the N-1-th frame image, the target bit number of the corresponding target region of the next frame image is calculated based on the proportion of the complexity of the target region in the complexity of the frame image, which can more accurately estimate the bit number required for the next frame image, and the encoder can more effectively encode the next frame image, avoiding the overflow of the buffer.
[0178] Step S804: If the encoding bit number of the i-th target region of the N-1-th frame image is greater than the target bit number, the compression factor of the i-th target region of the N-1-th frame image is increased by a target value to obtain the compression factor of the i-th target region of the N-th frame image;
[0179] Step S805: If the encoding bit number of the i-th target region of the N-1-th frame image is less than the target bit number, the compression factor of the i-th target region of the N-1-th frame image is reduced by a target value to obtain the compression factor of the i-th target region of the N-th frame image;
[0180] Step S806: If the encoding bit number of the i-th target region of the N-1-th frame image is equal to the target bit number, the compression factor of the i-th target region of the N-1-th frame image is determined as the compression factor of the i-th target region of the N-th frame image;
[0181] Step S807: The i-th target region of the N-th frame image is encoded based on the compression factor of the i-th target region of the N-th frame image to obtain the encoding bit number of the i-th target region of the N-th frame image.
[0182] Wherein, steps S804-807 are consistent with the corresponding steps in embodiment 4, and will not be repeated here.
[0183] To sum up, the video coding control method provided in the embodiment, the target bit number of the i-th target region of the N-1-th image is a pre-estimated value, and the method further comprises: pre-estimating the target bit number, specifically comprising: determining a basic bit number of each target region based on a target code rate, a target frame rate, and the number of target regions in each image, wherein the target code rate is related to a transmission channel of the target stream media after coding, and the target frame rate is related to the target stream media. In the embodiment, the basic bit number of each target region is determined based on the target code rate and the target frame rate related to the transmission channel of the target stream media after coding, and in combination with the number of target regions in each image, so as to pre-estimate the target bit number of the i-th target region in the N-1-th image based on the basic bit number. The target bit number of each target region can be accurately pre-estimated in combination with the condition of the transmission channel.
[0184] Corresponding to the video coding control method provided in the embodiment of the application, the application further provides a device embodiment applying the video coding control method.
[0185] As shown in the structural schematic diagram of the video coding control device embodiment provided in the application, the device comprises the following structures: an obtaining module 901 and a coding module 902. Figure 9
[0186] The obtaining module 901 is configured to obtain a target stream media.
[0187] The coding module 902 is configured to code each image in an image sequence of the target stream media based on the image sequence, wherein the target stream media satisfies target display parameters.
[0188] At least one image is coded into different target regions, and the coding bit numbers of the different target regions are different.
[0189] Optionally, the coding module comprises:
[0190] A division unit is configured to divide each image into at least two target regions based on a preset coding unit of a target number.
[0191] A coding unit is configured to code the at least two target regions respectively.
[0192] The number of target regions in each image in the image sequence of the stream media is the same.
[0193] Optionally, the coding unit comprises:
[0194] determining a compression factor of the i-th target region of the N-th frame image based on the number of encoded bits of the i-th target region of the N-1-th frame image, wherein N is an integer greater than 1, and i is a positive integer;
[0195] encoding the i-th target region of the N-th frame image based on the compression factor of the i-th target region of the N-th frame image, to obtain the number of encoded bits of the i-th target region of the N-th frame image.
[0196] Optionally, the determining sub-unit is specifically configured to:
[0197] if the number of encoded bits of the i-th target region of the N-1-th frame image is greater than the target number of bits, increasing the compression factor of the i-th target region of the N-1-th frame image by a target value to obtain the compression factor of the i-th target region of the N-th frame image;
[0198] if the number of encoded bits of the i-th target region of the N-1-th frame image is less than the target number of bits, decreasing the compression factor of the i-th target region of the N-1-th frame image by a target value to obtain the compression factor of the i-th target region of the N-th frame image;
[0199] if the number of encoded bits of the i-th target region of the N-1-th frame image is equal to the target number of bits, determining the compression factor of the i-th target region of the N-1-th frame image as the compression factor of the i-th target region of the N-th frame image;
[0200] wherein the value of the compression factor is inversely related to the number of encoded bits, and the number of encoded bits is positively related to the encoded clarity.
[0201] Optionally, the target number of bits of the i-th target region of the N-1-th frame image is a predicted value, and the method further comprises:
[0202] predicting the target number of bits.
[0203] Optionally, the predicting sub-unit is specifically configured to:
[0204] determining a basic number of bits of each target region based on a target code rate, a target frame rate, and the number of target regions in each frame image, wherein the target code rate is related to a transmission channel for transmitting the encoded target stream media.
[0205] Optionally, if the current frame is the first frame image, the target number of bits of the i-th target region of the first frame image is the basic number of bits.
[0206] If the current frame is the Nth image, the target bit number of the i-th target region of the Nth image is the sum of the difference between the target bit number of the i-th target region of the N-1th image and the encoding bit number of the i-th target region of the N-1th image and the base bit number.
[0207] Optionally, if the current frame is the Nth image, the target bit number of the i-th target region of the Nth image is determined according to the proportion of the complexity of the i-th target region of the N-1th image to the complexity of the N-1th image.
[0208] It should be noted that the functions of the structures of the video encoding control device provided in the embodiment are explained in the foregoing method embodiments, and thus will not be described in detail in this embodiment.
[0209] In summary, the video encoding control device provided in the embodiment encodes each frame of image in the image sequence of the target stream media based on the target display parameter, wherein the encoding bit numbers of different target regions of at least one frame of image are different after encoding, so that different encoding parameters are used to encode different target regions in a frame of image in the target stream media, the bit numbers of the data obtained after encoding of different regions are different, the stability of the data stream entering the buffer is ensured, and the overflow or underflow of the buffer is avoided.
[0210] Corresponding to the video encoding control method provided in the embodiment of the application, the application further provides an electronic device and a readable storage medium corresponding to the video encoding control method.
[0211] The electronic device comprises an encoder and a decoder.
[0212] The encoder is configured to encode each frame of image in the image sequence of the target stream media based on the target display parameter.
[0213] The buffer is configured to buffer the data encoded by the encoder and output the data through a transmission channel.
[0214] The encoder is configured to implement that the encoding bit numbers of different target regions of at least one frame of image are different after encoding.
[0215] The encoder is integrated in a processor of the electronic device, the buffer is part of a storage space in a memory of the electronic device, or the encoder and the buffer are integrated in a preset functional chip.
[0216] The electronic device implements the video encoding control method by referring to the foregoing video encoding control method embodiments.
[0217] Corresponding to the video encoding control method embodiment provided by the present application, the present application also provides a readable storage medium corresponding to the video encoding control method.
[0218] The readable storage medium has a computer program stored thereon, the computer program is called and executed by a processor, and each step of the video encoding control method according to any one of the preceding embodiments is implemented.
[0219] The computer program stored in the readable storage medium is executed to implement the video encoding control method, and reference is made to the preceding video encoding control method embodiments.
[0220] The embodiments in the specification are described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same or similar parts of each embodiment can be referred to each other. For the device provided by the embodiments, since it corresponds to the method provided by the embodiments, the description is relatively simple, and the related parts can be referred to the method part.
[0221] The above description of the provided embodiments enables a person skilled in the art to implement or use the present application. Various modifications of the embodiments will be apparent to a person skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features provided herein.
Claims
1. A method for video encoding control, comprising: obtaining a target stream media; encoding each frame of an image sequence of the target stream media based on the image sequence, the target stream media satisfying target display parameters; wherein a compression factor of a target region in a corresponding position of a next frame is determined based on a number of encoding bits of the target region in a previous frame; wherein a number of encoding bits of at least one frame after encoding for different target regions is different; the compression factor of the target region in the corresponding position of the next frame is determined based on the number of encoding bits of the target region in the previous frame, comprising: if the number of encoding bits of an i th target region of an N-1 th frame is greater than a target number of bits, the compression factor of the i th target region of the N-1 th frame is increased by a target value to obtain the compression factor of the i th target region of an N th frame; if the number of encoding bits of the i th target region of the N-1 th frame is less than the target number of bits, the compression factor of the i th target region of the N-1 th frame is decreased by the target value to obtain the compression factor of the i th target region of the N th frame; if the number of encoding bits of the i th target region of the N-1 th frame is equal to the target number of bits, the compression factor of the i th target region of the N-1 th frame is determined as the compression factor of the i th target region of the N th frame. 2.The method of claim 1, wherein the encoding each frame of the image sequence comprises: dividing each frame into at least two target regions based on a target number of preset encoding units; encoding the at least two target regions respectively; wherein a number of target regions of each frame of the image sequence of the stream media is the same. 3.The method of claim 2, wherein the encoding the at least two target regions respectively comprises: determining the compression factor of an i th target region of an N th frame based on a number of encoding bits of the i th target region of an N-1 th frame, wherein N is an integer greater than 1 and i is a positive integer; encoding the i th target region of the N th frame based on the compression factor of the i th target region of the N th frame to obtain a number of encoding bits of the i th target region of the N th frame. 4.The method of claim 1, wherein a value of the compression factor is inversely related to the number of encoding bits, and the number of encoding bits is positively related to a clarity after encoding. 5.The method of claim 4, wherein the target number of bits of the i th target region of the N-1 th frame is an estimated value, and the method further comprises: estimating the target number of bits. 6.The method of claim 5, wherein the estimating the target number of bits comprises: determining a basic number of bits of each target region based on a target code rate, a target frame rate, and a number of target regions in each frame, wherein the target code rate is related to a transmission channel for transmitting the target stream media after encoding. 7.The method of claim 6, wherein if a current frame is a first frame, the target number of bits of an i th target region of the first frame is the basic number of bits. If the current frame is the Nth frame image, the target bit number of the ith target region of the Nth frame image comprises the sum of the target bit number of the ith target region of the N-1th frame and the difference between the encoding bit number of the ith target region of the N-1th frame and the base bit number.
8. The method of claim 5, If the current frame is the Nth frame image, the target bit number of the ith target region of the Nth frame image comprises the sum of the target bit number of the ith target region of the N-1th frame and the difference between the encoding bit number of the ith target region of the N-1th frame and the base bit number.
9. A video encoding control apparatus, comprising: an obtaining module configured to obtain a target stream media; an encoding module configured to encode each frame of an image sequence based on the image sequence of the target stream media, the target stream media satisfying a target display parameter; wherein a compression factor of a target region at a corresponding position of a next frame is determined based on an encoding bit number of the target region in a previous frame; wherein the encoding bit number of at least one frame of the image sequence after encoding for different target regions is different; the compression factor of the target region at the corresponding position of the next frame is determined based on the encoding bit number of the target region in the previous frame, specifically configured to: if the encoding bit number of the ith target region of the N-1th frame image is greater than the target bit number, the compression factor of the ith target region of the N-1th frame image is increased by a target value to obtain the compression factor of the ith target region of the Nth frame image; if the encoding bit number of the ith target region of the N-1th frame image is less than the target bit number, the compression factor of the ith target region of the N-1th frame image is decreased by the target value to obtain the compression factor of the ith target region of the Nth frame image; if the encoding bit number of the ith target region of the N-1th frame image is equal to the target bit number, the compression factor of the ith target region of the N-1th frame image is determined as the compression factor of the ith target region of the Nth frame image.
10. An electronic device comprising: an encoder and a buffer; wherein the encoder is configured to encode each frame of an image sequence based on the image sequence of the target stream media, the target stream media satisfying a target display parameter; wherein a compression factor of a target region at a corresponding position of a next frame is determined based on an encoding bit number of the target region in a previous frame; an encoder and a buffer; The compression factor of the target region at the corresponding position of the next frame is determined based on the number of encoded bits of the target region in the previous frame image, and specifically used for: if the number of encoded bits of the i-th target region of the N-1th frame image is greater than the target bit number, the compression factor of the i-th target region of the N-1th frame image is increased by a target value to obtain the compression factor of the i-th target region of the Nth frame image; if the number of encoded bits of the i-th target region of the N-1th frame image is less than the target bit number, the compression factor of the i-th target region of the N-1th frame image is reduced by a target value to obtain the compression factor of the i-th target region of the Nth frame image; if the number of encoded bits of the i-th target region of the N-1th frame image is equal to the target bit number, the compression factor of the i-th target region of the N-1th frame image is determined as the compression factor of the i-th target region of the Nth frame image; a buffer for buffering the data encoded by the encoder and then outputting the data through a transmission channel; The encoder is configured to implement that the number of encoded bits of at least one frame image after encoding for different target regions is different based on at least the buffering result of the buffer; The encoder is integrated in a processor of an electronic device, the buffer is part of a storage space in a memory of the electronic device, or the encoder and the buffer are integrated in a preset functional chip.
Citation Information
Patent Citations
Method and device for controlling code rate in video coding
CN101795415A
AVC bit rate control method based on human visual system
CN108810530A