Video coding pre-processing method, system, device, medium and program product

Motion vector prediction through the optical flow network model solves the problem of high complexity of time domain filtering pre-processing algorithms in the existing technology, improves the efficiency and speed of video coding pre-processing, and is suitable for real-time coding requirements.

CN118660168APending Publication Date: 2024-09-17MIGU VIDEO TECH CO LTD +2
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410726501.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-05
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

Existing temporal filtering pre-processing algorithms based on motion compensation have high computational complexity and long processing time, making them difficult to apply to real-time encoding requirements.

Method used

The optical flow network model is used for motion vector prediction, replacing traditional hierarchical motion estimation, simplifying motion prediction calculations, and improving the efficiency and speed of video coding pre-processing.

Benefits of technology

It reduces the complexity and time of video encoding pre-processing, expands video encoding application scenarios, and improves user experience and market competitiveness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118660168A
    Figure CN118660168A
Patent Text Reader

Abstract

The invention provides a video coding pre-processing method, system and device, a medium and a program product. The method comprises the following steps: acquiring a to-be-filtered frame of a to-be-processed video and a reference frame of the to-be-filtered frame; inputting the to-be-filtered frame and the reference frame into an optical flow network model to obtain an optical flow graph corresponding to the reference frame; performing motion vector calculation on the optical flow diagram to obtain a motion vector corresponding to each pixel block in the reference frame; and performing coding pre-processing on the to-be-filtered frame based on the motion vector to obtain a processed to-be-filtered frame. According to the invention, the optical flow predicted by the optical flow network model is used for replacing the motion vector obtained by the traditional hierarchical motion estimation in the time domain filtering algorithm based on motion compensation, motion prediction is carried out through the optical flow network, the complexity of motion prediction calculation is simplified, and thus the calculation efficiency and speed of video coding pre-processing are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of video encoding technology, and in particular to a method, system, device, medium and program product for video encoding pre-processing. Background Art

[0002] With the advent of the big data era, video has become an important medium for people to communicate with each other. However, the growing demand for information has led to an explosive growth in the amount of video data. How to encode and compress video has become an important difficulty in current research. In order to further increase the efficiency of video encoding and reduce the size of the bitstream, the existing technology will pre-process the video before actual encoding. Among them, the time domain filtering technology based on motion compensation is an important part of this pre-processing step.

[0003] The time domain filtering technology based on motion compensation includes determining the frame type and collecting the frames to be filtered and the reference frames, downsampling the frames to be filtered and the reference frames and performing motion estimation of a pyramid structure, performing motion compensation according to the motion estimation results, and performing bilateral filtering according to the compensated reference frames to obtain filtered frames.

[0004] However, the motion estimation process based on the pyramid structure in the prior art is rough, and the temporal filtering pre-processing algorithm based on motion compensation has relatively high computational complexity and takes a long time to process. Summary of the invention

[0005] The embodiments of the present application provide a method, system, device, medium and program product for video encoding pre-processing to solve the problem that the existing motion compensation-based time-domain filtering pre-processing algorithm has relatively high computational complexity and long processing time.

[0006] In order to solve the above technical problems, this application is implemented as follows:

[0007] In a first aspect, an embodiment of the present application provides a method for pre-processing a video encoding, comprising:

[0008] Obtaining a frame to be filtered of a video to be processed and a reference frame of the frame to be filtered;

[0009] Inputting the frame to be filtered and the reference frame into an optical flow network model to obtain an optical flow graph corresponding to the reference frame;

[0010] Calculating motion vectors on the optical flow map to obtain motion vectors corresponding to each pixel block in the reference frame;

[0011] The frame to be filtered is subjected to pre-encoding processing based on the motion vector to obtain a processed frame to be filtered.

[0012] Optionally, the performing pre-encoding processing on the frame to be filtered based on the motion vector to obtain the processed frame to be filtered includes:

[0013] Performing motion compensation on the reference frame based on the motion vector to obtain a compensated frame corresponding to the reference frame;

[0014] The frame to be filtered is filtered based on the compensation frame to obtain a filtered frame to be filtered.

[0015] Optionally, the performing motion compensation on the reference frame based on the motion vector and obtaining a compensated frame corresponding to the reference frame further includes:

[0016] The reference frame is traversed using a sliding window to determine a current pixel block, and the following operations are performed on the current pixel block:

[0017] Marking the current pixel block with an edge smoothing mark according to the distance between the motion vector of the current pixel block and the motion vectors of surrounding pixel blocks;

[0018] According to the edge smoothing flag of the current pixel block, it is determined whether to perform edge smoothing compensation on the current pixel block.

