Video coding method and device, equipment and medium
Through the video encoding method that divides and distinguishes quantized parameter values in the video frame, the problem of high video code rate in the prior art is solved, and the effect of reducing the video code rate and improving the video compression efficiency while ensuring picture quality is achieved.
Patent Information
- Application Number
- CN202411440376.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-10-15
AI Technical Summary
In the low-latency demand scenarios, existing video encoding technology is difficult to effectively reduce the video code rate while ensuring the quality of the video picture, resulting in low video compression efficiency.
By dividing the first type of P frame and the second type of P frame in the video frame and assigning a larger quantization parameter value to the first type of P frame, it is ensured that it is greater than the second type of P frame and not greater than the minimum quantization parameter of the B frame. value, thereby improving video compression efficiency during encoding.
On the basis of ensuring the quality of video images, it effectively reduces the video code rate, improves video compression efficiency, and saves network bandwidth.
Smart Images

Figure CN118972583A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of video coding technology, and in particular to a video coding method, device, equipment and medium. Background Art
[0002] Video coding technology is a technology that represents video information by compressing redundant components in video images and using as little data as possible. In video coding technology, video frame sequences are usually encoded in units of group of pictures (GOP). Video frames can be divided into different categories within a GOP according to time or reference relationships, such as: key frames (Intra Frame, hereinafter referred to as "I frame"), bidirectional frames (Bi-directional Frame, hereinafter referred to as "B frame"), and predicted frames (hereinafter referred to as "P frame"), and different quantizer parameter (Quantizer Parameter, QP) values are assigned to each category. The quantizer parameter value of a video frame is related to the picture quality of the video frame after encoding. Generally, the higher the quantizer parameter value of a video frame, the lower the picture quality after encoding. The quantizer parameter value of each video frame of a video also affects the bit rate of the video. Generally, increasing the quantizer parameter value of some video frames of a video can reduce the bit rate of the video. In particular, in scenarios with low latency requirements, existing algorithms cannot effectively reduce the video bit rate while ensuring the video picture quality as much as possible.
[0003] Based on this, how to effectively reduce the video bit rate and improve the video compression efficiency while ensuring the video quality as much as possible has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] The embodiments of this specification provide a video encoding method, apparatus, device and medium, which can effectively reduce the video bit rate and improve the video compression efficiency while ensuring the video picture quality as much as possible.
[0005] In order to solve the above technical problems, an embodiment of the present specification provides a video encoding method, the method is applied to a video to be encoded, the video to be encoded includes at least one picture group, the first video frame in the picture group is an I frame, one of the picture groups includes at least one first picture group and at least one second picture group, the first picture group and the second picture group are arranged alternately, each of the first picture group and the second picture group includes a first number of B frames and one P frame, the method includes: Acquire a first type of P frame in the first image group; Determine a first quantization parameter value of the first-category P frame, so that the first quantization parameter value is greater than a second quantization parameter value of the second-category P frame, and is not greater than a minimum quantization parameter value among the quantization parameter values of each B frame in the first image group; wherein the second-category P frame is a P frame in the second image group; the interval video frames between the first-category P frame and the nearest second-category P frame in arrangement order is the first number; the interval video frames between two adjacent first-category P frames is the second number; the second number is equal to twice the first number plus 1; The first type of P frame is encoded according to the first quantization parameter value.
[0006] The embodiment of the present specification also provides a video encoding device, the device is applied to a video to be encoded, the video to be encoded includes at least one picture group, the first video frame in the picture group is an I frame, one of the picture groups includes at least one first picture group and at least one second picture group, the first picture group and the second picture group are arranged alternately, each of the first picture group and the second picture group includes a first number of B frames and one P frame, the device includes: A first acquisition module, used for acquiring a first type of P frame in the first image group; A first determination module is used to determine a first quantization parameter value of the first-category P frame, so that the first quantization parameter value is greater than a second quantization parameter value of the second-category P frame, and is not greater than a minimum quantization parameter value among the quantization parameter values of each B frame in the first image group; wherein the second-category P frame is a P frame in the second image group; the interval video frames between the first-category P frame and the nearest second-category P frame in arrangement order is the first number; the interval video frames between two adjacent first-category P frames is the second number; the second number is equal to twice the first number plus 1; The first encoding module is used to encode the first type of P frame according to the first quantization parameter value.
[0007] The embodiment of the present specification also provides a video encoding device, the device is applied to a video to be encoded, the video to be encoded includes at least one picture group, the first video frame in the picture group is an I frame, one of the picture groups includes at least one first picture group and at least one second picture group, the first picture group and the second picture group are arranged alternately, and each of the first picture group and the second picture group includes a first number of B frames and one P frame, the device includes: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Acquire a first type of P frame in the first image group; Determine a first quantization parameter value of the first-category P frame, so that the first quantization parameter value is greater than a second quantization parameter value of the second-category P frame, and is not greater than a minimum quantization parameter value among the quantization parameter values of each B frame in the first image group; wherein the second-category P frame is a P frame in the second image group; the interval video frames between the first-category P frame and the nearest second-category P frame in arrangement order is the first number; the interval video frames between two adjacent first-category P frames is the second number; the second number is equal to twice the first number plus 1; The first type of P frame is encoded according to the first quantization parameter value.
[0008] The embodiments of the present specification provide a computer-readable medium on which computer-readable instructions are stored. The computer-readable instructions can be executed by a processor to implement the steps in the above-mentioned video encoding method.
[0009] At least one embodiment provided in this specification can achieve the following beneficial effects: In the embodiment of the present specification, the P frames in the first image group and the P frames in the second image group arranged at intervals in the image group are respectively divided into the first type of P frames and the second type of P frames, and the first quantization parameter value assigned to the first type of P frames is greater than the second quantization parameter value assigned to the second type of P frames. Since the second type of P frames with smaller quantization parameter values but higher picture quality can be used as reference when encoding B frames, this method of increasing the quantization parameter values of some P frames at intervals can effectively reduce the video bit rate and improve the video compression efficiency by assigning larger quantization parameter values to the first type of P frames on the basis of ensuring the picture quality of the video frames as much as possible. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0011] Figure 1 A schematic diagram of a video encoding method provided in an embodiment of this specification; Figure 2 A schematic diagram of the structure of an image group provided in an embodiment of this specification when the number of B frames between adjacent P frames is 3; Figure 3 A schematic diagram of the structure of another image group provided in an embodiment of this specification when the number of B frames between adjacent P frames is 3; Figure 4 The embodiments of this specification provide corresponding to Figure 1 A swim lane diagram of a video coding method in ; Figure 5 The embodiments of this specification provide corresponding to Figure 1 A schematic diagram of the structure of a video encoding device; Figure 6 The embodiments of this specification provide corresponding to Figure 1 A structural schematic diagram of a video encoding device. DETAILED DESCRIPTION
[0012] In order to make the purpose, technical solutions and advantages of one or more embodiments of this specification clearer, the technical solutions of one or more embodiments of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this description, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of one or more embodiments of this specification.
[0013] In video encoding, intra-frame coding and inter-frame coding are usually used to remove information redundancy in the spatial and temporal domains of the input video. The encoded video frames can generally be divided into I frames, P frames, and B frames. I frames are usually encoded using intra-frame coding technology, and other encoded video frames are not referenced during encoding. During encoding, P frames need to refer to the video frames that have been encoded in the forward direction, and B frames need to refer to the video frames that have been encoded in the forward and backward directions.
[0014] In video coding technology, video frame sequences are usually encoded in GOP units. Video frames in a GOP can be divided into different categories according to time relationships or playback order, and different QP values are assigned to video frames in each category. Generally, the more a video frame is referenced in a picture group, the lower the QP value assigned to it. In the existing constant quantizer parameter (CQP) allocation strategy, the same QP allocation strategy is used for each picture group (mini-GOP). Therefore, in the existing CQP allocation strategy, all P frames in a picture group are assigned the same QP value. However, if a smaller quantization parameter value is set for all P frames, it usually results in a higher bit rate for the encoded video, which in turn causes the transmission of the video to occupy more network bandwidth.
[0015] In order to solve the defects in the prior art, this solution provides the following embodiments.
[0016] Figure 1 The flowchart of a video encoding method provided in the embodiment of the present specification is shown in FIG. From the program perspective, the execution subject of the flowchart may be a video encoding program. From the hardware perspective, the execution subject of the flowchart may be a device or equipment equipped with a video encoding program.
[0017] The method is applied to a video to be encoded, wherein the video to be encoded includes at least one image group, the first video frame in the image group is an I frame, and one image group includes at least one first image group and at least one second image group, the first image group and the second image group are arranged alternately, and each of the first image group and the second image group includes a first number of B frames and one P frame.
[0018] like Figure 1 As shown, the process may include the following steps.
[0019] Step 102: Obtain the first type of P frames in the first image group.
[0020] In the embodiments of the present specification, the video to be encoded may be a video waiting for a video encoder to perform video encoding processing. The video to be encoded includes a certain number of video frames, which may constitute a video frame sequence. These video frames may constitute at least one image group, that is, the video to be encoded may include one image group or multiple image groups. Generally, when a video encoder performs encoding processing on the video to be encoded, the video frame sequence is encoded and transmitted in units of image groups.
[0021] A group of images may refer to a group of continuous video frames between two adjacent I frames, including the previous I frame of the two adjacent I frames, but excluding the next I frame of the two adjacent I frames. In a group of images, the I frame is the first video frame, and the subsequent video frames may be B frames or P frames. Among them, the I frame may contain all the image information of a certain frame of the video, and it is not necessary to rely on other frames when encoding the I frame; the data of the P frame may contain pixel information that has changed relative to the reference frame of the P frame, and may not contain the complete image data of the video frame corresponding to the P frame. When encoding the P frame, it is necessary to refer to the I frame or P frame before the P frame for encoding. When encoding the B frame, data compression can be achieved by predicting and differentially encoding the I frame or P frame before the B frame and the P frame after the B frame. When encoding, the pixel differences between the current B frame and the I frame or P frame before the B frame and the P frame after the B frame can be predicted by motion estimation technology, and encoding can be performed based on these differences.
[0022] In the embodiments of the present specification, a picture group may generally include multiple P frames, and the number of B frames between each P frame may be the same. A P frame and a first number of B frames between the previous P frame and the previous P frame may be divided into a picture group. The first number may be set and adjusted according to actual needs, and is not specifically limited thereto.
[0023] In the embodiment of the present specification, in order to allocate differentiated quantization parameter values to P frames in an image group, the P frames can be further divided into a first type of P frames and a second type of P frames, and different quantization parameter values are allocated to the two types of P frames. Specifically, the first image group can include a first number of B frames and one of the first type of P frames; the second image group can include a first number of B frames and one of the second type of P frames. In addition, the first image group and the second image group are arranged alternately in the same image group.
[0024] Figure 2 The following is a schematic diagram of the structure of an image group when the number of B frames between adjacent P frames provided in the embodiment of this specification is 3. Figure 2 As shown, P1 is used to represent the first type of P frame, P2 is used to represent the second type of P frame, each first image group includes 3 B frames and one P1, each second image group includes 3 B frames and one P2. Moreover, the first image group and the second image group are arranged alternately.
[0025] Figure 1 The process also includes step 104: determining a first quantization parameter value of the first type P frame, so that the first quantization parameter value is greater than a second quantization parameter value of the second type P frame, and is not greater than the minimum quantization parameter value of the quantization parameter values of each B frame in the first image group.
[0026] Among them, the second type of P frames are P frames in the second image group; the interval video frames between the first type of P frames and the second type of P frames closest in arrangement order are the first number; the interval video frames between two adjacent first type P frames are the second number; the second number is equal to twice the first number plus 1.
[0027] In the embodiments of this specification, the quantization parameter value specifically refers to the value of the quantization parameter. The quantization parameter value may correspond to the serial number of the quantization step length, and there is a one-to-one correspondence between the quantization parameter value and the quantization step length value. In the video coding standard, the quantization parameter value is usually represented by a QP value. Generally, the smaller the QP value of the video frame, the lower the compression rate of the video frame during encoding, and the higher the quality of the encoded picture. Conversely, the larger the QP value of the video frame, the higher the compression rate of the video frame during encoding, and the lower the quality of the encoded picture. Therefore, by adjusting the size of the quantization parameter, the balance between the quality and compression rate of video encoding can be controlled to meet the needs of different application scenarios. In addition, since the video compression rate is related to the video bit rate, generally, increasing the video compression rate can reduce the video bit rate. Therefore, increasing the quantization parameter value during video encoding can also reduce the video bit rate. Among them, "bit rate" can refer to the number of data bits transmitted per unit time during data transmission. "Bit rate" is also called "bit rate", which can indicate how many bits are required per second to represent the compressed and encoded video data. The unit of bit rate is generally kilobit per second (KBPS).
[0028] In the embodiments of the present specification, since an excessively large quantization parameter value may lead to a significant reduction in picture quality, and the encoded P frame needs to be used as a coding reference frame for the B frame, in order to ensure the picture quality of the encoded P frame, the quantization parameter value of the P frame in the image group may not be greater than the minimum quantization parameter value among the quantization parameter values of each B frame in the image group. Correspondingly, the first quantization parameter value of the first type of P frame in the first image group may not be greater than the minimum quantization parameter value among the quantization parameter values of each B frame in the first image group. Similarly, the second quantization parameter value of the second type of P frame in the second image group may not be greater than the minimum quantization parameter value among the quantization parameter values of each B frame in the second image group.
[0029] In an embodiment of the present specification, if the second quantization parameter value of the second type of P frame is the same as the quantization parameter value allocated to all P frames in the existing CQP allocation strategy, since the first quantization parameter value of the first type of P frame is greater than the second quantization parameter value, it is equivalent to improving the quantization parameter value of some P frames on the basis of the CQP allocation strategy, which is beneficial to improving the video compression rate, reducing the video bit rate, and saving the network bandwidth of the transmission network.
[0030] In the embodiment of the present specification, the first image group and the second image group are arranged at intervals in the image group. Moreover, the first image group and the second image group both contain a first number of B frames and a last P frame. Therefore, the number of video frames between the first type of P frame in the first image group and the second type of P frame in the second image group closest in arrangement order is consistent with the first number. Moreover, the number of video frames between two adjacent first type P frames (the second number) is equal to twice the first number plus 1. Exemplarily, taking the first number equal to 3 as an example, if Figure 2 As shown, P1 is used to represent the first type of P frame, and P2 is used to represent the second type of P frame. The P2 closest to P1 with frame number 4 in arrangement order is P2 with frame number 8, and the number of video frames between P1 with frame number 4 and P2 with frame number 8 is 3; P1 adjacent to P1 with frame number 4 may be P1 with frame number 12, and the number of video frames between P1 with frame number 4 and P1 with frame number 12 is 7, that is, 7=2×3+1.
[0031] Step 106: Encode the first type of P frame according to the first quantization parameter value.
[0032] In the embodiment of the present specification, after determining the first quantization parameter value of the first type of P frame, the first type of P frame can be further encoded according to the first quantization parameter value. When encoding the first type of P frame, an inter-frame encoding method can be used, or a combination of intra-frame encoding and inter-frame encoding can be used, which is not specifically limited. Among them, intra-frame encoding is a technology in video encoding, and intra-frame encoding mainly uses the spatial redundancy of the image to compress the image. Intra-frame coding relies on the similarity between adjacent pixels in an image and the main spatial domain frequency of the pattern area to remove redundant information to achieve the purpose of compressing the image. Inter-frame coding is mainly based on motion compensation prediction coding technology, and the motion vector is found by comparing the difference between the current frame and the reference frame (usually a reconstructed frame). The motion vector can be used to indicate the position of the current block in the reference frame. Since the encoder is allowed to transmit the motion vector and the prediction error in inter-frame coding without transmitting the data of the entire current frame, the inter-frame coding technology can significantly reduce the amount of video data while maintaining good image quality.
[0033] Figure 1According to the method, the P frames in the first image group and the P frames in the second image group arranged at intervals in the image group are respectively divided into the first type of P frames and the second type of P frames, and the first quantization parameter value assigned to the first type of P frames is greater than the second quantization parameter value assigned to the second type of P frames. Since the second type of P frames with smaller quantization parameter values but higher picture quality can be used as reference when encoding B frames, this method of increasing the quantization parameter values of some P frames at intervals can effectively reduce the video bit rate and improve the video compression efficiency by assigning a larger quantization parameter value to the first type of P frames on the basis of ensuring the picture quality of the video frames as much as possible.
[0034] In the embodiments of the present specification, the encoder can not only determine the first quantization parameter of the first type of P frame and encode the first type of P frame according to the first quantization parameter value, but also determine the second quantization parameter of the second type of P frame and encode the second type of P frame according to the second quantization parameter value, thereby completing the encoding of all P frames in an image group.
[0035] Based on this, the above video encoding method may further include the following steps: Obtain the second type of P frame; Determine the second quantization parameter value of the second type P frame so that the second quantization parameter value is less than the first quantization parameter value and not less than the quantization parameter value of the I frame; The second type of P frame is encoded according to the second quantization parameter value.
[0036] In the embodiments of this specification, since the quantization parameter value is too small, the video compression rate may be greatly reduced, thereby greatly increasing the video bit rate. Therefore, in order to control the video bit rate and ensure the video compression rate, it is usually required that the quantization parameter value of the P frame in the image group is not less than the quantization parameter value of the I frame in the image group. Therefore, the second quantization parameter value of the second type of P frame can be no less than the quantization parameter value of the I frame in the image group. In this way, the video bit rate can be avoided from being too high, the video bit rate can be effectively controlled, and it is beneficial to save the network bandwidth of the video transmission network.
[0037] In the embodiment of the present specification, when encoding the second type of P frame according to the second quantization parameter value, an inter-frame coding method or a combination of intra-frame coding and inter-frame coding may be used, and no specific limitation is made thereto. As the intra-frame coding and inter-frame coding have been described in the foregoing content, they will not be described here again.
[0038] In the embodiment of the present specification, before obtaining the first type of P frame and the second type of P frame, it is firstly possible to determine in the image group which video frames are the first type of P frames and which video frames are the second type of P frames. Before determining the frame type of the video frame, it is also necessary to first determine the frame sequence number of the video frame. After determining the frame sequence number of the video frame, it is possible to determine which video frames belong to the first type of P frames and which video frames belong to the second type of P frames according to the frame sequence numbers of these video frames.
[0039] Based on this, Figure 1 In the method, in step 102, before obtaining the first type of P frame in the first image group, the following steps may also be included: Determining the frame sequence number of each video frame according to the time information of each video frame in the image group; Determining, based on the frame sequence numbers of the video frames, the frame sequence numbers of the first-type P frames in the image group; Based on the frame serial numbers of the video frames, the frame serial numbers of the second-category P frames in the image group are determined.
[0040] In the embodiments of the present specification, the time information of each video frame in the image group may refer to the playback time information of each video frame in the image group according to the video playback timeline when the video is played, or may refer to the timestamp information added to each video frame according to the acquisition time when the video acquisition device acquires each video frame, and there is no specific limitation on this.
[0041] In the embodiment of the present specification, since the first video frame of each image group is an I frame, the frame number of each video frame is determined according to the time sequence of each video frame in the image group. The frame number of the I frame in the image group can be determined first. Usually, the frame number of the I frame can be determined as 0. After the frame number of the I frame is determined, the video frames can be numbered in sequence starting from the frame number of the I frame and with 1 as the numbering interval based on the playback time sequence of each video frame in the image group to obtain the frame number of each video frame. For example: image group A contains a total of 50 video frames, and the first video frame is an I frame. The frame number of the I frame in image group A can be determined as 0, and the frame number of the first video frame after the I frame can be determined as 1. The numbering is carried out in this way until the entire image group A is compiled. The frame number of the last video frame of image group A is 49.
[0042] In the embodiment of the present specification, based on the frame sequence number of each video frame, the frame sequence number of each first-category P frame in the image group is determined. The frame sequence number of the first first-category P frame in the image group can be determined based on the frame sequence number of each video frame, and then the subsequent first-category P frames can be determined based on the difference relationship between the frame sequence numbers of the first-category P frames. Similarly, based on the frame sequence number of each video frame, the frame sequence number of each second-category P frame in the image group can also be determined in this way.
[0043] Based on this, determining the frame sequence number of each of the first-type P frames in the image group based on the frame sequence number of each video frame may specifically include the following steps: Based on the frame numbers of the video frames, determining the frame number whose difference with the frame number of the I frame is a first difference as the frame number of the first first-category P frame in the image group; the first difference is equal to the value of the first number plus 1; The frame numbers whose frame number difference with the frame number of the first first-category P frame is an integer multiple of the second difference are determined as the frame numbers of other first-category P frames; the second difference is equal to the value of the second number plus 1; the other first-category P frames are the first-category P frames in the image group except the first first-category P frame.
[0044] Correspondingly, determining the frame sequence number of each second-category P frame in the image group based on the frame sequence number of each video frame may specifically include the following steps: Based on the frame numbers of the video frames, determining the frame number whose difference from the frame number of the I frame is the second difference as the frame number of the first second-category P frame in the image group; The frame number whose frame number difference with the frame number of the first second-category P frame is an integer multiple of the second difference is determined as the frame number of the other second-category P frame; the other second-category P frame is the second-category P frame in the image group except the first second-category P frame.
[0045] Alternatively, in another implementation manner of the present specification, determining the frame sequence number of each of the first-type P frames in the image group based on the frame sequence number of each video frame may specifically include the following steps: Based on the frame numbers of the video frames, determining the frame number whose difference from the frame number of the I frame is the second difference as the frame number of the first first-category P frame; The frame number whose difference with the frame number of the first first-category P frame is an integral multiple of the second difference is determined as the frame number of the other first-category P frame.
[0046] Correspondingly, determining the frame sequence number of each second-category P frame in the image group based on the frame sequence number of each video frame may specifically include the following steps: Based on the frame numbers of the video frames, determining the frame number whose difference with the frame number of the I frame is a first difference as the frame number of the first second-category P frame in the image group; the first difference is equal to the value of the first number plus 1; The frame number whose difference with the frame number of the first second-category P frame is an integral multiple of a second difference is determined as the frame number of the other second-category P frame; the second difference is equal to the value of the second number plus 1.
[0047] In the embodiments of the present specification, the first P frame of the image group can be determined as the first P frame of the first category, and the second P frame of the image group can be determined as the first P frame of the second category, and then the interval cycle (the interval cycle can refer to the alternating appearance of the first category P frame and the second category P frame) can be continued; or, the first P frame of the image group can be determined as the first P frame of the second category, and the second P frame of the image group can be determined as the first P frame of the first category, and then the interval cycle can be continued.
[0048] In the embodiment of the present specification, since the number of B frames included in each image group is the first number, the first number of B frames is spaced between the I frame and the first P frame in the image group, so that the sequence number difference (first difference) between the frame sequence number of the first P frame in the image group and the frame sequence number of the I frame is equal to the value of the first number plus 1. Correspondingly, the sequence number difference (second difference) between the frame sequence number of the second P frame in the image group and the frame sequence number of the I frame is equal to twice the first difference, and since the first difference is equal to the value of the first number plus 1, the second number is equal to twice the first number plus 1, and thus, the second difference is also equal to the value of the second number plus 1.
[0049] In the embodiment of the present specification, since the interval video frames between two adjacent first-category P frames is the second number, the frame number difference (second difference) between two adjacent first-category P frames is equal to the value of the second number plus 1. After the frame number of the first first-category P frame is determined, the frame number whose difference with the frame number of the first first-category P frame is an integer multiple of the second difference can be determined as the frame number of the first-category P frame. Similarly, the frame number difference between two adjacent second-category P frames is also the second difference. After the frame number of the first second-category P frame is determined, the frame number whose difference with the frame number of the first second-category P frame is an integer multiple of the second difference can also be determined as the frame number of the second-category P frame. Exemplarily, taking the first number equal to 3 as an example, correspondingly, the second number is equal to 7, the first difference is equal to 4, and the second difference is equal to 8. Figure 2As shown, the frame number of the I frame is 0, the frame number of the first P1 is 4, the frame number of the first P2 is 8, the frame number of the second P1 is 12, and the frame number of the second P2 is 16. Among them, P1 represents the first type of P frame, and P2 represents the second type of P frame.
[0050] Figure 3 A schematic diagram of the structure of another image group provided in an embodiment of this specification when the number of B frames between adjacent P frames is 3, as shown in FIG. Figure 3 As shown, the frame number of the I frame is 0, the frame number of the first P1 is 8, the frame number of the first P2 is 4, the frame number of the second P1 is 16, and the frame number of the second P2 is 12.
[0051] In the embodiment of the present specification, after the frame sequence number of the video frame is determined, the quantization parameter value of the video frame can be determined according to the frame sequence number of the video frame based on a preset mapping relationship.
[0052] Based on this, the determining of the first quantization parameter value of the first type of P frame may specifically include the following steps: Determine the level identifier of the first type of P frame based on the first mapping relationship and the frame sequence number of the first type of P frame; the first mapping relationship is used to represent the mapping relationship between the frame sequence number of the video frame and the level identifier of the video frame; Based on a second mapping relationship and the level identifier of the first type of P frame, the first quantization parameter value of the first type of P frame is determined; the second mapping relationship is used to represent the mapping relationship between the level identifier of the video frame and the quantization parameter value of the video frame.
[0053] Correspondingly, the determining of the second quantization parameter value of the second type P frame may specifically include the following steps: Determine the level identifier of the second-type P frame based on the first mapping relationship and the frame number of the second-type P frame; the first mapping relationship is used to represent the mapping relationship between the frame number of the video frame and the level identifier of the video frame; Based on the second mapping relationship and the level identifier of the second type of P frame, the second quantization parameter value of the second type of P frame is determined; the second mapping relationship is used to represent the mapping relationship between the level identifier of the video frame and the quantization parameter value of the video frame.
[0054] In the embodiments of the present specification, the layer identifier of a video frame can be used to indicate the possibility of the video frame being referenced. In practical applications, the layer identifier of a video frame can be represented by layerID, and the lower the layerID, the higher the possibility of the video frame being referenced. Exemplarily, if there are three types of layer identifiers of a video frame, namely: layerID=0, layerID=1, and layerID=2, then the video frame with layerID=0 can refer to other video frames with layer identifier layerID=0 during encoding, but cannot refer to video frames with layer identifier layerID=1 and layer identifier layerID=2; the video frame with layer identifier layerID=1 can refer to other video frames with layer identifier layerID=1 and video frames with layer identifier layerID=0 during encoding, but cannot refer to video frames with layer identifier layerID=2; the video frame with layer identifier layerID=2 can refer to other video frames with layer identifier layerID=2, video frames with layer identifier layerID=1, and video frames with layer identifier layerID=0 during encoding. Since the first mapping relationship and the second mapping relationship will be explained in detail in the subsequent embodiments of the present specification, they will not be described in detail here.
[0055] In the embodiments of the present specification, an image group may include first-category P frames and second-category P frames, and may also include I frames and B frames. Therefore, the encoder may first determine the quantization parameter values of video frames other than first-category P frames and second-category P frames based on a preset mapping relationship and the frame numbers of these video frames, and then encode these video frames according to the quantization parameter values of these video frames.
[0056] Based on this, the aforementioned video encoding method may further include the following steps: Acquire other video frames in the image group except the first-category P frames and the second-category P frames; Determining a level identifier of each of the other video frames based on the first mapping relationship and the frame sequence number of each of the other video frames; Determine a quantization parameter value of each of the other video frames based on the second mapping relationship and the level identifier of each of the other video frames; The other video frames are encoded according to the quantization parameter values of the other video frames.
[0057] In an embodiment of the present specification, other video frames in an image group except for the first type P frame and the second type P frame may refer to I frames and B frames in the image group. The first mapping relationship may be used to represent the mapping relationship between the frame sequence number of a video frame and the level identifier of the video frame, and may also be used to represent the mapping relationship between the frame sequence number of a video frame and the frame type of the video frame, so that the frame type and level identifier of a video frame may be determined based on the first mapping relationship and the frame sequence number of a video frame. If the frame type of a video frame has been determined, the level identifier of the video frame may be determined based on the first mapping relationship.
[0058] In the embodiments of the present specification, the second mapping relationship can be used to represent the mapping relationship between the level identifier of a video frame and the quantization parameter value of the video frame, and can also be used to represent the mapping relationship between the frame type of a video frame and the quantization parameter value of the video frame, so that the quantization parameter value of the video frame can be determined based on the second mapping relationship and the level identifier and frame type of a certain video frame. If the frame type of a certain video frame has been determined, the quantization parameter value of the video frame can be determined based on the second mapping relationship and the level identifier of the video frame.
[0059] Table 1 is an example table of the first mapping relationship. Table 2 is an example table of the second mapping relationship. Exemplarily, as shown in Tables 1 and 2, based on Table 1, the frame type and the level identifier of a certain frame can be determined according to the frame sequence number of the frame, and then through Table 2, the quantization parameter value of the frame can be determined according to the frame type and the level identifier of the frame.
[0060] Table 1:
[0061] Table 2:
[0062] In practical applications, the third mapping relationship between the frame number of the video frame and the quantization parameter value of the video frame can also be used to directly determine the quantization parameter value of the video frame according to the frame number of the video frame. The first mapping relationship, the second mapping relationship and the third mapping relationship can all be pre-set based on expert experience or a computer model, and can also be adjusted according to actual needs.
[0063] In the embodiment of the present specification, the first mapping relationship may record a mapping relationship between frame numbers of a third number of video frames after the I frame and level identifiers of the third number of video frames.
[0064] Correspondingly, determining the layer identifier of the first type of P frame based on the first mapping relationship and the frame sequence number of the first type of P frame may specifically include the following steps: Taking the frame number of the first type of P frame as a quotient of the third number to obtain a first remainder; The layer identifier of the first type of P frame is determined according to the first mapping relationship and the first remainder.
[0065] Correspondingly, determining the layer identifier of the second type of P frame based on the first mapping relationship and the frame sequence number of the second type of P frame may specifically include the following steps: Taking the frame number of the second type of P frame as a quotient of the third number to obtain a second remainder; The layer identifier of the second type of P frame is determined according to the first mapping relationship and the second remainder.
[0066] Correspondingly, determining the level identifier of each of the other video frames based on the first mapping relationship and the frame sequence number of each of the other video frames may specifically include the following steps: Taking the frame sequence number of each of the other video frames as a quotient of the third number to obtain each third remainder; The level identifier of each of the other video frames is determined according to the first mapping relationship and the third remainders.
[0067] In the embodiment of the present specification, the first mapping relationship may record a mapping relationship between the frame sequence numbers of the third number of video frames after the I frame and the level identifiers of the third number of video frames, wherein the third number may be no less than the second number plus 1, that is, the third number is no less than the number of video frames included in the two image groups. Usually, the number of video frames included in the two image groups can be taken as the third number.
[0068] In the embodiments of the present specification, the first mapping relationship may include the mapping relationship between the frame number of the video frame in the first first image group in the image group and the level identifier of the video frame, and the mapping relationship between the frame number of the video frame in the first second image group and the level identifier of the video frame. The first mapping relationship of the video frames in each subsequent first image group may refer to the first mapping relationship of the first first image group, and the first mapping relationship of the video frames in each subsequent second image group may refer to the first mapping relationship of the first second image group. As an implementation method, the frame number of a certain video frame may be divided by the third number to obtain a remainder, and then the level identifier corresponding to the remainder may be found through the first mapping relationship, and finally the level identifier corresponding to the remainder may be determined as the level identifier of the video frame.
[0069] Exemplarily, as shown in Table 1, Table 1 contains a mapping relationship between the frame numbers of video frames with frame numbers ranging from 0 to 8 and the level identifiers of the video frames. The third number in Table 1 is 8. If it is necessary to determine the level identifier of the video frame with a frame number of 11, 11 can be divided by 8 to obtain a remainder of 3. Since when the frame number is 3, the corresponding level identifier is 2, it can be determined that the level identifier of the video frame with a frame number of 11 is 2.
[0070] Figure 4 The embodiments of this specification provide corresponding to Figure 1 A swim lane diagram of a video coding method in . Figure 4 As shown, from a program perspective, the executor of the video encoding process may be a video encoding program. From a hardware perspective, the executor of the process may be a device or equipment equipped with a video encoding program. The process is applied to a video to be encoded, and the video to be encoded may include at least one image group, the first video frame in the image group is an I frame, and one of the image groups may include at least one first image group and at least one second image group, the first image group and the second image group are arranged alternately, and each of the first image group and the second image group may include a first number of B frames and one P frame. As shown in FIG. Figure 4 As shown, the method may include a frame sequence number determination stage, a quantization parameter value determination stage and a video frame encoding stage, and may specifically include the following steps.
[0071] Step 402: Determine the frame sequence number of each video frame according to the time information of each video frame in the image group.
[0072] Step 404: Based on the frame numbers of the video frames, determine the frame number that differs from the frame number of the I frame by a first difference as the frame number of the first first-category P frame in the picture group.
[0073] Step 406: Determine the frame numbers whose sequence number difference from the frame sequence number of the first first-category P frame is an integral multiple of the second difference as the frame sequence numbers of other first-category P frames.
[0074] Step 408: Determine the layer identifier of the first type of P frame based on the first mapping relationship and the frame sequence number of the first type of P frame.
[0075] Step 410: Determine a first quantization parameter value of the first type of P frame based on the second mapping relationship and the level identifier of the first type of P frame.
[0076] Step 412: Encode the first type of P frame according to the first quantization parameter value.
[0077] Step 414: Based on the frame numbers of the video frames, determine the frame number that differs from the frame number of the I frame by a second difference as the frame number of the first second-category P frame in the picture group.
[0078] Step 416: Determine the frame numbers whose frame number difference from the frame number of the first second-category P frame is an integral multiple of the second difference as the frame numbers of other second-category P frames.
[0079] Step 418: Determine the layer identifier of the second type of P frame based on the first mapping relationship and the frame sequence number of the second type of P frame.
[0080] Step 420: Determine a second quantization parameter value of the second type of P frame based on the second mapping relationship and the level identifier of the second type of P frame.
[0081] Step 422: Encode the second type of P frame according to the second quantization parameter value.
[0082] Step 424: Obtain the video encoding result.
[0083] In practical applications, in step 404, the frame number whose difference with the frame number of the I frame is the second difference can be determined as the frame number of the first first-category P frame in the image group. Correspondingly, in step 414, the frame number whose difference with the frame number of the I frame is the first difference can be determined as the frame number of the first second-category P frame in the image group.
[0084] Among them, step 404 to step 412 is the process of encoding the first type of P frame in the image group. Step 414 to step 422 is the process of encoding the second type of P frame in the image group. After encoding the first type of P frame and the second type of P frame in the image group, the encoding of the P frame in the image group of the video to be encoded is completed. For the I frame and B frame in the image group of the video to be encoded, the quantization parameter value of the I frame and the quantization parameter value of each B frame can also be determined according to the frame sequence number of the I frame and the B frame and the first mapping relationship and the second mapping relationship, and the I frame is encoded according to the quantization parameter value of the I frame, and the B frame is encoded according to the quantization parameter value of each B frame. In this way, the encoding of all video frames in the image group of the video to be encoded is completed, and the video encoding result is obtained. The specific processing process can be referred to the description in the aforementioned embodiment, which will not be repeated here.
[0085] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.
[0086] Figure 5 The embodiments of this specification provide corresponding to Figure 1A structural diagram of a video encoding device. The device is applied to a video to be encoded, the video to be encoded includes at least one image group, the first video frame in the image group is an I frame, one of the image groups includes at least one first image group and at least one second image group, the first image group and the second image group are arranged alternately, and each of the first image group and the second image group includes a first number of B frames and a P frame. Figure 5 As shown, the device may include the following modules.
[0087] The first acquisition module 502 is used to acquire the first type of P frames in the first image group.
[0088] The first determination module 504 is used to determine the first quantization parameter value of the first category P frame, so that the first quantization parameter value is greater than the second quantization parameter value of the second category P frame, and is not greater than the minimum quantization parameter value of the quantization parameter values of each B frame in the first image group; wherein the second category P frame is the P frame in the second image group; the interval video frames between the first category P frame and the second category P frame closest in arrangement order is the first number; the interval video frames between two adjacent first category P frames is the second number; the second number is equal to twice the first number plus 1.
[0089] The first encoding module 506 is configured to encode the first type of P frame according to the first quantization parameter value.
[0090] based on Figure 5 The present specification also provides some specific implementations of the device, which will be described below.
[0091] Optionally, the device may further include: The second determination module is used to determine the frame sequence number of each video frame in the image group according to the time information of each video frame in the image group before acquiring the first type of P frame in the first image group.
[0092] The third determination module is used to determine the frame sequence number of each of the first-type P frames in the image group based on the frame sequence number of each video frame.
[0093] The fourth determination module is used to determine the frame sequence number of each of the second-category P frames in the image group based on the frame sequence number of each of the video frames.
[0094] Optionally, the device may further include: The second acquisition module is used to acquire the second type of P frame.
[0095] The fifth determination module is used to determine the second quantization parameter value of the second type P frame so that the second quantization parameter value is smaller than the first quantization parameter value and not smaller than the quantization parameter value of the I frame.
[0096] The second encoding module is used to encode the second type of P frame according to the second quantization parameter value.
[0097] Optionally, the third determining module may specifically include: The first determination unit is used to determine the frame number of the first first-category P frame in the image group based on the frame numbers of the video frames, the frame number whose difference with the frame number of the I frame is a first difference; the first difference is equal to the value of the first number plus 1.
[0098] The second determination unit is used to determine the frame numbers whose sequence number difference with the frame sequence number of the first first-category P frame is an integer multiple of the second difference as the frame sequence numbers of other first-category P frames; the second difference is equal to the value of the second number plus 1; the other first-category P frames are the first-category P frames in the image group except the first first-category P frame.
[0099] or, The third determining unit is used to determine, based on the frame numbers of the video frames, a frame number having a difference with the frame number of the I frame by the second difference as the frame number of the first first-category P frame.
[0100] The fourth determining unit is used to determine the frame number whose sequence number difference with the frame sequence number of the first first-category P frame is an integral multiple of the second difference as the frame sequence number of the other first-category P frame.
[0101] Optionally, the fourth determining module may specifically include: The first determination unit is used to determine the frame number of the first second-category P frame in the image group based on the frame numbers of the video frames, the frame number whose difference with the frame number of the I frame is a first difference; the first difference is equal to the value of the first number plus 1.
[0102] The second determination unit is used to determine the frame number whose sequence number difference with the frame sequence number of the first second-category P frame is an integer multiple of the second difference as the frame sequence number of other second-category P frames; the second difference is equal to the value of the second number plus 1; the other second-category P frames are the second-category P frames in the image group except the first second-category P frame.
[0103] or, The third determining unit is used to determine, based on the frame numbers of the video frames, a frame number having a difference with the frame number of the I frame by the second difference as the frame number of the first second-category P frame.
[0104] The fourth determining unit is used to determine the frame number whose sequence number difference with the frame sequence number of the first second-category P frame is an integral multiple of the second difference as the frame sequence number of the other second-category P frame.
[0105] Optionally, the first determining module may specifically include: The layer identifier determination unit is used to determine the layer identifier of the first type P frame based on a first mapping relationship and the frame sequence number of the first type P frame; the first mapping relationship is used to represent the mapping relationship between the frame sequence number of the video frame and the layer identifier of the video frame.
[0106] A quantization parameter value determination unit is used to determine the first quantization parameter value of the first type P frame based on a second mapping relationship and the level identifier of the first type P frame; the second mapping relationship is used to represent the mapping relationship between the level identifier of the video frame and the quantization parameter value of the video frame.
[0107] Optionally, the first mapping relationship may record a mapping relationship between frame sequence numbers of a third number of video frames after the I frame and level identifiers of the third number of video frames.
[0108] Correspondingly, the level identification determination unit may specifically include: The remainder determination subunit is used to obtain a first remainder by dividing the frame sequence number of the first type of P frame by the third number.
[0109] The layer identifier determination subunit is used to determine the layer identifier of the first type of P frame according to the first mapping relationship and the first remainder.
[0110] Optionally, the fifth determining module may specifically include: A layer identifier determination unit is used to determine the layer identifier of the second type of P frame based on a first mapping relationship and a frame number of the second type of P frame; the first mapping relationship is used to represent the mapping relationship between the frame number of the video frame and the layer identifier of the video frame.
[0111] A quantization parameter value determination unit is used to determine the second quantization parameter value of the second type P frame based on a second mapping relationship and a level identifier of the second type P frame; the second mapping relationship is used to represent the mapping relationship between the level identifier of the video frame and the quantization parameter value of the video frame.
[0112] Optionally, the device may further include: The third acquisition module is used to acquire other video frames in the image group except the first-category P frames and the second-category P frames.
[0113] The sixth determination module is used to determine the level identifier of each of the other video frames based on the first mapping relationship and the frame sequence number of each of the other video frames.
[0114] The seventh determination module is used to determine the quantization parameter value of each of the other video frames based on the second mapping relationship and the level identifier of each of the other video frames.
[0115] The third encoding module is used to encode each of the other video frames according to the quantization parameter value of each of the other video frames.
[0116] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.
[0117] Figure 6 The embodiments of this specification provide corresponding to Figure 1 A structural diagram of a video encoding device. The device is applied to a video to be encoded, the video to be encoded includes at least one image group, the first video frame in the image group is an I frame, one of the image groups includes at least one first image group and at least one second image group, the first image group and the second image group are arranged alternately, and each of the first image group and the second image group includes a first number of B frames and a P frame. Figure 6 As shown, the device 600 may include: at least one processor 610; and, A memory 630 is communicatively connected to the at least one processor; wherein, The memory 630 stores instructions 620 executable by the at least one processor 610. The instructions are executed by the at least one processor 610 to enable the at least one processor 610 to: A first type of P frame in the first image group is obtained.
[0118] Determine a first quantization parameter value of the first category P frame so that the first quantization parameter value is greater than a second quantization parameter value of the second category P frame and is not greater than a minimum quantization parameter value among the quantization parameter values of each B frame in the first image group; wherein the second category P frame is a P frame in the second image group; the interval video frames between the first category P frame and the second category P frame closest in arrangement order is the first number; the interval video frames between two adjacent first category P frames is a second number; and the second number is equal to twice the first number plus 1.
[0119] The first type of P frame is encoded according to the first quantization parameter value.
[0120] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. Figure 6 As for the device shown, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0121] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous. In the 1990s, it was very clear whether the improvement of a technology was hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented with hardware entity modules. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask chip manufacturers to design and make dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0122] The controller may be implemented in any suitable manner, for example, the controller may take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (e.g., software or firmware) executable by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, and the memory controller may also be implemented as part of the control logic of the memory. It is also known to those skilled in the art that, in addition to implementing the controller in a purely computer-readable program code manner, the controller may be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, such a controller may be considered as a hardware component, and the devices for implementing various functions included therein may also be considered as structures within the hardware component. Or even, the devices for implementing various functions may be considered as both software modules for implementing the method and structures within the hardware component.
[0123] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0124] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0125] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0126] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0127] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0128] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0129] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0130] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0131] Computer readable media include permanent and non-permanent, removable and non-removable media that 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 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 in this article, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0132] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0133] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0134] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.
Claims
1. A video encoding method, the method being applied to a video to be encoded, the video to be encoded comprising at least one picture group, the first video frame in the picture group being an I frame, one of the picture groups comprising at least one first picture group and at least one second picture group, the first picture group and the second picture group being arranged alternately, each of the first picture group and the second picture group comprising a first number of B frames and one P frame, the method include: Acquire a first type of P frame in the first image group; Determine a first quantization parameter value of the first-category P frame, so that the first quantization parameter value is greater than a second quantization parameter value of the second-category P frame, and is not greater than a minimum quantization parameter value among the quantization parameter values of each B frame in the first image group; wherein the second-category P frame is a P frame in the second image group; the interval video frames between the first-category P frame and the nearest second-category P frame in arrangement order is the first number; the interval video frames between two adjacent first-category P frames is the second number; the second number is equal to twice the first number plus 1; The first type of P frame is encoded according to the first quantization parameter value.
2. The method according to claim 1, before obtaining the first type of P frame in the first image group, further comprising: include: Determining the frame sequence number of each video frame according to the time information of each video frame in the image group; Determining, based on the frame sequence numbers of the video frames, the frame sequence numbers of the first-type P frames in the image group; Based on the frame serial numbers of the video frames, the frame serial numbers of the second-category P frames in the image group are determined.
3. The method according to claim 1, further comprising: include: Obtain the second type of P frame; Determine the second quantization parameter value of the second type P frame so that the second quantization parameter value is less than the first quantization parameter value and not less than the quantization parameter value of the I frame; The second type of P frame is encoded according to the second quantization parameter value.
4. The method according to claim 2, wherein the frame sequence number of each of the first-type P frames in the image group is determined based on the frame sequence number of each video frame, specifically: include: Based on the frame numbers of the video frames, determining a frame number whose difference from the frame number of the I frame is a first difference as the frame number of the first first-category P frame in the image group; The first difference is equal to the value of the first quantity plus 1; Determine the frame sequence number whose sequence number difference from the frame sequence number of the first first-category P frame is an integral multiple of the second difference as the frame sequence number of other first-category P frames; The second difference is equal to the value of the second number plus 1; the other first-category P frames are first-category P frames in the image group except the first first-category P frame; or, Based on the frame numbers of the video frames, determining the frame number whose difference from the frame number of the I frame is the second difference as the frame number of the first first-category P frame; The frame number whose difference with the frame number of the first first-category P frame is an integral multiple of the second difference is determined as the frame number of the other first-category P frame.
5. The method according to claim 2, wherein the frame sequence number of each second-type P frame in the image group is determined based on the frame sequence number of each video frame, specifically: include: Based on the frame numbers of the video frames, determining the frame number whose difference from the frame number of the I frame is a first difference as the frame number of the first second-category P frame in the image group; The first difference is equal to the value of the first quantity plus 1; Determine the frame number whose sequence number difference from the frame sequence number of the first second-category P frame is an integral multiple of the second difference as the frame sequence number of other second-category P frames; the second difference is equal to the value of the second number plus 1; the other second-category P frames are the second-category P frames in the image group except the first second-category P frame; or, Based on the frame numbers of the video frames, determining the frame number whose difference from the frame number of the I frame is the second difference as the frame number of the first second-category P frame; The frame number whose difference with the frame number of the first second-category P frame is an integral multiple of the second difference is determined as the frame number of the other second-category P frame.
6. The method according to claim 2, wherein the first quantization parameter value of the first type of P frame is determined by: include: Determine a layer identifier of the first type of P frame based on the first mapping relationship and the frame sequence number of the first type of P frame; The first mapping relationship is used to represent a mapping relationship between a frame sequence number of a video frame and a level identifier of the video frame; Determine the first quantization parameter value of the first-type P frame based on the second mapping relationship and the level identifier of the first-type P frame; The second mapping relationship is used to represent a mapping relationship between a level identifier of the video frame and a quantization parameter value of the video frame.
7. The method according to claim 6, wherein the first mapping relationship records a mapping relationship between frame sequence numbers of a third number of video frames after the I frame and level identifiers of the third number of video frames; The determining, based on the first mapping relationship and the frame sequence number of the first type of P frame, the layer identifier of the first type of P frame specifically includes: Taking the frame number of the first type of P frame as a quotient of the third number to obtain a first remainder; The layer identifier of the first type of P frame is determined according to the first mapping relationship and the first remainder.
8. The method according to claim 3, wherein the second quantization parameter value of the second type P frame is determined by: include: Determine a layer identifier of the second-type P frame based on the first mapping relationship and the frame sequence number of the second-type P frame; The first mapping relationship is used to represent a mapping relationship between a frame sequence number of a video frame and a level identifier of the video frame; Determine the second quantization parameter value of the second-type P frame based on the second mapping relationship and the level identifier of the second-type P frame; The second mapping relationship is used to represent a mapping relationship between a level identifier of the video frame and a quantization parameter value of the video frame.
9. The method according to claim 8, further comprising: include: Acquire other video frames in the image group except the first-category P frames and the second-category P frames; Determining a level identifier of each of the other video frames based on the first mapping relationship and the frame sequence number of each of the other video frames; Determine a quantization parameter value of each of the other video frames based on the second mapping relationship and the level identifier of each of the other video frames; The other video frames are encoded according to the quantization parameter values of the other video frames.
10. A video encoding device, the device being applied to a video to be encoded, the video to be encoded comprising at least one picture group, the first video frame in the picture group being an I frame, one of the picture groups comprising at least one first picture group and at least one second picture group, the first picture group and the second picture group being arranged alternately, each of the first picture group and the second picture group comprising a first number of B frames and one P frame, the device include: A first acquisition module, used for acquiring a first type of P frame in the first image group; A first determination module is used to determine a first quantization parameter value of the first-category P frame, so that the first quantization parameter value is greater than a second quantization parameter value of the second-category P frame, and is not greater than a minimum quantization parameter value among the quantization parameter values of each B frame in the first image group; wherein the second-category P frame is a P frame in the second image group; the interval video frames between the first-category P frame and the nearest second-category P frame in arrangement order is the first number; the interval video frames between two adjacent first-category P frames is the second number; the second number is equal to twice the first number plus 1; The first encoding module is used to encode the first type of P frame according to the first quantization parameter value.
11. The device according to claim 10, further comprising: include: a second determining module, configured to determine the frame sequence number of each video frame in the image group according to the time information of each video frame in the image group before acquiring the first type of P frame in the first image group; A third determining module, configured to determine the frame sequence number of each of the first-category P frames in the image group based on the frame sequence number of each of the video frames; The fourth determining module is used to determine the frame serial number of each of the second-category P frames in the image group based on the frame serial number of each of the video frames.
12. The device according to claim 10, further comprising: include: A second acquisition module, used for acquiring the second type of P frame; a fifth determining module, configured to determine the second quantization parameter value of the second type P frame, so that the second quantization parameter value is smaller than the first quantization parameter value and not smaller than the quantization parameter value of the I frame; The second encoding module is used to encode the second type of P frame according to the second quantization parameter value.
13. A video encoding device, the device being applied to a video to be encoded, the video to be encoded comprising at least one picture group, the first video frame in the picture group being an I frame, one of the picture groups comprising at least one first picture group and at least one second picture group, the first picture group and the second picture group being arranged alternately, each of the first picture group and the second picture group comprising a first number of B frames and one P frame, the device include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Acquire a first type of P frame in the first image group; Determine a first quantization parameter value of the first-category P frame, so that the first quantization parameter value is greater than a second quantization parameter value of the second-category P frame, and is not greater than a minimum quantization parameter value among the quantization parameter values of each B frame in the first image group; wherein the second-category P frame is a P frame in the second image group; the interval video frames between the first-category P frame and the nearest second-category P frame in arrangement order is the first number; the interval video frames between two adjacent first-category P frames is the second number; the second number is equal to twice the first number plus 1; The first type of P frame is encoded according to the first quantization parameter value.
14. A computer-readable medium having computer-readable instructions stored thereon, wherein the computer-readable instructions can be executed by a processor to implement the video encoding method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Code rate control method and code rate control device used for video coding
CN105898329A
Video coding method and device, electronic equipment and computer readable storage medium
CN111787322A
Video coding method and device, equipment and medium
CN114339196A
Video coding method and device, electronic equipment and storage medium
CN116962694A
Video compression method and device based on P and B frames, and readable storage medium
CN117528104A
