Video encoding method, device, equipment and medium
By categorizing P-frames with distinct quantization parameters and alternating their placement within a GOP, the method enhances video encoding efficiency and reduces bitrate while maintaining image quality, addressing the limitations of existing algorithms.
Patent Information
- Application Number
- CN202411440376.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2044-10-15
AI Technical Summary
Existing video coding algorithms struggle to effectively reduce video bitrate while maintaining image quality, especially in scenarios requiring low latency.
A video encoding method that classifies P-frames into two categories with different quantization parameter values, alternating them within a GOP, ensuring the first category P-frames have higher quantization parameters than the second, and adjusting intervals between these categories to optimize compression efficiency and bitrate.
This approach effectively reduces video bitrate and improves compression efficiency by using higher quantization parameters for selected P-frames, minimizing image quality degradation and conserving network bandwidth.
Smart Images

Figure CN118972583B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of video coding technology, and in particular to a video coding method, apparatus, device, and medium. Background Art
[0002] Video coding is a technology that represents video information using minimal data by compressing redundant components within video images. In video coding, video frame sequences are typically encoded in groups of pictures (GOPs). Within a GOP, video frames can be categorized into different types based on temporal or reference relationships, such as intra frames (I-frames), bidirectional predicted frames (B-frames), and predicted frames (P-frames). Different quantizer parameters (QP) are assigned to each type. The QP value of a video frame is related to the image quality of the encoded video frame. Generally, higher QP values result in lower image quality. The QP values of individual video frames also affect the video bitrate. Generally, increasing the QP values of some frames in a video can reduce the video bitrate. In particular, in scenarios where low latency is required, existing algorithms cannot effectively reduce the video bitrate while maintaining image quality.
[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 that can effectively reduce the video bit rate and improve the video compression efficiency while ensuring the video image quality as much as possible.
[0005] 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, wherein the video to be encoded includes at least one group of pictures, the first video frame in the group of pictures is an I frame, and one of the group of pictures 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. The method includes:
[0006] Obtaining a first type of P frame in the first image group;
[0007] Determining a first quantization parameter value for the first-category P-frames, such that the first quantization parameter value is greater than a second quantization parameter value for the second-category P-frames and is no greater than a minimum quantization parameter value among the quantization parameter values of the B-frames in the first image group; wherein the second-category P-frames are P-frames in the second image group; the interval between the first-category P-frame and the nearest P-frame of the second-category in arrangement order is the first number of video frames; the interval between two adjacent P-frames of the first category is a second number of video frames; and the second number is equal to twice the first number plus 1.
[0008] The first type of P frame is encoded according to the first quantization parameter value.
[0009] An embodiment of the present specification further provides a video encoding device, the device being applied to a video to be encoded, the video to be encoded comprising at least one group of pictures, the first video frame in the group of pictures being an I frame, the group of pictures comprising at least one first image subgroup and at least one second image subgroup, the first image subgroup and the second image subgroup being arranged alternately, each of the first image subgroup and the second image subgroup comprising a first number of B frames and one P frame, the device comprising:
[0010] A first acquisition module, configured to acquire a first type of P frame in the first image group;
[0011] a first determining module, configured to determine a first quantization parameter value of the first-category P-frame, such that the first quantization parameter value is greater than a second quantization parameter value of the second-category P-frame and is no greater than a minimum quantization parameter value among the quantization parameter values of the B-frames in the first image group; wherein the second-category P-frame is the P-frame in the second image group; the interval between the first-category P-frame and the nearest P-frame of the second-category in arrangement order is the first number of video frames; the interval between two adjacent P-frames of the first category is a second number of video frames; and the second number is equal to twice the first number plus 1;
[0012] The first encoding module is configured to encode the first type of P frame according to the first quantization parameter value.
[0013] An embodiment of the present specification further provides a video encoding device, the device being applied to a video to be encoded, the video to be encoded including at least one group of pictures, the first video frame in the group of pictures being an I frame, the group of pictures including at least one first image subgroup and at least one second image subgroup, the first image subgroup and the second image subgroup being arranged alternately, each of the first image subgroup and the second image subgroup including a first number of B frames and one P frame, the device comprising:
[0014] at least one processor; and,
[0015] a memory communicatively connected to the at least one processor; wherein,
[0016] 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:
[0017] Obtaining a first type of P frame in the first image group;
[0018] Determining a first quantization parameter value for the first-category P-frames, such that the first quantization parameter value is greater than a second quantization parameter value for the second-category P-frames and is no greater than a minimum quantization parameter value among the quantization parameter values of the B-frames in the first image group; wherein the second-category P-frames are P-frames in the second image group; the interval between the first-category P-frame and the nearest P-frame of the second-category in arrangement order is the first number of video frames; the interval between two adjacent P-frames of the first category is a second number of video frames; and the second number is equal to twice the first number plus 1.
[0019] The first type of P frame is encoded according to the first quantization parameter value.
[0020] The embodiments of this 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.
[0021] At least one embodiment provided in this specification can achieve the following beneficial effects:
[0022] In the embodiments of this specification, the P frames in the first image group and the P frames in the second image group, which are arranged at intervals within an image group, are classified as first-category P frames and second-category P frames, respectively, and the first quantization parameter value assigned to the first-category P frames is greater than the second quantization parameter value assigned to the second-category P frames. Because the second-category P frames, which have smaller quantization parameter values but higher image quality, can be used as a 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 video compression efficiency by assigning larger quantization parameter values to the first-category P frames while minimizing the image quality of the video frames. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 any creative labor.
[0024] Figure 1 A schematic diagram of a video encoding method according to an embodiment of the present invention;
[0025] 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;
[0026] Figure 3 A schematic diagram of the structure of another image group provided by an embodiment of this specification when the number of B frames between adjacent P frames is 3;
[0027] Figure 4 The embodiments of this specification provide corresponding Figure 1 A swim lane diagram of a video coding method in ;
[0028] Figure 5 The embodiments of this specification provide corresponding Figure 1 A structural diagram of a video encoding device;
[0029] Figure 6 The embodiments of this specification provide corresponding Figure 1 A structural diagram of a video encoding device. DETAILED DESCRIPTION
[0030] To make the purpose, technical solutions, and advantages of one or more embodiments of this specification more clear, the technical solutions of one or more embodiments of this specification will be clearly and completely described below in conjunction 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 specification, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of one or more embodiments of this specification.
[0031] Intra-frame coding and inter-frame coding are commonly used to remove spatial and temporal redundancy in the input video. Encoded video frames can generally be divided into I-frames, P-frames, and B-frames. I-frames are typically encoded using intra-frame coding, without reference to other previously encoded video frames. P-frames require reference to previously encoded video frames, while B-frames require reference to both previously encoded and backward-encoded video frames.
[0032] In video coding technology, video frame sequences are typically encoded in GOP units. Video frames within a GOP can be divided into different categories based on temporal relationships or playback order, and different QP values are assigned to each category. Generally, the more a video frame is referenced within a GOP, the lower the QP value it is assigned. The existing Constant Quantizer Parameter (CQP) allocation strategy applies the same QP allocation strategy to each mini-GOP. Therefore, in the existing CQP allocation strategy, all P-frames within a GOP are assigned the same QP value. However, setting a small quantization parameter value for all P-frames typically results in a higher bitrate for the encoded video, which in turn requires more network bandwidth for video transmission.
[0033] In order to solve the defects in the prior art, this solution provides the following embodiments.
[0034] Figure 1 This is a flow chart of a video encoding method provided in an embodiment of this specification. From a program perspective, the execution subject of this flow can be a video encoding program. From a hardware perspective, the execution subject of this flow can be a device or equipment equipped with the video encoding program.
[0035] 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 image group in the first image group and the second image group includes a first number of B frames and one P frame.
[0036] like Figure 1 As shown, the process may include the following steps.
[0037] Step 102: Obtain a first type of P frame in the first image group.
[0038] In the embodiments of this specification, the video to be encoded may be a segment of video awaiting encoding processing by a video encoder. The video to be encoded includes a certain number of video frames, which may constitute a video frame sequence. These video frames may form at least one group of pictures (GOP), i.e., the video to be encoded may include one or multiple GOPs. Typically, when encoding the video to be encoded, a video encoder encodes and transmits the video frame sequence in GOP units.
[0039] A group of pictures (GOP) refers to a set of consecutive video frames between two adjacent I-frames, including the preceding I-frame and excluding the succeeding I-frame. In a GOP, an I-frame is the first video frame, and subsequent video frames can be B-frames or P-frames. An I-frame can contain all the image information for a particular frame in a video, and encoding an I-frame does not rely on other frames. P-frame data can contain pixel information that has changed relative to the P-frame's reference frame, but may not contain the complete image data from the captured video frame corresponding to the P-frame. Encoding a P-frame requires reference to the preceding I-frame or P-frame. When encoding a B-frame, data compression can be achieved by predicting and differentially encoding the preceding I-frame or P-frame and the succeeding P-frame. During encoding, motion estimation techniques can be used to predict the pixel differences between the current B-frame and the preceding I-frame or P-frame and the succeeding P-frame, and encoding can be performed based on these differences.
[0040] In the embodiments of this specification, a picture group may typically 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 based on actual needs and is not specifically limited.
[0041] In the embodiments of this specification, to differentiate the quantization parameter values for P frames within a picture group, the P frames can be further divided into a first category of P frames and a second category of P frames, and different quantization parameter values can be assigned to the two categories of P frames. Specifically, a first picture group can include a first number of B frames and one P frame of the first category; a second picture group can include a first number of B frames and one P frame of the second category. Furthermore, the first and second picture groups are arranged alternately within the same picture group.
[0042] Figure 2 This is a structural diagram of an image group provided by an embodiment of this specification when the number of B frames between adjacent P frames is 3. Figure 2As shown, P1 represents the first type of P frame, and P2 represents the second type of P frame. Each first image group contains three B frames and one P1, and each second image group contains three B frames and one P2. Moreover, the first image groups and the second image groups are arranged alternately.
[0043] 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 the second quantization parameter value of the second type P frame, and is not greater than the minimum quantization parameter value among the quantization parameter values of each B frame in the first image group.
[0044] Among them, the second type of P frame is the P frame in the second image group; the interval video frames between the first type of P frame and the second type of P frame closest in arrangement order is the first number; the interval video frames between two adjacent first type P frames is the second number; the second number is equal to twice the first number plus 1.
[0045] In the embodiments of this specification, the quantization parameter value specifically refers to the value of the quantization parameter. The quantization parameter value can correspond to the quantization step number, and there is a one-to-one correspondence between the quantization parameter value and the quantization step value. In video coding standards, the quantization parameter value is typically represented by a QP value. Generally, the smaller the QP value of a video frame, the lower the compression ratio of the video frame during encoding, and the higher the encoded image quality. Conversely, the larger the QP value of a video frame, the higher the compression ratio of the video frame during encoding, and the lower the encoded image quality. Therefore, by adjusting the size of the quantization parameter, the balance between video encoding quality and compression ratio can be controlled to meet the requirements of different application scenarios. Furthermore, since the video compression ratio is related to the video bit rate, generally increasing the video compression ratio can reduce the video bit rate. Therefore, increasing the quantization parameter value during video encoding can also reduce the video bit rate. "Bit rate" can refer to the number of data bits transmitted per unit time during data transmission. "Bit rate" is also called "bit rate" and can indicate the number of bits required per second to represent the compressed and encoded video data. The unit of bit rate is generally kilobit per second (KBPS).
[0046] In the embodiments of this specification, since an excessively large quantization parameter value may result in a significant reduction in picture quality, and the encoded P frame needs to be used as an encoding reference frame for the B frame, 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.
[0047] 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 values 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.
[0048] In the embodiment of the present specification, the first image group and the second image group are arranged at intervals within the image group. Moreover, both the first image group and the second image group 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. For example, 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, P2 is used to represent the second type of P frame, and 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; the P1 adjacent to P1 with frame number 4 can 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.
[0049] Step 106: Encode the first type of P frame according to the first quantization parameter value.
[0050] In the embodiments of this specification, after determining the first quantization parameter value for a first-type P-frame, the first-type P-frame can be further encoded based on the first quantization parameter value. When encoding the first-type P-frame, inter-frame coding or a combination of intra-frame and inter-frame coding can be used, without specific limitation. Intra-frame coding is a video coding technique that primarily utilizes the spatial redundancy of an image for image compression. It relies on the similarity between adjacent pixels in an image and the dominant spatial frequency of pattern regions to remove redundant information to achieve image compression. Inter-frame coding is primarily based on motion-compensated predictive coding techniques, which determine motion vectors by comparing the current frame with a reference frame (typically a reconstructed frame). The motion vector can be used to indicate the position of the current block in the reference frame. Because inter-frame coding allows the encoder to transmit the motion vector and prediction error without transmitting the entire current frame, inter-frame coding can significantly reduce the amount of video data while maintaining good image quality.
[0051] Figure 1 In the method, P frames in the first image group and the second image group, which are arranged alternately in the image group, are classified as first-category P frames and second-category P frames, respectively. The first-category P frames are assigned a first quantization parameter value that is greater than the second-category P frames. Because the second-category P frames, which have lower quantization parameter values but higher image quality, can be used as a reference when encoding B frames, this method of increasing the quantization parameter values of some P frames at intervals can effectively reduce the video bitrate and improve video compression efficiency by assigning larger quantization parameter values to the first-category P frames while minimizing video frame quality.
[0052] In the embodiments of this 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 a picture group.
[0053] Based on this, the above video encoding method may further include the following steps:
[0054] Obtaining the second type of P frame;
[0055] Determining 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;
[0056] The second-type P frame is encoded according to the second quantization parameter value.
[0057] In the embodiments of this specification, excessively small quantization parameter values can significantly reduce video compression, thereby significantly increasing the video bitrate. Therefore, to control the video bitrate and ensure video compression, it is generally required that the quantization parameter value of a P-frame within a GIP be no less than the quantization parameter value of an I-frame within the GIP. Therefore, the second quantization parameter value of the second-type P-frame can be no less than the quantization parameter value of an I-frame within the GIP. This prevents excessively high video bitrates, effectively controls the video bitrate, and helps conserve network bandwidth for video transmission networks.
[0058] In the embodiments of this specification, when encoding the second type of P-frames based on the second quantization parameter value, inter-frame coding or a combination of intra-frame coding and inter-frame coding may be used, without specific limitation. Intra-frame coding and inter-frame coding have been described above and will not be further elaborated here.
[0059] In the embodiments of this specification, before obtaining the first and second type P frames, it is first possible to determine which video frames in the image group are the first type P frames and which are the second type P frames. Furthermore, before determining the frame types of the video frames, it is also necessary to determine the frame numbers of the video frames. After determining the frame numbers of the video frames, it is then possible to determine which video frames belong to the first type P frames and which belong to the second type P frames based on the frame numbers of the video frames.
[0060] 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:
[0061] Determining a frame sequence number of each video frame according to time information of each video frame in the image group;
[0062] Determining, based on the frame sequence numbers of the video frames, the frame sequence numbers of the first-category P frames in the image group;
[0063] Based on the frame sequence numbers of the video frames, the frame sequence numbers of the second-category P frames in the image group are determined.
[0064] In the embodiments of this 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 time axis when the video is played, or it 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. There is no specific limitation on this.
[0065] In the embodiments of this specification, since the first video frame of each image group is an I-frame, the frame sequence number of each video frame is determined based on the time sequence of the video frames in the image group. The frame sequence number of the I-frame in the image group can be determined first. Generally, the frame sequence number of the I-frame can be determined as 0. After the frame sequence number of the I-frame is determined, the video frames can be numbered in sequence based on the playback time sequence of the video frames in the image group, starting from the frame sequence number of the I-frame and numbered at intervals of 1, to obtain the frame sequence number of each video frame. For example, if image group A contains a total of 50 video frames, and the first video frame is an I-frame, the frame sequence number of the I-frame in image group A can be determined as 0, and the frame sequence number of the first video frame after the I-frame can be determined as 1. This numbering sequence is repeated until the entire image group A is compiled. The frame sequence number of the last video frame in image group A is 49.
[0066] In the embodiments of this specification, the frame sequence numbers of each first-category P-frame in a picture group are determined based on the frame sequence numbers of each video frame. The frame sequence number of the first first-category P-frame in the picture group can be determined based on the frame sequence numbers of each video frame. Subsequently, subsequent first-category P-frames can be determined based on the difference between the frame sequence numbers of the first-category P frames. Similarly, the same method can be used to determine the frame sequence numbers of each second-category P-frame in a picture group based on the frame sequence numbers of each video frame.
[0067] Based on this, determining the frame sequence number of each of the first-category P frames in the image group based on the frame sequence number of each video frame may specifically include the following steps:
[0068] Based on the frame numbers of the video frames, determining a 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 image group; the first difference is equal to the value of the first number plus 1;
[0069] The frame numbers whose frame number difference from 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 other than the first first-category P frame.
[0070] 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:
[0071] Based on the frame serial numbers of the video frames, determining the frame serial number whose difference from the frame serial number of the I frame is the second difference as the frame serial number of the first second-category P frame in the image group;
[0072] The frame number whose frame number difference from 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.
[0073] Alternatively, in another embodiment of the present specification, determining the frame sequence number of each of the first-category P frames in the image group based on the frame sequence number of each video frame may specifically include the following steps:
[0074] 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;
[0075] 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 is determined as the frame sequence number of the other first-category P frame.
[0076] 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:
[0077] Based on the frame numbers of the video frames, determining a frame number having a first difference from the frame number of the I frame as the frame number of the first second-category P frame in the group of images; the first difference being equal to the value of the first number plus 1;
[0078] The frame number whose sequence number difference from the frame sequence number of the first second-category P frame is an integral multiple of a second difference is determined as the frame sequence number of the other second-category P frame; the second difference is equal to the value of the second number plus 1.
[0079] 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.
[0080] In this embodiment of the present specification, since each image group contains a first number of B frames, the first number of B frames separates the I frame from the first P frame in the image group. Consequently, the difference in sequence number (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 difference in sequence number (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. Furthermore, since the first difference is equal to the value of the first number plus 1, and the second number is equal to twice the first number plus 1, the second difference is also equal to the value of the second number plus 1.
[0081] 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. By the same token, 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. For example, 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. As Figure 2 As 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.
[0082] Figure 3 A structural diagram 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.
[0083] In the embodiment of the present specification, after the frame number of the video frame is determined, the quantization parameter value of the video frame can be determined according to the frame number of the video frame based on a preset mapping relationship.
[0084] Based on this, determining the first quantization parameter value of the first type of P frame may specifically include the following steps:
[0085] Determining a level identifier of the first type of P frame based on a first mapping relationship and a 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;
[0086] Based on the 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.
[0087] Correspondingly, determining the second quantization parameter value of the second type of P frame may specifically include the following steps:
[0088] Determining the level identifier of the second-type P frame based on the first mapping relationship and the frame sequence number of the second-type P frame, wherein 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;
[0089] 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.
[0090] 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 a layerID. The lower the layerID, the higher the possibility of the video frame being referenced. For example, if there are three types of layer identifiers for 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 a layer identifier of layerID=0 during encoding, but cannot refer to video frames with a layer identifier of layerID=1 and layerID=2; the video frame with a layer identifier of layerID=1 can refer to other video frames with a layer identifier of layerID=1 and video frames with a layer identifier of layerID=0 during encoding, but cannot refer to video frames with a layer identifier of layerID=2; the video frame with a layer identifier of layerID=2 can refer to other video frames with a layer identifier of layerID=2, video frames with a layer identifier of layerID=1, and video frames with a layer identifier of layerID=0 during encoding. Since the first mapping relationship and the second mapping relationship will be explained in detail in subsequent embodiments of this specification, they will not be described in detail here.
[0091] 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 other video frames other than first-category P frames and second-category P frames based on a preset mapping relationship and the frame sequence numbers of these video frames, and then encode these video frames according to the quantization parameter values of these video frames.
[0092] Based on this, the aforementioned video encoding method may further include the following steps:
[0093] Acquire other video frames in the image group except the first-category P frames and the second-category P frames;
[0094] 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;
[0095] Determining 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;
[0096] Each of the other video frames is encoded according to the quantization parameter value of each of the other video frames.
[0097] In the embodiments of the present specification, other video frames in the image group other than the first-category P-frames and the second-category P-frames 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 hierarchical 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 hierarchical 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 hierarchical identifier of the video frame may be determined based on the first mapping relationship.
[0098] In the embodiments of this 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 video frame. If the frame type of a 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.
[0099] Table 1 is an example table of the first mapping relationship. Table 2 is an example table of the second mapping relationship. For example, as shown in Tables 1 and 2, based on Table 1, the frame type and layer identifier of a frame can be determined according to the frame sequence number of the frame. Then, based on Table 2, the quantization parameter value of the frame can be determined according to the frame type and layer identifier of the frame.
[0100] Table 1:
[0101]
[0102] Table 2:
[0103]
[0104] In practical applications, a third mapping relationship between the frame number of a 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 based on 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.
[0105] In this embodiment of the present specification, the first mapping relationship may record a mapping relationship between the frame sequence numbers of a third number of video frames after the I frame and the level identifiers of the third number of video frames.
[0106] 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:
[0107] Taking the quotient of the frame sequence number of the first type of P frame and the third number to obtain a first remainder;
[0108] Determine a layer identifier of the first type of P frame according to the first mapping relationship and the first remainder.
[0109] Correspondingly, determining the 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 may specifically include the following steps:
[0110] Taking the quotient of the frame sequence number of the second type of P frame and the third number to obtain a second remainder;
[0111] Determine the layer identifier of the second type of P frame according to the first mapping relationship and the second remainder.
[0112] 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:
[0113] Taking the quotient of the frame sequence number of each of the other video frames and the third number to obtain each third remainder;
[0114] The level identifier of each of the other video frames is determined according to the first mapping relationship and the third remainders.
[0115] In the embodiments of this specification, the first mapping relationship may record a mapping relationship between the frame sequence numbers of a third number of video frames following the I frame and the level identifiers of the third number of video frames. The third number may be no less than the second number plus 1, i.e., the third number is no less than the number of video frames included in the two image groups. Typically, the third number can be the number of video frames included in the two image groups.
[0116] In the embodiments of this specification, the first mapping relationship may include a 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 a 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. Finally, the level identifier corresponding to the remainder may be determined as the level identifier of the video frame.
[0117] For example, 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 frame number 11, 11 can be divided by 8, resulting in a remainder of 3. Since the corresponding level identifier is 2 when the frame number is 3, it can be determined that the level identifier of the video frame with frame number 11 is 2.
[0118] Figure 4 The embodiments of this specification provide corresponding 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 image group 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 at intervals, and each image group in the first image group and the second image group may include a first number of B frames and one P frame. As shown 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.
[0119] Step 402: Determine the frame sequence number of each video frame according to the time information of each video frame in the image group.
[0120] 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 image group.
[0121] 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.
[0122] 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.
[0123] 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.
[0124] Step 412: Encode the first type of P frame according to the first quantization parameter value.
[0125] 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 GOP.
[0126] Step 416: Determine the frame numbers 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 numbers of other second-category P frames.
[0127] 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.
[0128] 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.
[0129] Step 422: Encode the second type of P frame according to the second quantization parameter value.
[0130] Step 424: Obtain the video encoding result.
[0131] In actual 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.
[0132] Steps 404 to 412 are the process for encoding the first type of P frames in the GOP. Steps 414 to 422 are the process for encoding the second type of P frames in the GOP. After encoding the first and second type of P frames in the GOP, encoding of the P frames in the GOP of the video to be encoded is complete. For the I frames and B frames in the GOP of the video to be encoded, the quantization parameter value of the I frame and the quantization parameter values of each B frame can be determined based on the frame sequence numbers of the I and B frames and the first and second mapping relationships. The I frame is encoded based on the quantization parameter value of the I frame, and the B frames are encoded based on the quantization parameter values of each B frame. This completes encoding of all video frames in the GOP of the video to be encoded, resulting in a video encoding result. The specific processing process can be found in the description of the previous embodiment and will not be repeated here.
[0133] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.
[0134] Figure 5 The embodiments of this specification provide corresponding Figure 1 A structural diagram of a video encoding device. The device is applied to a video to be encoded, wherein the video to be encoded comprises at least one image group, wherein the first video frame in the image group is an I frame, and wherein one image group comprises at least one first image group and at least one second image group, wherein the first image group and the second image group are arranged alternately, and each of the first image group and the second image group comprises a first number of B frames and one P frame. Figure 5 As shown, the device may include the following modules.
[0135] The first acquisition module 502 is configured to acquire a first type of P frame in the first image group.
[0136] The first determination module 504 is used to determine the first quantization parameter value of the first type of P frame, so that the first quantization parameter value is greater than the second quantization parameter value of the second type of P frame, and is not greater than the minimum quantization parameter value among the quantization parameter values of each B frame in the first image group; wherein, the second type of P frame is the P frame in the second image group; the interval video frames between the first type of P frame and the second type of P frame closest in arrangement order is the first number; the interval video frames between two adjacent first type P frames is the second number; the second number is equal to twice the first number plus 1.
[0137] The first encoding module 506 is configured to encode the first type of P frame according to the first quantization parameter value.
[0138] based on Figure 5The present specification also provides some specific implementations of the device, which will be described below.
[0139] Optionally, the device may further include:
[0140] The second determining module is configured to determine the frame sequence number of each video frame in the image group according to time information of each video frame before acquiring the first type of P frame in the first image group.
[0141] The third determining module is configured 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.
[0142] The fourth determining module is configured 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.
[0143] Optionally, the device may further include:
[0144] The second acquisition module is used to acquire the second type of P frame.
[0145] The fifth determining module is 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.
[0146] The second encoding module is configured to encode the second type of P frame according to the second quantization parameter value.
[0147] Optionally, the third determining module may specifically include:
[0148] The first determination unit is used to determine 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 based on the frame numbers of the video frames; the first difference is equal to the value of the first number plus 1.
[0149] The second determination unit is used to determine the frame numbers whose frame number difference from the frame number of the first first-category P frame is an integer multiple of the second difference 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 other than the first first-category P frame.
[0150] or,
[0151] The third determining unit is configured to determine, based on the frame numbers of the video frames, a 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.
[0152] The fourth determining unit is configured to determine the frame sequence number of the other first-category P frame as the frame sequence number of the other first-category P frame whose sequence number difference from the frame sequence number of the first first-category P frame is an integral multiple of the second difference.
[0153] Optionally, the fourth determining module may specifically include:
[0154] The first determining unit is used to determine 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 based on the frame numbers of the video frames; the first difference is equal to the value of the first number plus 1.
[0155] 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 other than the first second-category P frame.
[0156] or,
[0157] The third determining unit is configured to determine, based on the frame numbers of the video frames, a 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.
[0158] The fourth determining unit is configured to determine a 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 the other second-category P frame.
[0159] Optionally, the first determining module may specifically include:
[0160] The layer identifier determination unit is used to determine the layer identifier of the first type of P frame based on a 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 layer identifier of the video frame.
[0161] 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.
[0162] 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.
[0163] Correspondingly, the level identification determination unit may specifically include:
[0164] The remainder determination subunit is configured to obtain a first remainder by dividing the frame sequence number of the first type of P frame by the third number.
[0165] The layer identifier determination subunit is configured to determine the layer identifier of the first type of P frame according to the first mapping relationship and the first remainder.
[0166] Optionally, the fifth determining module may specifically include:
[0167] The layer identifier determination unit is used to determine the 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 the mapping relationship between the frame sequence number of the video frame and the layer identifier of the video frame.
[0168] 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 the 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.
[0169] Optionally, the device may further include:
[0170] The third acquisition module is configured to acquire other video frames in the image group except the first-category P frames and the second-category P frames.
[0171] The sixth determining module is configured to determine a level identifier of each of the other video frames based on the first mapping relationship and a frame sequence number of each of the other video frames.
[0172] The seventh determining module is configured to 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.
[0173] The third encoding module is configured to encode each of the other video frames according to the quantization parameter value of each of the other video frames.
[0174] Based on the same idea, the embodiments of this specification also provide devices corresponding to the above methods.
[0175] Figure 6 The embodiments of this specification provide corresponding Figure 1A structural diagram of a video encoding device. The device is applied to a video to be encoded, wherein the video to be encoded comprises at least one image group, wherein the first video frame in the image group is an I frame, and wherein one image group comprises at least one first image group and at least one second image group, wherein the first image group and the second image group are arranged alternately, and each of the first image group and the second image group comprises a first number of B frames and one P frame. Figure 6 As shown, the device 600 may include:
[0176] at least one processor 610; and,
[0177] A memory 630 in communication with the at least one processor; wherein,
[0178] The memory 630 stores instructions 620 that can be executed 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:
[0179] A first type of P frame in the first image group is obtained.
[0180] Determine a 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 among 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.
[0181] The first type of P frame is encoded according to the first quantization parameter value.
[0182] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various 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.
[0183] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0184] In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures like diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using physical hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly performed using software called a "logic compiler." This is similar to the software compilers used during program development. Before compilation, the original code must be written in a specific programming language, called a Hardware Description Language (HDL). There are many types of HDL, including 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, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that simply by programming a method flow in one of these hardware description languages and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.
[0185] The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the memory control logic. Those skilled in the art will also appreciate that, in addition to implementing the controller purely in computer-readable program code, the controller can also be implemented in the form of logic gates, switches, an application-specific integrated circuit, a programmable logic controller, an embedded microcontroller, etc. by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the means for implementing the various functions included therein can also be considered as structures within the hardware component. Alternatively, the means for implementing the various functions can be considered both a software module implementing the method and a structure within the hardware component.
[0186] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having 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 smartphone, 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.
[0187] For the convenience of description, the above devices are described as being divided into 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.
[0188] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. 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 magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0189] 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 flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, 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 flowcharts and / or block diagrams. 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.
[0190] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work 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 The function specified in one or more boxes.
[0191] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device 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.
[0192] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0193] 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.
[0194] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can be implemented using any method or technology for information storage. 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 RAM (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 technologies, compact disc read-only memory (CD-ROM), digital versatile disc (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 herein, computer-readable media does not include transitory computer-readable media such as modulated data signals and carrier waves.
[0195] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0196] This specification may be described in the general context of computer-executable instructions, such as program modules, executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like 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 communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media, including storage devices.
[0197] The foregoing is merely an example of the present invention and is not intended to limit the present invention. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be included within the scope of the claims of the present invention.
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 group of pictures, the first video frame in the group of pictures being an I frame, one of the group of pictures comprising at least one first image group and at least one second image group, the first image group and the second image group being arranged alternately, each of the first image group and the second image group comprising a first number of B frames and one P frame, the method comprising: 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: 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 of claim 1, further comprising: 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 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 comprises: 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 determining the frame sequence number of each of the second-type P frames in the image group based on the frame sequence number of each of the video frames comprises: 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 determining the first quantization parameter value of the first type of P frame specifically comprises: 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 determining the second quantization parameter value of the second type P frame comprises: 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 of claim 8, further comprising: 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 comprising: 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 apparatus of claim 10, further comprising: 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 apparatus of claim 10, further comprising: 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 comprising: 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