[0019] Optionally, performing motion compensation on the reference frame based on the motion vector includes:

[0020] If the current pixel block has an edge smoothing flag, collecting motion vectors of surrounding pixel blocks of the current pixel block;

[0021] Removing completely repeated motion vectors from the motion vectors of the surrounding pixel blocks to obtain the deduplicated motion vectors;

[0022] Perform edge smoothing compensation on the current pixel block according to the deduplicated motion vector and edge pixels of the current pixel block.

[0023] Optionally, the obtaining of a to-be-filtered frame of the to-be-processed video and a reference frame of the to-be-filtered frame includes:

[0024] Determine the type of the current frame to be encoded of the video to be processed;

[0025] According to the type of the current frame to be encoded, determining whether the current frame to be encoded is a frame to be filtered;

[0026] If the current frame to be encoded is a frame to be filtered, image frames that are adjacent in time domain to the current frame to be encoded are collected as the reference frames.

[0027] Optionally, inputting the frame to be filtered and the reference frame into an optical flow network model to obtain an optical flow graph corresponding to the reference frame includes:

[0028] The frame to be filtered and the reference frame are input into an optical flow network model, and the optical flow network model downsamples the filtered frame and the reference frame and then inputs them into a residual optical flow network in the optical flow network model to obtain a residual optical flow map;

[0029] The residual optical flow map is upsampled to obtain an optical flow map corresponding to the reference frame.

[0030] In a second aspect, an embodiment of the present application provides a system for pre-processing video encoding, including:

[0031] An acquisition module, used to acquire a to-be-filtered frame of a video to be processed and a reference frame of the to-be-filtered frame;

[0032] An optical flow module, used to input the frame to be filtered and the reference frame into an optical flow network model to obtain an optical flow map corresponding to the reference frame;

[0033] A vector module, used to calculate the motion vector of the optical flow map to obtain the motion vector corresponding to each pixel block in the reference frame;

[0034] The processing module is used to perform pre-encoding processing on the frame to be filtered based on the motion vector to obtain a processed frame to be filtered.

[0035] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the steps of the video encoding pre-processing method as described in the first aspect above are implemented.

[0036] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for pre-processing video encoding as described in the first aspect above are implemented.

[0037] According to a fifth aspect, a computer program product is provided, comprising computer instructions, which, when executed by a processor, implement the steps of the method for pre-processing video encoding as described in the first aspect.

[0038] In an embodiment of the present application, a to-be-filtered frame of a video to be processed and a reference frame of the to-be-filtered frame are obtained; the to-be-filtered frame and the reference frame are input into an optical flow network model to obtain an optical flow map corresponding to the reference frame; motion vectors are calculated for the optical flow map to obtain motion vectors corresponding to each pixel block in the reference frame; and pre-encoding processing is performed on the to-be-filtered frame based on the motion vector to obtain a processed to-be-filtered frame. In an embodiment of the present application, the optical flow predicted by the optical flow network model is used to replace the motion vector obtained by the traditional hierarchical motion estimation in the time domain filtering algorithm based on motion compensation, and motion prediction is performed through the optical flow network to simplify the complexity of motion prediction calculation, thereby improving the computational efficiency and speed of video encoding pre-processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0040] Figure 1 is a flowchart of a pyramid structure algorithm provided by an embodiment of the present application;

[0041] Figure 2 is a flowchart of a method for pre-processing video encoding provided by an embodiment of the present application;

[0042] Figure 3 It is a structural schematic diagram of an optical flow structure model provided in an embodiment of the present application;

[0043] Figure 4 is a schematic diagram of edge smoothing compensation provided by an embodiment of the present application;

[0044] Figure 5 is a schematic diagram of a video encoding pre-processing embodiment provided in an embodiment of the present application;

[0045] Figure 6 is a schematic diagram of an output optical flow graph provided in an embodiment of the present application;

[0046] Figure 7 is a schematic diagram of a pixel block after motion compensation provided by an embodiment of the present application;

[0047] Figure 8 is a schematic diagram of a pixel block after edge smoothing compensation provided by an embodiment of the present application;

[0048] Fig. 9 It is a structural diagram of a system for pre-processing video encoding provided by an embodiment of the present application;

[0049] Fig.10 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0051] Motion compensation aims to reduce the redundancy between frames in a video sequence caused by camera or object movement. Figure 1 At present, the implementation process of temporal filtering based on motion compensation in the encoder mainly includes four parts:

[0052] The first step is to determine the current frame type and filtering control flag. If the filtering conditions are met, several adjacent frames of the current frame are collected as reference frames.

