Video coding method and device, computer equipment and computer storage medium
By using the minimum perceptible error and the expected number difference in video encoding to adjust the encoding bit rate, the problem of low video encoding efficiency in the existing technology is solved, and efficient video encoding processing is achieved.
Patent Information
- Application Number
- CN202310212297.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-24
- Publication Date
- 2024-08-27
AI Technical Summary
While existing video coding methods ensure coding quality, computer equipment requires a long calculation time and amount of calculations to perform complex coding parameter analysis, resulting in low video coding efficiency.
By determining the reference video frame and target video frame from the target video, the encoded video frame and encoding bit rate are obtained, the number of target pixel points is determined based on the minimum perceptible error of the pixel points, and the encoding bit rate is adjusted based on the difference between the expected number and the actual number. to achieve an encoding process close to the expected quality.
It improves the efficiency of video encoding, reduces the consumption of computing resources, and ensures that the encoding quality is close to expected requirements.
Smart Images

Figure CN118555408A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a video encoding method, apparatus, computer equipment and computer storage medium. Background Art
[0002] Computer technology includes video processing technology, and video processing technology can be used to encode videos to facilitate the storage and transmission of the corresponding videos on the network. In the actual process of video encoding, in order to reduce the delay of the encoded video during transmission and save bandwidth, when the computer device encodes the video, it usually first determines the encoding bit rate used when encoding the video frame based on the video information. Most of the current video encoding methods determine the encoding bit rate by referring to the change information of one or more encoding parameters (such as: encoding parameters that affect the video picture quality).
[0003] In this case, if the encoding quality (such as the picture clarity and color vividness of the encoded video) needs to be guaranteed, when the computer equipment uses the current video encoding method to determine the encoding bit rate, it will take a long time and a lot of calculation to perform a complex and comprehensive analysis of the change information of the encoding parameters, resulting in low efficiency of the entire video encoding. Therefore, how to make the encoding quality of video encoding close to the expected quality requirements while improving the efficiency of video encoding has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] The embodiments of the present application provide a video encoding method, apparatus, computer device and computer storage medium, which can make the encoding quality of video encoding close to the expected quality requirements while improving the efficiency of video encoding.
[0005] On the one hand, an embodiment of the present application provides a video encoding method, including:
[0006] determining a reference video frame and a target video frame from a target video;
[0007] Acquire an encoded video frame obtained after encoding the reference video frame, and an encoding bit rate used when encoding the reference video frame;
[0008] Determine, according to the pixel value of each pixel in the reference video frame, a minimum perceptible error of the corresponding pixel, and determine the number of target pixels from the reference video frame, wherein the difference between the pixel value of the target pixel and the pixel value of the pixel corresponding to the target pixel in the encoded video frame is less than or equal to the minimum perceptible error of the target pixel;
[0009] Determine the encoding rate of the target video frame according to the determined number of target pixels and the encoding rate of the reference video frame according to the expected number of target pixels, wherein the expected number is used to represent: the minimum number of target pixels contained in the video frame that meets the expected quality requirements;
[0010] The target video frame is encoded using the encoding bit rate of the target video frame to obtain an encoded video of the target video.
[0011] On the one hand, an embodiment of the present application provides a video encoding device, including:
[0012] A video frame determination unit, used to determine a reference video frame and a target video frame from a target video;
[0013] An acquisition unit, used to acquire a coded video frame obtained after encoding the reference video frame, and a coding bit rate used when encoding the reference video frame;
[0014] an error determination unit, configured to determine a minimum perceptible error of a corresponding pixel point according to a pixel value of each pixel point in the reference video frame, and determine the number of target pixels from the reference video frame, wherein a difference between a pixel value of the target pixel point and a pixel value of a pixel point corresponding to the target pixel point in the encoded video frame is less than or equal to the minimum perceptible error of the target pixel point;
[0015] A bit rate determination unit, configured to determine the encoding bit rate of the target video frame according to the expected number of target pixels, the determined number of target pixels and the encoding bit rate of the reference video frame, wherein the expected number is used to represent: the minimum number of target pixels contained in the video frame that meets the expected quality requirements;
[0016] The encoding unit is used to encode the target video frame using the encoding bit rate of the target video frame to obtain an encoded video of the target video.
[0017] In one aspect, an embodiment of the present application provides a computer device, including:
[0018] A processor configured to execute one or more computer programs;
[0019] A computer storage medium storing one or more computer programs, wherein the one or more computer programs are suitable for being loaded by the processor and implementing the video encoding method according to the first aspect.
[0020] On the one hand, an embodiment of the present application further provides a computer storage medium, wherein the computer storage medium stores one or more computer programs, wherein the one or more computer programs are suitable for being loaded by a processor and implementing the video encoding method as in the first aspect.
[0021] On the other hand, an embodiment of the present application provides a program product, which includes a computer program, and the computer program is suitable for being loaded by a processor and executing the video encoding method of the first aspect.
[0022] In an embodiment of the present application, the expected quality requirement is indicated by the expected number of target pixels, so that the computer device can measure the quality difference between the encoding quality when the computer device uses the encoding bit rate of the reference video frame for encoding processing and the encoding quality corresponding to the expected quality requirement according to the difference between the expected number of target pixels and the actual number of target pixels (i.e., the number of target pixels determined from the reference video frame). Since the reference video frame and the target video frame are both video frames in the target video, and usually when the same encoding bit rate is used to encode the two, the encoding quality reflected by the computer device is similar, so the quality of the encoded frame obtained by encoding is also similar. Therefore, the computer device can refer to the quality difference reflected by the expected number and the actual number to adaptively adjust the encoding bit rate of the reference video frame, so as to quickly determine a coding bit rate that can be used to obtain a coding frame close to the expected quality requirement, and the determined coding bit rate is the coding bit rate of the target video. It can be seen that when a computer device determines the encoding bit rate of a target video frame based on the expected number of target pixels, the actual number of target pixels, and the encoding bit rate of a reference video frame, it can not only enable the computer device to use the determined encoding bit rate to encode the target video frame to obtain an encoded frame that is close to the expected quality requirement, but also improve the overall efficiency of the computer device when encoding the target video. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0024] Figure 1 It is a schematic diagram of a coding rate adjustment principle provided in an embodiment of the present application;
[0025] Figure 2 is a schematic flow chart of a video encoding method provided in an embodiment of the present application;
[0026] Figure 3a It is a schematic diagram of a minimum perceptible error calculation process provided by an embodiment of the present application;
[0027] Figure 3b is a schematic diagram of a contrast filter matrix provided in an embodiment of the present application;
[0028] Figure 3c It is a schematic diagram of the relationship between brightness contrast and brightness contrast perceptible error provided by an embodiment of the present application;
[0029] Figure 4 is a schematic flow chart of another video encoding method provided in an embodiment of the present application;
[0030] Figure 5 is a structural diagram of a video encoding device provided in an embodiment of the present application;
[0031] Figure 6 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to enable those skilled in the art to better understand the solutions provided by the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be noted that the various specific embodiments described in the embodiments of the present application are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the various embodiments in the present application, all other embodiments obtained by ordinary technicians of the art without making creative work are within the scope of protection of this application.
[0033] The embodiment of the present application proposes a video encoding scheme. When the scheme is applied to the video encoding scenario, it can not only make the encoded video have a higher quality to present a better visual display effect, but also improve the overall efficiency of video encoding. Among them, video encoding can be understood as the process of converting a file in the original video format into a file in another video format through compression technology. In general, video encoding will cause certain damage to the quality of the video frame, making the quality of the encoded video frame lower than the quality of the video frame before encoding. Therefore, in the video encoding process, it is necessary to make the encoded video frame have a higher quality as much as possible. The following will be combined with Figure 1The schematic diagram of the principle of encoding bit rate adjustment shown in the figure explains the general principle of the video encoding scheme proposed in the embodiment of the present application: when it is necessary to perform video encoding on the target video, the computer device first determines the reference video frame and the target video frame from the target video, and then obtains the encoded video frame obtained after encoding the reference video frame, and the encoding bit rate adopted when encoding the reference video frame. Among them, the encoding order of the reference video frame is before the target video frame, and the target video frame can be regarded as the video frame that needs to be encoded at present. In addition, after determining the reference video frame, the computer device can also determine the minimum perceptible error (JND, Just Noticeable Difference) of each pixel point according to the pixel value of each pixel point in the reference video frame. Based on the determined minimum perceptible error, the computer device can determine the number of target pixels from the reference video frame. Specifically, each pixel in the reference video frame has a corresponding encoded pixel in the encoded video frame. When the difference between the pixel value of a certain pixel in the reference video frame and the pixel value of the corresponding pixel in the encoded video frame is less than or equal to the minimum perceptible error of the pixel (i.e., the aforementioned "a certain pixel"), the computer device can determine the pixel as a target pixel. Further, after determining the number of target pixels from the reference video frame, the computer device can determine the encoding rate of the target video frame according to the expected number of target pixels, the determined number of target pixels, and the encoding rate of the reference video frame, wherein the expected number refers to the minimum number of target pixels contained in the video frame that meets the expected quality requirements. Further, the computer device can use the determined encoding rate of the target video frame to encode the target video frame, so that the computer device can encode each video frame in the target video based on this principle, thereby realizing the encoding process of the target video and finally obtaining the encoded video of the target video.
[0034] Since the difference between the pixel value of the target pixel in the reference video frame and the pixel value of the corresponding pixel in the coded video frame is less than or equal to the corresponding minimum perceptible error, and the minimum perceptible error is used to measure the maximum image distortion that cannot be perceived by the human eye, the number of target pixels determined from the reference video frame can be used to indicate the degree of damage to the picture quality when the computer device uses the coding rate of the reference video frame to encode the reference video frame. Among them, the more target pixels there are, the smaller the degree of damage is, which further indicates that the visual presentation effect of the coded video frame when displayed is closer to the visual presentation effect corresponding to the reference video frame, and the quality of the coded video frame is easier to meet the expected quality requirements. Among them, the expected quality requirements are indicated by the expected number of target pixels, so that the computer device can measure the quality difference between the coding quality when the computer device uses the coding rate of the reference video frame for coding and the coding quality corresponding to the expected quality requirements according to the difference between the expected number of target pixels and the actual number of target pixels (that is, the number of target pixels determined from the reference video frame). Since the reference video frame and the target video frame are both video frames in the target video, when the same encoding bit rate is usually used to encode the two, the encoding quality reflected by the computer device is similar, so the quality of the encoded frame obtained by encoding is also similar. Therefore, the computer device can refer to the quality difference reflected by the expected number and the actual number to adaptively adjust the encoding bit rate of the reference video frame, so as to quickly determine a coding bit rate that can be used to obtain a coding frame close to the expected quality requirement, and the determined coding bit rate is the coding bit rate of the target video. It can be seen that when the computer device determines the encoding bit rate of the target video frame according to the expected number of target pixels, the actual number of target pixels, and the encoding bit rate of the reference video frame, not only can the computer device use the determined encoding bit rate to encode the target video frame to obtain a coding frame close to the expected quality requirement, but also the overall efficiency of the computer device when encoding the target video can be improved.
[0035] In one embodiment, the computer device for executing the above-mentioned video coding scheme may be composed of one or two devices in a terminal device and a server, and the number of each device may be one or more. Wherein, when the computer device includes a terminal device, the terminal device may specifically include but is not limited to: a smart phone, a tablet computer, a laptop computer, a desktop computer, a vehicle-mounted terminal, a smart TV, a game console, etc. In addition, one or more applications (or clients) for providing video coding services may be run in the terminal device, and among the one or more applications, at least one application's video coding service is developed using the principle of the above-mentioned video coding scheme. Of course, in addition to the application for providing video coding services, various other applications may also be run in the terminal device, such as image processing applications, multimedia playback applications, and navigation applications, etc., which are not specifically limited in the embodiments of the present application. In addition, when the computer device includes a server, the server may specifically include but is not limited to an independent physical server, a server cluster or distributed system composed of multiple physical servers, and one or more cloud servers that provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms, etc., and the embodiments of the present application do not make specific restrictions on this. However, it should be noted that the server included in the computer device can at least provide corresponding support services (such as computing services, storage services, push services, etc.) for the implementation of the video encoding service. In other words, the server included in the computer device can establish a communication connection with the client (or application) that provides the video encoding service, and the client can run on the target terminal device, and the target terminal device refers to: a terminal device that has a communication connection established with the server.
[0036] Based on the general principle of the above video encoding scheme, the embodiment of the present application provides a video encoding method, which can be executed by the above computer device. In addition, the flow chart of the video encoding method can be found in Figure 2 As shown by Figure 2 It can be seen that the method may include steps S201-S205:
[0037] S201: Determine a reference video frame and a target video frame from a target video.
[0038] In one embodiment, the target video refers to a video that needs to be encoded, and the video may include multiple video frames, and the computer device encodes the target video by encoding each video frame in sequence. That is to say, the multiple video frames contained in the target video have an encoding sequence, and the reference video frame and the target video frame exist in these multiple video frames. Among them, for ease of understanding, the target video frame can be regarded as a video frame that needs to be encoded, and the reference video frame is a video frame that has been encoded before the target video frame is encoded. For example, suppose that the computer device determines the encoding sequence for video frame A as a, the encoding sequence for video frame B as b, and the encoding sequence for video frame C as c, and the encoding sequence indicated by a is before the encoding sequence indicated by b, and the encoding sequence indicated by b is before c. Then, when the target video frame is video frame B, since the encoding sequence of video frame A is before video frame B, video frame A can be used as a reference video frame. Correspondingly, video frame C cannot be used as a reference video frame because its encoding sequence is after video frame B.
[0039] In a specific implementation, the computer device can determine the target video frame by traversing the video frames in the target video. Specifically, the computer device first determines the encoding order of each video frame in the target video, and then traverses the video frames in the target video according to the encoding order. That is to say, the i-th traversed video frame is the i-th video frame determined by the computer device to be encoded, and i can be a positive integer greater than 1. In this case, the computer device can use the currently traversed video frame as the target video frame, and determine a video frame from the traversed video frames in the target video as a reference video frame. It should be noted that in one implementation, when the video frame currently traversed by the computer device is the first video frame to be encoded, there is no traversed video frame in the target video, and the computer device can select a video frame from the last encoded video as a reference video frame. Optionally, the computer device can use any video frame in the last encoded video as a reference video frame, or the last encoded video frame in the last encoded video as a reference video frame. Of course, in other implementations, when the video frame currently traversed by the computer device is the first video frame to be encoded, the computer device may also not determine the reference video frame, and subsequently directly use the preset default encoding bit rate as the encoding bit rate of the target video frame to implement the encoding processing of the target video frame. The embodiments of the present application will not explain this in detail.
[0040] S202: Obtain an encoded video frame obtained by encoding the reference video frame, and an encoding bit rate used when encoding the reference video frame.
[0041] In one embodiment, when the computer device completes the encoding process for a video frame, corresponding encoding information will be generated. The encoding information may include the encoded frame obtained by encoding, and may also include parameter information of one or more encoding parameters used when implementing the encoding. Optionally, there may be an encoding bit rate in the one or more encoding parameters, so that the computer device can obtain the encoded video frame and the encoding bit rate used when encoding the reference video frame from the encoding information of the reference video frame. Of course, in other embodiments, the computer device may also obtain the encoding bit rate in other ways, such as: sending a bit rate acquisition request to a target module in the computer device, the bit rate acquisition request is used to request to obtain the encoding bit rate of the reference video frame, the target module is used to encode the video frame, and then the computer device can obtain the encoding bit rate of the reference video frame by receiving the encoding bit rate fed back by the target module.
[0042] Among them, the coding rate is also called bit rate or bit rate, which usually refers to the amount of information transmitted through the channel within a unit time (such as 1 second), and the unit of the coding rate is generally bit / second (bit / s). The coding rate in video coding refers to the sampling rate of converting the video from an analog signal to a digital signal. Different coding rates determine the degree of compression when the computer device encodes the target video, so the coding rate is a key factor in determining the final quality and file size of the encoded video of the target video. In general, the higher the coding rate, the higher the image quality of the encoded video, relative to the image quality of the video encoded at a lower coding rate, but the larger the encoded video is. In an embodiment of the present application, the goal of video encoding is to save as much coding rate as possible, while ensuring the quality of the encoded video as much as possible, so when the computer device encodes the target video frame in the target video, it can first determine a coding rate that allows the quality of the encoded video frame to meet the expected quality requirements, so that the encoding rate is used to encode the target video frame, which can not only achieve the purpose of saving the coding rate, but also ensure the quality of the encoded video.
[0043] S203. Determine the minimum perceptible error of the corresponding pixel according to the pixel value of each pixel in the reference video frame, and determine the number of target pixels from the reference video frame, and the difference between the pixel value of the target pixel and the pixel value of the corresponding pixel in the encoded video frame is less than or equal to the minimum perceptible error of the target pixel.
[0044] In one embodiment, the minimum perceptible error reflects the tolerance of the human eye to changes in the video frame. Therefore, in the field of image processing, the minimum perceptible error can be used to measure the sensitivity of the human eye to distortion in different areas of the image, and the smaller the minimum perceptible error, the higher the sensitivity. In an embodiment of the present application, when the deviation between the video frame before encoding and the encoded frame obtained by encoding is less than or equal to the minimum perceptible error, the difference in visual presentation effect between the video frame before encoding and the encoded frame obtained by encoding is negligible. In actual scenes, the sensitivity of the human eye is different under different background brightness. Specifically, the sensitivity of the human eye is lower in a dark environment (i.e., when the background brightness is low) than in a bright environment (i.e., when the background brightness is high), and the tolerance to changes is greater. In addition, the sensitivity of the human eye under different brightness contrasts is also different. Among them, the brightness contrast in a video frame refers to the difference between the brightness values of different pixels. The greater the brightness contrast, the greater the difference in brightness values between different pixels, and the more uneven the distribution of brightness values of spatial pixels in the corresponding area of the video frame. The non-uniformity of brightness values can lead to a masking effect on the stimulus in the human eye, that is, the brightness contrast will affect the sensitivity of the human eye to changes in the video frame. Specifically, the human eye is more sensitive to areas with non-uniform brightness than to uniform areas. For example, in a video frame area where the brightness value changes dramatically, the human eye is less sensitive to color changes, while in a video frame area where the brightness value changes gently, the human eye is more sensitive to color changes.
[0045] Based on this, in order to determine a more applicable minimum perceptible error, the computer device can exemplarily adopt the following method: Figure 3a In the manner shown, the brightness perceptible error (or: brightness adaptive perceptible threshold) and the brightness contrast perceptible error are determined respectively, and then the minimum perceptible error is determined according to the brightness perceptible error and the brightness contrast perceptible error. Specifically, the computer device can first use the brightness filter matrix to filter the reference video frame to obtain a brightness filter map of the reference video frame. In addition, the computer device can also use the contrast filter matrix to filter the reference video frame to obtain a contrast filter map of the reference video frame, and then determine the minimum perceptible error of each pixel point according to the contrast filter map and the brightness filter map.
[0046] Among them, the pixel value of a pixel in the brightness filter map can be used to indicate the average brightness of a local area in the reference video frame, and the size of the local area is related to the dimension of the brightness filter matrix. Specifically, if the brightness filter matrix is an M*N matrix, the size of the local area can be Mpx*Npx, where px is the abbreviation of pixel, and M and N are both positive integers. In addition, each pixel in the reference video frame has a corresponding pixel in the brightness filter map. Optionally, in one implementation, a pixel in the reference video frame can correspond to a pixel in the brightness filter map, and in another implementation, multiple pixels in the reference video frame can also correspond to a pixel in the brightness filter map, and the embodiment of the present application does not limit this. Correspondingly, the pixel value of a pixel in the contrast filter map can be used to indicate the brightness contrast of a local area in the reference video frame, and the size of the local area is related to the dimension of the contrast filter matrix. If the contrast filter matrix is an X*Y matrix, the size of the local area can be Xpx*Ypx, and X and Y are both positive integers. It is worth mentioning that in the embodiment of the present application, the number of contrast filter matrices may be k, and the dimensions of each contrast filter matrix are the same, but the action directions of different contrast filter matrices may be different. For example, k is a positive integer in the interval [1, 4]. When k=4, the contrast filter matrix used in the embodiment of the present application may be exemplarily Figure 3b The individual contrast filter matrices in .
[0047] Then, when determining the perceptible error in brightness contrast, the computer device can first use the contrast filter matrix in k directions to filter the reference video frame to obtain the gradient values of each pixel of the reference video frame in k directions, and then take the maximum gradient value in k directions as the brightness contrast of the corresponding pixel, and then obtain a contrast filter map containing the brightness contrast of each pixel. In practical applications, the computer device can use the method shown in Formula 1 and Formula 2 to determine the contrast filter map of the reference video frame, and use the method shown in Formula 3 to determine the perceptible error in brightness contrast of each pixel in the reference video frame according to the contrast filter map. In Formula 1, I represents the reference video frame, which contains the pixel value of each pixel in the reference video frame; represents the i-th contrast filter matrix, and G i It means using A contrast filter image obtained after filtering; is a hyperparameter, and illustratively,
[0048]
[0049] In Formula 2, LC represents the contrast filter map of the reference video frame, LC(x) represents the brightness contrast of pixel x in the reference video frame; G i () represents the brightness contrast corresponding to the pixel point x in the contrast filter map obtained using the i-th contrast filter matrix; k is the number of contrast filter matrices, and k is a positive integer.
[0050] LC(x)=max i=1,...,k G i (x) Formula 2
[0051] In Formula 3, CM represents the brightness contrast error, CM(x) represents the brightness contrast perceptible error of pixel x in the reference video frame, and LC(x) represents the brightness contrast of pixel x in the reference video frame; α and β are both hyperparameters, and α=16, β=26 for example. The relationship between brightness contrast and brightness contrast perceptible error can be referred to Figure 3c .
[0052]
[0053] In addition, exemplarily, the computer device may also determine the brightness perceptible error of each pixel in the reference video frame according to the brightness filter map of the reference video frame in the manner shown in Formula 4, and then determine the minimum perceptible error of the pixel according to the brightness perceptible error and brightness contrast perceptible error of the pixel in the manner shown in Formula 5. In Formula 4, LA(x) represents the brightness perceptible error of pixel x in the reference video frame; B represents the brightness filter map obtained by filtering the reference video frame using the brightness filter matrix, and B(x) represents the pixel value corresponding to the pixel x in the reference video frame in the brightness filter map, which is used to indicate the average brightness value of the local area where the pixel x is located.
[0054]
[0055] In Formula 5, JND(x) represents the minimum perceptible error of pixel x in the reference video frame, CM(x) represents the perceptible error of brightness contrast of pixel x in the reference video frame, LA(x) represents the perceptible error of brightness contrast of pixel x in the reference video frame, c is a hyperparameter, and exemplarily, c=0.25.
[0056] JND(x)=LA(x)+CM(x)-c·min{LA(x),CM(x)} Equation 5
[0057] It should be noted that, in other embodiments, the computer device may also adopt other methods to determine the minimum perceptible error by referring to the brightness perceptible error and the contrast perceptible error, or even refer to the brightness perceptible error, the contrast perceptible error, and other parameters to determine the minimum perceptible error, and the embodiments of the present application are not limited to this. Exemplarily, other methods may be such as the method shown in Formula 6, or the method shown in Formula 7, and the embodiments of the present application are not described in detail. In Formula 7, m and n respectively represent the weight of LA(x) and the weight of CM(x), and the weight may be a preset value, or the computer device may refer to the values of LA(x) and CM(x) and then determine the value by other methods, and the embodiments of the present application are not limited to this.
[0058] JND(x)=LA(x)+CM(x)-c·max{LA(x),CM(x)} Equation 6
[0059] JND(x)=m*LA(x)+n*CM(x) Formula 7
[0060] S204, determining the encoding rate of the target video frame according to the expected number of target pixels, the determined number of target pixels and the encoding rate of the reference video frame, wherein the expected number is used to represent: the minimum number of target pixels contained in the video frame that meets the expected quality requirements.
[0061] In one embodiment, the expected number may be pre-set in the computer device, or may be calculated by the computer device according to the expected quality requirement, and the expected quality requirement may be parsed by the computer device from the encoding quality request of the target video, or may be obtained through other means, and the embodiment of the present application is not limited to this.
[0062] S205 , encoding the target video frame using the encoding bit rate of the target video frame to obtain an encoded video of the target video.
[0063] In an embodiment of the present application, the expected quality requirement is indicated by the expected number of target pixels, so that the computer device can measure the quality difference between the encoding quality when the computer device uses the encoding bit rate of the reference video frame for encoding processing and the encoding quality corresponding to the expected quality requirement according to the difference between the expected number of target pixels and the actual number of target pixels (i.e., the number of target pixels determined from the reference video frame). Since the reference video frame and the target video frame are both video frames in the target video, and usually when the same encoding bit rate is used to encode the two, the encoding quality reflected by the computer device is similar, so the quality of the encoded frame obtained by encoding is also similar. Therefore, the computer device can refer to the quality difference reflected by the expected number and the actual number to adaptively adjust the encoding bit rate of the reference video frame, so as to quickly determine a coding bit rate that can be used to obtain a coding frame close to the expected quality requirement, and the determined coding bit rate is the coding bit rate of the target video. It can be seen that when a computer device determines the encoding bit rate of a target video frame based on the expected number of target pixels, the actual number of target pixels, and the encoding bit rate of a reference video frame, it can not only enable the computer device to use the determined encoding bit rate to encode the target video frame to obtain an encoded frame that is close to the expected quality requirement, but also improve the overall efficiency of the computer device when encoding the target video.
[0064] The present application embodiment also provides another video encoding method, which can also be executed by the above-mentioned computer device. Figure 4 , Figure 4 FIG. 1 is a flow chart of the video encoding method. Figure 4 It can be seen that the method may include steps S401-S406:
[0065] S401: Determine a reference video frame and a target video frame from a target video.
[0066] In one embodiment, the coding order of the reference video frame may be adjacent to the coding order of the target video frame, and the coding order of the reference video frame precedes the coding order of the target video frame. That is, when the target video frame is the video frame that needs to be coded currently, the reference video frame may be the last coded video frame. In another embodiment, the reference video frame may also be any video frame in the first video segment, or the last coded video frame in the first video segment, and the target video frame may be specifically the first coded video frame in the second video segment, and the coding rate of other video frames in the second video segment may follow the coding rate of the target video frame. Among them, the first video segment and the second video segment are obtained by segmenting the target video, and the coding order of the first video segment takes precedence over the coding order of the second video segment, and may specifically be the video segment whose coding order is before the second video segment. That is, if the first video segment is the pth coded video segment, the second video segment is the p+1th coded video segment.
[0067] S402: Obtain an encoded video frame obtained by encoding the reference video frame, and an encoding bit rate used when encoding the reference video frame.
[0068] In one embodiment, before obtaining the coded video frame, the computer device may first predict whether the target video frame is a video frame after the scene switching. For video frames in the same scene, the computer device uses similar encoding rates when encoding the coded frames while ensuring that the quality of the coded frames after encoding is close to the expected quality requirements. Therefore, in order to save computing resources and improve the encoding efficiency of the target video frame, the embodiment of the present application can directly use the encoding rate of the reference video frame as the encoding rate of the target video frame when the prediction result indicates that "the target video frame and the reference video frame are in the same scene (such as shooting under the same natural scenery)". For video frames in different scenes, if the quality of the coded frames after encoding is to be guaranteed to be close to the expected quality requirements, there will be certain differences in the encoding rates used when encoding the two video frames. For example, when the target video frame is shot in a botanical garden and the reference video frame is shot in an empty room, the background complexity of the target video frame will be greater than the background complexity of the reference video frame, so that the encoding rate used when encoding the target video frame will be greater than the encoding rate used when encoding the reference video frame, so that the quality of the corresponding coded frame obtained after encoding is close to the expected quality requirements.
[0069] In a specific application, the computer device can predict whether the scene is switched in the following manner: the computer device first obtains the encoding parameter value of the historical encoding frame and the encoding parameter value of the reference video frame, and when the difference between the encoding parameter value of the historical encoding frame and the encoding parameter value of the reference video frame is greater than or equal to the preset difference, it is considered that the scene of the target video frame is switched, thereby triggering the execution of step S402. Among them, the encoding order of the historical encoding frame is adjacent to the encoding order of the reference video frame, and the encoding order of the historical encoding frame is prior to the encoding order of the reference video frame, and the encoding parameter value is used to indicate the parameter value of the target encoding parameter used when encoding the corresponding video frame. Among them, the target encoding parameter can be a motion vector, or a QP (Quantizer Parameter), or a SATD (Sum of Absolute Transformed Difference), and the parameter value of the target encoding parameter can be obtained from the encoding information of the reference video frame, and the encoding information is generated by the computer device after completing the encoding process of the reference video frame.
[0070] Correspondingly, in one embodiment, when the difference between the encoding parameter value of the historical encoding frame and the encoding parameter value of the reference video frame is less than a preset difference, the computer device can use the encoding bit rate adopted when encoding the reference video frame as the encoding bit rate of the target video frame, and adopt the encoding bit rate of the target video frame to encode the target video frame to obtain the encoded video of the target video.
[0071] S403. Determine the minimum perceptible error of the corresponding pixel according to the pixel value of each pixel in the reference video frame, and determine the number of target pixels from the reference video frame, and the difference between the pixel value of the target pixel and the pixel value of the corresponding pixel in the encoded video frame is less than or equal to the minimum perceptible error of the target pixel.
[0072] In one embodiment, the relevant implementation method of step S403 can refer to the specific embodiment of the above-mentioned step S203, and this application will not repeat it here.
[0073] S404: Determine a bit rate adjustment amount according to a difference between a preset expected number of target pixel points and the determined number of target pixel points, wherein the bit rate adjustment amount is positively correlated with the difference in number.
[0074] In one embodiment, when determining the bit rate adjustment amount, the computer device may first obtain the bit rate adjustment parameters of the target video frame, and then determine the bit rate adjustment amount based on the bit rate adjustment parameters and the quantitative difference between the expected number and the determined number of target pixels. It is worth noting that when the expected number is less than the actual number (i.e., the determined number of target pixels), the quantitative difference is a negative value, and the corresponding bit rate adjustment amount may also be a negative value. In other words, the quantitative difference and the bit rate adjustment amount in the embodiments of the present application do not refer to absolute values. Optionally, the computer device may determine the bit rate adjustment amount in a manner as shown in Formula 8. In Formula 8, Br a is the bit rate adjustment amount, γ represents the bit rate adjustment parameter, S represents the expected number, and T represents the number of target pixels determined from the reference video frame.
[0075] Br a =γ·(ST) Formula 8
[0076] Optionally, in other application scenarios, the computer device may also use other methods to determine the bit rate adjustment amount, so that the bit rate adjustment amount is positively correlated with the corresponding quantity difference. For example, the computer device may use the method shown in Formula 9 to determine the bit rate adjustment amount. In Formula 9, Br a is the bit rate adjustment amount, γ represents the bit rate adjustment parameter; D represents the first ratio, which refers to the ratio between the expected number and the total number of pixels contained in the reference video frame; R represents the second ratio, which refers to the ratio between the number of target pixels determined from the reference video frame and the total number of pixels contained in the reference video frame.
[0077] Br a =γ·(DR) Formula 9
[0078] In practical applications, the encoding rate used by the computer device and the second ratio in Formula 9 are in a nonlinear relationship. Therefore, in order to obtain a more accurate rate adjustment amount, the computer device can use a function indicating a nonlinear mapping relationship to implement it when determining the rate adjustment amount. Among them, the function indicating the nonlinear mapping relationship can be one or more of an exponential function, a piecewise function, a logarithmic function, and a power function, etc., and the embodiment of the present application does not make specific restrictions. When the function used is a piecewise function, illustratively, the piecewise function can be specifically shown in Formula 10. The piecewise function shown in Formula 10 indicates that the encoding rate parameter of the target video frame can be determined according to the encoding rate used when the reference video frame is encoded. Specifically, when the computer device obtains the rate adjustment parameter of the target video frame, it can first determine the rate interval in which the encoding rate of the reference video frame is located, and according to the preset correspondence between the rate interval and the rate adjustment parameter, determine the rate adjustment parameter corresponding to the rate interval in which the encoding rate of the reference video frame is located, and then use the determined rate adjustment parameter as the rate adjustment parameter of the target video frame.
[0079]
[0080] Among them, Br1 and Br2 are the starting points of different bit rate intervals, which can be determined according to specific encoding requirements. The embodiment of the present application does not impose specific restrictions on the values of the two. However, it is worth mentioning that in specific video encoding, when a computer device uses a coding rate in a lower bit rate interval (i.e., the coding bit rate in this interval is smaller) to encode the video, as the coding bit rate increases, R will increase rapidly, resulting in Br a Then, in order to make Br a It can change smoothly to determine the encoding bit rate suitable for the target video frame more quickly and accurately, and the computer device can set a smaller value for the bit rate adjustment parameter γ1. Correspondingly, when the computer device uses a coding bit rate in a higher bit rate interval (that is, the coding bit rate in this interval is smaller) for video encoding, the change in the coding bit rate has a smaller impact on R, so as the coding bit rate increases, the increase of R gradually slows down. At this time, the computer device can take a larger value for the bit rate adjustment parameter γ3. It should be noted that there is no limitation on the size relationship between γ1 and γ3, that is, in the embodiment of the present application, γ1 is not limited to be less than γ3.
[0081] In other embodiments, in order to reduce the amount of calculation of the computer device, the bit rate adjustment parameter may of course also be a pre-set fixed value, which is not described in detail in the embodiments of the present application.
[0082] S405 : Determine the encoding bit rate of the target video frame based on the encoding bit rate of the reference video frame and the bit rate adjustment amount.
[0083] In one embodiment, the computer device can directly use the weighted summation result of the coding rate of the reference video frame and the rate adjustment amount as the coding rate of the target video frame. The weight used in the weighted summation can be pre-set or determined according to the value of the coding rate and the value of the rate adjustment amount. In addition, the weight of the coding rate of the reference video frame can be the same as the weight of the rate adjustment amount (such as both are 1) or different, and the determination method of the weight of the embodiment of the present application is not limited. Of course, in other embodiments, in order to adapt to video encoding in other complex scenes, the computer device can also use other composite functions to determine the coding rate of the target video frame based on the coding rate and the rate adjustment amount of the reference video frame.
[0084] S406: Encode the target video frame using the encoding bit rate of the target video frame to obtain an encoded video of the target video.
[0085] In one embodiment, the relevant implementation method of step S406 can refer to the specific embodiment of the above-mentioned step S205, and this application will not repeat it here.
[0086] In an embodiment of the present application, when determining the encoding bit rate of the target video frame, the computer device first determines the bit rate adjustment amount according to the difference between the expected number of target pixels and the actual number of target pixels (i.e., the number of target pixels determined from the reference video frame), and the expected number of target pixels is used to indicate the expected quality requirement of the encoded video frame, so that the computer device can measure the quality difference between the encoding quality when the computer device uses the encoding bit rate of the reference video frame for encoding and the encoding quality corresponding to the expected quality requirement according to the difference in number. Then, since the reference video frame and the target video frame are both video frames in the target video, and usually when the same encoding bit rate is used to encode the two, the quality of the encoded frame encoded by the computer device is similar. Therefore, the computer device can quickly determine the encoding bit rate of the target video frame by adjusting the encoding bit rate of the reference video frame using the bit rate adjustment amount to obtain the encoding bit rate of the target video frame. In addition, since the human visual system has a masking effect on some video distortions, when encoding the video, it is only necessary to make the computer device use the corresponding encoding bit rate to achieve the image quality of the video frame obtained by encoding, which can be shielded by the masking effect of the human eye. At the computer's logical processing level, whether the masking effect of the human eye when viewing the video frame will be triggered can be expressed based on the minimum perceptible error of the pixel point, so that the computer device can reduce the occurrence of encoding redundancy, thereby saving encoding resources (such as encoding bit rate). Based on this, the embodiment of the present application can also realize the encoding processing of the corresponding video in scenarios such as cloud games, video conferencing and network on-demand video transmission using limited bandwidth, so as to effectively reduce the encoding bit rate while ensuring the picture quality, thereby achieving a balance between encoding cost and encoding performance.
[0087] Based on the above Figure 2 as well as Figure 4 In a related embodiment of the present application, a video encoding device is also proposed, which may be a computer program running on the above-mentioned computer device. In a specific embodiment, the video encoding device may be used to perform the following Figure 2 as well as Figure 4 The steps of the video encoding method shown in Figure 5 The video encoding device at least includes a video frame determination unit 501, an acquisition unit 502, an error determination unit 503, a bit rate determination unit 504 and an encoding unit 505, wherein:
[0088] The video frame determination unit 501 is used to determine a reference video frame and a target video frame from a target video;
[0089] The acquisition unit 502 is used to acquire the encoded video frame obtained after encoding the reference video frame, and the encoding bit rate used when encoding the reference video frame;
[0090] The error determination unit 503 is used to determine the minimum perceptible error of the corresponding pixel point according to the pixel value of each pixel point in the reference video frame, and determine the number of target pixel points from the reference video frame, and the difference between the pixel value of the target pixel point and the pixel value of the pixel point corresponding to the target pixel point in the encoded video frame is less than or equal to the minimum perceptible error of the target pixel point;
[0091] The bit rate determination unit 504 is used to determine the encoding bit rate of the target video frame according to the expected number of target pixels, the determined number of target pixels and the encoding bit rate of the reference video frame, wherein the expected number is used to represent: the minimum number of target pixels included in the video frame that meets the expected quality requirement;
[0092] The encoding unit 505 is configured to encode the target video frame using the encoding bit rate of the target video frame to obtain an encoded video of the target video.
[0093] In one implementation, the bit rate determination unit 504 may be specifically configured to perform:
[0094] Determining a bit rate adjustment amount according to a number difference between the expected number and the determined number of target pixels, wherein the bit rate adjustment amount is positively correlated with the number difference;
[0095] The encoding bit rate of the target video frame is determined based on the encoding bit rate of the reference video frame and the bit rate adjustment amount.
[0096] In yet another implementation, the bit rate determining unit 504 may also be specifically configured to execute:
[0097] Obtaining a bit rate adjustment parameter of the target video frame;
[0098] The bit rate adjustment amount is determined according to the bit rate adjustment parameter and a difference between the expected number and the determined number of target pixels.
[0099] In yet another implementation, the bit rate determining unit 504 may also be specifically configured to execute:
[0100] Determining a bit rate interval in which the encoding bit rate of the reference video frame lies;
[0101] Determining the bit rate adjustment parameter corresponding to the bit rate interval in which the encoding bit rate of the reference video frame is located according to a preset correspondence relationship between the bit rate interval and the bit rate adjustment parameter;
[0102] The determined bit rate adjustment parameter is used as the bit rate adjustment parameter of the target video frame.
[0103] In yet another implementation, the acquiring unit 502 may also be specifically configured to execute:
[0104] Acquire a coding parameter value of a historical coding frame and a coding parameter value of the reference video frame, wherein the coding order of the historical coding frame is adjacent to the coding order of the reference video frame, and the coding order of the historical coding frame is prior to the coding order of the reference video frame, and the coding parameter value is used to indicate a parameter value of a target coding parameter used when encoding the corresponding video frame;
[0105] If the difference between the encoding parameter value of the historical encoding frame and the encoding parameter value of the reference video frame is greater than or equal to the preset difference, the step of obtaining the encoded video frame obtained after encoding the reference video frame and the encoding bit rate used when encoding the reference video frame is triggered.
[0106] In yet another implementation, the acquiring unit 502 may also be specifically configured to execute:
[0107] If the difference between the encoding parameter value of the historical encoding frame and the encoding parameter value of the reference video frame is less than the preset difference, the encoding bit rate used when encoding the reference video frame is used as the encoding bit rate of the target video frame;
[0108] The target video frame is encoded using the encoding bit rate of the target video frame to obtain an encoded video of the target video.
[0109] In yet another embodiment, the coding order of the reference video frame is adjacent to the coding order of the target video frame, and the coding order of the reference video frame is prior to the coding order of the target video frame; or,
[0110] The reference video frame is any video frame or the last encoded video frame in the first video segment, and the target video frame is the first encoded video frame in the second video segment, wherein the first video segment and the second video segment are obtained by segmenting the target video, and the encoding order of the first video segment is prior to the encoding order of the second video segment.
[0111] In yet another implementation manner, the error determination unit 503 may also be specifically configured to execute:
[0112] Using a brightness filter matrix to filter the reference video frame to obtain a brightness filter map of the reference video frame;
[0113] Using a contrast filter matrix to filter the reference video frame to obtain a contrast filter map of the reference video frame;
[0114] The minimum perceptible error of each pixel is determined according to the contrast filter map and the brightness filter map.
[0115] According to one embodiment of the present application, Figure 5 The various units in the video encoding device shown are divided based on logical functions, and the above-mentioned various units can be separately or all merged into one or several other units to constitute, or one (some) of the units can be further divided into multiple functionally smaller units to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. In other embodiments of the present application, the above-mentioned video encoding device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented with the assistance of multiple units.
[0116] According to another embodiment of the present application, the program can be executed on a general communication device such as the above-mentioned computer device, which includes a central processing unit (CPU), a random access memory medium (RAM), a read-only memory medium (ROM), and other processing elements and storage elements. Figure 2 and Figure 4 A computer program (including program code) for each step of the method shown in FIG. Figure 5 The video encoding device shown in the figure is used to implement the video encoding method of the embodiment of the present application. The computer program can be recorded on a computer storage medium, for example, and loaded into the above-mentioned computer device through the computer storage medium and run therein.
[0117] In the embodiment of the present application, the expected quality requirement is indicated by the expected number of target pixels, so that the video encoding device can measure the quality difference between the encoding quality when the computer device uses the encoding bit rate of the reference video frame for encoding processing and the encoding quality corresponding to the expected quality requirement according to the difference between the expected number of target pixels and the actual number of target pixels (i.e., the number of target pixels determined from the reference video frame). Since the reference video frame and the target video frame are both video frames in the target video, and usually when the same encoding bit rate is used to encode the two, the encoding quality reflected by the video encoding device is similar, and thus the quality of the encoded frame obtained by encoding is also similar. Therefore, the computer device can make an adaptive adjustment to the encoding bit rate of the reference video frame with reference to the quality difference reflected by the expected number and the actual number, so as to quickly determine a coding bit rate that can be used to obtain a coding frame close to the expected quality requirement, and the determined coding bit rate is the coding bit rate of the target video. It can be seen that when the video encoding device determines the encoding bit rate of the target video frame based on the expected number of target pixel points, the actual number of target pixel points, and the encoding bit rate of the reference video frame, it can not only enable the video encoding device to use the determined encoding bit rate to encode the target video frame to obtain an encoded frame close to the expected quality requirement, but also improve the overall efficiency of the video encoding device when encoding the target video.
[0118] Based on the relevant description of the above method embodiment and device embodiment, the present application embodiment also provides a computer device. Figure 6. The computer device at least includes a processor 601 and a computer storage medium 602, and the processor 601 and the computer storage medium 602 are connected via a bus or other means. Among them, the computer storage medium 602 mentioned above is a memory device in the computer device, which is used to store programs and data. It can be understood that the computer storage medium 602 here can include both the built-in storage medium in the computer device and the extended storage medium supported by the computer device. The computer storage medium 602 provides a storage space, which stores the operating system of the computer device. In addition, one or more computer programs suitable for being loaded and executed by the processor 601 are also stored in the storage space, and these computer programs can be one or more program codes. It should be noted that the computer storage medium here can be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk storage; optionally, it can also be at least one storage medium located away from the aforementioned processor. The processor 601 (or CPU (Central Processing Unit)) is the computing core and control core of the computer device, which is suitable for implementing one or more computer programs, and is specifically suitable for loading and executing one or more computer programs to implement corresponding method processes or corresponding functions.
[0119] In one embodiment, the processor 601 may load and execute one or more computer programs stored in the computer storage medium 602 to implement the above-mentioned Figure 2 as well as Figure 4 Corresponding method steps in the method embodiment shown. In a specific implementation, one or more computer programs in the computer storage medium 602 can be loaded by the processor 601 and execute the following steps:
[0120] determining a reference video frame and a target video frame from a target video;
[0121] Acquire an encoded video frame obtained after encoding the reference video frame, and an encoding bit rate used when encoding the reference video frame;
[0122] Determine, according to the pixel value of each pixel in the reference video frame, a minimum perceptible error of the corresponding pixel, and determine the number of target pixels from the reference video frame, wherein the difference between the pixel value of the target pixel and the pixel value of the pixel corresponding to the target pixel in the encoded video frame is less than or equal to the minimum perceptible error of the target pixel;
[0123] Determine the encoding rate of the target video frame according to the determined number of target pixels and the encoding rate of the reference video frame according to the expected number of target pixels, wherein the expected number is used to represent: the minimum number of target pixels contained in the video frame that meets the expected quality requirements;
[0124] The target video frame is encoded using the encoding bit rate of the target video frame to obtain an encoded video of the target video.
[0125] In one implementation, the processor 601 may be specifically configured to load and execute:
[0126] Determining a bit rate adjustment amount according to a number difference between the expected number and the determined number of target pixels, wherein the bit rate adjustment amount is positively correlated with the number difference;
[0127] The encoding bit rate of the target video frame is determined based on the encoding bit rate of the reference video frame and the bit rate adjustment amount.
[0128] In yet another implementation, the processor 601 may also be specifically configured to load and execute:
[0129] Obtaining a bit rate adjustment parameter of the target video frame;
[0130] The bit rate adjustment amount is determined according to the bit rate adjustment parameter and a difference between the expected number and the determined number of target pixels.
[0131] In yet another implementation, the processor 601 may also be specifically configured to load and execute:
[0132] Determining a bit rate interval in which the encoding bit rate of the reference video frame lies;
[0133] Determining the bit rate adjustment parameter corresponding to the bit rate interval in which the encoding bit rate of the reference video frame is located according to a preset correspondence relationship between the bit rate interval and the bit rate adjustment parameter;
[0134] The determined bit rate adjustment parameter is used as the bit rate adjustment parameter of the target video frame.
[0135] In yet another implementation, the processor 601 may also be specifically configured to load and execute:
[0136] Acquire a coding parameter value of a historical coding frame and a coding parameter value of the reference video frame, wherein the coding order of the historical coding frame is adjacent to the coding order of the reference video frame, and the coding order of the historical coding frame is prior to the coding order of the reference video frame, and the coding parameter value is used to indicate a parameter value of a target coding parameter used when encoding the corresponding video frame;
[0137] If the difference between the encoding parameter value of the historical encoding frame and the encoding parameter value of the reference video frame is greater than or equal to the preset difference, the step of obtaining the encoded video frame obtained after encoding the reference video frame and the encoding bit rate used when encoding the reference video frame is triggered.
[0138] In yet another implementation, the processor 601 may also be specifically configured to load and execute:
[0139] If the difference between the encoding parameter value of the historical encoding frame and the encoding parameter value of the reference video frame is less than the preset difference, the encoding bit rate used when encoding the reference video frame is used as the encoding bit rate of the target video frame;
[0140] The target video frame is encoded using the encoding bit rate of the target video frame to obtain an encoded video of the target video.
[0141] In yet another embodiment, the coding order of the reference video frame is adjacent to the coding order of the target video frame, and the coding order of the reference video frame is prior to the coding order of the target video frame; or,
[0142] The reference video frame is any video frame or the last encoded video frame in the first video segment, and the target video frame is the first encoded video frame in the second video segment, wherein the first video segment and the second video segment are obtained by segmenting the target video, and the encoding order of the first video segment is prior to the encoding order of the second video segment.
[0143] In yet another implementation, the processor 601 may also be specifically configured to load and execute:
[0144] Using a brightness filter matrix to filter the reference video frame to obtain a brightness filter map of the reference video frame;
[0145] Using a contrast filter matrix to filter the reference video frame to obtain a contrast filter map of the reference video frame;
[0146] The minimum perceptible error of each pixel is determined according to the contrast filter map and the brightness filter map.
[0147] In an embodiment of the present application, the expected quality requirement is indicated by the expected number of target pixels, so that the computer device can measure the quality difference between the encoding quality when the computer device uses the encoding bit rate of the reference video frame for encoding processing and the encoding quality corresponding to the expected quality requirement according to the difference between the expected number of target pixels and the actual number of target pixels (i.e., the number of target pixels determined from the reference video frame). Since the reference video frame and the target video frame are both video frames in the target video, and usually when the same encoding bit rate is used to encode the two, the encoding quality reflected by the computer device is similar, so the quality of the encoded frame obtained by encoding is also similar. Therefore, the computer device can refer to the quality difference reflected by the expected number and the actual number to adaptively adjust the encoding bit rate of the reference video frame, so as to quickly determine a coding bit rate that can be used to obtain a coding frame close to the expected quality requirement, and the determined coding bit rate is the coding bit rate of the target video. It can be seen that when a computer device determines the encoding bit rate of a target video frame based on the expected number of target pixels, the actual number of target pixels, and the encoding bit rate of a reference video frame, it can not only enable the computer device to use the determined encoding bit rate to encode the target video frame to obtain an encoded frame that is close to the expected quality requirement, but also improve the overall efficiency of the computer device when encoding the target video.
[0148] The embodiment of the present application further provides a computer storage medium, in which one or more computer programs corresponding to the above-mentioned video encoding method are stored. When the processor loads and executes the one or more computer programs, the description of the video encoding method in the embodiment can be implemented, and the embodiment of the present application will not be repeated here. Correspondingly, the description of the beneficial effects of adopting the same method will not be repeated here. In addition, it is worth mentioning that the computer program can be deployed on one or more devices that can communicate with each other for execution.
[0149] In addition, it should be noted that according to one aspect of the embodiments of the present application, a program product or a computer program is also provided, the program product includes a computer program, and the computer program is stored in a computer storage medium. The processor in the computer device reads the computer program from the computer storage medium and then executes the computer program, thereby enabling the computer device to perform the above Figure 2 as well as Figure 4 In the related embodiments of the video encoding method shown, implementation methods are proposed for various optional modes of various aspects.
[0150] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment method can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer storage medium, and when the computer program is executed, it can include all the processes related to the above-mentioned video encoding method. Among them, the computer storage medium may include a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0151] In addition, it can be understood that what is disclosed above is only a partial embodiment of the present application, and it certainly cannot be used to limit the scope of rights of the present application. Ordinary technicians in this field can understand that the entire or partial process of implementing the above-mentioned embodiment and the equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A video encoding method, It is characterized in that include: determining a reference video frame and a target video frame from a target video; Acquire an encoded video frame obtained after encoding the reference video frame, and an encoding bit rate used when encoding the reference video frame; Determine, according to the pixel value of each pixel in the reference video frame, a minimum perceptible error of the corresponding pixel, and determine the number of target pixels from the reference video frame, wherein the difference between the pixel value of the target pixel and the pixel value of the pixel corresponding to the target pixel in the encoded video frame is less than or equal to the minimum perceptible error of the target pixel; Determine the encoding rate of the target video frame according to the determined number of target pixels and the encoding rate of the reference video frame according to the expected number of target pixels, wherein the expected number is used to represent: the minimum number of target pixels contained in the video frame that meets the expected quality requirements; The target video frame is encoded using the encoding bit rate of the target video frame to obtain an encoded video of the target video.
2. The method according to claim 1, It is characterized in that The step of determining the encoding rate of the target video frame according to the preset expected number of target pixels, the number of target pixels and the encoding rate of the reference video frame comprises: Determining a bit rate adjustment amount according to a number difference between the expected number and the determined number of target pixels, wherein the bit rate adjustment amount is positively correlated with the number difference; The encoding bit rate of the target video frame is determined based on the encoding bit rate of the reference video frame and the bit rate adjustment amount.
3. The method according to claim 2, It is characterized in that The determining the bit rate adjustment amount according to the difference between the expected number and the determined number of target pixels includes: Obtaining a bit rate adjustment parameter of the target video frame; The bit rate adjustment amount is determined according to the bit rate adjustment parameter and a difference between the expected number and the determined number of target pixels.
4. The method according to claim 2, It is characterized in that The obtaining the bit rate adjustment parameter of the target video frame includes: Determining a bit rate interval in which the encoding bit rate of the reference video frame lies; Determining the bit rate adjustment parameter corresponding to the bit rate interval in which the encoding bit rate of the reference video frame is located according to a preset correspondence relationship between the bit rate interval and the bit rate adjustment parameter; The determined bit rate adjustment parameter is used as the bit rate adjustment parameter of the target video frame.
5. The method according to claim 1, It is characterized in that The method further comprises: Acquire a coding parameter value of a historical coding frame and a coding parameter value of the reference video frame, wherein the coding order of the historical coding frame is adjacent to the coding order of the reference video frame, and the coding order of the historical coding frame is prior to the coding order of the reference video frame, and the coding parameter value is used to indicate a parameter value of a target coding parameter used when encoding the corresponding video frame; If the difference between the encoding parameter value of the historical encoding frame and the encoding parameter value of the reference video frame is greater than or equal to the preset difference, the step of obtaining the encoded video frame obtained after encoding the reference video frame and the encoding bit rate used when encoding the reference video frame is triggered.
6. The method according to claim 5, It is characterized in that The method further comprises: If the difference between the encoding parameter value of the historical encoding frame and the encoding parameter value of the reference video frame is less than the preset difference, the encoding bit rate used when encoding the reference video frame is used as the encoding bit rate of the target video frame; The target video frame is encoded using the encoding bit rate of the target video frame to obtain an encoded video of the target video.
7. The method according to claim 1, It is characterized in that The coding order of the reference video frame is adjacent to the coding order of the target video frame, and the coding order of the reference video frame is prior to the coding order of the target video frame; or, The reference video frame is any video frame or the last encoded video frame in the first video segment, and the target video frame is the first encoded video frame in the second video segment, wherein the first video segment and the second video segment are obtained by segmenting the target video, and the encoding order of the first video segment is prior to the encoding order of the second video segment.
8. The method according to claim 1, It is characterized in that The step of determining the minimum perceptible error of a corresponding pixel point according to the pixel value of each pixel point in the reference video frame comprises: Using a brightness filter matrix to filter the reference video frame to obtain a brightness filter map of the reference video frame; Using a contrast filter matrix to filter the reference video frame to obtain a contrast filter map of the reference video frame; The minimum perceptible error of each pixel is determined according to the contrast filter map and the brightness filter map.
9. A video encoding device, It is characterized in that include: A video frame determination unit, used to determine a reference video frame and a target video frame from a target video; An acquisition unit, used to acquire a coded video frame obtained after encoding the reference video frame, and a coding bit rate used when encoding the reference video frame; an error determination unit, configured to determine a minimum perceptible error of a corresponding pixel point according to a pixel value of each pixel point in the reference video frame, and determine the number of target pixels from the reference video frame, wherein a difference between a pixel value of the target pixel point and a pixel value of a pixel point corresponding to the target pixel point in the encoded video frame is less than or equal to the minimum perceptible error of the target pixel point; A bit rate determination unit, configured to determine the encoding bit rate of the target video frame according to the expected number of target pixels, the determined number of target pixels and the encoding bit rate of the reference video frame, wherein the expected number is used to represent: the minimum number of target pixels contained in the video frame that meets the expected quality requirements; The encoding unit is used to encode the target video frame using the encoding bit rate of the target video frame to obtain an encoded video of the target video.
10. A computer device, It is characterized in that include: A processor configured to execute one or more computer programs; A computer storage medium storing one or more computer programs, wherein the one or more computer programs are suitable for being loaded by the processor and implementing the video encoding method according to any one of claims 1 to 8.
11. A computer storage medium, It is characterized in that The computer storage medium stores one or more computer programs, and the one or more computer programs are suitable for being loaded by a processor and implementing the video encoding method according to any one of claims 1-8.
