Video encoding method, apparatus, device, and storage medium
By acquiring image and encoding information from video frames, and using convolutional neural networks to predict bitrate parameters, the encoding quality of ROI and non-ROI regions is optimized. This solves the problem that the CRF algorithm cannot precisely control the output file size, and achieves more accurate bitrate allocation and encoding effect.
Patent Information
- Application Number
- CN202510653298.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-20
- Publication Date
- 2026-11-20
AI Technical Summary
Existing CRF algorithms cannot precisely control the output file size in video encoding, resulting in poor bitrate allocation.
By acquiring the image information of the first image frame of the video and the encoding information of the previously encoded second image frame, a convolutional neural network is used to predict the bitrate parameters of the first image frame, optimize the encoding quality of ROI and non-ROI regions, and dynamically manage the bitrate allocation.
It achieves more precise bitrate allocation, avoids bitrate runaway, and improves the encoding effect of image frames and the control of output file size.
Smart Images

Figure CN123145407A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of video coding technology, and in particular to a video coding method, apparatus, device and storage medium. Background Technology
[0002] In current video compression technologies, bitrate control is a key technology in video encoding. Bitrate control can dynamically adjust encoding parameters to control the bitrate (the amount of data transmitted per unit time) of the output video, thereby balancing video quality, bandwidth usage, and storage requirements.
[0003] In related technologies, taking the CRF (Constant Rate Factor) bitrate control algorithm as an example, the CRF algorithm dynamically allocates bitrate while maintaining consistent image quality. This algorithm sets a fixed quality factor (CRF value, typically ranging from 0 to 51), allowing the encoder to automatically allocate fewer bits for simple scenes and more bits for complex scenes, thereby achieving stable variable bitrate output with consistent visual quality.
[0004] However, in the aforementioned related technologies, the encoder automatically allocates bits, which cannot precisely control the output file size, resulting in poor bitrate allocation. Summary of the Invention
[0005] This application provides a video encoding method, apparatus, device, and storage medium that can improve bitrate allocation performance. The technical solution is as follows:
[0006] According to one aspect of the embodiments of this application, a video encoding method is provided, the method comprising:
[0007] The image information of the first image frame of the video and the encoding information of the second image frame of the video are obtained, wherein the second image frame is located before the first image frame in the video;
[0008] Based on the image information and the encoding information, the bitrate parameter of the first image frame is predicted, and the bitrate parameter is used to determine the bitrate allocation of the first image frame;
[0009] The first image frame is encoded according to the bitrate parameter.
[0010] According to one aspect of the embodiments of this application, a video encoding / decoding apparatus is provided, the apparatus comprising:
[0011] An information acquisition module is used to acquire image information of a first image frame of a video and encoding information of a second image frame of the video, wherein the second image frame is located before the first image frame in the video;
[0012] The parameter prediction module is used to predict the bitrate parameter of the first image frame based on the image information and the encoding information, and the bitrate parameter is used to determine the bitrate allocation of the first image frame.
[0013] An image encoding module is used to encode the first image frame according to the bitrate parameter.
[0014] According to one aspect of the embodiments of this application, a computer device is provided, the computer device including a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the above-described video encoding method.
[0015] According to one aspect of the embodiments of this application, a computer-readable storage medium is provided, wherein a computer program and a video stream are stored in the computer program, the computer program being executed by a processor to implement the above-described video encoding method to generate the video stream.
[0016] According to one aspect of the embodiments of this application, a computer program product is provided, the computer program product including a computer program, the computer program being loaded and executed by a processor to implement the above-described video encoding method.
[0017] This application also provides a method for generating a video stream, wherein the video stream is obtained by encoding video data using the above-described video encoding method.
[0018] The technical solutions provided in this application embodiment may have the following beneficial effects:
[0019] By acquiring the image information of the first image frame and the encoding information of the image frame preceding the first image frame in the video (i.e., the second image frame), the bitrate parameter of the first image frame is predicted. This bitrate parameter determines the bitrate allocation of the first image frame to achieve encoding of the first image frame.
[0020] On the one hand, by using the image content of the first image frame itself as part of the prediction basis for the bitrate parameter, the bitrate of the first region is allocated based on the image content, ensuring that the bitrate allocation result meets the bitrate requirements of the image content. On the other hand, by using the encoding information of the already encoded second image frame as another part of the prediction basis for the bitrate parameter, the problem of bitrate runaway during the encoding process of the first image frame can be avoided, thus achieving control over the size of the output file. Therefore, this application introduces predicted bitrate parameters, improving the bitrate allocation effect. In addition, while the bitrate allocation effect is improved, the encoding effect of the image frame is also improved. Attached Figure Description
[0021] Figure 1This application exemplarily illustrates a basic flowchart of a video encoding process;
[0022] Figure 2 This is a simplified block diagram of a communication system provided in one embodiment of this application;
[0023] Figure 3 This is a schematic diagram illustrating the placement of a video encoder and a video decoder in a streaming environment, as exemplarily shown in this application.
[0024] Figure 4 This is a schematic diagram illustrating the bit rate control method exemplarily shown in this application;
[0025] Figure 5 This is a schematic diagram of a video encoding method provided in one embodiment of this application;
[0026] Figure 6 This is a flowchart of a video encoding method provided in one embodiment of this application;
[0027] Figure 7 This is a flowchart of a video encoding method provided in another embodiment of this application;
[0028] Figure 8 This is a flowchart of a video encoding method provided in another embodiment of this application;
[0029] Figure 9 This is a schematic diagram of a bitrate reservoir provided in one embodiment of this application;
[0030] Figure 10 This is a schematic diagram illustrating the prediction of bitrate parameters using a convolutional neural network model, provided in one embodiment of this application.
[0031] Figure 11 This is a schematic diagram of a video encoding method provided in another embodiment of this application;
[0032] Figure 12 This is a schematic diagram of a method for constructing training samples according to an embodiment of this application;
[0033] Figure 13 This is a flowchart of a video encoding method in a video call provided in one embodiment of this application;
[0034] Figure 14 This is a flowchart of a video encoding method in a video conferencing system provided in one embodiment of this application;
[0035] Figure 15 This is a flowchart of a video encoding method in a short video provided in one embodiment of this application;
[0036] Figure 16 This is a block diagram of a video encoding apparatus provided in one embodiment of this application;
[0037] Figure 17 This is a structural block diagram of a computer device provided in one embodiment of this application. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0039] Before describing the embodiments of this application, firstly, in conjunction with Figure 1 A brief introduction to video coding technology. Figure 1 An example is shown in a basic flowchart of a video encoding process.
[0040] A video signal is a sequence of images consisting of multiple frames. A frame represents the spatial information of a video signal. Taking YUV mode as an example, a frame includes a luminance sample matrix (Y) and two chrominance sample matrices (Cb and Cr). From the perspective of how video signals are acquired, they can be divided into two types: those captured by a camera and those generated by a computer. Due to differences in statistical characteristics, the corresponding compression coding methods may also differ.
[0041] In some mainstream video coding technologies, such as H.265 / HEVC (High Efficient Video Coding), H.266 / VVC (Versatile Video Coding) standard, and AVS (Audio Video Coding Standard) (such as AVS3), a hybrid coding framework is used to perform a series of operations and processes on the input raw video signal.
[0042] 1. Block Partition Structure: The input image is divided into several non-overlapping processing units, each of which undergoes a similar compression operation. This processing unit is called a CTU (Coding Tree Unit) or LCU (Large Coding Unit). Further subdivisions can be made below the CTU to obtain one or more basic coding units, called CUs (Coding Units). Each CU is the most basic element in a coding process. The following describes the various coding methods that can be used for each CU.
[0043] 2. Predictive Coding (102): This includes intra-frame prediction and inter-frame prediction. The original video signal is predicted from a selected reconstructed video signal to obtain a residual video signal. The encoder needs to select the most suitable predictive coding mode from among many possible modes for the current CU (i.e., the current block) and inform the decoder. Intra-frame prediction refers to predicting signals from already encoded and reconstructed regions within the same image. Inter-frame prediction refers to predicting signals from other encoded images different from the current image (i.e., the current frame).
[0044] 3. Transform & Quantization 103: The residual video signal undergoes transformation operations such as DFT (Discrete Fourier Transform) and DCT (Discrete Cosine Transform) to convert the signal into the transform domain, which are called transform coefficients. In the transform domain, the signal undergoes further lossy quantization, losing some information to make the quantized signal more suitable for compression. Some video coding standards may offer more than one transform option; therefore, the encoder needs to select one transform for the current CU and inform the decoder. The fineness of quantization is usually determined by the quantization parameter. A larger QP (Quantization Parameter) value means that coefficients with a wider range of values will be quantized into the same output, thus usually resulting in greater distortion and a lower bitrate; conversely, a smaller QP value means that coefficients with a smaller range of values will be quantized into the same output, thus usually resulting in less distortion and a higher bitrate.
[0045] 4. Entropy Coding (or Statistical Coding): The quantized transform domain signal is statistically compressed and encoded based on the frequency of each value, ultimately outputting a binary (0 or 1) compressed bitstream. Simultaneously, other information generated during encoding, such as the selected mode and motion vectors, also requires entropy coding to reduce the bit rate. Statistical coding is a lossless coding method that effectively reduces the bit rate required to represent the same signal. Common statistical coding methods include Variable Length Coding (VLC) or Content-Adaptive Binary Arithmetic Coding (CABAC).
[0046] 5. Loop Filtering 105: After the encoded image undergoes inverse quantization, inverse transform, and prediction compensation operations (the reverse of operations 2-4 above), a reconstructed decoded image can be obtained. Compared with the original image, the reconstructed image differs in some information due to the influence of quantization, resulting in distortion. Filtering the reconstructed image, such as deblocking, SAO (Sample Adaptive Offset), or ALF (Adaptive Lattice Filter), can effectively reduce the distortion caused by quantization. Since these filtered reconstructed images will be used as a reference for subsequent encoded images to predict future signals, the above filtering operations are also called loop filtering, or filtering operations within the encoding loop.
[0047] As can be seen from the above encoding process, at the decoding end, for each CU, after obtaining the compressed bitstream, the decoder first performs entropy decoding to obtain various mode information and quantized transform coefficients. Each coefficient undergoes inverse quantization and inverse transform to obtain the residual signal. On the other hand, based on the known encoding mode information, the prediction signal corresponding to that CU can be obtained. After adding the two, the reconstructed signal is obtained. Finally, the reconstructed value of the decoded image needs to undergo a loop filtering operation to generate the final output signal.
[0048] like Figure 2 The diagram illustrates a simplified block diagram of a communication system provided in one embodiment of this application. The communication system 200 includes a plurality of devices that can communicate with each other via, for example, a network 250. For example, the communication system 200 includes a first device 210 and a second device 220 interconnected via the network 250. Figure 2 In this embodiment, the first device 210 and the second device 220 perform unidirectional data transmission. For example, the first device 210 may encode video data, such as a video image stream captured by the first device 210, for transmission to the second device 220 via network 250. The encoded video data is transmitted in the form of one or more encoded video streams. The second device 220 may receive the encoded video data from network 250, decode the encoded video data to recover the video data, and display video images based on the recovered video data. Unidirectional data transmission is common in applications such as media services.
[0049] In another embodiment, the communication system 200 includes a third device 230 and a fourth device 240 that perform bidirectional transmission of encoded video data, which may occur, for example, during a video conference. For bidirectional data transmission, each of the third device 230 and the fourth device 240 may encode video data (e.g., a stream of video images captured by the device) for transmission over network 250 to the other device. Each of the third device 230 and the fourth device 240 may also receive encoded video data transmitted by the other device, decode the encoded video data to recover the video data, and display the video images on an accessible display device based on the recovered video data.
[0050] exist Figure 2 In the embodiments described, the first device 210, the second device 220, the third device 230, and the fourth device 240 may be computer devices such as servers, personal computers, and smartphones, but the principles disclosed in this application are not limited to these. The embodiments of this application are applicable to PCs (Personal Computers), mobile phones, tablets, media players, and / or dedicated video conferencing equipment. Network 250 refers to any number of networks that transmit encoded video data between the first device 210, the second device 220, the third device 230, and the fourth device 240, including, for example, wired and / or wireless communication networks. Communication network 250 may exchange data in circuit-switched and / or packet-switched channels. This network may include telecommunications networks, local area networks, wide area networks, and / or the Internet. For the purposes of this application, unless explained below, the architecture and topology of network 250 may be irrelevant to the operation of the disclosures in this application.
[0051] As an example, Figure 3 Figure 300 illustrates the placement of a video encoder and video decoder in a streaming environment. The subject matter disclosed in this application is equally applicable to other video-enabled applications, including, for example, video conferencing, digital TV, storing compressed video on digital media including CDs (Compact Discs), DVDs (Digital Versatile Discs), memory sticks, etc.
[0052] The streaming system may include an acquisition subsystem 313, which may include a video source 301 such as a digital camera, which creates an uncompressed video image stream 302. In an embodiment, the video image stream 302 includes samples captured by a digital camera. The video image stream 302 is depicted as a thick line to emphasize the high data volume of the video image stream compared to encoded video data 304 (or encoded video bitstream). The video image stream 302 may be processed by an electronic device 320, which includes a video encoder 303 coupled to the video source 301. The video encoder 303 may include hardware, software, or a combination of hardware and software to implement or enforce aspects of the disclosed subject matter as described in more detail below. The encoded video data 304 (or encoded video bitstream 304) is depicted as a thin line to emphasize the lower data volume of the encoded video data 304 (or encoded video bitstream 304), which may be stored on a streaming server 305 for future use. One or more streaming client subsystems, such as Figure 3 Client subsystems 306 and 308 can access streaming server 305 to retrieve copies 307 and 309 of encoded video data 304. Client subsystem 306 may include, for example, a video decoder 310 in electronic device 330. Video decoder 310 decodes the incoming copy 307 of the encoded video data and produces an output video picture stream 311 that can be displayed on display 312 (e.g., a screen) or another presentation device (not depicted). In some streaming systems, the encoded video data 304, video data 307, and video data 309 (e.g., video stream) may be encoded according to certain video encoding / compression standards.
[0053] It should be noted that electronic devices 320 and 330 may include other components (not shown). For example, electronic device 320 may include a video decoder (not shown), and electronic device 330 may also include a video encoder (not shown). The video decoder is used to decode received encoded video data; the video encoder is used to encode the video data.
[0054] It should be noted that the technical solutions provided in this application can be applied to H.266 / VVC standards, H.265 / HEVC standards, AVS (such as AVS3), or next-generation video codec standards, and this application does not limit them.
[0055] It should also be noted that the execution entity for each step of the method provided in this application embodiment can be an encoding end device (such as the first device 210 mentioned above). The technical solutions provided in this application embodiment can be used in the video encoding process. The encoding end device can be a computer device, which refers to an electronic device with data computing, processing, and storage capabilities, such as a PC, mobile phone, tablet computer, media player, dedicated video conferencing equipment, server, etc.
[0056] Furthermore, the method provided in this application can be used alone or in combination with other methods in any order. The encoder based on the method provided in this application can be implemented by one or more processors or one or more integrated circuits.
[0057] The following is a description of some related technologies involved in this application.
[0058] With the booming development of the video industry, the demand for efficient video coding to ensure Quality of Service (QoS) is becoming increasingly urgent. This is particularly evident in high-resolution, high-frame-rate live broadcasts such as sports events and video games. The human eye does not uniformly focus on all parts of a visual scene, but rather tends to concentrate attention on specific regions closely related to its perceptual task, namely the Region of Interest (ROI). These ROIs play a crucial role in influencing perceived video quality and subsequent audience analysis. To improve perceived video quality at a fixed bitrate and align with the inherent mechanisms of the human visual system, the technical solution proposed in this application allocates more bits to CUs within the ROI compared to those within the Region of Uninterest (ROU). This optimizes the coding process, better serves the audience's perceptual priorities, and maintains overall bitrate efficiency. Region of Interest (ROI) coding, as a technique for improving the subjective and objective image quality of specific areas within a limited bandwidth budget, is widely used in various subjectively prioritized coding scenarios.
[0059] In the field of video coding, Region of Interest (ROI)-based coding strategies are used to achieve efficient encoding and high-quality presentation of specific regions. The core idea behind ROI-based coding methods is to flexibly adjust encoding parameters and resource allocation based on the importance of the video content and the viewer's focus, thereby maximizing the preservation of visual details and fidelity within the ROI region while meeting overall bitrate limitations.
[0060] Bitrate control is a crucial task in video encoding, aiming to minimize video quality loss while strictly adhering to a preset constant target bitrate. To achieve this, the bitrate control algorithm must carefully determine the optimal QP for each video segment, ensuring that the encoded bitrate R... v (QP) will not exceed the specified maximum value R. max This constraint is crucial because the quantization process essentially compresses the video signal at the cost of bit rate, where R... max As a fixed upper limit on the total number of bits, R v (QP) represents the number of bits actually encoded in the live stream.
[0061] In practical video coding applications, bitrate control often incorporates Rate-Distortion Optimization (RDO) strategies, such as the basic RDO formula: J = D + λ·R. The core of RDO is minimizing the Lagrange cost function. J: Total cost (to be minimized). D: Distortion (usually measured by PSNR (Peak Signal-to-Noise Ratio), SSIM (Structural Similarity Index Measure), or MSE (Mean Squared Error). R: Bitrate (number of bits). λ: Lagrange multiplier, controlling the weighting of bitrate and distortion. Physical meaning: When λ is large, bitrate is preferentially reduced (high compression, low quality). When λ is small, distortion is preferentially reduced (high quality, high bitrate).
[0062] Guided by the QP value allocated to the coding unit (CU) by the rate control mechanism, RDO strives to minimize the cost function within each CU, thereby reducing the overall quality loss of the encoded video.
[0063] To effectively address the aforementioned challenges, it is crucial to establish a clear rate-distortion model that correlates average bit rate with QP value. Such models in related technologies aim to reveal the intrinsic relationship between perceptual video quality and bit rate. There are various types of rate models in related technologies, ranging from intuitive and concise linear expressions to complex and sophisticated mathematical formulas.
[0064] For example, HEVC coding uses a linear model for bitrate estimation. In contrast, the following quadratic model is applied in VM8 (Video Model 8) to MPEG4 (Moving Picture Experts Group-4), H.264 / AVC (Advanced Video Coding), and HEVC coding: R = C1 × MAD / QP + C2 × MAD / QP^2, where C1 and C2 are model parameters. These types of models play a crucial role in video coding applications, precisely balancing the delicate relationship between video quality and bitrate limitations.
[0065] In related technologies, although each bitrate control model is tailored to a video coding system under specific conditions, the core goal of all these methods is consistent: to allocate the optimal number of bits to each coding unit and to accurately determine its quantization parameters.
[0066] The encoder's rate controller operates at three main levels: Group of Pictures (GOP), frame, and coding unit (CU).
[0067] 1. GOP Level: At this level, input parameters include the target bitrate, sequence frame rate, GOP size, and virtual buffer occupancy. The rate control algorithm calculates the average number of bits per GOP based on these parameters to ensure the overall bitrate meets the preset target.
[0068] 2. Frame Level: This stage focuses on the average bit allocation per frame, setting a fixed bit target for the current frame. Considering the frame's hierarchical structure, the QP value at the frame level is calculated using the R-λ model to ensure that the intra-frame coding quality is consistent with the overall bit rate target.
[0069] 3. CU Level: This process involves three steps. First, based on the frame budget and the CU's own Mean Absolute Difference (MAD), the required bit allocation for each CU is calculated. Second, using the determined frame budget, an R-λ model is applied to calculate a suitable λ value for each CU within a given QP range. Finally, by performing Rate Distortion Optimization (RDO), the optimal mode decision that best matches the given QP is found, ensuring that the CU coding quality remains consistent with the overall bitrate target.
[0070] The bit rate control component inside the encoder operates according to the following principle: Figure 4As shown, by accurately understanding the encoder's internal state, the actual number of bits consumed by encoded frames, and the buffer status, proactive bit allocation and QP adjustment operations are performed on frames to be encoded. This aims to maximize video quality through scientific and optimized bit resource allocation within a given target bitrate constraint. Specifically, as... Figure 4 As shown, for the current frame (e.g., the first image frame) of video source 201, bitrate control 203 is achieved through pre-analysis 202 and video buffer 205 of historical frames (e.g., the second image frame). For example, encoding of the current frame of video source 201 is implemented based on the QP and λ obtained from bitrate control 203 and the video encoder 204. For example, the encoded information obtained from encoding the current frame is stored in the video buffer 205, and bitstream storage / transmission 206 is performed.
[0071] Among related technologies, the bitrate control strategies widely used in the field of video coding mainly include the following:
[0072] 1. CQP (Constant Quantization Parameter) method: This method uses a constant quantization parameter (QP) for encoding. Although rarely used in practical video coding applications, it is often used in academic research for benchmark testing of specific coding algorithm performance optimization because it avoids performance fluctuations caused by QP adjustment.
[0073] 2. CRF Method: This strategy, based on a constant quality factor, is widely used in both open-source and commercial encoders. Its advantage lies in its ability to effectively save bandwidth resources while maintaining stable video quality. However, a limitation of this method is that the exact size of the encoded output file cannot be determined in advance.
[0074] The biggest difference between CRF encoding and other rate control strategies lies in the fact that the determination of its initial QP (quantization parameter) is completely independent of the bit consumption during the encoding process. While most of the CRF formula calculation process is the same as ABR (Average Bitrate), the core concept of CRF is to set a constant rate factor that remains unchanged throughout the encoding process, determining a fixed relationship between video quality and bit rate. This means that regardless of changes in the video content, the CRF encoder will determine the quantization parameters for each frame based on this constant rate factor, unaffected by the actual number of bits consumed during encoding.
[0075] In practical business applications, since the content of the video source is often unknown, when using CRF encoding, in order to ensure that the maximum video size is controllable, especially to prevent excessive bit generation due to improper selection of the initial CRF value in complex scenarios, thus wasting bandwidth resources, a VBV control unit is usually introduced. VBV dynamically adjusts the encoder output by setting a threshold for the maximum peak bitrate of the video, ensuring that the instantaneous bitrate of the video stream does not exceed the preset upper limit, thereby effectively limiting the video size.
[0076] 3. ABR method: With the goal of setting an average bitrate, this strategy focuses on reducing the overall bitrate control error of the video, striving to improve video compression efficiency while ensuring high bitrate control accuracy.
[0077] 4. CBR (Constant Bitrate) method: Compared to the Variable Bitrate (VBR) scheme, the CBR method emphasizes that the peak bitrate per second should remain constant during the encoding process. Due to its strict bitrate stability requirements, the CBR method dominates in applications such as live video streaming.
[0078] 5. VBV (Video Buffering Verifier): As an auxiliary mechanism, VBV provides buffer resource management functions for major bitrate control modes such as CRF, ABR, and CBR. By introducing VBV, the bit allocation process of the encoder can be optimized more reasonably, thereby improving encoding efficiency and video playback smoothness.
[0079] 6. Multi-pass coding: Among multi-pass coding techniques, the most common is the two-pass coding strategy. In this mode, the encoder first performs a preliminary encoding of the video, and uses the statistical information from the first encoding to guide the QP adjustment during the second encoding, thereby achieving better compression performance.
[0080] It's worth noting that the main difference between ABR and CBR modes lies in the application of VBV control. When the encoder is configured with VBV, if the maximum bit rate is set equal to the average bit rate, it operates in CBR mode; otherwise, the system will run in a combination of standard ABR and VBV. This distinction helps in flexibly selecting the appropriate bit rate control strategy based on actual application needs to achieve optimal video encoding results.
[0081] In summary, these rate control mechanisms working collaboratively at different levels collectively construct a systematic and highly adaptable bitrate management framework, ensuring optimal video quality throughout the entire video encoding process while strictly adhering to preset bitrate limits. This mechanism is irreplaceable for achieving efficient, high-quality video encoding, especially in environments with limited bandwidth or demanding transmission conditions.
[0082] Please refer to Figure 5 The diagram illustrates a video encoding method provided in one embodiment of this application.
[0083] like Figure 5 As shown, for the first image frame 520 to be encoded in the video, preprocessing is required to obtain the image information of the first image frame 520. The image information of the first image frame 520 mentioned in this application is used for the image content of the first image frame 520, such as indicating ROI, indicating ROU, etc. Specifically, the image information of the first image frame includes at least one of the following: C roi C rou P roi P rou Among them, C roi C rou It is a parameter related to complexity. roi P rou It is a parameter related to the number of pixels.
[0084] like Figure 5 As shown, when encoding the first image frame 520, the second image frame 510 is an image frame preceding the first image frame 520. Exemplarily, the second image frame 510 is an image frame that has already been encoded. Exemplarily, the encoding information of the second image frame 510 is obtained. The encoding information of the second image frame 510 mentioned in this application refers to information obtained during or after encoding the second image frame 510. Exemplarily, the encoding information of the second image frame 510 includes the bitrate of the second image frame (referred to as R in this application). frame-1 (to refer to), the QP of the second image frame (in this application, QP) frame-1 (used to refer to).
[0085] like Figure 5 As shown, the bitrate parameter of the first image frame 520 is predicted by the CNN (Convolutional Neural Network) model 530 based on the encoding information of the second image frame 510 and the image information of the first image frame 520. The bitrate parameter mentioned in this application refers to a parameter used to control the bitrate allocation of the first region. For example, this bitrate parameter includes λ. roi , λ rouAt least one of them. Where, λ roi Used to control the bitrate allocation of ROIs in the first image frame, λ rou Used to control the bitrate allocation of ROUs in the first image frame.
[0086] Optionally, a bitrate reservoir of 540 R can also be obtained. over For example, the bitrate reservoir 540 is used to indicate bitrate consumption for a first region. over This is the maximum bitrate limit of the bitrate reservoir, 540. For example, R... over It is also used as one of the inputs to the CNN model. Combined with the encoding information of the second image frame 510 and the image information of the first image frame 520, the bit rate parameter is obtained.
[0087] like Figure 5 As shown, after obtaining the encoding information of the second image frame 510, the bitrate reservoir 540 is updated using the encoding information of the second image frame 510. Using the updated bitrate reservoir 540, the R of the bitrate reservoir 540 is obtained. over This is used to predict the aforementioned bitrate parameters. The specific update process is explained in the following embodiments and will not be repeated here.
[0088] Optionally, the K value of ROI can also be obtained. roi (Not shown in the figure). For example, K roi For example, K is the quality enhancement factor. roi Used to enhance bitrate allocation for ROI. For example, K... roi It is also used as one of the inputs to the CNN model. Combined with the encoding information of the second image frame 510 and the image information of the first image frame 520, the bit rate parameter is obtained.
[0089] like Figure 5 As shown, after obtaining the bitrate parameters, the bitrate parameters can be further adjusted based on the status information of the bitrate reservoir 540. The specific adjustment process is explained in the following embodiments and will not be repeated here.
[0090] like Figure 5 As shown, after obtaining the bitrate parameter, the bitrate parameter is used to encode the first image frame 520. Specifically, the QP corresponding to ROI and ROU is determined according to the bitrate parameter, so that the CU of ROI and ROU regions are encoded respectively. For the specific encoding process, please refer to the explanation of the following embodiments, which will not be repeated here.
[0091] like Figure 5 As shown, after obtaining the encoding information of the first image frame 520, the encoding information of the first image frame 520 is used to update the bit rate reservoir 540.
[0092] After encoding the first image frame 520, the above steps are repeated for the third image frame (not shown in the figure) to be encoded, in order to predict the bitrate parameters of the third image frame. In short, the encoded information of the first image frame and the image information of the third image frame are obtained, and the bitrate parameters of the third image frame are predicted using a CNN model.
[0093] The technical solution provided in this application predicts the bitrate parameter of a first image frame by acquiring image information of the first image frame and encoding information of the preceding image frame (i.e., the second image frame). This bitrate parameter can control the bitrate allocation of a first region within the first image frame, thereby achieving encoding of the first image frame. On one hand, by using the image content of the first image frame itself as part of the prediction basis for the bitrate parameter, the bitrate of the first region is allocated based on the image content, ensuring that the bitrate allocation result meets the bitrate requirements of the image content. On the other hand, by using the encoding information of the already encoded second image frame as another part of the prediction basis for the bitrate parameter, the problem of bitrate runaway during the encoding process of the first image frame can be avoided, thus achieving control over the size of the output file. Therefore, this application introduces a predicted bitrate parameter, improving the bitrate control effect. Furthermore, while improving the bitrate control effect, the encoding effect of the image frame is also improved.
[0094] This application proposes a CRF-ROI dual bitrate control model, aiming to improve the overall quality of video streams by optimizing the coding quality of ROI (Region of Interest) and non-ROI regions. A frame-level and line-level dual bitrate control model is designed to optimize ROI and non-ROI regions separately, thereby improving the coding quality of the ROI region. An ROI reservoir model (i.e., the aforementioned bitrate reservoir) is proposed to dynamically acquire and manage the bitrate consumption of ROI and non-ROI regions. By adjusting quantization parameters, the coding quality of ROI is optimized while maintaining the stability of the overall bitrate. A convolutional neural network (CNN) is used to predict the bitrate parameters λ of ROI and non-ROI regions to improve the accuracy of bitrate allocation and coding efficiency. Through fine-grained management of the bitrate allocation of ROI and non-ROI regions, bandwidth resources are maximized, ensuring high coding quality in critical regions.
[0095] Please refer to Figure 6 This document illustrates a flowchart of a video encoding method provided in one embodiment of this application. The execution subject of this method may be the first device 210 described above. For ease of explanation, the description focuses on the encoding end device as the execution subject of each step. The method may include at least one of the following steps (610-630).
[0096] Step 610: Obtain the image information of the first image frame of the video and the encoding information of the second image frame of the video. The second image frame is located before the first image frame in the video.
[0097] In some embodiments, the first image frame is any frame appearing in the video. This application does not limit the type of video. Exemplarily, the video here includes, but is not limited to, videos during real-time video calls, videos during video conferences, videos during screen sharing, non-real-time videos, etc. In some embodiments, the first image frame is an image frame in the video to be encoded. The video mentioned in the embodiments of this application can be the original video or a sequence of image frames. Optionally, the image frame sequence is obtained by splitting the original video. Exemplarily, the video is split according to a preset frame rate to obtain at least two image frames, which are also the image frame sequence.
[0098] In some embodiments, the sequential order of image frames in the image frame sequence is related to the original video. For example, the order of the image frames in the image frame sequence is determined according to their chronological order in the original video. For example, at least two image frames are rearranged according to a specified order to obtain at least two rearranged image frames, which constitute the aforementioned image frame sequence. The sequential order of the image frames in this sequence is the specified order. This specified order is a preset order. This specified order can be any order other than chronological order. This specified order can be a randomly rearranged order.
[0099] In other embodiments of this application, a frame located before the first image frame in the video can be considered as an image frame generated in the original video before the first image frame, or as an image frame in the above image frame sequence that appears sequentially before the first image frame. Similarly, a frame located after the first image frame in the video, as mentioned in other embodiments of this application, can be considered as an image frame generated in the original video after the first image frame, or as an image frame in the above image frame sequence that appears sequentially after the first image frame.
[0100] In some embodiments, there may be an encoded video frame before the image frame mentioned in step 610, or there may be an unencoded image frame after the image frame mentioned in step 610. This application does not limit this.
[0101] In this application, image information refers to information related to the image content of the first image frame that can be collected from the first image frame. For example, image information of the first image frame is obtained through manual annotation or prediction by a neural network model.
[0102] In some embodiments, the image information of the first image frame includes at least one of image information of the Region of Interest (ROI) and image information of the Region of Unknown Units (ROU). Exemplarily, the image information of the ROI indicates information related to the ROI in the first image frame. Exemplarily, the image information of the ROU indicates information related to the ROU in the first image frame.
[0103] In some embodiments, the image information of the first image frame includes complexity information and pixel count information. For example, the complexity information is used to indicate the complexity of the image content of the first image frame. For example, the pixel count is used to indicate the number of pixels corresponding to the image content of the first image frame.
[0104] In some embodiments, the image information includes first complexity information, second complexity information, first pixel count information, and second pixel count information. In some embodiments, the image information includes at least one of the first complexity information, second complexity information, first pixel count information, and second pixel count information.
[0105] For example, the first complexity information of the first image frame is used to indicate the complexity of the ROI in the first image frame. For example, the first complexity information is C. roi For example, the first complexity information, namely the encoding complexity of the ROI, measures the richness of detail and encoding difficulty of the video content in that region, directly affecting the bitrate requirement allocated to the ROI. For example, the first complexity information, namely the texture complexity feature of the ROI (Region of Interest), is obtained by calculating the energy of the DCT coefficients of that region.
[0106] For example, the second complexity information of the first image frame is used to indicate the complexity of the ROU in the first image frame. For example, the second complexity information is C. rou For example, the second complexity information, i.e., the encoding complexity of ROU, is similar to that of C. roi These elements complement each other, together forming a comprehensive characterization of the coding complexity of the entire frame and providing a basis for the reasonable allocation of bitrate in the ROU region. For example, the first complexity information, namely the motion characteristics of the non-ROI region, is taken as the average value of the motion vector (MV) amplitude in that region.
[0107] For example, the first pixel count information of the first image frame is used to indicate the number of pixels of the ROI in the first image frame. For example, the first pixel count information is P. roi For example, the first pixel count information, i.e., the number of pixels of the ROI, intuitively reflects the area ratio of the ROI in the entire frame. Combined with encoding complexity, it helps to calculate the bitrate allocation per unit pixel in the ROI. For example, the first pixel count information is the spatial location weight of the ROI, derived from the probability map output by the pre-trained visual saliency model.
[0108] For example, the second pixel count information of the first image frame is used to indicate the number of pixels of ROU in the first image frame. For example, the second pixel count information is P. rou For example, the second pixel count information, i.e., the pixel count of ROU, is related to P. roi Together, they constitute a complete description of the pixel distribution of the entire frame, playing a crucial role in determining the bitrate allocation of a unit pixel in the ROU region. For example, the second pixel number information is a priori spatial distribution of non-ROI regions, calculated based on the geometric position of the intra-coding unit (CU).
[0109] In some embodiments, image information of the first image frame is obtained by performing preprocessing on the first image frame. For example, as shown... Figure 11 The diagram illustrates the entire process of real-time video stream encoding and bitrate control. The process encompasses pre-analysis, the encoding stage, and neural network-driven bitrate control decisions, aiming to achieve precise management of ROI and ROU bitrates while meeting the low latency and high performance requirements of real-time environments.
[0110] In the preliminary analysis stage (including Figure 11 The ROI map generation and pre-analysis process begins with detailed video content analysis to systematically obtain key information about ROIs and ROUs (i.e., image information from the first image frame). Specifically, this includes: 1. Location information: Accurately identifying the positions of ROIs and ROUs in the current frame using visual analysis techniques, clarifying their geometric layout within the image (i.e., obtaining the aforementioned P...). roi and P rou 2. Coding Complexity: Calculate the coding complexity of ROI and ROU separately (i.e., the C above). roi and C rou This typically involves quantizing and evaluating image texture, motion, and edge characteristics to reflect the encoding difficulty of each region. 3. Quantization parameters: Record the quantization parameters used in the encoded frame. These are core variables determining encoding efficiency and video quality, directly affecting the actual number of bits generated (i.e., the QP of the second image frame mentioned above). 4. Actual bit count: Monitor the actual number of bits after encoding each frame (i.e., the bitrate of the second image frame mentioned above). It is closely related to quantization parameters, encoding complexity, and encoding strategy, and is an important basis for evaluating encoding performance and adjusting bitrate control strategies. The above measured data is input into the Rate Control Pool (RCP) model in real time.
[0111] For the first image frame, the encoding complexity of the ROI region is C. roiThis means that the sum of absolute transformation differences (SATD) is calculated after motion compensation during the look-ahead process. This application downsamples and filters the current frame image (i.e., the first image frame) to obtain an image with the original size... Figure 1 A half-resolution low-resolution image is obtained. Half-pixel precision prediction is performed on this low-resolution image, and then the prediction result is subtracted from the original full-resolution image to obtain the residual signal. The residual is then subjected to a Hadamard transform, and the sum of the absolute values is calculated to obtain the SATD. The sum of the SATDs of all pixels within the ROI and ROU regions is C0. roi and C rou The specific calculation formula is as follows:
[0112] C roi =∑SATD roi
[0113] C rou =∑SATD rou
[0114] The size of the ROI region is P, which is the number of pixels within the region. roi Measurement. Accordingly, the encoding complexity of the ROU region is C. rou Its size is P rou express.
[0115] Step 620: Based on the image information and encoding information, predict the bitrate parameter of the first image frame. The bitrate parameter is used to determine the bitrate allocation of the first image frame.
[0116] In some embodiments, the bitrate parameter of the first image frame is predicted based on the image information of the first image frame and the encoding information of the second image frame of the video, wherein the second image frame is located before the first image frame in the video. Optionally, the second image frame is located before the first image frame in the above image frame sequence. For example, if the first image frame is considered to be the image frame to be encoded, then the second image frame here is considered to be the image frame that has already been encoded.
[0117] For example, the bitrate parameter is a parameter related to bitrate allocation. For example, the bitrate parameter directly indicates the allocated bitrate. For example, the bitrate parameter is used to indicate an increase or decrease in bitrate allocation.
[0118] Optionally, the bitrate parameter is used to determine the bitrate allocated to the first image frame. Optionally, the bitrate parameter is used to determine the bitrate allocated to at least one pixel in the first image frame. Optionally, the bitrate parameter is used to determine the bitrate allocated to a first region in the first image frame. Exemplarily, the first region refers to a region in the image frame composed of at least one pixel, also called a pixel region or pixel area. Exemplarily, the number of first regions is one or more.
[0119] In some embodiments, the bitrate parameters include bitrate control parameters. Exemplarily, the bitrate control parameters are used to control the bitrate allocation of the first image frame. Exemplarily, the bitrate control parameters (such as λ) are optimizations used to balance bitrate and distortion. In this case, the bitrate control parameters are similar to a "trade-off coefficient" that determines how the encoder prioritizes video quality over file size during compression. Specifically, the bitrate control parameters are used to determine the QP of the first image frame. Optionally, the bitrate control parameters are used to determine the QP of a first region within the first image frame.
[0120] Optionally, the bitrate parameter is used to control the bitrate allocation of a first region in the first image frame. For example, the first image frame can be divided into multiple regions, each corresponding to a bitrate parameter, with different bitrate parameters for different regions. For example, each region corresponds to a bitrate control parameter, with different bitrate control parameters for different regions. For example, the region division can be based on whether it is of interest to the human eye, dividing it into ROI and ROU. Of course, other division methods can also be used, such as dividing according to a specified block size, or dividing according to a specified position, etc. For example, the first bitrate parameter and the second bitrate parameter mentioned below are merely examples, and this application does not limit the number of bitrate parameters. For example, each divided region corresponds to a bitrate parameter, and the number of bitrate parameters is equal to the number of regions divided in the first image frame. The second image frame in this application is an image frame preceding the first image frame. For example, the second image frame is an image frame that has already been encoded. For example, the second image frame is the previous frame of the first image frame, or the previous N frames (N is an integer greater than 1).
[0121] In some embodiments, the encoding information of the second image frame refers to information obtained during or after the encoding process of the second image frame. This application does not limit the specific type of such encoding information. Exemplarily, the encoding information includes one of the following: bitrate, QP, frame rate, frame type, etc.
[0122] For example, the encoding information includes the bitrate. For example, the bitrate of the second image frame reflects the actual bitrate consumption of the encoder during the encoding process of the second image frame, providing a direct historical reference for the bitrate prediction of the current first image frame. For example, the bitrate, also known as the frame-level bitrate allocation coefficient, is given by the higher-level GOP code control algorithm.
[0123] For example, the encoding information includes QP. For example, the QP of the second image frame reflects the encoder's choice of video quality and bitrate balance during the encoding of the second image frame, providing important clues for predicting the quantization parameters of the current first image frame. The QP of the second image frame is the quantization parameter of the second image frame.
[0124] In some embodiments, the bitrate parameter is used to control the bitrate allocation of a first region in a first image frame, the first region including at least one of the following: Region of Interest (ROI) and Region of Unknown (ROU). Exemplarily, the bitrate parameter is used to control the bitrate allocation of the ROI in the first image frame. Exemplarily, the bitrate parameter is used to control the bitrate allocation of the ROU in the first image frame. Exemplarily, the bitrate parameter is used to control the bitrate allocation of both the ROI and ROU in the first image frame.
[0125] In some embodiments, the bitrate parameter includes a first bitrate parameter and a second bitrate parameter. In some embodiments, the bitrate parameter includes at least one of the first bitrate parameter and the second bitrate parameter. Exemplarily, the first bitrate parameter is used to control the bitrate allocation of the ROI, and the second bitrate parameter is used to control the bitrate allocation of the ROU.
[0126] In some embodiments, the code rate parameter is a Lagrange multiplier λ. Exemplarily, the first code rate parameter is represented by λ. roi This indicates that the second bit rate parameter is represented by λ. rou express.
[0127] In some embodiments, based on the image information of the first image frame and the encoding information of the second image frame of the video, only the first bitrate parameter of the first image frame is predicted.
[0128] In some embodiments, the second bitrate parameter of the first image frame is predicted only based on the image information of the first image frame and the encoding information of the second image frame of the video.
[0129] In some embodiments, a first bitrate parameter and a second bitrate parameter of the first image frame are predicted based on the image information of the first image frame and the encoding information of the second image frame of the video.
[0130] In some embodiments, a first bitrate parameter and a second bitrate parameter of the first image frame are predicted based on the image information of the first image frame and the encoding information of the second image frame of the video.
[0131] In practical video coding applications, bitrate control is deeply integrated with RDO (Rapid Distortion) strategies, such as the RDO formula: J = D + λ·R. When λ is large, bitrate is reduced first (high compression, low quality). When λ is small, distortion is reduced first (high quality, high bitrate).
[0132] For example, for ROI, its corresponding first bitrate parameter is smaller, resulting in a higher bitrate. For ROU, its corresponding second bitrate parameter is larger, resulting in a lower bitrate.
[0133] In this embodiment of the application, the bitrate parameter can be directly predicted, or the change in the bitrate parameter can be predicted.
[0134] The following is a brief explanation of the changes in the predicted bitrate parameter.
[0135] For example, the base bitrate parameter corresponding to the first image frame is obtained. For example, the base bitrate parameter can be a preset parameter, or it can be the calculated initial bitrate parameter corresponding to the first image frame.
[0136] For example, based on the image information of the first image frame and the encoding information of the second image frame of the video, the change in the bitrate parameter of the first image frame is predicted. For example, the change in the bitrate parameter is used to indicate the change relative to the base bitrate parameter (such as the initial λ mentioned below). cu The change in the bitrate parameter (value). For example, the change in the bitrate parameter includes at least one of a first change and a second change. The first change is used to indicate the bitrate parameter of the ROI (i.e., the first bitrate parameter mentioned above) in conjunction with the base bitrate parameter. The second change is used to indicate the bitrate parameter of the ROU (i.e., the second bitrate parameter mentioned above) in conjunction with the base bitrate parameter. For example, the first bitrate parameter equals the base bitrate parameter + the first change. For example, the second bitrate parameter equals the base bitrate parameter + the second change. For example, the change can be a positive or negative number.
[0137] For example, the change in the bitrate parameter of the first image frame is predicted based on the image information of the first image frame, the encoding information of the second image frame, and the base bitrate parameter of the first image frame.
[0138] In this embodiment, a neural network model is introduced to predict the bitrate parameter. The specific model architecture and prediction process are explained in the following embodiments and will not be repeated here.
[0139] In the technical solution provided by this application embodiment, the image information of the first image frame is relatively rich, including at least one of first complexity information, second complexity information, first pixel count information, and second pixel count information. This diverse image information can fully indicate the complexity of the ROI and ROU content, as well as the size of the areas occupied by the ROI and ROU. Based on this, the accuracy of the predicted bitrate parameters can be improved. Furthermore, the bitrate parameters are also divided into first bitrate parameters and second bitrate parameters to respectively control the bitrate allocation for the ROI and ROU, which is beneficial to improving the accuracy of the bitrate allocation control for the ROI and ROU.
[0140] Step 630: Encode the first image frame according to the bit rate parameter.
[0141] In some embodiments, the QP corresponding to ROI and ROU in the first image frame is determined according to the bitrate parameter. Exemplarily, the bitrate parameter includes bitrate parameters (first bitrate parameter and second bitrate parameter) corresponding to ROI and ROU respectively. Exemplarily, each bitrate parameter corresponds to a QP based on a pre-configured encoding table. Exemplarily, the first bitrate parameter corresponds to a first QP, and the second bitrate parameter corresponds to a second QP. Exemplarily, for the i-th patch in the first image frame, if the i-th patch is in an ROI, the i-th patch is encoded using the first QP. Exemplarily, for the i-th patch in the first image frame, if the i-th patch is in an ROU, the i-th patch is encoded using the second QP. In some embodiments, the basic quantization parameter of the first image frame is QP. frame By utilizing λ roi and λ rou Using a pre-configured encoding table, the quantization parameters for the ROI and ROU regions can be determined separately. For example, the QP for the ROI is QP. roi The QP of ROU is QP rou .
[0142] In some embodiments, the QP corresponding to each patch in the first image frame is determined according to the bitrate parameter. For example, the bitrate parameter includes the bitrate parameter corresponding to each patch in the first image frame. For example, for the i-th patch in the first image frame, the QP corresponding to the i-th patch is determined according to the bitrate parameter corresponding to the i-th patch. For example, the i-th patch is encoded using the QP of the i-th patch. i is a positive integer.
[0143] For example, after each tile in the first image frame is encoded, the encoding of the first image frame is completed, and the encoding information of the first image frame is obtained.
[0144] The video encoding process in this embodiment first utilizes millimeter-scale detection for object detection to identify and collect information about the Region of Interest (ROI), thereby obtaining the image information of the first image frame. Secondly, GOP bits are allocated according to a rate control method to ensure consistency with the previous process. Furthermore, the encoded QP and RDO (Rate Distortion Optimization) information for each frame are obtained, and the rate parameters for the ROI and ROU regions are calculated using a subsequent model. The initial λ for each patch within each frame... cu The values can be derived from the r-λ rate control framework described above. However, in order to finely adjust the rate allocation for ROI and ROU regions, this application needs to adjust these basic values to derive the final adjustment parameter λ for each region. roi and λ rouThis customized approach ensures optimal bitrate distribution between regions of interest and non-interest, thereby improving overall perceived quality while maintaining bitrate stability.
[0145] For the specific encoding process, please refer to the explanation of encoding in the above embodiments, which will not be repeated here.
[0146] The technical solution provided in this application predicts the bitrate parameter of a first image frame by acquiring image information of the first image frame and encoding information of the preceding image frame (i.e., the second image frame). This bitrate parameter can control the bitrate allocation of a first region within the first image frame, thereby achieving encoding of the first image frame. On one hand, by using the image content of the first image frame itself as part of the prediction basis for the bitrate parameter, the bitrate of the first region is allocated based on the image content, ensuring that the bitrate allocation result meets the bitrate requirements of the image content. On the other hand, by using the encoding information of the already encoded second image frame as another part of the prediction basis for the bitrate parameter, the problem of bitrate runaway during the encoding process of the first image frame can be avoided, thus achieving control over the size of the output file. Therefore, this application introduces a predicted bitrate parameter, improving the bitrate allocation effect. Furthermore, while improving the bitrate allocation effect, the encoding effect of the image frame is also improved.
[0147] Please refer to Figure 7 The diagram illustrates a flowchart of a video encoding method according to another embodiment of this application, wherein the execution subject of the method may be the first device 210 described above. For ease of explanation, the description focuses on the encoding end device as the execution subject of each step. The method may include at least one of the following steps (710-750).
[0148] Step 710: Obtain the image information of the first image frame of the video and the encoding information of the second image frame of the video. The second image frame is located before the first image frame in the video.
[0149] Step 720: Obtain the bitrate consumption information of the second image frame.
[0150] For example, the status information of the bitrate reservoir is obtained, and the bitrate reservoir is used to indicate the bitrate consumption of the first region in the second image frame. For example, the bitrate consumption information is also the status information of the bitrate reservoir.
[0151] In this embodiment, the bitrate reservoir is used to indicate the bitrate consumption of a first region in a second image frame. Exemplarily, the bitrate reservoir indicates the bitrate consumption of a Region of Interest (ROI) in the second image frame. Exemplarily, the bitrate reservoir indicates the bitrate consumption of a Region of Unknown Origin (ROU) in the second image frame. Exemplarily, the bitrate reservoir indicates the bitrate consumption of both ROI and ROU in the second image frame simultaneously. Exemplarily, the term "second image frame" should be interpreted broadly and does not necessarily refer to a single image frame; it could also refer to the bitrate consumption of the first region reflected in multiple image frames preceding the first image frame.
[0152] In some embodiments, the bitrate reservoir is such as Figure 9 As shown in 900. The bitrate reservoir in this application is also called the ROI bitrate reservoir, ROI reservoir model, or ROI reservoir, or reservoir. This application establishes a dedicated ROI bitrate reservoir to indicate the bitrate consumption of the ROI region and the ROU region.
[0153] like Figure 9 As shown, the bitrate reservoir operates independently of the reservoir used by the original codec bitrate control mechanism. In this application, as more bits are allocated to the ROI, the bitrate ΔR increases. i As the number of bits consumed by the ROU increases, the water level in the ROI reservoir rises accordingly. Conversely, when the number of bits consumed by the ROU region ΔR... u When the ROI is reduced, the water level in the ROI reservoir drops.
[0154] The following is a further explanation of how the ROI reservoir model is implemented.
[0155] First, we can use a conceptual analogy to understand the ROI reservoir. Imagine the ROI reservoir as a real water tank. Bits are like water, and the bit rate ΔR... i It refers to the water flow rate into the pool, and ΔR corresponds to the number of bits consumed in the ROU region. u It's similar to the speed at which water is drained from a pool.
[0156] Secondly, bit allocation and water level increase. In video coding, the Region of Interest (ROI) is the key area of focus and requires high-quality encoding. When the algorithm decides to allocate more bits to the ROI region, i.e., ΔR... i Increasing the amount of resources is like filling a reservoir faster; the water level in the reservoir will rise accordingly. This means that the Region of Interest (ROI) can receive more coding resources, thereby improving the coding quality of that region.
[0157] Furthermore, the ROU region affects the water level drop. ROUs are regions with relatively low coding quality requirements. When the number of bits consumed by the ROU region (ΔR) decreases... uWhen the amount of data decreases, it's equivalent to a slower flow of water from the reservoir (or a return flow to the ROI reservoir), causing the water level in the ROI reservoir to drop. At this point, bits of resources need to be saved from the ROU region and reallocated to the ROI region.
[0158] In some embodiments, bit detection is performed first. The encoder monitors in real time the number of bits ΔR allocated to the ROI region. i And the number of bits consumed in the ROU region ΔR u This requires precise statistics and recording of bit usage in different regions during the encoding process. Secondly, water level calculation and updating are performed. Based on the monitored ΔR... i and ΔR u The water level change in the ROI reservoir is calculated using a specific mathematical model. For example, an initial water level can be set, and then the change is calculated each time based on ΔR over a unit of time. i and ΔR u The difference between the ROI and RUI (Reservoir Area) water levels is used to update the water level. A positive difference causes the water level to rise, while a negative difference causes it to fall. Finally, feedback adjustment is performed. The water level information of the ROI is fed back to the bitrate control module. When the water level rises to a certain threshold, it indicates that the ROI region has acquired sufficient bit resources, and the bit allocation to the ROI region can be appropriately reduced. When the water level drops to a certain level, it indicates that the ROI region lacks sufficient bit resources, requiring further saving of bits from the RUI region or a readjustment of the bit allocation strategy to increase the bit supply to the ROI region.
[0159] The technical solution provided in this application introduces a bitrate reservoir to predict bitrate parameters. The bitrate consumption of ROI and ROU in the encoded image frame is used as a priori to guide the bitrate allocation of ROI and ROU in the current frame, which helps to improve the accuracy of the predicted bitrate parameters.
[0160] In some embodiments, the bitrate consumption information includes a bitrate cap, which is used to indicate that the bitrate consumption of the ROI in the second image frame has reached the bitrate cap.
[0161] In some embodiments, when the water level in the bitrate reservoir reaches the overflow bitrate of the bitrate reservoir, the status information of the bitrate reservoir includes the overflow bitrate, which is the upper limit of the bitrate of the bitrate reservoir.
[0162] In some embodiments, the overflow rate is represented by R. over This refers to the overflow bitrate (also known as the bitrate cap), which is the maximum bitrate allowed by the bitrate control reservoir. When the actual bitrate exceeds this threshold, it indicates that the encoder may face the risk of bitrate runaway, requiring adjustments to the bitrate allocation of the current frame. In some embodiments, the overflow bitrate is also called the bitrate overrun compensation factor, which is dynamically adjusted based on the buffer state.
[0163] For example, when the water level in the bitrate reservoir reaches the overflow bitrate of the bitrate reservoir, step 720 is executed. For example, step 720 at this time is implemented to obtain the overflow bitrate. For example, the bitrate parameter of the first image frame is predicted based on the image information of the first image frame, the overflow bitrate of the bitrate reservoir, and the encoding information of the second image frame. For example, the bitrate parameter is predicted based on the image information, bitrate consumption information, and encoding information.
[0164] For example, the image information of the first image frame, the state information of the bitrate reservoir, and the encoding information of the second image frame are input into the convolutional neural network model to obtain the bitrate parameters of the first image frame output by the convolutional network model.
[0165] In some embodiments, steps 720 and 730 may both be performed, or one may be performed selectively; this application does not limit this.
[0166] In some embodiments, the overflow code rate is a preset value. For example, the overflow code rate is a fixed value.
[0167] In some embodiments, the buffer is not limited until it is full, at which point it affects the model. (Using R...) over (Overflow Bitrate) indicates the maximum bitrate limit set by the bitrate control reservoir. This limit is used to determine if the actual bitrate is too high. When the actual bitrate exceeds this threshold, it alerts the encoder that there may be a risk of bitrate runaway and that the bitrate allocation strategy needs adjustment. It focuses on controlling the upper limit of the bitrate. R over This is a preset fixed overflow threshold parameter. After the water level in the reservoir is updated, if it reaches or exceeds R... over If the condition is met, it will be used as one of the input parameters of the convolutional neural network model; otherwise, it will not be input.
[0168] The technical solution provided in this application only uses the overflow bitrate as one of the prediction criteria for bitrate parameters (one of the model's input parameters) when the buffer reaches its bitrate limit, i.e., the water level in the bitrate reservoir reaches the overflow bitrate. If the actual bitrate is determined to be too high, i.e., exceeding this threshold, it indicates a potential risk of bitrate runaway, requiring adjustment of the bitrate allocation strategy. Therefore, using the overflow bitrate as the prediction criterion for bitrate parameters helps reduce the risk of bitrate runaway while predicting the bitrate parameters.
[0169] Step 730: Obtain the quality enhancement factor of the first image frame.
[0170] For example, a quality enhancement factor is used to indicate the degree of enhancement for ROI bitrate allocation.
[0171] In some embodiments, the quality enhancement factor is K. roi The ROI quality enhancement factor is a user-defined parameter that indicates the required improvement in encoding quality for the ROI region, directly affecting λ. roi The value of K. roi It can also be the shape description parameters of the ROI, generated through contour curvature analysis.
[0172] K roi The value depends on the input definition required by the actual coding scenario; it can be a fixed value or it can change dynamically.
[0173] Fixed value case: If the encoding scene has relatively stable quality requirements for the ROI region, which do not change with frame variations, such as in some scenarios where the key ROI is always required to reach a certain fixed resolution standard, then K roi It can be preset to a fixed value, and this fixed value is used in every frame to enhance the quality of the ROI region.
[0174] Dynamic changes: If the encoding scene is complex, the quality requirements for the ROI region vary across different frames. For example, in a movie, different scenes require different levels of attention and quality in their key areas. In this case, K... roi It will dynamically adjust according to the specific needs of each frame to meet diverse encoding quality requirements.
[0175] Of course, a quality decay factor K can also be preset for ROU. rou The ROU quality degradation factor, also a user-defined parameter, indicates the required reduction in encoding quality for the ROU region and directly affects λ. rou The value of . For example, the quality decay factor K rou It can also be used as part of the basis for predicting the bit rate parameter, that is, as part of the input information for the following convolutional neural network model.
[0176] The technical solution provided in this application introduces a quality enhancement factor as one of the prediction criteria for bitrate parameters, which helps to improve the prediction accuracy of bitrate parameters. This quality enhancement factor, to a certain extent, indicates the degree of enhancement in bitrate allocation for the Region of Interest (ROI). By intervening in the predicted bitrate parameters through the quality enhancement factor, the bitrate allocation for the ROI is enhanced. Furthermore, the quality enhancement factor can be fixed or dynamically changing, reflecting the diversity and flexibility of the method for determining the quality enhancement factor, and can meet the needs of different scenarios.
[0177] Step 740: Predict the bitrate parameters based on image information, bitrate consumption information, quality enhancement factor, and encoding information.
[0178] In some embodiments, if only step 730 is performed and step 720 is not performed, step 740 may be implemented as: predicting the bitrate parameter based on image information, quality enhancement factor and coding information.
[0179] In some embodiments, if only step 720 is performed without step 730, step 740 can be implemented as: predicting the bitrate parameter based on the image information, bitrate consumption information, and encoding information. Specifically, step 740 can be implemented as: predicting the bitrate parameter based on the image information, the bitrate cap, and the encoding information.
[0180] In some embodiments, the image information of the first image frame, the state information of the bitrate reservoir, the quality enhancement factor, and the encoding information of the second image frame are input into the convolutional neural network model to obtain the bitrate parameters of the first image frame output by the convolutional network model.
[0181] In some embodiments, the bitrate parameter of the first image frame is output by a convolutional neural network model, and the input information of the convolutional neural network model includes the image information of the first image frame and the encoding information of the second image frame. Exemplarily, the input information of the convolutional neural network model also includes the state information of the bitrate reservoir and the quality enhancement factor.
[0182] CNN-based λ cu Value inference (i.e., the bitrate parameter mentioned above) is the first step in ROI bitrate control. This application fully utilizes known video content features and deep learning techniques to construct a CNN model to accurately estimate the λ of ROI and ROU. cu The model's design and training primarily focus on the following aspects: Model Architecture: A multi-layer convolutional structure is adopted, including several convolutional layers, pooling layers, normalization layers, and fully connected layers, to fully extract and integrate multi-dimensional features such as local texture, color, edge, and motion characteristics of the CU. Furthermore, to adapt to CUs of different scales and complexities, this application introduces a multi-scale feature fusion and attention mechanism to enhance the model's adaptability to complex scenes and its sensitivity to the ROI. Feature Input: The model's input includes not only raw pixel values but also contextual information provided by the encoder, such as prediction patterns, residual signals, and motion vectors. This information helps the model understand the encoding complexity of the CU and its relationship with the surrounding environment, thereby more accurately predicting the required λ. cu Value. Objective function and training: using the measured optimal λ. cu The model is trained end-to-end using backpropagation, with the measured values serving as the supervisory signal and evaluation metrics such as MSE or SSIM as the loss function. Furthermore, to prevent overfitting, this application implements data augmentation, early stopping, and regularization strategies, and employs cross-validation to ensure the model's generalization ability.
[0183] In some embodiments, the convolutional neural network model includes: a first hidden layer, a second hidden layer, and a decoding layer; the first hidden layer is used to extract features related to bitrate allocation from the input information to obtain first feature information; the second hidden layer is used to reduce the dimension of the feature space of the first feature information to obtain second feature information; the decoding layer is used to decode the second feature information to obtain an output result, the output result including bitrate parameters.
[0184] This application proposes a ROI bitrate control strategy based on a shallow four-layer neural network, which fully considers the specific requirements for encoding speed of each frame in a real-time live streaming environment. To achieve precise control of the bitrate allocation between ROI and ROU regions, the following input parameters are included: image information of the first image frame (including C... roi C rou P roi P rou ), the encoding information of the second image frame (R) frame-1 QP frame-1 Overflow rate (R) over ), quality enhancement factor (K) roi ).
[0185] In terms of neural network architecture design, the convolutional neural network model in this application adopts a shallow structure containing two hidden layers. The first hidden layer (e.g., Figure 10 The first hidden layer (1010) contains 52 intermediate feature nodes, aiming to extract high-level features closely related to ROI and ROU code rate allocation from the input variables through nonlinear transformation. The second hidden layer (such as...) Figure 10 The second hidden layer (1020) further refines these features, containing 36 intermediate feature nodes, aiming to improve the model's generalization ability and prediction stability by reducing the dimensionality of the feature space. Finally, the network output layer (equivalent to the decoding layer) contains two nodes, corresponding to the predicted λ. roi and λ rou These two values, as important parameters for bitrate control, will guide the setting of quantization parameters during the actual encoding process, thereby achieving fine-grained control of the bitrate of the ROI and ROU regions. The shallow four-layer neural network model proposed in this application, through a carefully designed set of input variables and a reasonable network architecture, successfully captures the key factors affecting the bitrate allocation of ROI and ROU, providing a powerful tool for achieving accurate and efficient ROI bitrate control in real-time live streaming environments.
[0186] This application proposes a CNN model-driven bitrate control decision: It employs a specially trained convolutional neural network (CNN) model to predict bitrate parameters that distinguish between the Region of Interest (ROI) and the Region of Unknown (ROU). The core functions of this model include: 1. Input processing: fusing reservoir state information, ROI, and ROU features to form a high-dimensional feature vector suitable for CNN model processing. 2. Feature learning: utilizing the multi-layer convolution and pooling operations of the CNN, automatically extracting deep features highly correlated with bitrate control from the input features, such as local texture patterns, spatial relationships, and temporal series variations. 3. Bitrate parameter prediction: the last layer of the model performs a classification or regression task, outputting the bitrate parameter λ for the ROI and ROU. roi and λ rou These two parameters determine the relative bitrate weight that each region should be assigned when encoding the next frame.
[0187] The proposed convolutional neural network model is based on a multi-layer convolutional structure and includes the following core components: Convolutional layers: Extracting local texture, edge, and motion features through multiple levels of 3×3 or 1×1 convolutional kernels. Shallow convolutions focus on fine-grained details (such as color gradients), while deep convolutions capture abstract semantics (such as motion vector correlations). Pooling layers: Interspersed between convolutional layers, using max pooling to achieve feature dimensionality reduction, enhance translation invariance, and reduce computational cost. Normalization layers: Employing batch normalization to stabilize the training process and mitigate abnormal gradient fluctuations. Multi-scale feature fusion: Dynamically fusing feature maps from different levels (such as high-resolution shallow features and deep semantic features) through skip connections (such as residual structures) or channel concatenation to adapt to the scale diversity of the CU. Attention mechanism: Inserting channel / spatial attention modules at key levels to enhance the sensitivity of the ROI region through feature weight recalibration and suppress irrelevant background interference.
[0188] For example, such as Figure 10 The 52-node and 36-node layers, as labeled, correspond to the dimensions of the fully connected layers. The 52-node layer receives multi-scale fusion features (such as local statistics like first and second complexity information) from the convolutional backbone and performs high-order nonlinear transformations. The 36-node layer, as a hidden layer, further compresses information and interacts cross-modal with contextual features (encoder metadata such as encoding information from the second image frame) to generate latent representations.
[0189] P at the input terminal roi K roi Features are injected into the network through parallel branches, extracted through independent convolutional paths, and then concatenated at intermediate node layers to achieve multi-source information complementarity.
[0190] For example, the convolutional neural network model in this application uses MSE as the main loss term to constrain λ. cuThe numerical accuracy is improved by combining SSIM as an auxiliary loss to enhance the structural consistency of the predicted values. For example, the convolutional neural network model in this application employs L2 weight decay (λ = 1e-4) and random dropout (Dropout rate 0.5) to prevent overfitting, and data augmentation includes random pruning and motion blur simulation. For example, the convolutional neural network model in this application uses the AdamW optimizer (initial learning rate 3e-4, cosine annealing scheduling), filters hyperparameters through five-fold cross-validation, and determines the validation set loss plateau through an early stopping mechanism.
[0191] This application achieves a balance between computational efficiency and prediction accuracy through implicit hierarchical partitioning and explicit feature routing, ultimately realizing end-to-end λ-multiplexing. cu Adaptive prediction.
[0192] The technical solution provided in this application introduces a convolutional neural network (CNN) model to predict the bitrate parameter. By fully understanding the image information of the first image frame and the encoding information of the second image frame through the CNN model, the prediction accuracy of the CNN model for the bitrate parameter can be improved. Furthermore, directly predicting the bitrate parameter through the CNN model can also improve the prediction efficiency of the bitrate parameter.
[0193] In some embodiments, the training process of a convolutional neural network model is as follows.
[0194] Step 1: Obtain at least one set of training samples. The training samples include sample image information of sample image frames, sample encoding information of image frames located before the sample image frames in the sample video, and label bitrate parameters of the sample image frames. The label bitrate parameters are used to determine the bitrate allocation of the sample image frames.
[0195] For example, at least one set of training samples is obtained. The training samples include sample image information of the sample image frame, sample encoding information of the image frame preceding the sample image frame, and label bitrate parameters of the sample image frame. The sample image information is used to indicate the image content of the sample image frame, and the label bitrate parameters are used to control the bitrate allocation of the first region in the sample image frame.
[0196] For example, as described in the above embodiments, the training samples also include at least one of the quality enhancement factor of the sample image frame and the overflow bit rate of the bit rate reservoir.
[0197] For example, the sample image information of the sample image frame includes first complexity information, second sample complexity information, first sample pixel count information, and second sample pixel count information.
[0198] For example, the sample encoding information of the image frames preceding the sample image frame includes the bitrate and QP of the image frames preceding the sample image frame. For example, the image frames preceding the sample image frame include the image frame before the sample image frame.
[0199] Step 2: Input the sample image information and sample encoding information into the convolutional neural network model to obtain the predicted bit rate parameters output by the convolutional neural network model.
[0200] For example, the predicted bitrate parameter is the bitrate parameter predicted by the convolutional neural network model for the sample image frame.
[0201] Step 3: Train the convolutional neural network model based on the difference between the predicted bitrate parameter and the label bitrate parameter.
[0202] For example, a loss function is determined based on the difference between the predicted bitrate parameter and the label bitrate parameter. For example, the parameters of the convolutional neural network model are adjusted with the goal of minimizing the loss function to obtain the trained convolutional neural network model. For example, the loss function is at least one of MSE and SSIM.
[0203] This application constructs a high-quality training dataset to improve the generalization ability and prediction accuracy of CNN models. This application describes the entire process of real-time video stream encoding and bitrate control, and conducts subjective and objective experimental verification (see the embodiments below). Experimental results confirm that the CRF-ROI encoding strategy can improve the visual quality of the ROI region while maintaining the stability of the overall video quality.
[0204] The construction of the training dataset in this application is crucial for effective CNN model training. High-quality, representative training datasets are indispensable. Therefore, this application follows these principles in constructing the dataset: Sample diversity: Source videos covering various content types, such as news reports, movie clips, sports events, and natural scenery, are collected to ensure the model can handle diverse visual scenes and coding challenges. Simultaneously, each video clip is manually annotated, clearly identifying the ROI and ROU, providing the model with accurate supervision information. Bitrate coverage: Encoded versions at different bitrate levels are generated to simulate various bitrate requirements in real-world applications. This helps the model learn to adjust λ under different bitrate constraints. cu To optimize ROI quality.
[0205] Dynamic Range and Quality Gradient: During the encoding process, a series of QP values are manually set to generate CU samples with different levels of quantization distortion. This allows the model to experience a complete quality gradient from near-lossless to severely distorted during training, thus better simulating the decision-making requirements of actual encoding. Label Generation: For each CU sample, an optimization algorithm (such as genetic algorithm, particle swarm optimization, etc.) is used to find its optimal λ under the current bitrate constraint. cu The value is used as the label for model training. This process is usually carried out offline to ensure that the model "sees" the ideal λ value during the training phase. cu Allocation. Through the above two steps, this application constructs a CNN-based bitrate control framework that can accurately allocate a suitable λ to each CU during HEVC encoding. cu This method optimizes the ROI quality without sacrificing overall bitrate stability. Experimental results show that this method significantly outperforms traditional bitrate control strategies in both subjective visual quality and objective evaluation metrics, providing strong support for further optimization of HEVC encoding technology.
[0206] In some embodiments, the acquisition of training samples is explained as follows: The label bitrate parameter includes a first label bitrate parameter and a second label bitrate parameter. The first label bitrate parameter is the label value of the first bitrate parameter, and the second label bitrate parameter is the label value of the second bitrate parameter. Correspondingly, the prediction bitrate parameter includes a first prediction bitrate parameter and a second prediction bitrate parameter. The first prediction bitrate parameter is the predicted value of the first bitrate parameter, and the second prediction bitrate parameter is the predicted value of the second bitrate parameter.
[0207] For example, the process of obtaining the tag bitrate parameter includes the following steps.
[0208] First round of encoding: For the sample image frame, select the first sample QP, perform the first round of encoding on the sample image frame, and obtain the first tag code rate parameter.
[0209] For example, for a sample image frame, a first sample QP is selected, and a first round of encoding is performed on the sample image frame to obtain the first tag bitrate parameter of the sample image frame. The first tag bitrate parameter is used to control the bitrate allocation of ROI in the sample image frame.
[0210] For example, the first tag bitrate parameter and the second tag bitrate parameter are used to determine the bitrate allocation of different regions in the sample image frame.
[0211] For example, the first sample QP is any QP value within the allowed range of encoding.
[0212] Second round of encoding: For the sample image frame, select the second sample QP, combine it with the first tag bitrate parameter, and perform the second round of encoding on the sample image frame to obtain the second tag bitrate parameter.
[0213] For example, for a sample image frame, a second sample QP is selected, and combined with the first tag bitrate parameter, a second round of encoding is performed on the sample image frame to obtain the second tag bitrate parameter of the sample image frame. The second tag bitrate parameter is used to control the bitrate allocation of ROUs in the sample image frame.
[0214] For example, the second sample QP is any QP value within the allowed range of encoding.
[0215] like Figure 12 As shown, this application proposes a dataset construction scheme to support the training of the proposed neural network model. Figure 12 As shown, the process consists of the following main steps, covering quantization parameter range setting, ROI detection and storage, video encoding and data acquisition, and full-range QPs data generation, aiming to generate a high-quality dataset that can fully reflect the complexity of the encoding process and effectively train the model.
[0216] 1. Quantization Parameter Range Setting. The quantization parameter (QP) is a core parameter in video coding, directly affecting coding quality and bitrate. For real-time streaming applications, this application first defines a QP range [QP...]. min QP max This ensures that appropriate QP values are covered for all videos to be encoded. Considering the general application of the HEVC standard without particular concern for subjective video quality, this application directly selects the entire QP range [0, 51] allowed by the standard. This setting takes into account both coding efficiency and ensures that the model is exposed to a wide range of coding conditions during training, thereby improving generalization ability.
[0217] 2. ROI Detection and Storage. Utilizing the advanced computer vision tool mm-detection, this application performs automatic detection and storage of Regions of Interest (ROIs) during the preprocessing stage of the training video dataset. mm-detection can accurately identify faces, bodies, specific objects, and visually significant scene regions in video frames. This process not only reduces the workload of manual annotation but also ensures the consistency and accuracy of ROI information. The detection results are stored in the form of ROI maps, providing a foundation for subsequent coding experiments and data collection.
[0218] 3. Video Encoding and Data Acquisition. Within the defined QP range, this application encodes each selected QP value. i Two rounds of coding experiments were conducted. The first round of coding (e.g.) Figure 12The first round of encoding (1210) focuses on obtaining the λ of the ROI region. roi Data is a crucial metric for measuring ROI encoding complexity and bitrate allocation. Subsequently, this application fixes the ROI region λ obtained from the first round of encoding. roi The value is used for a second round of encoding. Figure 12 In the second round of coding 1220), the QP value is changed to QP. j The range also extends from QP min To QP max The purpose of the second round of encoding is to collect the λ values of the ROU region. rou The data is used to comprehensively depict the bitrate control status of the entire video frame. Simultaneously, this application records a series of input variables closely related to the encoding process, such as the bitrate difference between the current frame and the previous frame, and the bitrate overload condition R. over The average quantization unit parameter λ of the ROI and ROU regions cu Coding complexity C roi C rou Pixel density P roi P rou And the QP value of the previous frame. frame These rich encoding environment information, along with the encoded λ, roi and λ rou These together constitute the input features of the neural network model.
[0219] 4. Full-range QP data generation. To fully expose the model to various encoding conditions, this application generates full-range QP data for each video in the dataset (from QP...). min To QP max The encoding and data acquisition process described above is repeated for all possible QP values. In this way, a comprehensive training dataset is generated, containing a variety of encoding configurations, a wide range of content types, and complexity levels, ensuring that the model can fully learn the complex relationship between bitrate parameters and encoding performance under different conditions during training.
[0220] 5. Data Preparation and Cleaning. To ensure the quality and consistency of the training data, this application adopted a series of rigorous measures in the data preparation stage.
[0221] First, this application segments the training video into independent scenes containing only one I-frame (intra frame), avoiding the changes in encoding complexity and bitrate fluctuations that may occur due to multiple I-frame scenes, thus affecting the stability and comparability of the data. Second, this application rigorously screens the collected training data, removing any samples with QP values exceeding a preset range in the ROI or ROU regions, ensuring that all encoded instances in the dataset conform to encoding specifications and model training requirements.
[0222] 6. Final Dataset and Model Performance. After careful data preparation and cleaning, this application ultimately produced a high-quality training dataset containing 42,000 video samples. These videos cover a wide range of common real-time streaming scenarios, including video games, sports events, television programs, news reports, movies, and TV series, helping the model learn a broad range of content characteristics and encoding requirements during training. The neural network model trained on this dataset demonstrated excellent performance on the test set, achieving an accuracy of 92%, validating the effectiveness of the dataset construction strategy presented in this application.
[0223] 7. Model Structure Optimization and Feature Impact Analysis. To further improve model performance, this application optimizes the model structure. This application introduces the Huber loss function as a regression constraint. This function combines the advantages of mean squared error loss and smoothed absolute error loss, providing more robust gradients when facing outliers and isolated points, which is beneficial for better model convergence during training.
[0224] Furthermore, this application also employs pairwise ranking loss to enhance the model's performance on λ. roi and λ rou The constraint of the value relative to the upper and lower bounds of QP ensures that the bitrate parameter predicted by the model is always within a reasonable range. Regarding feature selection, this application conducted experimental explorations, examining the impact of potential influencing factors such as video resolution and frame rate on the model's prediction accuracy. However, empirical results show that including these features did not significantly improve the model's prediction performance. This indicates that, for the neural network model of this application, the selected encoding process-related variables are sufficient to characterize the essence of the bitrate control problem, while the basic attributes of the video (such as resolution and frame rate) have a relatively small impact on the prediction results under the current model architecture. This finding helps simplify the model's input features, reduce computational complexity, and focus on the key factors of the encoding process itself, ensuring the model's efficient operation in real-time streaming applications.
[0225] The use of two rounds of encoding for sample acquisition instead of a single round is primarily to obtain more accurate and comprehensive bitrate control data for different regions (ROI and ROU), thereby better training the neural network model. The specific reasons are as follows: 1. Separating ROI and ROU data: In video encoding, the encoding requirements and importance of ROI and ROU regions differ. The first round of encoding focuses on obtaining the bitrate parameters of the ROI region, allowing for precise measurement of its encoding complexity and bitrate allocation. With only one round of encoding, it's difficult to accurately obtain relevant data for the ROI region while simultaneously considering both. The second round of encoding, after fixing the bitrate parameters of the ROI region obtained in the first round, aims to collect the bitrate parameters of the ROU region. This allows for a focus on the bitrate control of the ROU region while maintaining a relatively stable bitrate allocation in the ROI region, avoiding interference from changes in the ROI region on ROU data acquisition, and thus more accurately obtaining bitrate control information for the ROU region under different quantization parameters (QP). 2. Improving data quality and model training effectiveness: Two rounds of encoding allow for more detailed control of variables during the encoding process. By first determining the bitrate parameters for the Region of Interest (ROI), and then encoding and collecting data for the Region of Unknown Areas (ROU) under different QP values, richer and more representative training data can be generated. This data covers the different regions under different encoding conditions, helping the neural network model learn more complex bitrate control relationships. Using a single round of encoding may lead to data confusion and inaccuracies, making it difficult to clearly separate the individual effects of ROI and ROU regions on bitrate control. Such imprecise data may result in poor model performance, hindering accurate bitrate control in practical applications. A single round of encoding makes it difficult to achieve fine-grained management of bitrate allocation for ROI and ROU regions, failing to meet the stringent requirements for latency control, performance optimization, and bitrate stability in demanding real-time video streaming environments.
[0226] like Figure 12 As shown, K roi =QP i -QP j In video coding, QP (quantization parameter) directly affects coding quality and bitrate. Here, K... roi It is defined as the target quality enhancement factor of ROI (Region of Interest).
[0227] Quantization of Quality Enhancement: In video coding, different QP values correspond to different levels of coding fineness, and changes in the QP value reflect changes in coding quality. This is achieved by calculating two QP values (QP...). j and QP iThe difference between QP and QP (Quickness Points) can quantify the degree of enhancement in the coding quality of the ROI region. For example, in multi-round coding experiments, changing the QP value to explore the impact of different coding conditions on the ROI region, this difference can clearly reflect the improvement in coding quality relative to a certain baseline QP. i Another QP (QP j The magnitude of the improvement or decrease in ROI region quality under different conditions provides effective data for the model to learn the relationship between ROI region quality and bitrate control.
[0228] Adapting to bitrate control requirements: In actual bitrate control, the encoding quality needs to be dynamically adjusted based on the importance of the ROI region. roi It can serve as an indicator to help determine whether the ROI region achieves the expected quality enhancement effect under different QP settings, thereby providing a reference for subsequent bitrate allocation strategies to meet the high-quality requirements of key regions (ROI) in real-time video streams.
[0229] like Figure 12 As shown, R over =max(R) frame )-R′ frame , where R over R′ represents the overflow bit rate. frame Indicates the use of QP i The actual frame bitrate during encoding. A measure of bitrate fluctuation: R frame Represents the actual frame rate, max(R) frame The maximum frame rate (Rmax) is the maximum value under certain conditions (such as a specific encoding configuration or within a dataset range). In real-time video streaming encoding, bitrate fluctuations can affect the stability and quality of video playback. This is achieved by calculating max(Rmax). frame )-R′ frame This can be used to measure the difference between the current frame bitrate and the maximum allowed bitrate, i.e., to determine whether there is a bitrate overflow. If the difference is positive and large, it means that the current frame bitrate is relatively low and there is room for improvement; if the difference is close to 0 or negative, it means that there may be a risk of bitrate overflow, and the encoding parameters need to be adjusted.
[0230] Stable bitrate output: In bitrate control mechanisms such as the reservoir model, it is necessary to monitor bitrate overflow to smooth bitrate fluctuations. Rover helps determine the bitrate status after encoding the current frame, so as to adjust the bitrate allocation strategy for the next frame in a timely manner, maintain a constant bitrate output for the video stream, avoid playback stuttering or sudden changes in image quality, and improve the user viewing experience. At the same time, during model training, this metric allows the model to learn bitrate overflow-related features, thereby making better bitrate control decisions in practical applications.
[0231] The following describes how to adjust the bitrate parameter.
[0232] In some embodiments, the bitrate parameters are adjusted according to the status information of the bitrate reservoir to obtain the adjusted bitrate parameters. The bitrate reservoir is used to indicate the bitrate consumption of the first region in the second image frame, and the adjusted bitrate parameters are used to encode the first image frame.
[0233] In some embodiments, the bitrate parameter is adjusted according to the bitrate consumption information of the second image frame to obtain the adjusted bitrate parameter, which is then used to encode the first image frame.
[0234] For example, the first image frame is encoded according to the adjusted bitrate parameters. For example, the first image frame is encoded according to the adjusted first bitrate parameters and second bitrate parameters. For example, the bitrate parameters need further adjustment.
[0235] For example, the status information of the bitrate reservoir can reflect the water level of the bitrate reservoir.
[0236] In some embodiments, when the status information of the bitrate reservoir indicates that the water level of the bitrate reservoir is greater than or equal to the overflow bitrate of the bitrate reservoir, the first bitrate parameter in the bitrate parameters is adjusted to obtain the adjusted first bitrate parameter. For example, when the bitrate consumption information indicates that the bitrate consumption of the ROI in the second image frame is greater than or equal to the upper bitrate limit, the first bitrate parameter in the bitrate parameters is adjusted to obtain the adjusted first bitrate parameter.
[0237] In some embodiments, when the status information of the bitrate reservoir indicates that the water level in the bitrate reservoir is less than the overflow bitrate, the second bitrate parameter in the bitrate parameters is adjusted to obtain the adjusted second bitrate parameter. For example, when the bitrate consumption information indicates that the bitrate consumption of the ROI in the second image frame is less than the upper bitrate limit, the second bitrate parameter in the bitrate parameters is adjusted to obtain the adjusted second bitrate parameter.
[0238] In some embodiments, the first bitrate parameter and the second bitrate parameter are used to determine the bitrate allocation of different regions in the first image frame.
[0239] In some embodiments, the first bitrate parameter is used to control the bitrate allocation of the ROI, the second bitrate parameter is used to control the bitrate allocation of the ROU, and the overflow bitrate is the upper limit of the bitrate reservoir.
[0240] When the bitrate consumption information indicates that the bitrate consumption is less than the upper limit of the bitrate and the bitrate consumption is less than the first threshold, the increment of the second bitrate parameter is decreased to obtain the adjusted second bitrate parameter; when the bitrate consumption information indicates that the bitrate consumption is less than the overflow bitrate and the bitrate consumption is greater than the second threshold, the increment of the second bitrate parameter is increased to obtain the adjusted second bitrate parameter; wherein, the first threshold is less than or equal to the second threshold.
[0241] When the status information of the bitrate reservoir indicates that the water level in the reservoir is less than the overflow bitrate, there are two adjustment methods. First, if the status information indicates that the water level in the bitrate reservoir is less than the overflow bitrate and the water level is less than the first threshold (low water level), decrease the increment of the second bitrate parameter to obtain the adjusted second bitrate parameter. Second, if the status information indicates that the water level in the bitrate reservoir is less than the overflow bitrate and the water level is greater than the second threshold (high water level), increase the increment of the second bitrate parameter to obtain the adjusted second bitrate parameter. Wherein, the first threshold is less than or equal to the second threshold.
[0242] In the technical solution provided in this application embodiment, when the water storage tank has not yet reached the overflow rate (also known as the overflow threshold) R over At that time, only λ is adjusted. rou This is sufficient to ensure that the overall bitrate increase remains within an acceptable range. When the reservoir level is low, λ should be appropriately reduced. rou The increment should be adjusted to ensure the reservoir consumes code at a stable rate; conversely, when the water level rises, λ should be increased proportionally. rou The increment is used to accelerate the continuous outflow of coding rate from the reservoir.
[0243] In some embodiments, the increment refers to the adjustment range (step size). For example: Decrease the increment: reduce λ by a smaller step size. rou (e.g., λ) rou =λ rou -0.1), slowing down bitrate leakage. Increase increment: increase λ with larger step sizes. rou (e.g., λ) rou =λ rou +0.3), accelerating bitrate consumption. The purpose of this adjustment is to precisely control the rate of change of the water level in the reservoir.
[0244] In some embodiments, if the water storage tank exceeds the overflow value R over Then the effect on λ should be reduced. roi Adjustments are made to reduce the bitrate flowing into the reservoir, helping to keep it below the overflow threshold. For ROI(λ) roi ) and ROU(λ rou The intensity of the λ adjustment depends on the state of the ROI reservoir. A smaller λ value means that the CU is more likely to be divided into smaller blocks, resulting in smaller calculated quantization parameters and increased bitrate consumption in the corresponding areas.
[0245] The high and low water levels of the reservoir model are explained further here.
[0246] The ROI (Region of Interest) reservoir can be viewed as a container for storing and regulating bitrate. The level of the reservoir reflects the sufficiency of bitrate resources within the ROI. A low level indicates relatively scarce bitrate resources, while a high level indicates relatively abundant bitrate resources. rou With bitrate consumption: λ rou λ is a key parameter in bitrate control, as it relates to the bitrate consumption of the ROU region. rou The incremental changes will directly affect the speed at which the ROU region consumes bitrate.
[0247] Explanation of low water level: When the water level in the reservoir is low, it means that there are few available bitrate resources in the ROI area. In this case, if λ rou Excessive increments will cause the ROU region to rapidly consume a large amount of bitrate. Rapid bitrate consumption in the ROU region may further deplete already scarce bitrate resources from the ROI region, compromising the encoding quality of the ROI region. Therefore, λ should be appropriately reduced. rou The incremental increase slows down the rate of bitrate consumption in the ROU area, ensuring that the reservoir (i.e., the overall bitrate allocation system) can consume bitrate at a relatively stable and slow rate, thereby reserving sufficient bitrate resources for the ROI area.
[0248] Explanation of high water level: When the water level in the reservoir rises, it indicates that the ROI region has sufficient bitrate resources. To utilize bitrate resources more efficiently and avoid resource idleness and waste, the bitrate needs to flow more quickly. Increase λ proportionally. rou The increase in bitrate will accelerate the rate at which the ROU region consumes bitrate, allowing excess bitrate (coding rate) in the reservoir to continuously flow out and be rationally allocated to the ROU region. This will improve the overall coding efficiency while ensuring the quality of the ROI region.
[0249] In this embodiment, λ is predicted based on a CNN model. roi and λ rouThe algorithm further calculates the adjusted bitrate parameters (or constrained bitrate parameters) for each region and applies them to the actual encoding process. In this way, the encoder can dynamically adjust the quantization step size (quantization parameter) based on the region (ROI or ROU) to which each pixel belongs and the global bitrate control requirements of the current frame when encoding each pixel, achieving differentiated bitrate allocation for ROI and ROU. The significant advantages of this method are that it can address the following issues in demanding real-time video streaming environments: 1. Latency control: By quickly responding to changes in measured data and updating bitrate parameters in real time, it effectively controls encoding latency, meeting the needs of real-time applications such as live streaming. 2. Performance optimization: By finely managing the bitrate allocation of ROI and ROU, it maximizes the use of limited bandwidth resources, ensuring high encoding quality for critical regions (ROI) while maintaining reasonable encoding efficiency for non-critical regions (ROU). 3. Bitrate stability: Through the collaborative work of the reservoir model and the CNN model, it can smooth bitrate fluctuations, maintain a constant bitrate output for the video stream, avoid playback stuttering or sudden changes in image quality, and improve the user viewing experience.
[0250] The encoding and bitrate control process proposed in this application utilizes deep learning technology to achieve intelligent and dynamic management of ROI and ROU bitrates in real-time video streams. This method not only adapts to the special requirements of real-time environments but also effectively optimizes the allocation of bitrate resources between ROI and ROU while ensuring video service quality.
[0251] In summary, the CNN-based ROI bitrate control method proposed in this application achieves fine-grained bitrate control of both ROI and ROU by combining real-time video stream characteristics with neural network model prediction, effectively improving video encoding efficiency and quality. Especially in real-time video streaming scenarios, it meets the requirements for low latency and high performance. Furthermore, the neural network structure can be optimized, training strategies improved, and integration with other encoding techniques can be implemented to achieve more efficient and adaptive ROI bitrate control.
[0252] In some embodiments, the bitrate parameters predicted by the CNN model are applied by dynamically adjusting the quantization step size when encoding the first image frame. The following is a detailed analysis: Calculate the adjusted bitrate parameters for each region.
[0253] In some embodiments, the calculation may be performed in conjunction with other relevant parameters of the current frame, such as coding complexity, quantization parameters, actual number of bits, and overall bitrate control targets and constraints. For example, it could be a weighted summation, combining the first and second bitrate parameters with other parameters to obtain the adjusted bitrate parameters.
[0254] For example, the formula is: Adjusted bitrate parameter = f(first bitrate parameter, second bitrate parameter, first complexity information, QP of the second image frame, bitrate of the second image frame), where f is a user-defined function used to calculate the adjusted bitrate parameter based on these parameters.
[0255] For example, the adjusted bitrate parameter is applied for encoding.
[0256] For example, the quantization step size is dynamically adjusted based on the region (ROI or ROU) to which the pixel belongs, using the corresponding adjusted bitrate parameter. For instance, for pixels in the ROI region, the quantization step size might be adjusted based on the adjusted first bitrate parameter, assuming the adjustment formula is first QP = g(QP of the first image frame, adjusted first bitrate parameter), where g is a function that calculates the new quantization step size first QP based on the current quantization parameter, the QP of the first image frame, and the adjusted first bitrate parameter. Similarly, for pixels in the ROU region, the quantization step size second QP is adjusted based on the adjusted second bitrate parameter in a similar manner. This approach achieves differentiated allocation of bitrate between ROI and ROU, thereby effectively optimizing the allocation of bitrate resources between ROI and ROU while ensuring video service quality.
[0257] The constraints on the bitrate parameter are explained below. The constrained bitrate parameter is obtained by applying at least one of the following constraints to the bitrate parameter.
[0258] Constraint 1: Apply a lower limit constraint to the first bitrate parameter in the bitrate parameters based on the QP of the second image frame.
[0259] For example, constraints 1 and 2 here are dynamic range constraints. For example, the original λ of the CNN output... roi and λ rou Apply boundary constraints. For example, add a lower bound constraint (i.e., constraint 1).
[0260] For example, the constrained λ roi =max(λ) roi α*QP frame-1 Constraint 1 ensures that the minimum bitrate allocation in the ROI region is not over-compressed (α is an empirical coefficient, usually taken as 0.5-0.8).
[0261] Constraint 2: Apply an upper limit constraint to the second bitrate parameter in the bitrate parameters based on the first bitrate parameter in the bitrate parameters.
[0262] For example, the original λ of the CNN output roi and λ rou Apply boundary constraints. For example, add an upper limit constraint (i.e., constraint 2).
[0263] For example, the constrained λ rou =min(λ) rou λ after β* constraint roi Constraint 2 limits the upper limit of bitrate compression in non-ROI regions (β is usually 3-5, forcing the ROU bitrate to not exceed 3-5 times that of the ROI).
[0264] Constraint 3: Perform temporal smoothing filtering on the bitrate parameter based on the third bitrate parameter of the image frame preceding the first image frame.
[0265] For example, constraint 3 is a temporal smoothing filter constraint. For example, inter-frame jitter is eliminated by exponential moving average (EMA). For example, the bitrate parameter after temporal smoothing filter includes a first bitrate parameter and a second bitrate parameter after temporal smoothing filter.
[0266] For example, for the first image frame, the temporally smoothed λ roi =γ·λ after constraint roi +(1-γ)*λ of the third image frame roi .
[0267] For example, for the first image frame, the temporally smoothed λ rou =γ·λ after constraint rou +(1-γ)*λ of the third image frame rou Here, γ is a smoothing factor (0.2-0.5) to suppress bitrate spikes caused by rapid scene switching. For example, the λ value of the third image frame, i.e., the historical frame, is obtained from the buffer state of the reservoir model.
[0268] For example, the time-domain smoothed λ roi and time-domain smoothed λ rou This means that the bitrate parameter after time-domain smoothing filtering is updated to the bitrate parameter after the above constraints.
[0269] Among them, the constrained bitrate parameter is used to encode the first image frame, the first bitrate parameter is used to control the bitrate allocation of ROI, and the second bitrate parameter is used to control the bitrate allocation of ROU.
[0270] For example, after applying the above constraints, the above adjustment steps are performed. That is, the constrained bitrate parameters are updated using the state information of the reservoir model. For example, the adjustment of the bitrate parameters is coupled with the bitrate reservoir model. The constrained λ parameter is input into the virtual buffer model (i.e., the reservoir model) for global bitrate rebalancing.
[0271] For example, ΔB = Rtarget - Ractual(t-1). Rtarget is considered to be the target bitrate, and Ractual(t-1) is the actual bitrate.
[0272] For example, the final λ roi =λ roi *(1+Bmax*ΔB). Where Bmax is the maximum buffer capacity (e.g., Rover), and ΔB reflects the bitrate accumulation / deficit status. When ΔB>0 (bitrate insufficient), λ is appropriately increased to reduce bitrate consumption. When ΔB<0 (bitrate excessive), λ is decreased to improve quality.
[0273] Step 750: Encode the first image frame according to the bitrate parameter.
[0274] For example, the first image frame is encoded using the adjusted bitrate parameters.
[0275] For example, the first image frame is encoded using constrained bitrate parameters.
[0276] For example, the first image frame is encoded using a constrained and adjusted bitrate parameter.
[0277] Please refer to Figure 8 The diagram illustrates a flowchart of a video encoding method according to another embodiment of this application, wherein the execution subject of the method may be the first device 210 described above. For ease of explanation, the description focuses on the encoding end device as the execution subject of each step. The method may include at least one of the following steps (810-850).
[0278] Step 810: Obtain the image information of the first image frame of the video and the encoding information of the second image frame of the video. The second image frame is located before the first image frame in the video.
[0279] Step 820: Based on the image information and encoding information, predict the bitrate parameter of the first image frame. The bitrate parameter is used to determine the bitrate allocation of the first image frame.
[0280] Step 830: According to the pre-configured encoding table, obtain the first QP corresponding to the first code rate parameter and the second QP corresponding to the second code rate parameter. The encoding table is used to indicate the mapping relationship between the code rate parameter and the QP.
[0281] For example, the first QP is denoted as QP roi For example, the second QP is denoted as QP. rou .
[0282] The calculated QP is typically applied to all coding units (CUs) within the ROI region. roi .
[0283] In ROI-based video coding, the goal is to allocate bitrate and control quality in targeted areas. The ROI is a key area of focus, and the aim is to allocate more bitrate by reducing the quantization parameter value to improve image quality. Therefore, after determining the quantization parameter QP for the ROI area... roi Then, it is generally applied to all CUs within the region to improve the overall quality of the ROI region. Similarly, the ROU region will also use the determined QP. rou The CUs within this region are encoded to ensure the quality of the ROI region while making reasonable use of bitrate resources and optimizing the overall encoding effect.
[0284] Step 840: For the patches in the first image frame that are in the ROI, the first QP is used for encoding; for the patches in the first image frame that are in the ROU, the second QP is used for encoding.
[0285] The specific encoding process will not be elaborated here.
[0286] Step 850: After encoding all the tiles in the first image frame, the encoding information of the first image frame is obtained.
[0287] The following describes the update of the bitrate reservoir based on the encoding information of the first image frame. It should be noted that after encoding the second image frame to obtain its encoding information, the bitrate reservoir update process also needs to be performed. Here, only the first image frame is used as an example for the following explanation of the bitrate reservoir update; other image frames are described similarly to the first image frame and will not be repeated.
[0288] In some embodiments, the bitrate reservoir is updated based on the encoding information of the first image frame obtained by encoding the first image frame; wherein, the updated bitrate reservoir is used to indicate the bitrate consumption of the first region in the first image frame, and the status information of the updated bitrate reservoir is used to predict the bitrate parameters of the third image frame by combining the image information of the third image frame of the video and the encoding information of the first image frame, wherein the third image frame is an image frame after the first image frame.
[0289] For example, the bitrate consumption information is updated based on the encoding information of the first image frame obtained by encoding the first image frame; wherein, the updated bitrate consumption information is used to combine the image information of the third image frame and the encoding information of the first image frame to predict the bitrate parameters of the third image frame, which is located after the first image frame in the video.
[0290] In some embodiments, the bitrate allocation amount for the increase of ROI in the first image frame and the bitrate allocation amount for the decrease of ROU in the first image frame are determined based on the encoding information of the first image frame.
[0291] In some embodiments, the bitrate reservoir level is updated based on the sum of the bitrate allocation increase of ROI in the first image frame and the bitrate allocation decrease of ROU in the first image frame.
[0292] To estimate the increased bitrate allocation in the ROI region and the decreased bitrate allocation in the ROU region, the calculation method is as follows:
[0293] Based on a pre-configured encoding table and λ roi Calculate the quantization parameter QP of the ROI region. roi The encoding table typically contains the relationship between different quantization parameters and their corresponding bitrate consumption, based on λ. roi By querying the encoding table, the most suitable quantization parameters for the ROI region under the current bitrate control strategy can be obtained. Similarly, based on λ... rou Calculate the quantization parameter QP of the ROU region. rou Then, based on the encoding complexity C of the ROI region... roi and quantization parameter QP roi And the encoding complexity C of the ROU region. rou and quantization parameter QP rou The rate-distortion model is used to calculate the bit rate consumption of each region. The rate-distortion model typically estimates the number of bits generated during encoding by considering factors such as quantization parameters and encoding complexity. The increase in bit rate allocation for the ROI region and the decrease in bit rate allocation for the ROU region can be expressed as:
[0294] ΔR i =R i -R′ i =α×C roi / QP roi -α×C roi / QP frame
[0295] ΔR u =R u -R′ u =α×C rou / QP rou -α×C rou / QP frame
[0296] Where f(C, QP) represents the code rate consumption when the encoding complexity is C and the quantization parameter is QP, and α is a fixed parameter. ΔR i This refers to the amount of bitrate allocated to the ROI region. ΔR u This refers to the amount of bitrate allocated to the ROU region that is reduced.
[0297] It is important to note that the above calculations assume that the coding complexity of the ROI and ROU regions remains constant after changing the quantization parameters. In reality, there may be some deviation. To improve calculation accuracy, the impact of quantization parameter changes on coding complexity can be further considered, and corrections can be made through iteration or a more complex rate-distortion model. Finally, the calculated ΔR... i and ΔR u The number of pixels P in the ROI region roi The number of pixels P in the ROU region rou Perform correlation to obtain the bitrate increase or decrease per unit pixel. If further consideration is needed, the quality enhancement factor K for the ROI region can be considered. roi ΔR can be i Multiply by K roi Then the bit rate per unit pixel is calculated.
[0298] For example, the main reasons for the increase or decrease in bitrate per unit pixel are as follows: Precise bitrate allocation: In video encoding, bitrate needs to be precisely allocated according to the importance and characteristics of different regions. Calculating the increase or decrease in bitrate per unit pixel clarifies the specific changes in bitrate allocation for each pixel, helping to allocate bitrate to ROI and ROU regions more meticulously and accurately, avoiding bitrate waste or uneven distribution. Quality control: By observing the increase or decrease in bitrate per unit pixel, the impact of bitrate changes on image quality in different regions can be directly understood. When considering ROI quality enhancement factors, the degree of quality improvement in ROI regions can be more precisely controlled, ensuring optimal visual effects under limited bitrate. Optimized encoding efficiency: Understanding the increase or decrease in bitrate per unit pixel helps optimize the encoding algorithm. Based on the bitrate requirements of pixels in different regions, the encoding strategy can be adjusted to improve encoding efficiency, achieving a better balance between quality and bitrate in overall video encoding.
[0299] For example, ΔR is typically used. i Divide by the number of pixels P in the ROI region roi The bitrate increase or decrease per unit pixel in the ROI region is obtained, i.e., ΔR. i *K roi / P roi (Considering the quality improvement factor K) roi (Time). For the ROU region, ΔR is also used. u Divide by the number of pixels P in the ROU region rou By obtaining the increase or decrease in bitrate per unit pixel, we can measure the change in bitrate per unit pixel in two regions separately, providing a basis for more precise bitrate control.
[0300] In some embodiments, after encoding one frame, the update formula for the reservoir is:
[0301] R frame =R frame-1 +ΔRi +ΔR u
[0302] R frame =R frame-1 +α×C roi / QP roi +α×C rou / QP rou -α×(C roi +C rou ) / QP frame
[0303] Where, ΔR i and ΔR u These represent the increments of the ROI and ROU regions relative to the baseline bitrate, calculated based on the actual encoding results. After updating the reservoir, its status also needs to be checked. If it exceeds a preset threshold (such as overflow bitrate R),... over If the bitrate allocation for the next frame is not met, then the bitrate allocation for the next frame needs to be adjusted to ensure overall bitrate stability.
[0304] In some embodiments, the bitrate allocation increased by the ROI in the first image frame and the bitrate allocation decreased by the ROU in the first image frame (here interpreted as a vector, i.e., ΔR) are used. u The original bitrate level in the bitrate reservoir is updated by summing (and using negative numbers). For example, the updated bitrate level is obtained by superimposing the sum of the bitrate allocation increase for the ROI and the bitrate allocation decrease for the ROU in the first image frame onto the original bitrate level. In some embodiments, the original bitrate level in the bitrate reservoir can also be equal to the real-time bitrate of the second image frame. For example, the updated bitrate level is equal to the real-time bitrate of the first image frame.
[0305] In summary, by setting the quantization parameter λ for both the ROI and ROU regions... roi and λ rou By utilizing a pre-configured encoding table and rate-distortion model, the method can accurately estimate the increased bitrate allocation to the Region of Interest (ROI), thereby optimizing the bitrate of the ROI while maintaining overall bitrate stability. This method helps save bandwidth resources while ensuring video encoding quality, and is especially suitable for scenarios with high resolution requirements for specific areas (such as faces and text).
[0306] The reservoir model proposed in this application serves as a dynamic management system responsible for: 1. Bitrate update: Adjusting the average bitrate of the current encoded stream in real time based on the actual number of bits received for each frame, ensuring the overall bitrate remains within a preset target range. 2. Buffer occupancy monitoring: Monitoring the occupancy of the encoded output buffer to prevent buffer overflow or underloading issues caused by excessive bitrate fluctuations, maintaining the continuity and playback stability of the video stream. The state information of the reservoir model, including the current bitrate and buffer status, together with the ROI and ROU features obtained in the pre-analysis phase, constitutes the input data of the deep learning model.
[0307] The update of the bitrate reservoir in this application involves the following aspects:
[0308] 1. Relationship between bitrate allocation and reservoir level: In the ROI reservoir model, the "water level" of the reservoir can be understood as the current bitrate resources available for the ROI region. After encoding the current frame, the actual bitrate R, as well as the relevant parameters and quantization parameters QP of each region, are obtained. This information reflects the bitrate usage and regional characteristics during the encoding of the current frame.
[0309] 2. Calculate the actual bitrate consumption of each region: Based on the region's encoding complexity and the number of pixels in the region, the actual bitrate consumption ratio of the ROI and ROU regions under the current encoding can be further analyzed. For example, through a certain mapping relationship (possibly based on historical data statistics or empirical formulas), the actual bitrate consumption Rroi of the ROI region and the actual bitrate consumption Rrou of the ROU region can be estimated, and R = Rroi + Rrou.
[0310] 3. Compare with expected bitrate: Based on the previously set expected bitrate allocation for the ROI and ROU regions (which may be related to QP, as QP affects quantization accuracy and bitrate consumption), compare the actual bitrate consumed by Rroi and Rrou. If the actual bitrate consumed by the ROI region is higher than expected, this may mean that the "water level" in the reservoir has decreased (because the ROI region consumes more bitrate resources that could have been used for subsequent frames); conversely, if the actual bitrate consumed by the ROI region is lower than expected, the "water level" in the reservoir has increased.
[0311] 4. Update the reservoir status: Based on the comparison results above, update the reservoir status (i.e., the "water level"). This update may involve adjusting the "bitrate resources" stored in the reservoir, such as increasing or decreasing the bitrate available for subsequent frame ROI regions. Simultaneously, the updated status (represented by the updated R, where R may represent the remaining bitrate resources in the reservoir or a parameter related to the adjusted bitrate allocation strategy) will be used for encoding decisions in subsequent frames to ensure the rationality and stability of bitrate allocation.
[0312] 5. Consider the impact of quantization parameters: The quantization parameter QP also plays a role in this process. Different QP values lead to different bitrate consumption and image quality. By analyzing the bitrate consumption at the current QP (in conjunction with R and parameters of each region), it can be determined whether the QP of subsequent frames needs to be adjusted, thereby affecting the state update of the reservoir and the bitrate allocation strategy.
[0313] In summary, this step dynamically adjusts the state of the ROI reservoir model based on the encoding results and regional characteristic information of the current frame, so as to provide a more reasonable basis for bitrate allocation for the encoding of the next frame.
[0314] In some embodiments, such as Figure 11 As shown, for the current image frame (such as the first image frame) 1100, the P of the current image frame 1100 is obtained through ROI map generation 1110. roi P rou For the current image frame 1100, perform pre-analysis 1210 to obtain the C of the current image frame 1100. roi C rou Next, according to C roi C rou P roi P rou and K roi R over Combined with the R obtained from encoding historical frames (such as the second image frame) frame-1 QP frame-1 The λ of the current image frame 1100 is obtained using a CNN model 1170 based on the ROI reservoir. roi , λ rou For example, based on the λ of the current image frame 1100 roi , λ rou The quantization parameter QP of the current image frame 1100 is obtained through RDO 1130 and transform quantization 1140 (here, transform quantization is equivalent to transform coding and quantization in the above embodiment). frame After entropy coding of 1150, the actual bitrate R of the current image frame 1100 is obtained. frame Finally, using the actual bitrate R of the current image frame 1100. frame Quantization parameters QP of the current image frame frame C roi C rou Execute the status update of the bitrate reservoir 1160.
[0315] In this embodiment, the water reservoir is updated using the encoding result of the current frame. During the encoding of the current frame, the change in the number of bits allocated to the ROI region (ΔR) is... i ) and the number of bits consumed in the ROU region (ΔR)u Situations that affect the water level in a reservoir include, for example, an increase in the number of bits allocated to the ROI region in the current frame, ΔR. i If the ROU region consumes fewer bits, ΔR increases, causing the water level in the reservoir to rise; if the ROU region consumes fewer bits, ΔR... u The smaller the bitrate, the lower the bitrate level in the reservoir, thus enabling dynamic updates to the bitrate reservoir. Furthermore, by directly using the sum of the bitrate allocation increase for ROIs and the bitrate allocation decrease for ROUs in the first image frame to update the bitrate reservoir level, both dynamic updates are achieved, improving both update efficiency and accuracy.
[0316] The following experimental results illustrate the video coding method proposed in this application.
[0317] In today's environment, which increasingly relies on high-quality real-time video transmission, efficient and flexible bitrate control schemes are crucial for ensuring a good user experience. This application aims to develop a novel bitrate control mechanism for real-time video encoding and successfully integrate it into the HEVC encoder V265, specifically employing a low-latency B configuration to meet the needs of real-time streaming applications. This integration aims to optimize ROI encoding while maintaining overall bitrate stability to achieve smooth and high-fidelity live video streaming. Exemplary experimental results are shown in Tables 1 to 4 below.
[0318] Table 1. Objective metrics for the ROI scenario in BasketballDrive at 1920x1080 resolution and 50fps (1500kbps).
[0319]
[0320] Table 2 Comparison of Class B-Class F bitrate and objective metrics for ROI with fixed QP offset and R-λ
[0321]
[0322] Table 3K roi Comparison of Class B to Class F bitrates and objective metrics for =4 and R-λ
[0323]
[0324]
[0325] In the ROI detection stage, this application utilizes advanced inspection algorithms to accurately identify and locate faces and various common objects in video frames. By analyzing the coordinate information provided by the detection results, this application can accurately delineate the ROI region, laying the foundation for subsequent differentiated coding processing. To comprehensively verify the effectiveness and universality of the proposed bitrate control scheme, this application selects a series of representative test sequences recommended by the HEVC standards committee, covering four types: Class B, Class C, Class D, and Class E. These sequences encompass different resolutions, content complexities, and motion characteristics, ensuring the breadth and rigor of the evaluation.
[0326] The ROI reservoir bitrate control algorithm proposed in this application contrasts sharply with traditional non-ROI encoding methods. Traditional encoding methods typically attempt to improve the visual quality of the ROI region simply by directly adjusting the λ value (Lagrange multiplier, used to balance encoding distortion and bitrate) within the ROI region. Taking the "BasketballDrive" sequence in Class B as an example, this application focuses on a typical 1080p high-definition video stream with a frame rate of 50fps and a target bitrate of approximately 1500kbps.
[0327] In the first row of Table 1, this application establishes a baseline rate control algorithm based on the R-λ strategy as a reference, which reflects the coding performance without distinguishing between ROI and non-ROI regions.
[0328] Next, the second row of Table 1 shows a widely used direct adjustment strategy: setting a negative QPoffset (quantization parameter offset) for the ROI region, which is set to -6 here. This method directly reduces the quantization step size of the ROI region, thereby improving its coding fineness. Experiments show that although this direct adjustment method does significantly improve objective quality indicators such as peak signal-to-noise ratio (PSNR) and structural similarity index (SSIM) of the ROI region to a certain extent, reflecting higher visual fidelity, it also brings a problem that cannot be ignored—a bit rate surge of up to 60%. In real-time video streaming scenarios, such a large bit rate fluctuation can easily cause a sharp increase in network bandwidth pressure, leading to packet loss, increased latency during transmission, and even severe stuttering at the playback end, seriously affecting the viewer's viewing experience.
[0329] To overcome the aforementioned problems, the ROI reservoir bitrate control algorithm of this application adopts a more refined and adaptive strategy. In the following three rows of Table 1, this application demonstrates how the ROI region parameter K increases with increasing bitrate. roi (ROI quality enhancement factor), and how the algorithm's performance changes. With K... roiAs the value increases, the coding quality of the ROI region continues to improve, as evidenced by further improvements in PSNR and SSIM metrics. This indicates that by appropriately adjusting K... roi This algorithm flexibly finds the optimal balance between meeting specific ROI quality requirements and overall bitrate constraints. Crucially, in stark contrast to methods that directly adjust QPoffset, the ROI reservoir algorithm cleverly achieves dynamic adjustment of ROU bit allocation while strengthening ROI encoding. By intelligently reducing the number of bits allocated to ROU regions, the algorithm effectively suppresses overall bitrate growth, ensuring that the total bitrate increase of the video stream does not exceed 5%. This feature is particularly important because it strictly meets the stringent requirements for video encoding bitrate fluctuation range in live streaming scenarios, ensuring transmission stability and avoiding network congestion and playback interruptions caused by sudden bitrate spikes.
[0330] The ROI reservoir bitrate control algorithm successfully maintains a stable overall bitrate while improving the encoding quality of ROI regions and ensuring the clear presentation of key visual elements. This achieves dual optimization of image quality and transmission stability in real-time video streaming. The algorithm not only demonstrates its effective adaptability to complex video content but also holds promise for significantly enhancing the viewing experience in practical applications, providing valuable innovative ideas and technical references for the development of modern real-time video coding technology.
[0331] In the experimental data in Tables 2 and 3, this application sets K... roi =4, This paper delves into the dynamic relationship between bitrate and various performance metrics (such as PSNR and SSIM) under different datasets and resolutions. Compared with the traditional ROI constant QPoffset method, the CNN-based ROI bitrate control system in this application demonstrates a subtle but significant advantage in improving the PSNR and SSIM quality of the ROI region. Furthermore, for the same ROI region, this CNN model improves quality while causing relatively small losses in PSNR and SSIM quality, reflecting a more refined and balanced bitrate control strategy. Particularly noteworthy is that using a CNN model for ROI bitrate control can significantly reduce the required bitrate consumption while maintaining improved ROI region quality.
[0332] Specifically, compared to the ROI constant QPoffset strategy, which requires an average additional 41% bitrate, the method in this application only requires an additional 2.8% bitrate overhead to achieve similar or even better ROI quality improvement. This strongly demonstrates that this application can effectively control bitrate growth while ensuring stable and high-quality visual output in the ROI region. From a microscopic perspective of each frame, the method in this application precisely controls the bitrate allocation in the ROU region, ensuring that the loss is evenly distributed within the frame, avoiding visual abruptness caused by local over-compression, and ensuring the harmony and naturalness of the overall image.
[0333] Experimental studies show that the innovative method for processing regions of interest proposed in this application demonstrates significant advantages in both objective quantitative evaluation and subjective visual assessment. The ROI region is highlighted with a red border. This region typically contains the most critical information in an image or video and is crucial for applications such as medical diagnosis, security monitoring, and content editing.
[0334] The core of this method lies in precisely enhancing the detail representation within a Region of Interest (ROI), especially in cases involving human detection, such as human contours and features identified by deep learning models. By applying this method, the edge sharpness, texture details, and contrast with the background of the human contour are significantly improved, making features that might have been difficult to discern due to noise, blur, or low contrast become clear and easily identifiable. This characteristic is crucial for high-precision tasks such as behavior analysis, identity verification, and even disease diagnosis.
[0335] It is worth noting that despite targeted optimization of the ROI, the proposed solution does not sacrifice overall visual quality in processing regions of non-interest (ROU). In the ROU portion, the image or video maintains visual quality comparable to or even improved upon the original material, without significant distortion, increased noise, or other forms of quality degradation. This balanced processing capability ensures high viewing comfort and information delivery efficiency across both ROI and ROU, meeting the dual requirements of overall visual consistency and highlighting key local information in practical applications. To further quantitatively verify the effectiveness of the proposed method, this application conducts a detailed performance comparison between the processed video sequence and the unprocessed original video.
[0336] Regarding subjective quality assessment, this application conducted detailed visual perception experiments, inviting professionals and general viewers to evaluate different K values. roi The video samples are scored according to the settings. When setting parameter K... roi When K is 2, a slight but noticeable improvement in subjective video quality is observed, indicating that the proposed method has begun to play a positive role. However, as K... roiAs the K value increased to 4, subjective quality saw a significant leap, with viewers generally reporting a marked improvement in detail clarity, color reproduction, and overall visual appeal. Despite continuing to increase the K value... roi When the value increases to 6, the objective indicators PSNR and SSIM further increase, but from a subjective evaluation perspective, the improvement in visual quality of the ROI region has reached saturation, i.e., K. roi =6 and K roi The subjective quality difference between 4 and 4 is not significant, suggesting that the gain effect of the proposed method is close to its limit within this specific parameter range.
[0337] As shown in Table 4, the 100 participants in the evaluation scored the visual quality using a Likert scale from 1 to 5, where 1 represents the lowest perceived quality and 5 represents the highest. In this experiment, the control group using the ROI constant QPoffset strategy showed a 2.5% improvement in the mean opinion score (MOS). However, the R-λ-based method proposed in this application resulted in a more significant improvement in the mean opinion score, reaching 9.1%. This result fully demonstrates the superiority of the proposed scheme in improving visual quality and consistency in the ROI region.
[0338] Table 4K roi Comparison of Class B to Class F bitrates and objective metrics for =4 and R-λ
[0339]
[0340] By optimizing the quantization parameter (QP) within the ROI region, the proposed solution successfully maintains a low QP value, thereby achieving superior visual perception quality. Simultaneously, thanks to the stability of the QP value, the video quality within the ROI region remains consistently high, avoiding inter-frame quality fluctuations and ensuring a smooth and comfortable viewing experience. Particularly noteworthy is that even in real-time streaming coding scenarios facing strict bandwidth limitations, the proposed solution can still be implemented smoothly and achieve good results. This fully demonstrates the high adaptability and universality of the method, effectively improving video coding efficiency and quality in various practical application environments, especially under conditions of limited bandwidth resources. In summary, by integrating a CNN-based ROI bitrate control model, the proposed solution exhibits superior bitrate control performance compared to traditional methods on numerous test sequences. Therefore, the CNN-based ROI bitrate control system proposed in this application is not only an innovative bitrate allocation management method but also a powerful tool for improving the visual experience of key areas (such as human faces and text information) in scenarios such as live video streaming, online education, and telemedicine, possessing significant theoretical value and broad application prospects.
[0341] Through a series of rigorous simulations and experiments, this application strongly demonstrates that the customized encoder possesses flexible and precise subjective visual quality control capabilities. This encoder is able to adjust K... roi During the parameterization process, the visual fidelity of the ROI region is gradually improved in a relatively smooth and controllable manner. This adjustment mechanism not only ensures the optimal presentation of key information within the ROI but also takes into account the visual quality of the ROU region, maintaining it at a level that is always satisfactory and acceptable to the viewer. In summary, the ROI region processing method proposed in this application, with its significant improvement in objective performance indicators and excellent performance in subjective visual experience, sets a new benchmark for image and video processing technologies in related fields.
[0342] Experimental results show that when the ROI enhancement parameter K roi Exceeding a certain threshold, excessively reducing the bit rate can lead to severe degradation of metrics within the ROI region, causing significant subjective quality issues such as noticeable block artifacts or texture loss. To address this problem, the key is to set a minimum λ for the ROI region. min Value, and set a maximum λ for the ROU region. max These values, λ, set upper and lower limits for the QP values of the corresponding regions, ensuring that subjective image quality is not compromised. min and λ max You can consult a predefined λ-QP lookup table and use the corresponding QP. min and QP max Compared to traditional manually designed linear or nonlinear models, using convolutional neural networks (CNNs) to predict model parameters can more comprehensively consider multiple influencing factors. Traditional manual empirical modeling techniques tend to overlook high-order features and their complex interactions, unintentionally introducing systematic errors. Conversely, especially in coding pattern decision-making involving multiple inputs and multiple outputs, CNN models offer a superior choice. The inherent ability of CNNs to recognize the complex relationships between these variables makes them a more reliable option, effectively reducing potential errors associated with more rudimentary methods. In the CNN-based ROI rate control model of this application, accurately predicting the coding complexities Croi and Crou of the ROI and ROU regions is crucial. Currently, the prediction in this application relies on estimating this complexity using the absolute difference and transform (SADT) within the current frame. However, the estimation of the coding complexity of the ROI and ROU can be enhanced by utilizing inter-frame prediction with multiple reference frames.
[0343] When observing a visual scene, the human eye's attention is not evenly distributed, but rather primarily focused on the Region of Interest (ROI). These regions typically contain key visual information, such as facial features, action details, and text content, playing a decisive role in the viewer's understanding of video content and their enjoyment of the viewing experience. Therefore, improving the encoding quality of ROI regions and enhancing their visual detail and fidelity is crucial for optimizing video encoding effects and improving viewer satisfaction. To address this need, this application delves into ROI-based encoding strategies, aiming to achieve targeted improvements in visual quality by allocating more bit resources to ROIs in a differentiated manner.
[0344] Under the Constant Rate Factor (CRF) bitrate control mode, this application further investigates an encoding strategy called the ROI Reservoir Model. This model can acquire the bitrate consumption of ROI and ROU regions in real time and dynamically adjust the bitrate allocation according to the reservoir status, ensuring that the encoding quality of the ROI region is maximized within the bitrate budget. Furthermore, this application proposes a parameter prediction model based on a convolutional neural network (CNN) to accurately predict the bitrate parameter λ of the ROI and ROU regions. Through the learning and inference capabilities of the CNN model, this application can more accurately estimate the required encoding complexity of each region, thereby achieving more precise bitrate allocation and ensuring that the visual quality of the ROI region is maximized under limited bandwidth conditions.
[0345] In summary, the coding rate control strategy based on the ROI reservoir model proposed in this application significantly improves the coding quality of the ROI region while maintaining the overall stability of the video bitrate through innovative coding algorithm design and efficient parameter prediction methods. These strategies perform excellently in live streaming scenarios with high resolution, high frame rate, and high bitrate, and are adaptable to various content sources, such as sports events, movies, news, and educational lectures, achieving excellent coding results in practice. Compared to traditional encoders that directly adjust the quantization parameter (QP) at the coding unit (CU) level, the coding strategy proposed in this application significantly reduces the required bitrate overhead while improving the coding quality of the ROI region, thereby providing higher service quality in demanding live streaming environments and offering viewers a better viewing experience.
[0346] The following are exemplary descriptions of application scenarios.
[0347] In some embodiments, the image frame is an image frame from a video call.
[0348] Please refer to Figure 13This document illustrates a flowchart of a video encoding method for video calls according to an embodiment of this application. The execution subject of this method may be the first device 210 described above. For ease of explanation, only the encoding end device is described as the execution subject of each step. The method may include at least one of the following steps (1310 to 1330).
[0349] Step 1310: Obtain the image information of the first image frame of the video call and the encoding information of the second image frame of the video call. The second image frame is located before the first image frame in the video call.
[0350] Step 1320: Based on the image information and encoding information, predict the bitrate parameter of the first image frame. The bitrate parameter is used to determine the bitrate allocation of the first image frame.
[0351] Step 1330: Encode the first image frame according to the bit rate parameter.
[0352] In some embodiments, bitrate consumption information of the second image frame is obtained.
[0353] In some embodiments, the bitrate parameter is predicted based on image information, bitrate consumption information, and encoding information.
[0354] In some embodiments, the quality enhancement factor of the first image frame is obtained.
[0355] In some embodiments, the bitrate parameter is predicted based on image information, bitrate consumption information, quality enhancement factor, and encoding information.
[0356] In some embodiments, the bitrate consumption information includes a bitrate cap, which is used to indicate that the bitrate consumption of the ROI in the second image frame has reached the bitrate cap.
[0357] In some embodiments, the bitrate parameter is adjusted according to the bitrate consumption information of the second image frame to obtain the adjusted bitrate parameter, which is then used to encode the first image frame.
[0358] In some embodiments, when the bitrate consumption information indicates that the bitrate consumption of the ROI in the second image frame is greater than or equal to the upper limit of bitrate, the first bitrate parameter in the bitrate parameters is adjusted to obtain the adjusted first bitrate parameter; when the bitrate consumption information indicates that the bitrate consumption is less than the upper limit of bitrate, the second bitrate parameter in the bitrate parameters is adjusted to obtain the adjusted second bitrate parameter; wherein, the first bitrate parameter and the second bitrate parameter are used to determine the bitrate allocation of different regions in the first image frame.
[0359] In some embodiments, when the bitrate consumption information indicates that the bitrate consumption is less than the upper limit of the bitrate and the bitrate consumption is less than the first threshold, the increment of the second bitrate parameter is decreased to obtain the adjusted second bitrate parameter; when the bitrate consumption information indicates that the bitrate consumption is less than the overflow bitrate and the bitrate consumption is greater than the second threshold, the increment of the second bitrate parameter is increased to obtain the adjusted second bitrate parameter; wherein, the first threshold is less than or equal to the second threshold.
[0360] In some embodiments, the encoding information includes QP.
[0361] In some embodiments, at least one of the following constraints is applied to the bitrate parameters to obtain constrained bitrate parameters: a lower limit constraint is applied to a first bitrate parameter in the bitrate parameters according to QP; an upper limit constraint is applied to a second bitrate parameter in the bitrate parameters according to the first bitrate parameter; and temporal smoothing filtering is performed on the bitrate parameters according to a third bitrate parameter of an image frame located before the first image frame in the video call; wherein the constrained bitrate parameters are used to encode the first image frame, and the first bitrate parameter and the second bitrate parameter are used to determine the bitrate allocation of different regions in the first image frame.
[0362] In some embodiments, the bitrate parameter is used to determine the bitrate allocation of a first region in a first image frame, the first region including at least one of the following: ROI and ROU.
[0363] This application implements a method to predict the bitrate parameter of a first image frame by acquiring the image information of the first image frame in a video call and the encoding information of the preceding image frame (i.e., the second image frame). This bitrate parameter can control the bitrate allocation of a first region within the first image frame to achieve encoding of the first image frame.
[0364] On the one hand, by using the image content of the first image frame itself as part of the prediction basis for the bitrate parameter, the bitrate of the first region is allocated based on the image content, ensuring that the bitrate allocation result meets the bitrate requirements of the image content. On the other hand, by using the encoding information of the already encoded second image frame as another part of the prediction basis for the bitrate parameter, the problem of bitrate runaway during the encoding process of the first image frame can be avoided, thus achieving control over the size of the output file. Therefore, this application introduces predicted bitrate parameters, improving the bitrate allocation effect. In addition, while the bitrate allocation effect is improved, the encoding effect of the image frame is also improved.
[0365] In some embodiments, the image frame is an image frame from a video conference.
[0366] Please refer to Figure 14This document illustrates a flowchart of a video encoding method for video conferencing according to an embodiment of this application. The execution subject of this method may be the first device 210 described above. For ease of explanation, the description focuses on the encoding end device as the execution subject of each step. The method may include at least one of the following steps (1410-1430).
[0367] Step 1410: Obtain the image information of the first image frame of the video conference and the encoding information of the second image frame of the video conference. The second image frame is located before the first image frame in the video conference.
[0368] Step 1420: Based on the image information and encoding information, predict the bitrate parameter of the first image frame. The bitrate parameter is used to determine the bitrate allocation of the first image frame.
[0369] Step 1430: Encode the first image frame according to the bit rate parameter.
[0370] In some embodiments, bitrate consumption information of the second image frame is obtained.
[0371] In some embodiments, the bitrate parameter is predicted based on image information, bitrate consumption information, and encoding information.
[0372] In some embodiments, the quality enhancement factor of the first image frame is obtained.
[0373] In some embodiments, the bitrate parameter is predicted based on image information, bitrate consumption information, quality enhancement factor, and encoding information.
[0374] In some embodiments, the bitrate consumption information includes a bitrate cap, which is used to indicate that the bitrate consumption of the ROI in the second image frame has reached the bitrate cap.
[0375] In some embodiments, the bitrate parameter is adjusted according to the bitrate consumption information of the second image frame to obtain the adjusted bitrate parameter, which is then used to encode the first image frame.
[0376] In some embodiments, when the bitrate consumption information indicates that the bitrate consumption of the ROI in the second image frame is greater than or equal to the upper limit of bitrate, the first bitrate parameter in the bitrate parameters is adjusted to obtain the adjusted first bitrate parameter; when the bitrate consumption information indicates that the bitrate consumption is less than the upper limit of bitrate, the second bitrate parameter in the bitrate parameters is adjusted to obtain the adjusted second bitrate parameter; wherein, the first bitrate parameter and the second bitrate parameter are used to determine the bitrate allocation of different regions in the first image frame.
[0377] In some embodiments, when the bitrate consumption information indicates that the bitrate consumption is less than the upper limit of the bitrate and the bitrate consumption is less than the first threshold, the increment of the second bitrate parameter is decreased to obtain the adjusted second bitrate parameter; when the bitrate consumption information indicates that the bitrate consumption is less than the overflow bitrate and the bitrate consumption is greater than the second threshold, the increment of the second bitrate parameter is increased to obtain the adjusted second bitrate parameter; wherein, the first threshold is less than or equal to the second threshold.
[0378] In some embodiments, the encoding information includes QP.
[0379] In some embodiments, at least one of the following constraints is applied to the bitrate parameters to obtain constrained bitrate parameters: a lower limit constraint is applied to a first bitrate parameter in the bitrate parameters according to QP; an upper limit constraint is applied to a second bitrate parameter in the bitrate parameters according to the first bitrate parameter; and temporal smoothing filtering is performed on the bitrate parameters according to a third bitrate parameter of an image frame located before the first image frame in the video conference; wherein the constrained bitrate parameters are used to encode the first image frame, and the first bitrate parameter and the second bitrate parameter are used to determine the bitrate allocation of different regions in the first image frame.
[0380] In some embodiments, the bitrate parameter is used to determine the bitrate allocation of a first region in a first image frame, the first region including at least one of the following: ROI and ROU.
[0381] This application implements a method to predict the bitrate parameter of a first image frame by acquiring the image information of the first image frame in a video conference and the encoding information of the preceding image frame (i.e., the second image frame). This bitrate parameter can control the bitrate allocation of a first region within the first image frame to achieve encoding of the first image frame.
[0382] On the one hand, by using the image content of the first image frame itself as part of the prediction basis for the bitrate parameter, the bitrate of the first region is allocated based on the image content, ensuring that the bitrate allocation result meets the bitrate requirements of the image content. On the other hand, by using the encoding information of the already encoded second image frame as another part of the prediction basis for the bitrate parameter, the problem of bitrate runaway during the encoding process of the first image frame can be avoided, thus achieving control over the size of the output file. Therefore, this application introduces predicted bitrate parameters, improving the bitrate allocation effect. In addition, while the bitrate allocation effect is improved, the encoding effect of the image frame is also improved.
[0383] In some embodiments, the image frame is an image frame from a short video.
[0384] Please refer to Figure 15This document illustrates a flowchart of a video encoding method for short videos according to an embodiment of this application. The execution subject of this method may be the first device 210 described above. For ease of explanation, only the encoding end device is described as the execution subject of each step. The method may include at least one of the following steps (1510-1530).
[0385] Step 1510: Obtain the image information of the first image frame of the short video and the encoding information of the second image frame of the short video. The second image frame is located before the first image frame in the short video.
[0386] Step 1520: Based on the image information and encoding information, predict the bitrate parameter of the first image frame. The bitrate parameter is used to determine the bitrate allocation of the first image frame.
[0387] Step 1530: Encode the first image frame according to the bit rate parameter.
[0388] In some embodiments, bitrate consumption information of the second image frame is obtained.
[0389] In some embodiments, the bitrate parameter is predicted based on image information, bitrate consumption information, and encoding information.
[0390] In some embodiments, the quality enhancement factor of the first image frame is obtained.
[0391] In some embodiments, the bitrate parameter is predicted based on image information, bitrate consumption information, quality enhancement factor, and encoding information.
[0392] In some embodiments, the bitrate consumption information includes a bitrate cap, which is used to indicate that the bitrate consumption of the ROI in the second image frame has reached the bitrate cap.
[0393] In some embodiments, the bitrate parameter is adjusted according to the bitrate consumption information of the second image frame to obtain the adjusted bitrate parameter, which is then used to encode the first image frame.
[0394] In some embodiments, when the bitrate consumption information indicates that the bitrate consumption of the ROI in the second image frame is greater than or equal to the upper limit of bitrate, the first bitrate parameter in the bitrate parameters is adjusted to obtain the adjusted first bitrate parameter; when the bitrate consumption information indicates that the bitrate consumption is less than the upper limit of bitrate, the second bitrate parameter in the bitrate parameters is adjusted to obtain the adjusted second bitrate parameter; wherein, the first bitrate parameter and the second bitrate parameter are used to determine the bitrate allocation of different regions in the first image frame.
[0395] In some embodiments, when the bitrate consumption information indicates that the bitrate consumption is less than the upper limit of the bitrate and the bitrate consumption is less than the first threshold, the increment of the second bitrate parameter is decreased to obtain the adjusted second bitrate parameter; when the bitrate consumption information indicates that the bitrate consumption is less than the overflow bitrate and the bitrate consumption is greater than the second threshold, the increment of the second bitrate parameter is increased to obtain the adjusted second bitrate parameter; wherein, the first threshold is less than or equal to the second threshold.
[0396] In some embodiments, the encoding information includes QP.
[0397] In some embodiments, at least one of the following constraints is applied to the bitrate parameters to obtain constrained bitrate parameters: a lower limit constraint is applied to a first bitrate parameter in the bitrate parameters according to QP; an upper limit constraint is applied to a second bitrate parameter in the bitrate parameters according to the first bitrate parameter; and temporal smoothing filtering is performed on the bitrate parameters according to a third bitrate parameter of an image frame located before the first image frame in the short video; wherein the constrained bitrate parameters are used to encode the first image frame, and the first bitrate parameter and the second bitrate parameter are used to determine the bitrate allocation of different regions in the first image frame.
[0398] In some embodiments, the bitrate parameter is used to determine the bitrate allocation of a first region in a first image frame, the first region including at least one of the following: ROI and ROU.
[0399] This application implements a method to predict the bitrate parameter of a first image frame by acquiring the image information of the first image frame of a short video and the encoding information of the image frames preceding the first image frame (i.e., the second image frame). This bitrate parameter can control the bitrate allocation of a first region in the first image frame to achieve encoding of the first image frame.
[0400] On the one hand, by using the image content of the first image frame itself as part of the prediction basis for the bitrate parameter, the bitrate of the first region is allocated based on the image content, ensuring that the bitrate allocation result meets the bitrate requirements of the image content. On the other hand, by using the encoding information of the already encoded second image frame as another part of the prediction basis for the bitrate parameter, the problem of bitrate runaway during the encoding process of the first image frame can be avoided, thus achieving control over the size of the output file. Therefore, this application introduces predicted bitrate parameters, improving the bitrate allocation effect. In addition, while the bitrate allocation effect is improved, the encoding effect of the image frame is also improved.
[0401] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0402] Please refer to Figure 16This diagram illustrates a block diagram of a video encoding apparatus according to an embodiment of this application. The apparatus has the functionality to implement the method example described above; this functionality can be implemented in hardware or by hardware executing corresponding software. The apparatus can be the encoding end device described above, or it can be located within an encoding end device. The apparatus 1600 may include: an information acquisition module 1610, a parameter prediction module 1620, and an image encoding module 1630.
[0403] The information acquisition module 1610 is used to acquire image information of a first image frame of the video and encoding information of a second image frame of the video, wherein the second image frame is located before the first image frame in the video.
[0404] The parameter prediction module 1620 is used to predict the bitrate parameter of the first image frame based on the image information and the encoding information, wherein the bitrate parameter is used to determine the bitrate allocation of the first image frame.
[0405] The image encoding module 1630 is used to encode the first image frame according to the bit rate parameter.
[0406] In some embodiments, the information acquisition module 1610 is used to acquire the bitrate consumption information of the second image frame.
[0407] In some embodiments, the parameter prediction module 1620 is used to predict the bitrate parameter based on the image information, the bitrate consumption information, and the encoding information.
[0408] In some embodiments, the information acquisition module 1610 is used to acquire the quality enhancement factor of the first image frame.
[0409] In some embodiments, the parameter prediction module 1620 is used to predict the bitrate parameter based on the image information, the bitrate consumption information, the quality enhancement factor, and the encoding information.
[0410] In some embodiments, the bitrate consumption information includes a bitrate cap, which is used to indicate that the bitrate consumption of the ROI in the second image frame has reached the bitrate cap.
[0411] In some embodiments, the device 1600 further includes a parameter adjustment module (not shown in the figure).
[0412] In some embodiments, the parameter adjustment module is used to adjust the bitrate parameter according to the bitrate consumption information of the second image frame to obtain the adjusted bitrate parameter, and the adjusted bitrate parameter is used to encode the first image frame.
[0413] In some embodiments, the parameter adjustment module is configured to adjust a first bitrate parameter in the bitrate parameters to obtain an adjusted first bitrate parameter when the bitrate consumption information indicates that the bitrate consumption of the ROI in the second image frame is greater than or equal to the upper bitrate limit; and to adjust a second bitrate parameter in the bitrate parameters to obtain an adjusted second bitrate parameter when the bitrate consumption information indicates that the bitrate consumption is less than the upper bitrate limit; wherein the first bitrate parameter and the second bitrate parameter are used to determine the bitrate allocation of different regions in the first image frame.
[0414] In some embodiments, the parameter adjustment module is configured to: decrease the increment of the second bitrate parameter to obtain the adjusted second bitrate parameter when the bitrate consumption information indicates that the bitrate consumption is less than the upper limit of the bitrate and the bitrate consumption is less than a first threshold; and increase the increment of the second bitrate parameter to obtain the adjusted second bitrate parameter when the bitrate consumption information indicates that the bitrate consumption is less than the overflow bitrate and the bitrate consumption is greater than a second threshold; wherein the first threshold is less than or equal to the second threshold.
[0415] In some embodiments, the parameter adjustment module is configured to apply at least one of the following constraints to the bitrate parameters to obtain constrained bitrate parameters: applying a lower limit constraint to a first bitrate parameter in the bitrate parameters according to the QP; applying an upper limit constraint to a second bitrate parameter in the bitrate parameters according to the first bitrate parameter; and performing temporal smoothing filtering on the bitrate parameters according to a third bitrate parameter of an image frame located before the first image frame in the video; wherein the constrained bitrate parameters are used to encode the first image frame, and the first bitrate parameter and the second bitrate parameter are used to determine the bitrate allocation of different regions in the first image frame.
[0416] In some embodiments, the bitrate parameter is used to determine the bitrate allocation of a first region in the first image frame, the first region including at least one of the following: ROI and ROU.
[0417] In some embodiments, the bitrate parameter is output by a convolutional neural network model, and the input information of the convolutional neural network model includes the image information and the encoding information.
[0418] In some embodiments, the image information includes first complexity information, second complexity information, first pixel count information, and second pixel count information; wherein, the first complexity information is used to indicate the complexity of the ROI in the first image frame, the second complexity information is used to indicate the complexity of the ROU in the first image frame, the first pixel count information is used to indicate the number of pixels of the ROI in the first image frame, and the second pixel count information is used to indicate the number of pixels of the ROU in the first image frame.
[0419] In some embodiments, the convolutional neural network model includes: a first hidden layer, a second hidden layer, and a decoding layer; the first hidden layer is used to extract features related to bitrate allocation from input information to obtain first feature information; the second hidden layer is used to reduce the dimension of the feature space of the first feature information to obtain second feature information; the decoding layer is used to decode the second feature information to obtain an output result, the output result including the bitrate parameter.
[0420] In some embodiments, the apparatus 1600 further includes a model training module (not shown in the figure).
[0421] In some embodiments, the model training module is configured to perform the training process of the convolutional neural network model: acquiring at least one set of training samples, the training samples including sample image information of sample image frames, sample encoding information of image frames located before the sample image frames in the sample video, and label bitrate parameters of the sample image frames, the label bitrate parameters being used to determine the bitrate allocation of the sample image frames; inputting the sample image information and the sample encoding information into the convolutional neural network model to obtain the predicted bitrate parameters output by the convolutional neural network model; and training the convolutional neural network model based on the difference between the predicted bitrate parameters and the label bitrate parameters.
[0422] In some embodiments, the tag bitrate parameter includes a first tag bitrate parameter and a second tag bitrate parameter.
[0423] In some embodiments, the model training module is used to perform the process of obtaining the label bitrate parameters: for the sample image frame, a first sample QP is selected, and a first round of encoding is performed on the sample image frame to obtain the first label bitrate parameters; for the sample image frame, a second sample QP is selected, and combined with the first label bitrate parameters, a second round of encoding is performed on the sample image frame to obtain the second label bitrate parameters; wherein, the first label bitrate parameters and the second label bitrate parameters are used to determine the bitrate allocation of different regions in the sample image frame.
[0424] In some embodiments, the image encoding module 1630 is configured to obtain, according to a pre-configured encoding table, a first QP corresponding to a first bitrate parameter in the bitrate parameters and a second QP corresponding to a second bitrate parameter in the bitrate parameters, wherein the encoding table is used to indicate the mapping relationship between the bitrate parameters and the QPs; for patches in the first image frame that are in a Region of Interest (ROI), encoding is performed using the first QP; for patches in the first image frame that are in a Region of Unknown (ROU), encoding is performed using the second QP; after encoding all patches in the first image frame is completed, the encoding information of the first image frame is obtained; wherein, the first bitrate parameter is used to determine the bitrate allocation of the ROIs in the first image frame, and the second bitrate parameter is used to determine the bitrate allocation of the ROUs in the first image frame.
[0425] In some embodiments, the apparatus 1600 further includes a bitrate update module (not shown).
[0426] In some embodiments, the bitrate update module is used to update the bitrate consumption information based on the encoding information of the first image frame obtained by encoding the first image frame; wherein the updated bitrate consumption information is used to predict the bitrate parameters of the third image frame by combining the image information of the third image frame and the encoding information of the first image frame, and the third image frame is located after the first image frame in the video.
[0427] In some embodiments, the bitrate update module is configured to determine, based on the encoding information of the first image frame, the bitrate allocation amount for the increase of ROI in the first image frame and the bitrate allocation amount for the decrease of ROU in the first image frame; and update the bitrate consumption information based on the sum of the bitrate allocation amount for the increase of ROI in the first image frame and the bitrate allocation amount for the decrease of ROU in the first image frame.
[0428] The technical solution provided in this application predicts the bitrate parameter of a first image frame by acquiring image information of the first image frame and encoding information of the preceding image frame (i.e., the second image frame). This bitrate parameter can control the bitrate allocation of a first region in the first image frame to achieve encoding of the first image frame.
[0429] On the one hand, by using the image content of the first image frame itself as part of the prediction basis for the bitrate parameter, the bitrate of the first region is allocated based on the image content, ensuring that the bitrate allocation result meets the bitrate requirements of the image content. On the other hand, by using the encoding information of the already encoded second image frame as another part of the prediction basis for the bitrate parameter, the problem of bitrate runaway during the encoding process of the first image frame can be avoided, thus achieving control over the size of the output file. Therefore, this application introduces predicted bitrate parameters, improving the bitrate allocation effect. In addition, while the bitrate allocation effect is improved, the encoding effect of the image frame is also improved.
[0430] It should be noted that the apparatus provided in the above embodiments is only illustrated by the division of the above functional modules when implementing its functions. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0431] Please refer to Figure 17 This diagram illustrates a structural block diagram of a computer device according to an embodiment of this application. The computer device can be either the encoding device or the decoding device described above. The computer device 170 may include a processor 171, a memory 172, a communication interface 173, and a bus 175.
[0432] The processor 171 includes one or more processing cores, and the processor 171 executes various functional applications and information processing by running software programs and modules.
[0433] The memory 172 can be used to store computer programs, and the processor 171 is used to execute the computer programs to implement the video encoding method described above.
[0434] Communication interface 173 can be used to communicate with other devices, such as receiving and receiving audio and video data.
[0435] Processor 171 can be used to implement encoding and decoding functions, such as encoding and decoding audio and video data.
[0436] The memory 172 is connected to the processor 171 via the bus 175.
[0437] Furthermore, the memory 172 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, including but not limited to: magnetic disks or optical disks, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), SRAM (Static Random-Access Memory), ROM (Read-Only Memory), magnetic storage, flash memory, and PROM (Programmable Read-Only Memory).
[0438] Those skilled in the art will understand that Figure 17 The structure shown does not constitute a limitation on the computer device 170, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0439] In an exemplary embodiment, a computer-readable storage medium is also provided, which stores a computer program and a video stream. When executed by a processor, the computer program implements the aforementioned video encoding method to generate a video stream. Optionally, the computer-readable storage medium may include ROM (Read-Only Memory), RAM (Random Access Memory), SSD (Solid State Drives), or optical disc, etc. The random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).
[0440] In an exemplary embodiment, a computer program product is also provided, the computer program product including a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, causing the computer device to perform the video encoding method described above.
[0441] It should be noted that the collection and processing of relevant data (including videos) in this application should strictly comply with the requirements of relevant national laws and regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the personal information subject.
[0442] It should be understood that "multiple" as mentioned herein refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. Furthermore, the step numbers described herein are only illustrative of one possible execution order. In some other embodiments, the steps may not be executed in numerical order, such as two steps with different numbers being executed simultaneously, or two steps with different numbers being executed in the reverse order of the illustration. This application does not limit this. In other possible embodiments, any of the steps or embodiments mentioned above can be freely combined to form new embodiments. This application does not limit the combination method or order of the steps or embodiments mentioned above.
[0443] The above description is merely an exemplary embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A video encoding method, characterized in that, The method includes: The image information of the first image frame of the video and the encoding information of the second image frame of the video are obtained, wherein the second image frame is located before the first image frame in the video; Based on the image information and the encoding information, the bitrate parameter of the first image frame is predicted, and the bitrate parameter is used to determine the bitrate allocation of the first image frame; The first image frame is encoded according to the bitrate parameter.
2. The method according to claim 1, characterized in that, The method further includes: Obtain the bitrate consumption information of the second image frame; The step of predicting the bitrate parameter of the first image frame based on the image information and the encoding information includes: The bitrate parameter is predicted based on the image information, the bitrate consumption information, and the encoding information.
3. The method according to claim 2, characterized in that, The method further includes: Obtain the quality enhancement factor of the first image frame; The step of predicting the bitrate parameter based on the image information, the bitrate consumption information, and the encoding information includes: The bitrate parameter is predicted based on the image information, the bitrate consumption information, the quality enhancement factor, and the encoding information.
4. The method according to claim 2 or 3, characterized in that, The bitrate consumption information includes a bitrate upper limit, which is used to indicate that the bitrate consumption of the region of interest (ROI) in the second image frame has reached the bitrate upper limit.
5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: Based on the bitrate consumption information of the second image frame, the bitrate parameter is adjusted to obtain the adjusted bitrate parameter, which is used to encode the first image frame.
6. The method according to claim 5, characterized in that, The step of adjusting the bitrate parameter based on the bitrate consumption information to obtain the adjusted bitrate parameter includes: When the bitrate consumption information indicates that the bitrate consumption of the ROI in the second image frame is greater than or equal to the upper limit of bitrate, the first bitrate parameter in the bitrate parameters is adjusted to obtain the adjusted first bitrate parameter. When the bitrate consumption information indicates that the bitrate consumption is less than the bitrate upper limit, the second bitrate parameter in the bitrate parameters is adjusted to obtain the adjusted second bitrate parameter. The first bitrate parameter and the second bitrate parameter are used to determine the bitrate allocation of different regions in the first image frame.
7. The method according to claim 6, characterized in that, When the bitrate consumption information indicates that the bitrate consumption is less than the bitrate upper limit, adjusting the second bitrate parameter in the bitrate parameters to obtain the adjusted second bitrate parameter includes: When the bitrate consumption information indicates that the bitrate consumption is less than the bitrate upper limit and the bitrate consumption is less than the first threshold, the increment of the second bitrate parameter is reduced to obtain the adjusted second bitrate parameter. When the bitrate consumption information indicates that the bitrate consumption is less than the overflow bitrate and the bitrate consumption is greater than the second threshold, the increment of the second bitrate parameter is increased to obtain the adjusted second bitrate parameter. Wherein, the first threshold is less than or equal to the second threshold.
8. The method according to any one of claims 1 to 7, characterized in that, The encoded information includes quantization parameters QP, and the method further includes: The following constraints are applied to the bitrate parameters to obtain the constrained bitrate parameters: According to the QP, a lower bound constraint is applied to the first bitrate parameter in the bitrate parameters; An upper limit constraint is applied to the second bitrate parameter in the bitrate parameters based on the first bitrate parameter in the bitrate parameters. Temporal smoothing filtering is performed on the bitrate parameter based on the third bitrate parameter of the image frame located before the first image frame in the video; The constrained bitrate parameter is used to encode the first image frame, and the first bitrate parameter and the second bitrate parameter are used to determine the bitrate allocation of different regions in the first image frame.
9. The method according to any one of claims 1 to 8, characterized in that, The bitrate parameter is used to determine the bitrate allocation of a first region in the first image frame, and the first region includes at least one of the following: Region of Interest (ROI) and Region of Non-Interest (ROU).
10. The method according to any one of claims 1 to 9, characterized in that, The bitrate parameter is output by a convolutional neural network model, and the input information of the convolutional neural network model includes the image information and the encoding information.
11. The method according to claim 10, characterized in that, The image information includes first complexity information, second complexity information, first pixel count information, and second pixel count information; Wherein, the first complexity information is used to indicate the complexity of the ROI in the first image frame, the second complexity information is used to indicate the complexity of the ROU in the first image frame, the first pixel count information is used to indicate the number of pixels of the ROI in the first image frame, and the second pixel count information is used to indicate the number of pixels of the ROU in the first image frame.
12. The method according to claim 10 or 11, characterized in that, The convolutional neural network model includes: a first hidden layer, a second hidden layer, and a decoding layer; The first hidden layer is used to extract features related to the bit rate allocation from the input information to obtain the first feature information; The second hidden layer is used to reduce the dimension of the feature space of the first feature information to obtain the second feature information; The decoding layer is used to decode the second feature information to obtain an output result, the output result including the bit rate parameter.
13. The method according to any one of claims 10 to 12, characterized in that, The training process of the convolutional neural network model is as follows: At least one set of training samples is obtained, the training samples include sample image information of sample image frames, sample encoding information of image frames located before the sample image frames in the sample video, and label bitrate parameters of the sample image frames, the label bitrate parameters being used to determine the bitrate allocation of the sample image frames; The sample image information and the sample encoding information are input into the convolutional neural network model to obtain the predicted bit rate parameters output by the convolutional neural network model; The convolutional neural network model is trained based on the difference between the predicted bitrate parameter and the label bitrate parameter.
14. The method according to claim 13, characterized in that, The tag bitrate parameters include a first tag bitrate parameter and a second tag bitrate parameter. The process of obtaining the tag bitrate parameters includes the following steps: For the sample image frame, a first sample QP is selected, and a first round of encoding is performed on the sample image frame to obtain the first tag code rate parameter; For the sample image frame, a second sample QP is selected, and combined with the first tag code rate parameter, a second round of encoding is performed on the sample image frame to obtain the second tag code rate parameter; The first tag bitrate parameter and the second tag bitrate parameter are used to determine the bitrate allocation of different regions in the sample image frame.
15. The method according to any one of claims 1 to 14, characterized in that, Encoding the first image frame according to the bitrate parameter includes: According to the pre-configured encoding table, the first QP corresponding to the first bitrate parameter in the bitrate parameters and the second QP corresponding to the second bitrate parameter in the bitrate parameters are obtained. The encoding table is used to indicate the mapping relationship between the bitrate parameters and QP. For the patch in the first image frame that is in the ROI, the first QP is used to perform encoding; For the patch in the first image frame that is at ROU, the second QP is used for encoding; After encoding all the tiles in the first image frame, the encoding information of the first image frame is obtained; The first bitrate parameter is used to determine the bitrate allocation of ROIs in the first image frame, and the second bitrate parameter is used to determine the bitrate allocation of ROUs in the first image frame.
16. The method according to any one of claims 1 to 15, characterized in that, The method further includes: Update the bitrate consumption information based on the encoding information of the first image frame obtained by encoding the first image frame; The updated bitrate consumption information is used to combine the image information of the third image frame and the encoding information of the first image frame to predict the bitrate parameters of the third image frame, which is located after the first image frame in the video.
17. The method according to claim 16, characterized in that, The step of updating the bitrate consumption information based on the encoding information of the first image frame obtained by encoding the first image frame includes: Based on the encoding information of the first image frame, determine the bitrate allocation amount for the increased ROI in the first image frame and the bitrate allocation amount for the decreased ROU in the first image frame. The bitrate consumption information is updated based on the sum of the bitrate allocation increase of ROI in the first image frame and the bitrate allocation decrease of ROU in the first image frame.
18. A video encoding device, characterized in that, The device includes: An information acquisition module is used to acquire image information of a first image frame of a video and encoding information of a second image frame of the video, wherein the second image frame is located before the first image frame in the video; The parameter prediction module is used to predict the bitrate parameter of the first image frame based on the image information and the encoding information, and the bitrate parameter is used to determine the bitrate allocation of the first image frame. An image encoding module is used to encode the first image frame according to the bitrate parameter.
19. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing a computer program that is loaded and executed by the processor to implement the video encoding method as described in any one of claims 1 to 17.
20. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program and a video stream, the computer program being executed by a processor to implement the video encoding method as described in any one of claims 1 to 17.