[0053] The second step is to perform four-fold and two-fold downsampling of the filtered frame and the reference frame to perform motion estimation of the pyramid structure. The estimation method refers to performing three whole-pixel motion estimations in the order of four-fold and two-fold downsampling and original size. After completing the above three motion estimations, the encoder will use the last motion estimation as the starting point and use a 6-tap interpolation filter on the original filtered frame to perform sub-pixel motion estimation of blocks with 8×8 pixels as the unit. The result will be used as the final motion result;

[0054] In the third step, according to the motion estimation results obtained in the previous step, motion compensation is performed on each reference frame to align it with the frame to be filtered as much as possible;

[0055] The fourth step is to perform bilateral filtering on the frame to be filtered based on the compensated reference frame in units of 8×8 pixel blocks to obtain the final filtered frame. The pixels of the frame to be filtered after filtering are shown in the following formula:

[0056]

[0057] Among them, I n Represents the pixel value of the frame to be filtered after filtering (brightness and chrominance are calculated separately); I o Represents the original pixel value of the frame to be filtered; N represents the number of reference frames, and its value can be customized in the encoder settings (generally speaking, the larger the value, the more accurate the filtering will be, but the complexity will increase accordingly); I r (i) represents the pixel value of the i-th reference frame; w r(i,a) represents the weight of the i-th reference frame.

[0058] However, the traditional pyramid algorithm has high complexity in motion estimation strategy and takes a long time to process, making it difficult to apply to real-time encoding and transcoding applications such as live broadcasting.

[0059] Please refer to Figure 2 , the embodiment of the present application provides a method for pre-processing a video encoding, comprising:

[0060] Step 11: Obtain a frame to be filtered of the video to be processed and a reference frame of the frame to be filtered;

[0061] Step 12: Input the frame to be filtered and the reference frame into the optical flow network model to obtain an optical flow map corresponding to the reference frame;

[0062] Optionally, the optical flow network model is used to output the optical flow graph. Before inputting it into the optical flow network model, the optical flow network model to be used can be determined first. Please refer to Figure 3 , the optical flow network model can be Figure 3 The basic framework optical flow prediction network model, for example, can be FlowNet, SpyNet or PWC-Net.

[0063] Optionally, if there are n reference frames, the frame to be filtered and each reference frame are packaged in pairs, there will be n input packages, each input package includes the frame to be filtered and the i-th reference frame, the n input packages are input into the optical flow network model in sequence as the input of the optical flow network, and n optical flow maps corresponding to each input will be output.

[0064] Step 13: Calculate the motion vector of the optical flow map to obtain the motion vector corresponding to each pixel block in the reference frame.

[0065] Optionally, motion vectors are calculated for the n output optical flow maps. Keyi wei converts each optical flow map into block motion vectors MVy, MVx in units of 8×8 pixel blocks:

[0066]

[0067] Among them, Fx i With Fy i is the optical flow value of the i-th pixel in the pixel block.

[0068] Step 14: Perform pre-encoding processing on the frame to be filtered based on the motion vector to obtain a processed frame to be filtered.

[0069] In an embodiment of the present application, a to-be-filtered frame of a video to be processed and a reference frame of the to-be-filtered frame are obtained; the to-be-filtered frame and the reference frame are input into an optical flow network model to obtain an optical flow map corresponding to the reference frame; motion vectors are calculated for the optical flow map to obtain motion vectors corresponding to each pixel block in the reference frame; and pre-encoding processing is performed on the to-be-filtered frame based on the motion vector to obtain a processed to-be-filtered frame. In an embodiment of the present application, the optical flow predicted by the optical flow network model is used to replace the motion vector obtained by the traditional hierarchical motion estimation in the time domain filtering algorithm based on motion compensation, and motion prediction is performed through the optical flow network to simplify the complexity of motion prediction calculation, thereby improving the computational efficiency and speed of video encoding pre-processing.

[0070] With the popularity of video in people's daily applications, people can now watch videos and live broadcasts on terminals anytime and anywhere, and video encoding technology is a top priority in the video field. The method in the embodiment of the present application can well reduce the technical problem of the length of time used for pre-processing of video encoding, can reduce the complexity of the processing process, can better expand the application scenarios of video encoding, for example, it can be applied to applications such as video platforms and live broadcast software for video encoding, can well improve user experience by reducing the time used for video processing, improve the user stickiness of the application, and for developers, can also improve market competitiveness and expand market share.

[0071] Optionally, inputting the frame to be filtered and the reference frame into an optical flow network model to obtain an optical flow graph corresponding to the reference frame includes:

[0072] The frame to be filtered and the reference frame are input into an optical flow network model, and the optical flow network model downsamples the filtered frame and the reference frame and then inputs them into a residual optical flow network in the optical flow network model to obtain a residual optical flow map;

[0073] The residual optical flow map is upsampled to obtain an optical flow map corresponding to the reference frame.

[0074] Among them, in optical flow estimation, the residual optical flow map contains error information caused by imperfect models or complex motion conditions.

[0075] Optional, please refer to Figure 3 In the embodiment of the present application, an optical flow network model based on a pyramid structure is provided. Taking the SpyNet structure as an example, w represents a warp operation, which represents the use of bilinear interpolation, which is similar to the operation of motion compensation; G 0 , G 1 and G 2 is a network for calculating residual optical flow; the "0" in the upper right corner represents the initial optical flow map, that is, the optical flow component in the initial optical flow map is 0. The specific processing process of the optical flow network in the embodiment of the present application is:

[0076] After the frame to be filtered and the reference frame are packaged and input into the optical flow network model, the frame to be filtered and the reference frame are downsampled twice in a row (for example, 2 times downsampling and 4 times downsampling respectively) and then compared with the initial optical flow Figure 1 The same is input into the G0 network to generate the residual optical flow map "0" (the resolution of this map is consistent with the input resolution). The output residual optical flow map "0" is then added to the initial optical flow map to obtain the optical flow Figure 3 The optical flow Figure 3 After further upsampling, the residual optical flow is obtained by warping with the reference frame that has been downsampled once and then adding it to the frame to be filtered after downsampling once. Figure 1 And so on, the final optical flow is generated with the same resolution as the original image. Figure 1 , which is the final output of the optical flow network model in the embodiment of the present application. Compared with the traditional hierarchical motion estimation method, the optical flow network model in the embodiment of the present application can achieve more precise motion vector prediction while further reducing the prediction complexity.

[0077] Optionally, in the embodiment of the present application, the pre-encoding processing of the frame to be filtered based on the motion vector to obtain the processed frame to be filtered further includes:

[0078] Performing motion compensation on the reference frame based on the motion vector to obtain a compensated frame corresponding to the reference frame;

[0079] The frame to be filtered is filtered based on the compensation frame to obtain a filtered frame to be filtered.

[0080] Optionally, the compensation frame is used to generate a new video frame in a video sequence to improve video quality, increase frame rate or perform motion estimation. In the embodiment of the present application, all n reference frames are traversed and motion compensation is performed in units of 8×8 pixel blocks to obtain a compensation frame corresponding to the reference frame.

[0081] After completing motion compensation for all n reference frames, the frame to be filtered is filtered. In the embodiment of the present application, bilateral filtering is taken as an example. In order to obtain a better filtering effect and retain the filtered frame information, the method of obtaining the filtering parameters is further adjusted in the embodiment of the present application: For the error used to calculate the filtering parameters (marked with E), the calculation method in the original algorithm is as follows:

[0082]

[0083] Wherein, SSD is the sum of squares of pixel differences between the current block and the motion estimation reference block; V is the variance of the current block. In the embodiment of the present application, since the motion estimation part is replaced by the optical flow network model, the corresponding pixel block of the reference frame after motion compensation is used to replace the data of the motion estimation reference block.

[0084] Similarly, the filter parameter noise (marked by N) is calculated as follows in the original algorithm:

[0085]

[0086] Wherein, HSD and VSD are the square differences between the current block and the reference block in the horizontal and vertical directions, respectively. In the embodiment of the present application, the corresponding pixel block of the reference frame after motion compensation is also used to replace the calculation.

[0087] In the embodiment of the present application, smooth motion compensation calculation is performed to eliminate the block effect caused by using the optical flow network for prediction, thereby improving the quality of the target frame. Motion compensation can also effectively reduce the redundancy of video data, reduce the amount of data after encoding, and improve the video compression rate while maintaining the video quality. Through the filtering process in the embodiment of the present application, the corresponding pixel block of the reference frame after motion compensation is used to replace the data of the motion estimation reference block. According to the adaptive adjustment of the optical flow network model in the embodiment of the present application, noise and artifacts in the image can be further removed, and image details can be smoothed, thereby improving the visual effect of the video and enhancing the viewing experience.

[0088] Optionally, in the embodiment of the present application, before performing motion compensation on the reference frame based on the motion vector and obtaining a compensated frame corresponding to the reference frame, the step further includes:

[0089] The reference frame is traversed using a sliding window to determine a current pixel block, and the following operations are performed on the current pixel block:

[0090] Marking the current pixel block with an edge smoothing mark according to the distance between the motion vector of the current pixel block and the motion vectors of surrounding pixel blocks;

[0091] According to the edge smoothing flag of the current pixel block, it is determined whether to perform edge smoothing compensation on the current pixel block.

[0092] Optionally, the edge smoothing flag is used to indicate the smoothness or clarity of the edge in the region. The edge smoothing compensation can reduce the noise or jagged effect at the edge. Therefore, after obtaining the motion vector corresponding to each pixel block in the reference frame, it is also necessary to determine the edge smoothing flag SmoothFlag of each 8×8 pixel block in each reference frame. i Specifically, the judgment method is:

[0093]

[0094] Among them, Distance is the average distance between the motion vector of the current block and the motion vectors of the adjacent blocks in four directions, and TH is the threshold, which is related to the width and height of the frame:

[0095]

[0096] Edge smoothing flag SmoothFlag i True means that edge smoothing compensation needs to be performed on the current pixel block; edge smoothing flag SmoothFlag i False means that there is no need to perform edge smoothing compensation on the current pixel block.

[0097] Optionally, in an embodiment of the present application, marking the current pixel block with an edge smoothing mark based on the distance between the motion vector of the current pixel block and the motion vectors of the surrounding pixel blocks helps to identify possible edges in the image, which can help the encoder better understand the motion information in the image, thereby more effectively compressing. Further, by marking the current pixel block with an edge smoothing mark, it is determined whether to perform edge smoothing compensation on the current pixel block. By performing edge smoothing compensation on the pixel block, artifacts or block effects that may occur during the encoding process can be reduced, thereby improving the visual quality of the video.

[0098] Optionally, in the embodiment of the present application, performing motion compensation on the reference frame based on the motion vector further includes:

[0099] If the current pixel block has an edge smoothing flag, collecting motion vectors of surrounding pixel blocks of the current pixel block;

[0100] Removing completely repeated motion vectors from the motion vectors of the surrounding pixel blocks to obtain the deduplicated motion vectors;

[0101] Perform edge smoothing compensation on the current pixel block according to the deduplicated motion vector and edge pixels of the current pixel block.

[0102] Optionally, if the current pixel block has an edge smoothing flag, that is, if the edge smoothing flag of the current pixel block is true, edge smoothing compensation is performed on the current pixel block again, and the specific steps are as follows:

[0103] Please refer to Figure 4 , record the two edge rows / columns of the current pixel block after motion compensation (please refer to Figure 4 The pixel in the middle shaded area) (chrominance is one row / column) is C(x,y).

[0104] Collect the motion vectors of the pixel blocks around the current pixel block (8×8 blocks in four directions, top, bottom, left, and right), and remove the completely repeated motion vectors. The current pixel block performs motion compensation on the current pixel block based on the deduplicated motion vectors. Assuming that the motion vectors in all four directions exist, the pixel compensated by the upper motion vector is recorded as T(x,y), the pixel on the left is recorded as L(x,y), the pixel on the right is recorded as R(x,y), and the pixel on the bottom is recorded as B(x,y).

[0105] Then the weighted edge pixel value C(x,y)' of the current block is:

[0106] C(x,y)′=(C(x,y)×w 1 +L(x,y)×w 2 +R(x,y)×w 3 +T(x,y)×w 4 +B(x,y)

[0107] × 5 +offset)>>5

[0108] Among them, w1+w2+w3+w4+w5=32, w is the weight, and offset is the offset value, which is set to 16. The pixel C(x, y) compensated by the original motion vector generally has a higher weight, which is usually set to 24.

[0109] Since the optical flow predicted by the optical flow network is based on pixels, which is different from the block-based motion estimation of traditional motion estimation, it is necessary to calculate the average value of the optical flow in units of blocks when processing the optical flow as the optical flow of the block. When performing motion compensation in this way, block effects are more likely to occur. In order to improve the quality of the compensated frame, a solution to the block effect is proposed in the embodiment of the present application. After removing the completely repeated vectors, the motion compensation calculation is performed again, which simplifies the calculation and reduces the complexity. In addition, when using the optical flow to perform motion compensation on the reference frame, the edge pixels and adjacent pixels of each block are weighted averaged to reduce this block effect, which can improve the performance of video encoding, reduce distortion during the encoding process, and improve compression efficiency, which helps to improve the quality and reliability of video encoding, especially when processing high-motion videos, it can better maintain image clarity and details.

[0110] Optionally, in the embodiment of the present application, obtaining a to-be-filtered frame of the to-be-processed video and a reference frame of the to-be-filtered frame includes:

[0111] Determine the type of the current frame to be encoded of the video to be processed;

[0112] According to the type of the current frame to be encoded, determining whether the current frame to be encoded is a frame to be filtered;

[0113] If the current frame to be encoded is a frame to be filtered, collect the temporally adjacent image frames corresponding to the current frame to be encoded as the reference frames.

[0114] Among them, the temporally adjacent image frames refer to two image frames adjacent in time in the video sequence.

[0115] Optionally, in the preprocessing step of the encoder, it is also necessary to first determine whether the current frame to be encoded F enc is a frame to be filtered F filter . Specifically: If the current frame is divisible by 8 and the frame is an I-frame or a P-frame, then the current frame to be encoded is a frame to be filtered. The current frame needs to be preprocessed as in the above embodiments. Otherwise, the current frame to be encoded is a non-filtered frame, and the motion compensation-based temporal filtering algorithm for the current frame is skipped.

[0116] If the current frame is a frame to be filtered, collect the temporally adjacent image frames corresponding to the current frame to be encoded as the reference frames, and determine n reference frames F filte (0 < i < 2n) corresponding to the frame to be filtered. For example, n can be 2 or 4. In the embodiments of the present application, by determining the frame type, judging whether filtering processing is required, and selecting appropriate reference frames, video data can be better compressed, the image quality can be improved, and the overall coding efficiency can be enhanced during the video coding process.

[0117] Please refer to Figure 5 . The present application also provides a flowchart of an embodiment. First, determine whether the current frame to be encoded is a frame to be filtered. If the current frame to be encoded is a frame to be filtered; determine n reference frames corresponding to the frame to be filtered, pack the frame to be filtered and the reference frames, input the input packet into the optical flow network model for optical flow prediction to generate n optical flow maps; perform post-processing on the optical flow maps to obtain the motion vectors corresponding to each pixel block in the reference frames; perform edge smoothing flag marking on the pixel blocks of the reference frames; perform motion compensation according to the pixel block motion vectors and the edge smoothing flags; perform bilateral filtering on the frame to be filtered. Compared with the prior art, in the embodiments of the present application, the traditional hierarchical motion estimation method is replaced with optical flow prediction based on a neural network, which greatly reduces the complexity of the motion estimation step. At the same time, in order to reduce the negative impact of the block effect brought by using the optical flow network in the embodiments of the present application, the adjacent pixels of the compensation block are used to weight the edge pixels of the compensation block to improve the objective quality of the compensated frame.

[0118] The output of the optical flow prediction network is an optical flow map, which stores optical flow in pixels. The traditional method outputs motion vectors in 8*8 pixel blocks. In order to compare the effect difference between the embodiment of the present application and the prior art, the present application also provides a test embodiment. By intuitively comparing the processing time of the embodiment of the present application and the prior art in the same device environment (CPU, GPU model is the same, the number of processing and other conditions are the same), the following are the actual test results of the embodiment of the present application and the prior art:

[0119] The optical flow network is deployed in the environment of a GPU model GTX1080ti (other parameter configurations are the same), and the optical flow network used in the test is FastFlowNet. If the number of reference frames of the frame to be filtered is set to n=4, the time for the embodiment of the present application to obtain the motion vectors of all reference frames of the frame to be filtered is 0.12s.

[0120] The HEVC standard open source encoder x265, which deploys a motion compensated temporal filtering algorithm, takes 7.05 seconds to calculate the motion vectors of all reference frames of the frame to be filtered when using an Intel i5-11400 six-core processor.

[0121] The complexity of the embodiment of the present application under the same environmental configuration is 0.017 times that of x265. It can be seen that the embodiment of the present application greatly reduces the complexity and reduces the time required for calculation.

[0122] In addition, the motion-compensated time-domain filtering algorithm is also optimized in the embodiment of the present application. Taking the BKimono1_1920×1080 sequence as an example, frame POC: 0 is taken as the frame to be filtered, and POC: 2 is taken as the reference frame.

[0123] After the frame to be filtered and the reference frame are put into the optical flow network, the output optical flow graph is as follows Figure 6 shown.

[0124] right Figure 6 The optical flow map is post-processed to generate a compensated frame after compensating the reference frame in units of 8×8 pixel blocks.

[0125] like Figure 7 As shown, some areas of the compensated frame generated by block-based motion compensation (especially the boundary between the background and the person) have obvious block effects.

[0126] After edge smoothing (weighting edge pixels and adjacent pixels) on the pixel block, an optimized pixel block is generated. Figure 8 As shown in the figure, it can be seen that the block effect after edge smoothing is significantly weakened. This optimized compensation frame will make the final filtered frame contain more inter-frame information, thereby improving the overall encoding quality.

[0127] The temporal filtering technology based on motion compensation can greatly reduce the pre-processing algorithm of the video bit rate under the same picture quality. However, due to the high complexity of the algorithm in the motion estimation strategy, it is difficult to apply it to the real-time encoding and transcoding applications such as live broadcast. It is also difficult for the traditional optimization method to reduce the overall complexity to meet the real-time needs. In the application embodiment, the optical flow network is used to replace the most complex hierarchical motion estimation to predict the motion information so that the complexity of the algorithm meets the real-time needs, and the pyramid structure of the optical flow network in the application embodiment can support various forms of mainstream optical flow networks, and the application range is wider. Compared with the existing technical solutions, the embodiment of the present application can greatly reduce the complexity in both CPU and GPU environments to improve the overall speed of encoding. In addition, the improvement of the motion compensation part of the embodiment of the present application effectively reduces the block effect of the compensation frame generated by the algorithm. And the embodiment of the present application greatly reduces the complexity of the relevant technology by utilizing the GPU computing power, so that the encoding time meets the requirements of real-time encoding. It can be applied to any live broadcast and transcoding platform supported by GPU resources, providing users with better video quality with lower bandwidth, that is, improving the user experience under the premise of saving bandwidth resources. In addition, mobile phones, which currently use live broadcast platforms more widely, have more abundant GPU computing power, so they can be used in a wider range.

[0128] Please refer to Fig. 9 The embodiment of the present application further provides a system 20 for pre-processing video encoding, comprising:

[0129] An acquisition module 21 is used to acquire a to-be-filtered frame of a video to be processed and a reference frame of the to-be-filtered frame;

[0130] An optical flow module 22, used for inputting the frame to be filtered and the reference frame into an optical flow network model to obtain an optical flow map corresponding to the reference frame;

[0131] A vector module 23, used to calculate the motion vector of the optical flow map to obtain the motion vector corresponding to each pixel block in the reference frame;

[0132] The processing module 24 is used to perform pre-encoding processing on the frame to be filtered based on the motion vector to obtain a processed frame to be filtered.

[0133] Optionally, the video encoding pre-processing system 20 further includes:

[0134] A compensation module, configured to perform motion compensation on the reference frame based on the motion vector to obtain a compensated frame corresponding to the reference frame;

[0135] The filtering module is used to filter the frame to be filtered based on the compensation frame to obtain a filtered frame to be filtered.

[0136] Optionally, the video encoding pre-processing system 20 further includes:

[0137] The labeling module is used to traverse the reference frame using a sliding window, and perform the following operations for a current pixel block currently corresponding to the sliding window:

[0138] Marking the current pixel block with an edge smoothing mark according to the distance between the motion vector of the current pixel block and the motion vectors of surrounding pixel blocks;

[0139] According to the edge smoothing flag of the current pixel block, it is determined whether to perform edge smoothing compensation on the current pixel block.

[0140] Optionally, the compensation module also includes:

[0141] An edge smoothing compensation module, used for collecting motion vectors of surrounding pixel blocks of the current pixel block if the current pixel block has an edge smoothing flag;

[0142] Removing completely repeated motion vectors from the motion vectors of the surrounding pixel blocks to obtain the deduplicated motion vectors;

[0143] Perform edge smoothing compensation on the current pixel block according to the deduplicated motion vector and edge pixels of the current pixel block.

[0144] Optionally, the acquisition module 21 includes:

[0145] A determination module, used to determine the type of the current frame to be encoded of the video to be processed;

[0146] According to the type of the current frame to be encoded, determining whether the current frame to be encoded is a frame to be filtered;

[0147] If the current frame to be encoded is a frame to be filtered, image frames that are adjacent in time domain to the current frame to be encoded are collected as the reference frames.

[0148] Optionally, the optical flow module includes:

[0149] The frame to be filtered and the reference frame are input into an optical flow network model, and the optical flow network model downsamples the filtered frame and the reference frame and then inputs them into a residual optical flow network in the optical flow network model to obtain a residual optical flow map;

[0150] The residual optical flow map is upsampled to obtain an optical flow map corresponding to the reference frame.

[0151] The video encoding pre-processing system provided in the embodiment of the present application can achieve Figure 2 The various processes implemented by the method embodiment and achieving the same technical effect are not described here to avoid repetition.

[0152] The present application embodiment provides an electronic device 30, see Fig.10 As shown, Fig.10 This is a principle block diagram of an electronic device 30 according to an embodiment of the present application, including a processor 31, a memory 32, and a program or instruction stored in the memory 32 and executable on the processor 31. When the program or instruction is executed by the processor, the steps in any one of the video encoding pre-processing methods of the present application are implemented.

[0153] An embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of an embodiment of a method for pre-processing video encoding as described above is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0154] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0155] The present application also provides a computer program product, including computer instructions, which, when executed by a processor, implement the above Figure 2 The various processes of any of the video encoding pre-processing method embodiments shown can achieve the same technical effect, and will not be described again here to avoid repetition.

[0156] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0157] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, storage and other aspects of user personal information involved in the technical solution of this disclosure are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information and network security.

[0158] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0159] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a service classification device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0160] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for pre-processing video encoding, characterized in that: include: Obtaining a frame to be filtered of a video to be processed and a reference frame of the frame to be filtered; Inputting the frame to be filtered and the reference frame into an optical flow network model to obtain an optical flow graph corresponding to the reference frame; Calculating motion vectors on the optical flow map to obtain motion vectors corresponding to each pixel block in the reference frame; The frame to be filtered is subjected to pre-encoding processing based on the motion vector to obtain a processed frame to be filtered.

2. The method according to claim 1, characterized in that The pre-coding processing of the frame to be filtered based on the motion vector to obtain the processed frame to be filtered comprises: Performing motion compensation on the reference frame based on the motion vector to obtain a compensated frame corresponding to the reference frame; The frame to be filtered is filtered based on the compensation frame to obtain a filtered frame to be filtered.

3. The method according to claim 2, characterized in that Before performing motion compensation on the reference frame based on the motion vector and obtaining a compensated frame corresponding to the reference frame, the method further includes: The reference frame is traversed using a sliding window to determine a current pixel block, and the following operations are performed on the current pixel block: Marking the current pixel block with an edge smoothing mark according to the distance between the motion vector of the current pixel block and the motion vectors of surrounding pixel blocks; According to the edge smoothing flag of the current pixel block, it is determined whether to perform edge smoothing compensation on the current pixel block.

4. The method according to claim 3, characterized in that The performing motion compensation on the reference frame based on the motion vector comprises: If the current pixel block has an edge smoothing flag, collecting motion vectors of surrounding pixel blocks of the current pixel block; Removing completely repeated motion vectors from the motion vectors of the surrounding pixel blocks to obtain the deduplicated motion vectors; Perform edge smoothing compensation on the current pixel block according to the deduplicated motion vector and edge pixels of the current pixel block.

5. The method according to claim 1, characterized in that The step of obtaining a to-be-filtered frame of a video to be processed and a reference frame of the to-be-filtered frame comprises: Determine the type of the current frame to be encoded of the video to be processed; According to the type of the current frame to be encoded, determining whether the current frame to be encoded is a frame to be filtered; If the current frame to be encoded is a frame to be filtered, image frames adjacent in time domain to the current frame to be encoded are collected as the reference frames.

6. The method according to claim 1, characterized in that The step of inputting the frame to be filtered and the reference frame into the optical flow network model to obtain an optical flow graph corresponding to the reference frame comprises: The frame to be filtered and the reference frame are input into an optical flow network model, and the optical flow network model downsamples the filtered frame and the reference frame and then inputs them into a residual optical flow network in the optical flow network model to obtain a residual optical flow map; The residual optical flow map is upsampled to obtain an optical flow map corresponding to the reference frame.

7. A system for pre-processing video encoding, characterized in that: include: An acquisition module, used to acquire a to-be-filtered frame of a video to be processed and a reference frame of the to-be-filtered frame; An optical flow module, used to input the frame to be filtered and the reference frame into an optical flow network model to obtain an optical flow map corresponding to the reference frame; A vector module, used to calculate the motion vector of the optical flow map to obtain the motion vector corresponding to each pixel block in the reference frame; The processing module is used to perform pre-encoding processing on the frame to be filtered based on the motion vector to obtain a processed frame to be filtered.

8. An electronic device, characterized in that: include: A processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the steps of the method for pre-processing video encoding as described in any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium, characterized in that: A computer program is stored on a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the video encoding pre-processing method according to any one of claims 1 to 6 are implemented.

10. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps of the method for pre-processing video encoding as claimed in any one of claims 1 to 6.

Citation Information

Cited By

  • Video compression method and device, equipment and storage medium

    CN120075451A