HK40091101A - Video processing method, apparatus, computer device, storage medium and program product - Google Patents
Video processing method, apparatus, computer device, storage medium and program product Download PDFInfo
- Publication number
- HK40091101A HK40091101A HK42023080035.1A HK42023080035A HK40091101A HK 40091101 A HK40091101 A HK 40091101A HK 42023080035 A HK42023080035 A HK 42023080035A HK 40091101 A HK40091101 A HK 40091101A
- Authority
- HK
- Hong Kong
- Prior art keywords
- target video
- video
- video frame
- parameter
- encoded
- Prior art date
Links
Description
技术领域Technical Field
本申请涉及计算机技术领域,尤其涉及视频编码技术领域,具体涉及一种视频处理方法、装置、计算机设备、存储介质及程序产品。This application relates to the field of computer technology, and more particularly to the field of video coding technology, specifically to a video processing method, apparatus, computer equipment, storage medium, and program product.
背景技术Background Technology
目前,视频编码技术在视频会话、视频点播、视频直播等视频业务中得到了非常广泛的应用,采用视频编码技术对视频进行编码处理能够在视频业务中节省视频占用的存储空间,提升视频传输效率。码率控制是视频编码技术中的关键一环,其通过在编码过程中调整QP(Quantizer Parameter,量化参数)来控制码率。采用合适的QP对视频进行编码处理,可以在编码得到的视频码率满足目标带宽的前提下,使得视频消费端的视频呈现质量与QoE(Quality of Experience,体验质量)指标之间的达到最佳平衡,提升视频编码效果。因此,如何更好地确定编码量化参数(即QP)进行视频编码成为当前的研究热点。Currently, video coding technology is widely used in video services such as video conferencing, video-on-demand, and live video streaming. Encoding video using this technology can save storage space and improve transmission efficiency. Bitrate control is a crucial aspect of video coding, achieved by adjusting the Quantizer Parameter (QP) during the encoding process. Using a suitable QP ensures that the encoded video bitrate meets the target bandwidth while achieving an optimal balance between video presentation quality and Quality of Experience (QoE) for the consumer, thus improving the overall video coding effect. Therefore, determining the optimal quantization parameter (QP) for video coding has become a current research hotspot.
发明内容Summary of the Invention
本申请实施例提供了一种视频处理方法、装置、计算机设备、存储介质及程序产品,可以针对性地确定编码量化参数进行视频编码。This application provides a video processing method, apparatus, computer equipment, storage medium, and program product that can specifically determine encoding quantization parameters for video encoding.
一方面,本申请实施例提供了一种视频处理方法,该视频处理方法包括:On one hand, embodiments of this application provide a video processing method, which includes:
从目标视频中获取待编码的目标视频帧;获取目标视频的视频属性特征,确定与视频属性特征相匹配的编码偏移参数;根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数;对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数;根据目标视频帧的编码量化参数对目标视频帧进行编码处理。The process involves: acquiring the target video frame to be encoded from the target video; obtaining the video attribute features of the target video and determining the encoding offset parameters that match the video attribute features; estimating the quantization parameters of the target video frame based on the encoding offset parameters to obtain the initial quantization parameters of the target video frame; adjusting the initial quantization parameters of the target video frame to obtain the encoded quantization parameters of the target video frame; and encoding the target video frame based on the encoded quantization parameters of the target video frame.
相应地,本申请实施例提供了一种视频处理装置,该视频处理装置包括:Accordingly, embodiments of this application provide a video processing apparatus, which includes:
获取单元,用于从目标视频中获取待编码的目标视频帧;获取目标视频的视频属性特征;The acquisition unit is used to acquire the target video frame to be encoded from the target video; and to acquire the video attribute features of the target video.
处理单元,用于确定与视频属性特征相匹配的编码偏移参数;根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数;对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数;根据目标视频帧的编码量化参数对目标视频帧进行编码处理。The processing unit is used to determine the coding offset parameters that match the video attribute features; estimate the quantization parameters of the target video frame based on the coding offset parameters to obtain the initial quantization parameters of the target video frame; adjust the initial quantization parameters of the target video frame to obtain the coding quantization parameters of the target video frame; and perform coding processing on the target video frame based on the coding quantization parameters of the target video frame.
在一种实现方式中,视频属性特征包括目标视频的分辨率信息、目标视频所属的视频类型信息、目标视频的码率信息、以及目标视频的播放效果参考信息中的任一种或多种;其中,不同的视频属性特征所匹配的编码偏移参数不相同。In one implementation, the video attribute features include one or more of the following: resolution information of the target video, video type information of the target video, bitrate information of the target video, and playback effect reference information of the target video; wherein, the encoding offset parameters matched with different video attribute features are different.
在一种实现方式中,处理单元,用于确定与视频属性特征相匹配的编码偏移参数时,具体用于执行如下步骤:In one implementation, the processing unit, when determining the encoding offset parameter that matches the video attribute features, specifically performs the following steps:
在参数匹配关系中确定与视频属性特征相匹配的属性特征指示信息,参数匹配关系包括多个属性特征指示信息和每个属性特征指示信息对应的参考偏移参数;将相匹配的属性特征指示信息对应的参考偏移参数,确定为与视频属性特征相匹配的编码偏移参数。In the parameter matching relationship, the attribute feature indication information that matches the video attribute feature is determined. The parameter matching relationship includes multiple attribute feature indication information and a reference offset parameter corresponding to each attribute feature indication information. The reference offset parameter corresponding to the matching attribute feature indication information is determined as the encoding offset parameter that matches the video attribute feature.
在一种实现方式中,目标视频帧的类型为关键帧类型;处理单元,用于根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数时,具体用于执行如下步骤:In one implementation, the target video frame is a keyframe type; the processing unit, used to estimate the quantization parameters of the target video frame based on the coding offset parameters, specifically performs the following steps to obtain the initial quantization parameters of the target video frame:
根据编码偏移参数对目标视频的N个已编码视频帧中指定类型的已编码视频帧的编码量化参数进行参数映射处理,得到指定类型的已编码视频帧的偏移量化参数,N为正整数;根据指定类型的已编码视频帧的偏移量化参数和N个已编码视频帧中其他类型的已编码视频帧的编码量化参数,确定N个已编码视频帧的统计参数;其他类型的已编码视频帧是指:N个已编码视频帧中除指定类型的已编码视频帧外的其他已编码视频帧;根据N个已编码视频帧的统计参数和N个已编码视频帧的数量,确定目标视频帧的初始量化参数。Based on the coding offset parameters, the coding quantization parameters of the specified type of encoded video frames among the N encoded video frames of the target video are mapped to obtain the offset quantization parameters of the specified type of encoded video frames, where N is a positive integer. Based on the offset quantization parameters of the specified type of encoded video frames and the coding quantization parameters of other types of encoded video frames among the N encoded video frames, the statistical parameters of the N encoded video frames are determined. Other types of encoded video frames refer to: other encoded video frames among the N encoded video frames besides the specified type of encoded video frames. Based on the statistical parameters of the N encoded video frames and the number of N encoded video frames, the initial quantization parameters of the target video frame are determined.
在一种实现方式中,编码偏移参数包括第一编码偏移参数和第二编码偏移参数;处理单元,用于根据编码偏移参数对目标视频的N个已编码视频帧中指定类型的已编码视频帧的编码量化参数进行参数映射处理,得到指定类型的已编码视频帧的偏移量化参数时,具体用于执行如下步骤:In one implementation, the encoding offset parameter includes a first encoding offset parameter and a second encoding offset parameter; the processing unit, used to perform parameter mapping processing on the encoding quantization parameters of a specified type of encoded video frames among N encoded video frames of the target video according to the encoding offset parameter, specifically performs the following steps when obtaining the offset quantization parameter of the specified type of encoded video frames:
若指定类型为关键帧类型,则根据第一编码偏移参数对关键帧类型的已编码视频帧的编码量化参数进行参数映射处理,得到关键帧类型的已编码视频帧的偏移量化参数;若指定类型为双向差别帧类型,则根据第二编码偏移参数对双向差别帧类型的已编码视频帧的编码量化参数进行参数映射处理,得到双向差别帧类型的已编码视频帧的偏移量化参数。If the specified type is a keyframe type, then the encoding quantization parameters of the encoded video frames of the keyframe type are mapped according to the first encoding offset parameter to obtain the offset quantization parameters of the encoded video frames of the keyframe type; if the specified type is a bidirectional difference frame type, then the encoding quantization parameters of the encoded video frames of the bidirectional difference frame type are mapped according to the second encoding offset parameter to obtain the offset quantization parameters of the encoded video frames of the bidirectional difference frame type.
在一种实现方式中,目标视频帧的类型为双向差别帧类型;处理单元,用于根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数时,具体用于执行如下步骤:In one implementation, the target video frame is a bidirectional difference frame type; the processing unit, used to estimate the quantization parameters of the target video frame based on the coding offset parameters, specifically performs the following steps to obtain the initial quantization parameters of the target video frame:
在目标视频中确定目标视频帧的参考视频帧;若参考视频帧的数量为一个,则将参考视频帧的参考量化参数确定为目标视频帧的初始量化参数;若参考视频帧的数量为M个,则获取M个参考视频帧中的每个参考视频帧的复杂度参数,并根据M个参考视频帧的复杂度参数对M个参考视频帧的参考量化参数进行加权求和计算,得到目标视频帧的初始量化参数,M为大于1的整数;其中,参考视频帧中的指定类型的参考视频帧的参考量化参数,是根据编码偏移参数对指定类型的参考视频帧的编码量化参数进行参数映射处理得到的;参考视频帧中的其他类型的参考视频帧的参考量化参数,是其他类型的参考视频帧的编码量化参数;其他类型的参考视频帧是指:参考视频帧中除指定类型的参考视频帧外的其他参考视频帧。In the target video, a reference video frame is determined. If there is only one reference video frame, its reference quantization parameter is used as the initial quantization parameter of the target video frame. If there are M reference video frames, the complexity parameter of each of the M reference video frames is obtained, and the reference quantization parameters of the M reference video frames are weighted and summed according to their complexity parameters to obtain the initial quantization parameter of the target video frame, where M is an integer greater than 1. The reference quantization parameter of a specified type of reference video frame is obtained by mapping the encoded quantization parameter of the specified type of reference video frame to the encoded quantization parameter based on the encoded offset parameter. The reference quantization parameter of other types of reference video frames is the encoded quantization parameter of those other types. Other types of reference video frames refer to all reference video frames other than those of the specified type.
在一种实现方式中,处理单元,还用于执行如下步骤:In one implementation, the processing unit is further configured to perform the following steps:
对目标视频帧进行类型检测;若目标视频帧的类型为关键帧类型或双向差别帧类型,则触发执行获取目标视频的视频属性特征,确定与视频属性特征相匹配的编码偏移参数的步骤;若目标视频帧的类型为前向差别帧类型,则获取目标视频帧的模糊复杂度参数,根据目标视频帧的模糊复杂度参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数。Type detection is performed on the target video frame; if the target video frame is a keyframe type or a bidirectional difference frame type, the step of obtaining the video attribute features of the target video and determining the encoding offset parameters that match the video attribute features is triggered; if the target video frame is a forward difference frame type, the fuzzy complexity parameter of the target video frame is obtained, and the quantization parameter of the target video frame is estimated based on the fuzzy complexity parameter of the target video frame to obtain the initial quantization parameters of the target video frame.
在一种实现方式中,处理单元,用于获取目标视频帧的模糊复杂度参数时,具体用于执行如下步骤:In one implementation, when the processing unit obtains the fuzziness complexity parameter of the target video frame, it specifically performs the following steps:
获取目标视频帧的预测残差参数;根据目标视频的N个已编码视频帧的累积复杂度参数、N个已编码视频帧的累积帧数和目标视频帧的预测残差参数,确定目标视频帧的模糊复杂度参数,N为正整数;其中,累积复杂度参数是对N个已编码视频帧的复杂度参数进行加权累积得到的;累积帧数是对N个已编码视频帧的帧数进行加权累积得到的。Obtain the prediction residual parameters of the target video frame; determine the fuzzy complexity parameters of the target video frame based on the cumulative complexity parameters of the N encoded video frames, the cumulative frame count of the N encoded video frames, and the prediction residual parameters of the target video frame, where N is a positive integer; where the cumulative complexity parameter is obtained by weighted accumulation of the complexity parameters of the N encoded video frames; and the cumulative frame count is obtained by weighted accumulation of the frame counts of the N encoded video frames.
在一种实现方式中,处理单元,用于根据目标视频帧的模糊复杂度参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数时,具体用于执行如下步骤:In one implementation, the processing unit, when estimating the quantization parameters of the target video frame based on the fuzziness complexity parameter of the target video frame to obtain the initial quantization parameters of the target video frame, specifically performs the following steps:
获取目标视频帧的压缩因子,根据目标视频帧的模糊复杂度参数和所述压缩因子确定所述目标视频帧的量化等级参数;获取目标视频帧的累计分配信息量和目标视频帧的累积复杂度参数;目标视频帧的累计分配信息量是对目标视频帧的分配信息量和N个已编码视频帧的分配信息量进行累计得到的;目标视频帧的累积复杂度参数是根据N个已编码视频帧的累积复杂度参数和目标视频帧的预测残差参数确定的;根据目标视频帧的累计分配信息量和目标视频帧的累积复杂度参数,确定量化等级参数的优化因子;根据优化因子对量化等级参数进行优化,得到目标视频帧的初始量化参数。The compression factor of the target video frame is obtained, and the quantization level parameter of the target video frame is determined based on the fuzziness complexity parameter of the target video frame and the compression factor. The cumulative allocation information and cumulative complexity parameter of the target video frame are obtained. The cumulative allocation information is obtained by accumulating the allocation information of the target video frame and the allocation information of N encoded video frames. The cumulative complexity parameter of the target video frame is determined based on the cumulative complexity parameters of the N encoded video frames and the prediction residual parameter of the target video frame. An optimization factor for the quantization level parameter is determined based on the cumulative allocation information and cumulative complexity parameter of the target video frame. The quantization level parameter is optimized based on the optimization factor to obtain the initial quantization parameters of the target video frame.
在一种实现方式中,处理单元,用于对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数时,具体用于执行如下步骤:In one implementation, the processing unit, when adjusting the initial quantization parameters of the target video frame to obtain the encoded quantization parameters of the target video frame, specifically performs the following steps:
根据目标视频中的N个已编码视频帧的累计编码信息量和N个已编码视频帧的累计分配信息量,确定对目标视频帧的初始量化参数的调整因子;N个已编码视频帧的累计编码信息量是对N个已编码视频帧的编码信息量进行累计得到的,N个已编码视频帧的累计分配信息量是对N个已编码视频帧的分配信息量进行累计得到的,N为正整数;根据调整因子对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数。Based on the cumulative encoded information and cumulative allocated information of N encoded video frames in the target video, an adjustment factor for the initial quantization parameters of the target video frame is determined. The cumulative encoded information of the N encoded video frames is obtained by accumulating the encoded information of the N encoded video frames, and the cumulative allocated information of the N encoded video frames is obtained by accumulating the allocated information of the N encoded video frames, where N is a positive integer. The initial quantization parameters of the target video frame are adjusted according to the adjustment factor to obtain the encoded quantization parameters of the target video frame.
相应地,本申请实施例提供一种计算机设备,该计算机设备包括处理器和计算机可读存储介质;其中,处理器适于实现计算机程序,计算机可读存储介质存储有计算机程序,计算机可读存储介质中存储的计算机程序适于由处理器加载并执行上述的视频处理方法。Accordingly, embodiments of this application provide a computer device, which includes a processor and a computer-readable storage medium; wherein the processor is adapted to implement a computer program, the computer-readable storage medium stores the computer program, and the computer program stored in the computer-readable storage medium is adapted to be loaded by the processor and executed by the above-described video processing method.
相应地,本申请实施例提供一种计算机可读存储介质,该计算机可读存储介质存储有计算机程序,该计算机程序被计算机设备的处理器读取并执行时,使得计算机设备执行上述的视频处理方法。Accordingly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when read and executed by a processor of a computer device, causes the computer device to perform the aforementioned video processing method.
相应地,本申请实施例提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行上述的视频处理方法。Accordingly, embodiments of this application provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the aforementioned video processing method.
本申请实施例中,可以获取目标视频的视频属性特征,确定与视频属性特征相匹配的编码偏移参数,然后可以根据编码偏移参数对目标视频中待编码的目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数,然后可以对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数,从而可以根据目标视频帧的编码量化参数对目标视频帧进行编码处理;可见,本申请实施例中确定出的目标视频帧的编码量化参数与目标视频的视频属性特征相适配,也就是说,可以根据目标视频的视频属性特征针对性地确定出用于对目标视频帧进行编码处理的编码量化参数,这样可以在编码得到的视频码率满足目标带宽的前提下,使得视频消费端的视频呈现质量与QoE(Quality ofExperience,体验质量)指标之间的达到最佳平衡,提升视频编码效果。In this embodiment, video attribute features of the target video can be obtained, and encoding offset parameters matching the video attribute features can be determined. Then, quantization parameters of the target video frame to be encoded in the target video can be estimated based on the encoding offset parameters to obtain the initial quantization parameters of the target video frame. The initial quantization parameters of the target video frame can then be adjusted to obtain the encoding quantization parameters of the target video frame. Thus, the target video frame can be encoded based on the encoding quantization parameters. It can be seen that the encoding quantization parameters of the target video frame determined in this embodiment are compatible with the video attribute features of the target video. In other words, encoding quantization parameters for encoding the target video frame can be specifically determined based on the video attribute features of the target video. This allows for the optimal balance between the video presentation quality and the QoE (Quality of Experience) index at the video consumer end, while ensuring that the bitrate of the encoded video meets the target bandwidth, thereby improving the video encoding effect.
附图说明Attached Figure Description
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
图1是本申请实施例提供的一种码率控制的原理示意图;Figure 1 is a schematic diagram illustrating the principle of bitrate control provided in an embodiment of this application;
图2是本申请实施例提供的一种码率控制的效果示意图;Figure 2 is a schematic diagram illustrating the effect of a bitrate control provided in an embodiment of this application;
图3是本申请实施例提供的一种视频处理系统的架构示意图;Figure 3 is a schematic diagram of the architecture of a video processing system provided in an embodiment of this application;
图4是本申请实施例提供的一种视频处理方法的流程示意图;Figure 4 is a flowchart illustrating a video processing method provided in an embodiment of this application;
图5是本申请实施例提供的另一种视频处理方法的流程示意图;Figure 5 is a flowchart illustrating another video processing method provided in an embodiment of this application;
图6是本申请实施例提供的另一种视频处理方法的流程示意图;Figure 6 is a flowchart illustrating another video processing method provided in an embodiment of this application;
图7a是本申请实施例提供的一种视频码率分布的统计示意图;Figure 7a is a statistical schematic diagram of a video bitrate distribution provided in an embodiment of this application;
图7b是本申请实施例提供的另一种视频码率分布的统计示意图;Figure 7b is a statistical schematic diagram of another video bitrate distribution provided in an embodiment of this application;
图8a是本申请实施例提供的一种视频处理方法的效果示意图;Figure 8a is a schematic diagram of the effect of a video processing method provided in an embodiment of this application;
图8b是本申请实施例提供的另一种视频处理方法的效果示意图;Figure 8b is a schematic diagram showing the effect of another video processing method provided in the embodiment of this application;
图9是本申请实施例提供的一种视频处理装置的结构示意图;Figure 9 is a schematic diagram of the structure of a video processing device provided in an embodiment of this application;
图10是本申请实施例提供的一种计算机设备的结构示意图。Figure 10 is a schematic diagram of the structure of a computer device provided in an embodiment of this application.
具体实施方式Detailed Implementation
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
为了清楚地理解本申请实施例提供的技术方案,在此对本申请实施例涉及的关键术语进行介绍:To clearly understand the technical solutions provided in the embodiments of this application, the key terms involved in the embodiments of this application are introduced here:
(1)本申请实施例涉及视频。视频是由连续的视频帧构成的视频帧序列,由于眼睛的视觉暂留效应,当视频帧序列以一定的速率播放时,我们看到的就是动作连续的视频。视频中的各个视频帧以GOP(Group of Pictures,图像组)为单位进行组织,视频中可以包括多个GOP,每个GOP以I帧(I Frame,关键帧)开始,以下一个I帧结束,GOP中的第一个视频帧叫做IDR(InstantaneousDecoding Refresh,即时解码刷新)帧,IDR帧一定是I帧,但是I帧不一定是IDR帧,IDR帧会导致DPB(Decoded Picture Buffer,参考帧列表)清空,而I帧不会。GOP中可以包括多个I帧,编码顺序位于I帧之后的视频帧可以引用编码顺序位于I帧之间的视频帧做运动参考。GOP中还可以包括P帧(PFrame,前向差别帧)和B帧(BFrame,双向差别帧),P帧表示的是本帧与之前的一个I帧(或P帧)的差别,解码时需要用之前缓存的画面叠加上本帧定义的差别,生成最终画面,B帧记录的是本帧与前后帧的差别,B帧可以作其它B帧的参考帧,也可以不作为其它B帧参考帧。(1) This application relates to video. A video is a sequence of consecutive video frames. Due to the persistence of vision, when the sequence of video frames is played at a certain rate, we see a video with continuous motion. Each video frame in a video is organized in a group of pictures (GOP). A video can include multiple GOPs. Each GOP begins with an I-frame (I-frame, keyframe) and ends with the next I-frame. The first video frame in a GOP is called an instantaneous decoding refresh (IDR) frame. An IDR frame is always an I-frame, but an I-frame is not necessarily an IDR frame. An IDR frame will cause the decoded picture buffer (DPB, reference frame list) to be cleared, while an I-frame will not. A GOP can include multiple I-frames. Video frames encoded after the I-frames can use video frames encoded between the I-frames as motion references. A GOP can also include P-frames (PFrames, forward difference frames) and B-frames (BFrames, bidirectional difference frames). A P-frame represents the difference between the current frame and a previous I-frame (or P-frame). During decoding, the previously buffered image is overlaid with the difference defined in the current frame to generate the final image. A B-frame records the difference between the current frame and the frames before and after it. A B-frame can be used as a reference frame for other B-frames, or it can not be used as a reference frame for other B-frames.
(2)本申请实施例涉及视频编码技术。视频编码技术是指对视频进行压缩,使得编码后的视频文件的文件体积(即数据量)小于编码前的视频文件的文件体积的技术。由于视频中连续的视频帧之间相似性极高,每一个视频帧内部以及连续的视频帧之间均存在大量的冗余信息,因此在对视频进行存储或传输之前,往往需要采用视频编码技术对视频进行压缩编码,去除视频在空间、时间等维度上的冗余信息,以节省存储空间、提升视频传输效率。(2) This application relates to video coding technology. Video coding technology refers to the technology of compressing video so that the file size (i.e., data volume) of the encoded video file is smaller than that of the original video file. Because the similarity between consecutive video frames in a video is extremely high, there is a large amount of redundant information within each video frame and between consecutive video frames. Therefore, before storing or transmitting the video, it is often necessary to use video coding technology to compress and encode the video to remove redundant information in the spatial, temporal, and other dimensions, so as to save storage space and improve video transmission efficiency.
视频编码技术中涉及量化,量化是指根据视频帧的QP,将视频帧中的连续取值(或者大量可能的离散取值)近似为有限多个(或较少的)离散值的过程。QP可以反映空间细节压缩情况,QP的值越小,量化程度越精细,图像中的大部分细节都会被保留,图像质量越高,产生的码率越大;与之相反地,QP的值越大,图像中的一些细节会丢失,码率降低,但图像的失真加强,质量下降。其中,码率也可以称为码流或码流率,是指视频在单位时间内使用的数据流量,通俗一点的理解就是取样率,是视频编码中画面质量控制中最重要的部分,一般采用的码率单位是Kb/s(千字节每秒)或者Mb/s(兆字节每秒);一般来说,同样分辨率下,视频文件的码率越大,压缩比就越小,画面质量就越高;码率越大,说明单位时间内取样率越大,数据流越大,精度就越高,恢复出的视频就越接近原始视频,图像质量越好,画质越清晰,要求播放设备的解码能力也越高。Quantization is involved in video coding technology. Quantization refers to the process of approximating continuous values (or a large number of possible discrete values) in a video frame to a finite number (or a small number) of discrete values based on the QP (Quantization Point) of the video frame. QP reflects the compression of spatial details. The smaller the QP value, the finer the quantization, and most of the details in the image are preserved, resulting in higher image quality and a higher bitrate. Conversely, the larger the QP value, the more details in the image are lost, the lower the bitrate, but the more image distortion is increased, and the lower the quality. Bitrate, also known as bitstream or bit rate, refers to the amount of data used in a video per unit of time. In simpler terms, it's the sampling rate, and it's the most important part of image quality control in video encoding. The commonly used unit for bitrate is Kb/s (kilobytes per second) or Mb/s (megabytes per second). Generally speaking, at the same resolution, the higher the bitrate of a video file, the lower the compression ratio and the higher the image quality. A higher bitrate means a higher sampling rate per unit of time, a larger data stream, higher precision, and a video that is closer to the original video, resulting in better image quality and clearer picture. However, this also requires higher decoding capabilities from the playback device.
(3)本申请实施例涉及码率控制。码率控制的本质是受限资源的优化分配问题,码率控制的基本原理可参见图1,码率控制是指利用视频的复杂度、编码实际产生的比特数目、及缓存器状态(例如缓存器当前剩余比特数目)等信息,对待编码的视频帧进行比特分配,调整待编码的视频帧的图像层QP和编码单元QP,从而在编码得到的视频码率满足目标带宽的前提下,使得视频消费端的视频质量和QoE(Quality of Experience,体验质量)指标之间达到最优平衡的目的。码率控制的效果可参见图2,黑色虚线表示目标带宽,在进行码率控制之前,灰色实线所表示的视频码率会超出目标带宽,这样将导致编码器无法在实际环境中应用;而在进行码率控制后,黑色实线所表示的视频码率未超出目标带宽。其中,图像层QP是指对视频帧进行量化所采用的QP,编码单元QP是对视频帧的编码单元进行量化所采用的QP,编码单元是指对视频帧进行编码所采用的编码基本单元,编码单元例如可以是宏块,视频帧需要划分为多个宏块进行编码处理。(3) This application's embodiments involve bitrate control. The essence of bitrate control is the optimal allocation of limited resources. The basic principle of bitrate control can be seen in Figure 1. Bitrate control refers to using information such as video complexity, the actual number of bits generated during encoding, and buffer status (e.g., the current number of remaining bits in the buffer) to allocate bits to the video frames to be encoded, adjusting the image layer QP and coding unit QP of the video frames to be encoded, so that the video quality and QoE (Quality of Experience) indicators at the video consumer end are optimally balanced while ensuring that the encoded video bitrate meets the target bandwidth. The effect of bitrate control can be seen in Figure 2. The black dashed line represents the target bandwidth. Before bitrate control, the video bitrate represented by the gray solid line will exceed the target bandwidth, which will cause the encoder to be unusable in a practical environment; after bitrate control, the video bitrate represented by the black solid line does not exceed the target bandwidth. Among them, the image layer QP refers to the QP used to quantize video frames, the coding unit QP is the QP used to quantize the coding units of video frames, and the coding unit refers to the basic coding unit used to encode video frames. The coding unit can be, for example, a macroblock. Video frames need to be divided into multiple macroblocks for coding processing.
常见的码率控制模式可以包括:CRF(Constant Rate Factor,恒定质量因子)模式,此模式的优点是能够在保持视频质量稳定的同时,尽量减少消耗带宽,缺点是不知道编码得到的文件确切大小。ABR(Average Bitrate,平均码率)模式,此模式以减少视频总的码率控制误差为首要前提,目的是在码率控制精度尽量高的前提下提升视频的压缩性能。CBR(Constant Bitrate,恒定码率)模式,与CBR模式相对的是VBR(Variable Bitrate,可变码率)模式,CBR模式对于编码过程中的每秒峰值码率有着严格的要求,多用于视频直播场景中。CQP(ConstantQuantization Parameter,恒定量化参数)模式,此模式在业务中使用较少,多用于学术研究,由于其他几种模式(例如上述CRF模式、ABR模式、CBR模式等)均会调整QP,引发性能波动,因此在学术研究中针对某一具体算法的性能调优时,多用CQP模式表征。VBV(Video Buffering Verifier,视频缓冲校验)模式,此模式为CRF模式、ABR模式、CBR模式等提供缓存资源分配,相对于传统的码率控制模式,可以使得编码器的比特分配过程更加合理。Multi-pass(多路编码)模式,常用2-pass模式,即一个视频编码两遍,从而利用第一遍编码的结果指导第二遍的QP调整,使得编码器获得更加优秀的压缩性能。Common bitrate control modes include: CRF (Constant Rate Factor) mode, which minimizes bandwidth consumption while maintaining stable video quality, but its disadvantage is that the exact size of the encoded file is unknown. ABR (Average Bitrate) mode prioritizes reducing the overall bitrate control error, aiming to improve compression performance while maximizing bitrate control accuracy. CBR (Constant Bitrate) mode, in contrast to VBR (Variable Bitrate) mode, imposes strict requirements on the peak bitrate per second during encoding and is often used in live video streaming. CQP (Constant Quantization Parameter) mode is less commonly used in business applications and is more prevalent in academic research. Since other modes (such as CRF, ABR, and CBR mentioned above) adjust the QP, causing performance fluctuations, CQP mode is often used in academic research to characterize the performance tuning of a specific algorithm. VBV (Video Buffering Verifier) mode provides buffer resource allocation for CRF, ABR, and CBR modes, allowing for more rational bit allocation by the encoder compared to traditional bitrate control modes. Multi-pass encoding mode, commonly 2-pass mode, encodes a video twice, using the result of the first pass to guide the QP adjustment in the second pass, resulting in superior compression performance.
(4)本申请实施例涉及QoE指标。QoE指标是业务相关产品运营和增长上最关注的一个指标,以视频业务为例,QoE指标的评价主体是视频消费对象,评价对象是视频业务和支撑视频业务的网络,QoE指标通过具体的指标值来表征视频消费对象对视频业务或视频业务产品(例如视频软件、视频应用程序、视频客户端等)的满意程度;在视频业务中,QoE指标可以包括但不限于以下至少一种:首帧时长、平均对象视频观看时长,视频画面质量、画面延迟、以及卡顿指标(例如卡顿感缓冲时间)等等。其中,首帧时长是指视频消费对象开始播放视频到视频消费对象观看到视频首帧画面所需时长;平均对象观看时长是指多个视频消费对象对视频的平均观看时长;视频画面质量是指视频消费对象是否可以欣赏高质量(例如高清晰度)或低质量(例如低清晰度)的视频,或者是指视频消费对象在观看视频的过程中是否会出现视频质量突然下降的情况;卡顿感缓冲时间是指视频在播放过程中出现卡顿到卡顿消除所需时长;画面延迟是指操作与其在屏幕上出现之间的时间延迟,例如实时体育直播时,即使是几秒钟的延迟,也可能导致观众在看到进球之前听到邻近公寓的欢呼声或在社交媒体上看到剧透。(4) The embodiments of this application involve the QoE metric. The QoE metric is one of the most important metrics for the operation and growth of business-related products. Taking video services as an example, the evaluation subject of the QoE metric is the video consumer, and the evaluation object is the video service and the network supporting the video service. The QoE metric uses specific metric values to characterize the satisfaction of video consumers with the video service or video service products (such as video software, video applications, video clients, etc.). In video services, the QoE metric may include, but is not limited to, at least one of the following: first frame duration, average viewing time of the target video, video picture quality, picture latency, and stuttering metrics (such as buffering time for stuttering sensations), etc. Among them, first frame duration refers to the time required from the start of video playback to the viewer seeing the first frame of the video; average view duration refers to the average viewing time of multiple video consumers; video quality refers to whether the video consumer can enjoy high-quality (e.g., high definition) or low-quality (e.g., low definition) video, or whether the video quality suddenly drops during viewing; buffering time refers to the time required from when the video stutters during playback to when the stuttering disappears; and screen latency refers to the time delay between an action and its appearance on the screen. For example, in live sports broadcasts, even a delay of a few seconds can cause viewers to hear cheers from neighboring apartments or see spoilers on social media before they see a goal.
视频业务的评价指标除QoE指标外,还可以包括QoS(Quality of Service,服务质量)指标,主要负责从网络的角度进行业务管理和提供业务的差异性,网络实体根据不同的质量需求来处理不同业务,比如常用QoS指标可以包括但不限于以下至少一种:卡顿率、卡顿时间、首帧时长等等。In addition to QoE metrics, video service evaluation metrics can also include QoS (Quality of Service) metrics. These metrics are mainly responsible for managing services and providing service differentiation from the network perspective. Network entities handle different services according to different quality requirements. Common QoS metrics may include, but are not limited to, at least one of the following: stuttering rate, stuttering time, first frame duration, etc.
在视频业务中,视频消费对象会使用各种各样的视频消费设备(例如手机、智能电视、机顶盒以及游戏主机等)来安装视频业务产品(例如视频软件、视频客户端、视频应用程序等),以在视频业务产品中观看视频;通常情况下,不同的视频消费设备所处的网络环境不相同,不同的视频消费设备支持的视频播放条件也存在差异,视频消费对象对不同类型视频的视频呈现效果的要求也不尽相同;因此,需要合适的编码配置(例如可以是QP)来对网络环境、视频播放条件、视频类型等进行适配,以针对性地提供更加优质高效的视频服务。基于此,本申请实施例提出一种视频处理方法,该视频处理方法可以对现有的码率控制方案进行优化,使得码率控制方案中确定出的QP能够与视频业务的网络环境、视频播放条件、视频类型等中的一种或多种进行适配,针对性地确定出QP来对视频进行编码处理,从而可以在编码得到的视频码率满足目标带宽的前提下,使得视频消费端的视频呈现质量与QoE指标之间的达到最佳平衡,提升视频消费对象的视频观看体验。In video services, users typically use various video consumption devices (such as mobile phones, smart TVs, set-top boxes, and game consoles) to install video service products (such as video software, video clients, and video applications) to watch videos. These devices often operate in different network environments, support varying video playback conditions, and have different requirements for video presentation quality. Therefore, appropriate encoding configurations (such as QP) are needed to adapt to network environments, playback conditions, and video types, providing targeted, higher-quality, and more efficient video services. Based on this, this application proposes a video processing method that optimizes existing bitrate control schemes. This method ensures that the QP determined in the bitrate control scheme is adapted to one or more of the network environment, playback conditions, and video types in the video service. By specifically determining the QP for video encoding, it achieves an optimal balance between video presentation quality and QoE (Quality of Image) at the consumer end, while ensuring the encoded video bitrate meets the target bandwidth, thus improving the video viewing experience for users.
下面结合图3对适于实现本申请实施例提供的视频处理方法的视频处理系统进行介绍,视频处理系统可以包括视频制作设备(编码端)301和视频消费设备(解码端)302,视频制作设备301与视频消费设备302之间可以通过有线通信方式进行直接连接,或者可以通过无线通信方式进行间接连接进行通信;针对目标视频中任一待编码的视频帧,视频制作设备301可以确定出合适的QP对该视频帧进行编码处理,并将编码处理后的目标视频发送至视频消费设备302;视频消费设备302可以对编码处理后的目标视频进行解码处理,解码出目标视频中包含的多个视频帧,并呈现解码出的各个视频帧,从而视频消费对象可以通过视频消费设备302观看目标视频。The following describes a video processing system suitable for implementing the video processing method provided in the embodiments of this application, with reference to Figure 3. The video processing system may include a video production device (encoding end) 301 and a video consumption device (decoding end) 302. The video production device 301 and the video consumption device 302 can be directly connected via wired communication or indirectly connected via wireless communication. For any video frame to be encoded in the target video, the video production device 301 can determine a suitable QP to encode the video frame and send the encoded target video to the video consumption device 302. The video consumption device 302 can decode the encoded target video, decode multiple video frames contained in the target video, and present the decoded video frames, so that the video consumer can watch the target video through the video consumption device 302.
其中,视频制作设备301可以是终端或服务器,视频消费设备301可以是终端;本申请实施例提及的终端可以是智能手机、平板电脑、笔记本电脑、台式计算机、智能音箱、智能手表、车载终端、智能电视等,但并不局限于此;本申请实施例提及的服务器可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、CDN(Content DeliveryNetwork,内容分发网络)、以及大数据等基础云计算服务的云服务器。Among them, the video production equipment 301 can be a terminal or a server, and the video consumption device 301 can be a terminal; the terminal mentioned in the embodiments of this application can be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smartwatch, vehicle terminal, smart TV, etc., but is not limited to these; the server mentioned in the embodiments of this application can be a server cluster or distributed system composed of multiple physical servers, or it can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data.
本申请实施例提供的视频处理方法可以应用于视频会话、视频点播、视频直播等视频业务场景中。例如,在由会话对象A和会话对象B参与的视频会话中,会话对象A使用的终端可以作为视频制作设备,对采集到的包含会话对象A的会话视频进行编码处理,并将编码处理后的会话视频传输至会话对象B使用的终端;会话对象A使用的终端也可以作为视频消费设备,解码并播放包含会话对象B的会话视频;会话对象B使用的终端与会话对象A使用的终端类似,既可以作为视频制作设备,又可以作为视频消费设备;在视频会话场景中根据视频会话业务的特点为会话视频中的各个视频帧确定出合适的QP,可以提升视频会话效果,提升会话对象的视频会话体验。又如,视频点播场景中,视频处理服务器可以作为视频制作设备,对视频点播对象通过视频点播客户端点播的点播视频进行编码处理,并将编码处理后的点播视频传输至视频点播客户端;运行视频点播客户端的终端可以作为视频消费设备,对编码处理后的点播视频进行解码处理,并在视频点播客户端中播放点播视频;在视频点播场景中根据视频点播业务的特点为点播视频中的各个视频帧确定出合适的QP,可以提升视频点播效果,提升视频点播对象的视频观看体验。类似地,在视频直播场景中,主播对象所使用的终端可以作为视频制作设备,对直播视频进行编码处理,并将编码处理后的直播视频传输至观众对象所使用的终端;观众对象所使用的终端可以作为视频消费设备,对编码处理后的直播视频进行解码处理,并播放直播视频;在视频直播场景中根据视频直播业务的特点为直播视频中的各个视频帧确定出合适的QP,可以提升视频直播效果,提升观众对象的直播观看体验。The video processing method provided in this application can be applied to video service scenarios such as video conferencing, video-on-demand, and live video streaming. For example, in a video conferencing session involving session object A and session object B, the terminal used by session object A can act as a video production device, encoding the captured video containing session object A and transmitting the encoded video to the terminal used by session object B. The terminal used by session object A can also act as a video consumption device, decoding and playing the video containing session object B. The terminal used by session object B is similar to that used by session object A, functioning as both a video production device and a video consumption device. In video conferencing scenarios, determining appropriate QPs for each video frame in the video conferencing session based on the characteristics of the video conferencing service can improve the video conferencing effect and enhance the video conferencing experience for the participants. For example, in a video-on-demand (VOD) scenario, a video processing server can act as a video production device, encoding the video-on-demand (VOD) video requested by the VOD client and transmitting the encoded video to the VOD client. The terminal running the VOD client can act as a video consumption device, decoding the encoded video and playing it within the VOD client. In a VOD scenario, determining appropriate QPs (Quality Per Frame) for each video frame based on the characteristics of the VOD service can improve the VOD effect and enhance the viewing experience for the VOD audience. Similarly, in a live video streaming scenario, the terminal used by the broadcaster can act as a video production device, encoding the live video and transmitting it to the terminal used by the audience. The terminal used by the audience can act as a video consumption device, decoding the encoded live video and playing it. In a live video streaming scenario, determining appropriate QPs for each video frame based on the characteristics of the live video service can improve the live streaming effect and enhance the live streaming viewing experience for the audience.
可以理解的是,本申请实施例描述的视频处理系统是为了更加清楚的说明本申请实施例的技术方案,并不构成对于本申请实施例提供的技术方案的限定,本领域普通技术对象可知,随着系统架构的演变和新业务场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。It is understood that the video processing system described in the embodiments of this application is for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and does not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
另外,本申请实施例提供的视频处理方法还可以与云技术(Cloud Technology)相结合,云技术是指在广域网或局域网内将硬件、软件、网络等系列资源统一起来,实现数据的计算、储存、处理和共享的一种托管技术;云技术中的云计算(Cloud Computing)技术可以为视频处理过程提供计算支持,云技术中的云存储(Cloud Storage)技术可以为视频处理过程提供存储服务。本申请实施例提供的视频处理方法还可以部署为视频处理云服务,当需要对视频进行编码处理时,可以直接调用视频处理云服务对视频进行编码处理。Furthermore, the video processing method provided in this application embodiment can also be combined with cloud technology. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to realize data computation, storage, processing, and sharing. Cloud computing technology within cloud technology can provide computational support for the video processing process, and cloud storage technology within cloud technology can provide storage services for the video processing process. The video processing method provided in this application embodiment embodiment can also be deployed as a video processing cloud service. When video encoding processing is required, the video processing cloud service can be directly invoked to encode the video.
基于上述视频处理系统的相关描述,下面结合附图对本申请实施例提出的视频处理方法进行详细介绍。Based on the above description of the video processing system, the video processing method proposed in the embodiments of this application will be described in detail below with reference to the accompanying drawings.
本申请实施例提供一种视频处理方法,该视频处理方法主要介绍视频属性特征、确定与视频属性特征相匹配的编码偏移参数的过程、当目标视频帧为I帧时初始量化参数的确定过程,当目标视频帧为B帧时初始量化参数的确定过程等内容。该视频处理方法可以由上述提及的视频处理系统中的视频制作设备301来执行,请参见图4,该视频处理方法可以包括以下步骤S401-步骤S406:This application provides a video processing method, which mainly introduces the process of determining video attribute features, determining encoding offset parameters that match the video attribute features, determining the initial quantization parameters when the target video frame is an I-frame, and determining the initial quantization parameters when the target video frame is a B-frame. This video processing method can be executed by the video production device 301 in the aforementioned video processing system. Referring to Figure 4, the video processing method may include the following steps S401-S406:
S401,从目标视频中获取待编码的目标视频帧。S401, Obtain the target video frame to be encoded from the target video.
目标视频中可以包括多个视频帧,目标视频中的各个视频帧按照各自的编码顺序依次被编码,可以从目标视频中获取待编码的目标视频帧。The target video may include multiple video frames. Each video frame in the target video is encoded sequentially according to its own encoding order. The target video frame to be encoded can be obtained from the target video.
S402,获取目标视频的视频属性特征。S402, Obtain the video attribute features of the target video.
目标视频的视频属性特征可以包括以下任一种或多种:目标视频的分辨率信息、目标视频所属的视频类型信息、目标视频的码率信息、以及目标视频的播放效果参考信息,目标视频的视频属性特征可以是从目标视频中获取到待编码的目标视频帧时获取的。The video attribute features of the target video may include any one or more of the following: resolution information of the target video, video type information of the target video, bitrate information of the target video, and playback effect reference information of the target video. The video attribute features of the target video may be obtained when the target video frame to be encoded is obtained from the target video.
其中:①目标视频的分辨率信息是指设置的目标视频在视频消费设备中进行播放时的分辨率大小;该分辨率信息可以是视频消费设备默认设置的,例如视频消费设备运行的视频业务产品(例如视频软件、视频应用程序、视频客户端等)中默认设置的分辨率为480P;或者,该分辨率信息可以是视频消费对象在视频消费设备中设置的,例如视频消费对象在视频消费设备运行的视频业务产品中设置的分辨率为1080P。②目标视频所属的视频类型信息是指目标视频所属的视频类型的标识,例如目标视频属于电视剧类型,或者目标视频属于电影类型,或者目标视频属于动漫类型等等。③目标视频的码率信息是指设置的编码得到的目标视频在单位时间(例如可以是1秒)内使用的数据流量大小,该码率信息可以设置为恒定码率(例如上述码率控制模式中的CBR模式),该码率信息也可以设置为平均码率(例如上述码率控制模式中的ABR模式);目标视频的码率信息可以是根据视频制作设备与视频消费设备之间的网络传输带宽(即前述内容中提及的目标带宽)设置的,目标视频的码率信息不能超过网络传输带宽。④目标视频的播放效果参考信息是指设置的目标视频在视频消费设备中的播放效果的描述信息,播放效果参考信息可以包括以下任一种:画质优先效果、码率优先效果、以及画质码率折中效果;该播放效果参考信息可以是视频消费设备默认设置的,例如视频消费设备运行的视频业务产品中默认设置的播放效果参考信息为码率优先效果;或者,该分辨率信息可以是视频消费对象在视频消费设备中设置的,例如视频消费对象在视频消费设备运行的视频业务产品中设置的播放效果参考信息为画质优先效果。Specifically: ① The target video's resolution information refers to the resolution of the target video when played on the video consumption device. This resolution information can be the default setting of the video consumption device, such as the default resolution of 480P in the video service products (such as video software, video applications, video clients, etc.) running on the video consumption device; or, this resolution information can be the resolution set by the video consumption object on the video consumption device, such as the resolution set to 1080P in the video service products running on the video consumption device. ② The target video's video type information refers to the identifier of the video type to which the target video belongs, such as whether the target video belongs to the TV series type, or the target video belongs to the movie type, or the target video belongs to the animation type, etc. ③ The target video's bitrate information refers to the amount of data traffic used by the encoded target video per unit time (e.g., 1 second). This bitrate information can be set to a constant bitrate (e.g., CBR mode in the bitrate control modes mentioned above) or an average bitrate (e.g., ABR mode in the bitrate control modes mentioned above). The target video's bitrate information can be set based on the network transmission bandwidth between the video production device and the video consumption device (i.e., the target bandwidth mentioned above), and the target video's bitrate information cannot exceed the network transmission bandwidth. ④ The target video's playback effect reference information refers to the description information of the target video's playback effect on the video consumption device. The playback effect reference information can include any of the following: quality-priority effect, bitrate-priority effect, and a quality-bitrate compromise effect. This playback effect reference information can be the default setting of the video consumption device, for example, the default playback effect reference information set in the video service product running on the video consumption device is bitrate-priority effect; or, this resolution information can be set by the video consumption object on the video consumption device, for example, the playback effect reference information set by the video consumption object in the video service product running on the video consumption device is quality-priority effect.
S403,确定与视频属性特征相匹配的编码偏移参数。S403, determine the encoding offset parameters that match the video attribute features.
在获取到目标视频的视频属性特征后,可以确定与视频属性特征相匹配的编码偏移参数。确定与视频属性特征相匹配的编码偏移参数的过程,是指确定与视频属性特征相匹配的编码偏移参数的参数值的过程,编码偏移参数可以包括第一编码偏移参数(ipratio)和第二编码偏移参数(pbratio)。其中,第一编码偏移参数(ipratio)是指平均的I帧的量化器相比P帧量化器增值,第一编码偏移参数(ipratio)的参数值越高,意味着更高的I帧质量;第二编码参数(pbratio)是指平均的B帧的量化器相比P帧量化器减值,第二编码参数(pbratio)的参数值越高,意味着更低的B帧质量。After obtaining the video attribute features of the target video, the encoding offset parameters that match these features can be determined. The process of determining the encoding offset parameters that match the video attribute features refers to determining the parameter values of these parameters. The encoding offset parameters can include a first encoding offset parameter (ipratio) and a second encoding offset parameter (pbratio). The first encoding offset parameter (ipratio) refers to the average increase in the quantizer value of I-frames compared to the quantizer value of P-frames; a higher value of the first encoding offset parameter (ipratio) indicates higher I-frame quality. The second encoding offset parameter (pbratio) refers to the average decrease in the quantizer value of B-frames compared to the quantizer value of P-frames; a higher value of the second encoding offset parameter (pbratio) indicates lower B-frame quality.
确定与视频属性特征相匹配的编码偏移参数的过程可以包括:在参数匹配关系中确定与视频属性特征相匹配的属性特征指示信息,参数匹配关系中可以包括多个属性特征指示信息和每个属性特征指示信息对应的参考偏移参数;将相匹配的属性特征指示信息对应的参考偏移参数,确定为与视频属性特征相匹配的编码偏移参数。下面分别对目标视频的视频属性特征包括目标视频的分辨率信息、目标视频的视频属性特征包括目标视频所属的类型信息、目标视频的视频属性特征包括目标视频的码率信息、以及目标视频的视频属性特征包括目标视频的播放效果参考信息这四种情况下,确定与视频属性特征相匹配的编码偏移参数的过程进行介绍:The process of determining the encoding offset parameter that matches the video attribute features may include: determining attribute feature indication information that matches the video attribute features in the parameter matching relationship, where the parameter matching relationship may include multiple attribute feature indications and a reference offset parameter corresponding to each attribute feature indication; and determining the reference offset parameter corresponding to the matching attribute feature indication as the encoding offset parameter that matches the video attribute features. The process of determining the encoding offset parameter that matches the video attribute features is described below for four cases: the target video's video attribute features include the target video's resolution information; the target video's video attribute features include the target video's type information; the target video's video attribute features include the target video's bitrate information; and the target video's video attribute features include the target video's playback effect reference information.
(1)目标视频的视频属性特征可以包括目标视频的分辨率信息,不同的分辨率信息所匹配的编码偏移参数不相同。在此情况下,参考匹配关系中的属性特征指示信息是指分辨率区间,与视频属性特征相匹配的属性特征指示信息是指目标视频的分辨率信息所属的分辨率区间;也就是说,当目标视频的视频属性特征包括目标视频的分辨率信息时,可以在参数匹配关系中确定目标视频的分辨率信息所属的分辨率区间,然后可以将目标视频的分辨率信息所属的分辨率区间对应的参考偏移参数,确定为与目标视频的视频属性特征相匹配的编码偏移参数。目标视频的视频属性特征包括目标视频的分辨率信息时,一种示例性的参考匹配关系可参见如下表1:(1) The video attribute features of the target video may include the resolution information of the target video. Different resolution information is matched with different encoding offset parameters. In this case, the attribute feature indication information in the reference matching relationship refers to the resolution range, and the attribute feature indication information that matches the video attribute features refers to the resolution range to which the resolution information of the target video belongs. That is, when the video attribute features of the target video include the resolution information of the target video, the resolution range to which the resolution information of the target video belongs can be determined in the parameter matching relationship. Then, the reference offset parameter corresponding to the resolution range to which the resolution information of the target video belongs can be determined as the encoding offset parameter that matches the video attribute features of the target video. When the video attribute features of the target video include the resolution information of the target video, an exemplary reference matching relationship can be seen in Table 1 below:
表1Table 1
如上表1所示,当目标视频的分辨率信息属于分辨率区间[0P,480P]时,可以尽量以画质优先,将第一编码参数的参数值设置为1.8(即ipratio(1.8)),第二编码参数的参数值设置为1.5(即pbratio(1.5));当目标视频的分辨率信息属于分辨率区间(480P,1080P]时,可以考虑画质和码率折中,将第一编码参数的参数值设置为1.5,第二编码参数的参数值设置为1.3;当目标视频的分辨率信息属于分辨率区间(1080P,+∞)时,可以优先考虑码率分布,高码率高分辨率下的画质在目前的网络传输带宽和视频消费设备的配置阶段已经足够,可以将第一编码参数的参数值设置为1.2,第二编码参数的参数值设置为1.1。As shown in Table 1 above, when the resolution information of the target video belongs to the resolution range [0P, 480P], image quality should be prioritized, and the parameter value of the first encoding parameter should be set to 1.8 (i.e., ipratio(1.8)) and the parameter value of the second encoding parameter should be set to 1.5 (i.e., pbratio(1.5)). When the resolution information of the target video belongs to the resolution range (480P, 1080P), a trade-off between image quality and bitrate can be considered, and the parameter value of the first encoding parameter should be set to 1.5 and the parameter value of the second encoding parameter should be set to 1.3. When the resolution information of the target video belongs to the resolution range (1080P, +∞), the bitrate distribution can be prioritized. The image quality under high bitrate and high resolution is sufficient under the current network transmission bandwidth and video consumption device configuration stage, and the parameter value of the first encoding parameter can be set to 1.2 and the parameter value of the second encoding parameter can be set to 1.1.
(2)目标视频的视频属性特征可以包括目标视频所属的视频类型信息,不同的视频类型信息所匹配的编码偏移参数不相同。在此情况下,参考匹配关系中的属性特征指示信息是指参考视频类型标识,与视频属性特征相匹配的属性特征指示信息是指与目标视频所属的视频类型信息相匹配的参考视频类型标识;也就是说,当目标视频的视频属性特征包括目标视频所属的类型信息时,可以在参数匹配关系中确定与目标视频所属的视频类型信息相匹配的参考视频类型标识,然后可以将相匹配的参考视频类型标识对应的参考偏移参数,确定为与目标视频的视频属性特征相匹配的编码偏移参数。目标视频的视频属性特征包括目标视频所属的类型信息时,一种示例性的参考匹配关系可参见如下表2:(2) The video attribute features of the target video may include the video type information to which the target video belongs. Different video type information is matched with different encoding offset parameters. In this case, the attribute feature indication information in the reference matching relationship refers to the reference video type identifier, and the attribute feature indication information that matches the video attribute features refers to the reference video type identifier that matches the video type information to which the target video belongs. That is, when the video attribute features of the target video include the type information to which the target video belongs, the reference video type identifier that matches the video type information to which the target video belongs can be determined in the parameter matching relationship. Then, the reference offset parameter corresponding to the matching reference video type identifier can be determined as the encoding offset parameter that matches the video attribute features of the target video. When the video attribute features of the target video include the type information to which the target video belongs, an exemplary reference matching relationship can be seen in Table 2 below:
表2Table 2
如上表2所示,当目标视频所属的视频类型信息与秀场、动漫中的任一种相匹配时,可以尽量以画质优先,将第一编码参数的参数值设置为1.8,第二编码参数的参数值设置为1.5;当目标视频所属的视频类型信息与游戏、美食、体育、旅游中的任一种相匹配时,可以考虑画质和码率折中,将第一编码参数的参数值设置为1.5,第二编码参数的参数值设置为1.3;当目标视频所属的视频类型信息与电视剧、电影中的任一种相匹配时,可以优先考虑码率分布,高码率高分辨率下的画质在目前的网络传输带宽和视频消费设备的配置阶段已经足够,可以将第一编码参数的参数值设置为1.2,第二编码参数的参数值设置为1.1。As shown in Table 2 above, when the target video's video type information matches any of the categories of "live show" or "anime," image quality should be prioritized, with the first encoding parameter set to 1.8 and the second encoding parameter set to 1.5. When the target video's video type information matches any of the categories of "games," "food," "sports," or "travel," a compromise between image quality and bitrate can be considered, with the first encoding parameter set to 1.5 and the second encoding parameter set to 1.3. When the target video's video type information matches any of the categories of "TV series" or "movie," bitrate distribution should be prioritized. Image quality at high bitrate and high resolution is sufficient for the current network transmission bandwidth and video consumption device configuration, so the first encoding parameter can be set to 1.2 and the second encoding parameter set to 1.1.
(3)目标视频的视频属性特征可以包括目标视频的码率信息,不同的码率信息所匹配的编码偏移参数不相同。在此情况下,参考匹配关系中的属性特征指示信息是指码率区间,与视频属性特征相匹配的属性特征指示信息是指目标视频的码率信息所属的码率区间;也就是说,当目标视频的视频属性特征包括目标视频的码率信息时,可以在参数匹配关系中确定目标视频的码率信息所属的码率区间,然后可以将目标视频的码率信息所属的码率区间对应的参考偏移参数,确定为与目标视频的视频属性特征相匹配的编码偏移参数。目标视频的视频属性特征包括目标视频的码率信息时,一种示例性的参考匹配关系可参见如下表3:(3) The video attribute features of the target video may include the bitrate information of the target video. Different bitrate information is matched with different encoding offset parameters. In this case, the attribute feature indication information in the reference matching relationship refers to the bitrate interval, and the attribute feature indication information that matches the video attribute features refers to the bitrate interval to which the bitrate information of the target video belongs. That is, when the video attribute features of the target video include the bitrate information of the target video, the bitrate interval to which the bitrate information of the target video belongs can be determined in the parameter matching relationship. Then, the reference offset parameter corresponding to the bitrate interval to which the bitrate information of the target video belongs can be determined as the encoding offset parameter that matches the video attribute features of the target video. When the video attribute features of the target video include the bitrate information of the target video, an exemplary reference matching relationship can be seen in Table 3 below:
表3Table 3
如上表3所示,当目标视频的码率信息属于码率区间[0Mb/s,2Mb/s)时,可以尽量以画质优先,将第一编码参数的参数值设置为1.8,第二编码参数的参数值设置为1.5;当目标视频的码率信息属于码率区间[2Mb/s,10Mb/s)时,可以考虑画质和码率折中,将第一编码参数的参数值设置为1.5,第二编码参数的参数值设置为1.3;当目标视频的码率信息属于码率区间[10Mb/s,+∞)时,可以优先考虑码率分布,高码率高分辨率下的画质在目前的网络传输带宽和视频消费设备的配置阶段已经足够,可以将第一编码参数的参数值设置为1.2,第二编码参数的参数值设置为1.1。As shown in Table 3 above, when the target video's bitrate falls within the bitrate range [0Mb/s, 2Mb/s), image quality should be prioritized, and the first encoding parameter should be set to 1.8, and the second encoding parameter to 1.5. When the target video's bitrate falls within the bitrate range [2Mb/s, 10Mb/s), a trade-off between image quality and bitrate can be considered, and the first encoding parameter should be set to 1.5, and the second encoding parameter to 1.3. When the target video's bitrate falls within the bitrate range [10Mb/s, +∞), bitrate distribution should be prioritized, as the image quality at high bitrate and high resolution is sufficient given the current network transmission bandwidth and video consumption device configuration. In this case, the first encoding parameter should be set to 1.2, and the second encoding parameter to 1.1.
(4)目标视频的视频属性特征可以包括目标视频的播放效果参考信息,不同的播放效果参考信息所匹配的编码偏移参数不相同。在此情况下,参考匹配关系中的属性特征指示信息是指参考播放效果标识,与视频属性特征相匹配的属性特征指示信息是指与目标视频的播放效果参考信息相匹配的参考播放效果标识;也就是说,当目标视频的视频属性特征包括目标视频的播放效果参考信息时,可以在参数匹配关系中确定与目标视频的播放效果参考信息相匹配的参考播放效果标识,然后可以将相匹配的参考播放效果标识对应的参考偏移参数,确定为与目标视频的视频属性特征相匹配的编码偏移参数。目标视频的视频属性特征包括目标视频的播放效果参考信息时,一种示例性的参考匹配关系可参见如下表4:(4) The video attribute features of the target video may include playback effect reference information of the target video. Different playback effect reference information is matched with different encoding offset parameters. In this case, the attribute feature indication information in the reference matching relationship refers to the reference playback effect identifier, and the attribute feature indication information that matches the video attribute features refers to the reference playback effect identifier that matches the playback effect reference information of the target video. That is, when the video attribute features of the target video include the playback effect reference information of the target video, the reference playback effect identifier that matches the playback effect reference information of the target video can be determined in the parameter matching relationship, and then the reference offset parameter corresponding to the matching reference playback effect identifier can be determined as the encoding offset parameter that matches the video attribute features of the target video. When the video attribute features of the target video include the playback effect reference information of the target video, an exemplary reference matching relationship can be seen in Table 4 below:
表4Table 4
如上表2所示,当目标视频的播放效果参考信息与画质优先效果相匹配时,可以将第一编码参数的参数值设置为1.8,第二编码参数的参数值设置为1.5;当目标视频的播放效果参考信息与画质码率折中效果相匹配时,可以将第一编码参数的参数值设置为1.5,第二编码参数的参数值设置为1.3;当目标视频的播放效果参考信息与码率优先效果相匹配时,可以将第一编码参数的参数值设置为1.2,第二编码参数的参数值设置为1.1。As shown in Table 2 above, when the playback effect reference information of the target video matches the picture quality priority effect, the parameter value of the first encoding parameter can be set to 1.8 and the parameter value of the second encoding parameter can be set to 1.5; when the playback effect reference information of the target video matches the picture quality bitrate compromise effect, the parameter value of the first encoding parameter can be set to 1.5 and the parameter value of the second encoding parameter can be set to 1.3; when the playback effect reference information of the target video matches the bitrate priority effect, the parameter value of the first encoding parameter can be set to 1.2 and the parameter value of the second encoding parameter can be set to 1.1.
需要说明的是,上述(1)-(4)分别介绍了目标视频的视频属性特征包括目标视频的分辨率信息、目标视频的视频属性特征包括目标视频所属的视频类型信息、目标视频的视频属性特征包括目标视频的码率信息、以及目标视频的视频属性特征包括目标视频的播放效果参考信息这四种情况下编码偏移参数的确定过程;但在实际视频编码场景中,目标视频的分辨率信息、目标视频所属的视频类型信息、目标视频的码率信息、以及目标视频的播放效果参考信息之间可以进行灵活组合;例如,目标视频的视频属性特征可以包括目标视频的分辨率信息和目标视频的码率信息,当目标视频的分辨率信息属于分辨率区间[0P,480P]、且目标视频的码率信息属于码率区间[0Mb/s,2Mb/s)时,可以尽量以画质优先,将第一编码参数的参数值设置为1.8,第二编码参数的参数值设置为1.5。It should be noted that (1)-(4) above respectively introduce the determination process of the encoding offset parameter in four cases: the target video's video attribute features include the target video's resolution information, the target video's video attribute features include the target video's video type information, the target video's video attribute features include the target video's bitrate information, and the target video's video attribute features include the target video's playback effect reference information. However, in actual video encoding scenarios, the target video's resolution information, the target video's video type information, the target video's bitrate information, and the target video's playback effect reference information can be flexibly combined. For example, the target video's video attribute features can include the target video's resolution information and the target video's bitrate information. When the target video's resolution information belongs to the resolution range [0P, 480P] and the target video's bitrate information belongs to the bitrate range [0Mb/s, 2Mb/s], the image quality can be prioritized, and the parameter value of the first encoding parameter can be set to 1.8, and the parameter value of the second encoding parameter can be set to 1.5.
S404,根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数。S404. Estimate the quantization parameters of the target video frame based on the coding offset parameters to obtain the initial quantization parameters of the target video frame.
目标视频帧的类型为关键帧类型(即I帧)和目标视频帧的类型为双向差别帧类型(即B帧)时,根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数的过程的过程是不相同的;下面分别介绍目标视频帧的类型为关键帧类型和目标视频帧的类型为双向差别帧类型时,根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数的过程:The processes for estimating the initial quantization parameters of the target video frame based on the coding offset parameter differ depending on whether the target video frame is a keyframe (I-frame) or a bidirectional difference frame (B-frame). The following describes the processes for estimating the initial quantization parameters of the target video frame based on the coding offset parameter when the target video frame is a keyframe and when it is a bidirectional difference frame:
(1)当目标视频帧的类型为关键帧类型时,根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数的过程可以包括:根据编码偏移参数对目标视频的N个已编码视频帧中指定类型的已编码视频帧的编码量化参数进行参数映射处理,得到指定类型的已编码视频帧的偏移量化参数,N为正整数;根据指定类型的已编码视频帧的偏移量化参数和N个已编码视频帧中其他类型的已编码视频帧的编码量化参数,确定N个已编码视频帧的统计参数;根据N个已编码视频帧的统计参数和N个已编码视频帧的数量,确定目标视频帧的初始量化参数。N个已编码视频帧是目标视频中编码顺序位于目标视频帧之前的N个已编码的视频帧,其他类型的已编码视频帧是指N个已编码视频帧中除指定类型的已编码视频帧外的其他已编码视频帧。(1) When the target video frame is a keyframe, the process of estimating the quantization parameters of the target video frame based on the encoding offset parameters to obtain the initial quantization parameters of the target video frame may include: performing parameter mapping processing on the encoding quantization parameters of the specified type of encoded video frames among the N encoded video frames of the target video based on the encoding offset parameters to obtain the offset quantization parameters of the specified type of encoded video frames, where N is a positive integer; determining the statistical parameters of the N encoded video frames based on the offset quantization parameters of the specified type of encoded video frames and the encoding quantization parameters of other types of encoded video frames among the N encoded video frames; and determining the initial quantization parameters of the target video frame based on the statistical parameters of the N encoded video frames and the number of N encoded video frames. The N encoded video frames are the N encoded video frames in the target video whose encoding order is before the target video frame. Other types of encoded video frames refer to the other encoded video frames among the N encoded video frames besides the specified type of encoded video frames.
在此,对上述关键帧类型的目标视频帧的初始量化参数的确定过程进行进一步地解释:①参数映射处理的实质是根据编码偏移参数将指定类型的已编码视频帧的编码量化参数,统一映射至目标类型(即上述其他类型)的结果,本申请实施例以指定类型是关键帧类型或双向差别帧类型,其他类型是前向差别帧(即P帧)类型为例进行介绍,也就是说,本申请实施例以前向差别帧类型的已编码视频帧为基础单位,将关键帧类型的已编码视频帧的编码量化参数和双向差别帧类型的已编码视频帧的编码量化参数,统一映射至前向差别帧类型,得到关键帧类型的已编码视频帧的偏移量化参数和双向差别帧类型的已编码视频帧的偏移量化参数。②统计参数的实质是指定类型的已编码视频帧的偏移量化参数和其他类型的已编码视频帧的编码量化参数的叠加总和。③目标视频帧的初始量化参数可以等于N个已编码视频帧的统计参数与N个已编码视频帧的数量之间的比值。综上①-③可知,关键帧类型的目标视频帧的初始量化参数是,目标视频中编码顺序位于目标视频帧之前的N个已编码视频帧的编码量化参数的叠加总和,与N个已编码视频帧的数量之间的比值,并且在计算叠加总和的过程中,需要对N个已编码视频帧中指定类型的已编码视频帧的编码量化参数进行参数映射处理,统一映射至目标类型后再进行叠加求和,通过参数映射处理,不仅可以使得目标视频帧的初始量化参数与目标视频的视频属性特征适配,还有利于在码率控制中进行归一化。Here, the process of determining the initial quantization parameters of the target video frame of the aforementioned keyframe type is further explained: ① The essence of parameter mapping is to uniformly map the quantization parameters of the encoded video frames of the specified type to the result of the target type (i.e., the other types mentioned above) based on the quantization offset parameters. This application embodiment uses keyframe type or bidirectional difference frame type as an example, and forward difference frame (i.e., P-frame) type as the other type. That is, this application embodiment uses the encoded video frames of the forward difference frame type as the basic unit, uniformly mapping the quantization parameters of the encoded video frames of the keyframe type and the quantization parameters of the encoded video frames of the bidirectional difference frame type to the forward difference frame type, obtaining the offset quantization parameters of the encoded video frames of the keyframe type and the offset quantization parameters of the encoded video frames of the bidirectional difference frame type. ② The essence of statistical parameters is the sum of the offset quantization parameters of the encoded video frames of the specified type and the quantization parameters of the encoded video frames of other types. ③ The initial quantization parameter of the target video frame can be equal to the ratio between the statistical parameters of N encoded video frames and the number of N encoded video frames. In summary, ①-③ show that the initial quantization parameter of the target video frame of the keyframe type is the ratio between the sum of the quantization parameters of the N encoded video frames whose encoding order precedes the target video frame and the number of the N encoded video frames. Furthermore, in the process of calculating the sum, it is necessary to perform parameter mapping processing on the quantization parameters of the encoded video frames of a specified type among the N encoded video frames, uniformly mapping them to the target type before summing. Through parameter mapping processing, not only can the initial quantization parameter of the target video frame be adapted to the video attribute features of the target video, but it is also beneficial for normalization in bitrate control.
此处重点介绍参数映射处理过程,根据编码偏移参数对目标视频的N个已编码视频帧中指定类型的已编码视频帧的编码量化参数进行参数映射处理,得到指定类型的已编码视频帧的偏移量化参数的过程可以包括:若指定类型为关键帧类型,则可以根据第一编码偏移参数(即ipratio)对关键帧类型的已编码视频帧的编码量化参数进行参数映射处理,得到关键帧类型的已编码视频帧的偏移量化参数;可参见下述公式1:This section focuses on the parameter mapping process. Based on the encoding offset parameter, the process of mapping the encoding quantization parameters of a specified type of encoded video frame among N encoded video frames of the target video to obtain the offset quantization parameter of the specified type of encoded video frame can include: if the specified type is a keyframe type, then the encoding quantization parameters of the keyframe type encoded video frame can be mapped based on the first encoding offset parameter (i.e., ipratio) to obtain the offset quantization parameter of the keyframe type encoded video frame; see Formula 1 below:
QP=QP+ipoffset=QP+6.0×log2(ipratio)公式1QP = QP + ipoffset = QP + 6.0 × log 2 (ipratio) (Formula 1)
在此上述公式1中的参数进行解释:第一个等号左边的QP表示关键帧类型的已编码视频帧的偏移量化参数;第一个等号右边和第二个等号右边的QP表示关键帧类型的已编码视频帧的编码量化参数;ipoffset表示第一偏移量,是根据第一编码偏移参数确定的;ipratio表示第一编码偏移参数;关键帧类型的首个已编码视频帧的编码量化参数可以设置为常数(例如可以是24)。Here is an explanation of the parameters in Formula 1 above: QP on the left side of the first equal sign represents the offset quantization parameter of the encoded video frame of the keyframe type; QP on the right side of the first and second equal signs represents the code quantization parameter of the encoded video frame of the keyframe type; ipoffset represents the first offset, which is determined based on the first code offset parameter; ipratio represents the first code offset parameter; the code quantization parameter of the first encoded video frame of the keyframe type can be set to a constant (e.g., 24).
若指定类型为双向差别帧类型,则可以根据第二编码偏移参数(即pbratio)对双向差别帧类型的已编码视频帧的编码量化参数进行参数映射处理,得到双向差别帧类型的已编码视频帧的偏移量化参数;参见下述公式2:If the specified type is a bidirectional difference frame type, the coded quantization parameters of the encoded video frames of the bidirectional difference frame type can be mapped according to the second coded offset parameter (i.e., pbratio) to obtain the offset quantization parameters of the encoded video frames of the bidirectional difference frame type; see Formula 2 below:
QP=QP+pboffset=QP+6.0×log2(pbratio)公式2QP = QP + pboffset = QP + 6.0 × log 2 (pbratio) (Formula 2)
在此对上述公式2中的参数进行解释:第一个等号左边的QP表示双向差别帧类型的已编码视频帧的偏移量化参数;第一个等号右边和第二个等号右边的QP表示双向差别帧类型的已编码视频帧的编码量化参数;pboffset表示第二偏移量,是根据第二编码偏移参数确定的;pbratio表示第二编码偏移参数。Here is an explanation of the parameters in Formula 2 above: QP on the left side of the first equal sign represents the offset quantization parameter of the encoded video frame of the bidirectional difference frame type; QP on the right side of the first and second equal signs represents the coding quantization parameter of the encoded video frame of the bidirectional difference frame type; pboffset represents the second offset, which is determined based on the second coding offset parameter; pbratio represents the second coding offset parameter.
(2)当目标视频帧的类型为双向差别帧类型时,根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数的过程可以包括:在目标视频中确定目标视频帧的参考视频帧,参考视频帧的数量可以为一个或M个,M为大于1的整数;若参考视频帧的数量为一个,则可以将参考视频帧的参考量化参数确定为目标视频帧的初始量化参数;若参考视频帧的数量为M个,则可以获取M个参考视频帧中的每个参考视频帧的复杂度参数,并根据M个参考视频帧的复杂度参数对M个参考视频帧的参考量化参数进行加权求和计算,得到目标视频帧的初始量化参数;在进行加权求和计算时,任一个参考视频帧的参考量化参数的权重可以是根据该参考视频帧的复杂度参数与M个参考视频帧的复杂度参数的总和确定的,任一个参考视频帧的参考量化参数的权重可以等于该参考视频帧的复杂度参数与M个参考视频帧的复杂度参数的总和之间的比值。需要说明的是,参考视频帧的复杂度参数可以是指参考视频帧的模糊复杂度参数,参考视频帧的模糊复杂度参数的确定过程,与当目标视频帧的类型为前向差别帧类型时目标视频帧的模糊复杂度参数的确定过程相同,具体可参见图5所示实施例中关于目标视频帧的类型为前向差别帧类型时目标视频帧的模糊复杂度参数的确定过程的相关描述;或者,参考视频帧的复杂度参数也可以是参考视频帧的时间复杂度或空间复杂度中的任意一种或两种。(2) When the target video frame is a bidirectional difference frame type, the process of estimating the quantization parameters of the target video frame based on the coding offset parameters to obtain the initial quantization parameters of the target video frame may include: determining the reference video frame of the target video frame in the target video, the number of reference video frames can be one or M, where M is an integer greater than 1; if the number of reference video frames is one, the reference quantization parameters of the reference video frame can be determined as the initial quantization parameters of the target video frame; if the number of reference video frames is M, the complexity parameters of each of the M reference video frames can be obtained, and the reference quantization parameters of the M reference video frames can be weighted and summed based on the complexity parameters of the M reference video frames to obtain the initial quantization parameters of the target video frame; when performing the weighted summation calculation, the weight of the reference quantization parameter of any reference video frame can be determined based on the complexity parameter of that reference video frame and the sum of the complexity parameters of the M reference video frames, and the weight of the reference quantization parameter of any reference video frame can be equal to the ratio between the complexity parameter of that reference video frame and the sum of the complexity parameters of the M reference video frames. It should be noted that the complexity parameter of the reference video frame can refer to the fuzzy complexity parameter of the reference video frame. The process of determining the fuzzy complexity parameter of the reference video frame is the same as the process of determining the fuzzy complexity parameter of the target video frame when the target video frame is of the forward difference frame type. For details, please refer to the relevant description of the process of determining the fuzzy complexity parameter of the target video frame when the target video frame is of the forward difference frame type in the embodiment shown in Figure 5. Alternatively, the complexity parameter of the reference video frame can also be any one or both of the time complexity and space complexity of the reference video frame.
其中,参考视频帧中的指定类型的参考视频帧的参考量化参数,是根据编码偏移参数对指定类型的参考视频帧的编码量化参数进行参数映射处理得到的,指定类型的参考视频帧的编码量化参数的参数映射处理过程,与指定类型的已编码视频帧的编码量化参数的参数映射处理过程相同,具体可以参见前述内容中关于指定类型的已编码视频帧的编码量化参数的参数映射处理过程的相关描述,在此不再赘述;参考视频帧中的其他类型的参考视频帧的参考量化参数,是其他类型的参考视频帧的编码量化参数,其他类型的参考视频帧是指参考视频帧中除指定类型的参考视频帧外的其他参考视频帧。也就是说,双向差别帧类型的目标视频帧的初始量化参数是,目标视频帧的一个参考视频帧的参考量化参数,或者是对目标视频帧的M个参考视频帧的参考量化参数进行复杂度参数加权求和的结果;并且,当参考视频帧的类型为其他类型时,参考视频帧的参考量化参数等于参考视频帧的编码量化参数,无需进行参数映射处理;当参考视频帧的类型为指定类型时,需要根据编码偏移参数将指定类型的参考视频帧的编码量化参数,统一映射至目标类型,得到指定类型的参考视频帧的参考量化参数;通过参数映射处理,不仅可以使得目标视频帧的初始量化参数与目标视频的视频属性特征适配,还有利于在码率控制中进行归一化。The reference quantization parameters of a specified type of reference video frame in the reference video frame are obtained by mapping the encoded quantization parameters of the specified type of reference video frame according to the encoded offset parameters. The parameter mapping process of the encoded quantization parameters of the specified type of reference video frame is the same as that of the encoded quantization parameters of the specified type of encoded video frame. For details, please refer to the relevant description of the parameter mapping process of the encoded quantization parameters of the specified type of encoded video frame in the previous content, which will not be repeated here. The reference quantization parameters of other types of reference video frames in the reference video frame are the encoded quantization parameters of other types of reference video frames. Other types of reference video frames refer to other reference video frames in the reference video frame besides the reference video frames of the specified type. In other words, the initial quantization parameter of the target video frame of the bidirectional difference frame type is either the reference quantization parameter of a reference video frame of the target video frame, or the result of a complexity-weighted sum of the reference quantization parameters of M reference video frames of the target video frame. Furthermore, when the type of the reference video frame is other, the reference quantization parameter of the reference video frame is equal to the encoded quantization parameter of the reference video frame, and no parameter mapping processing is required. When the type of the reference video frame is a specified type, the encoded quantization parameter of the reference video frame of the specified type needs to be uniformly mapped to the target type according to the encoded offset parameter to obtain the reference quantization parameter of the reference video frame of the specified type. Through parameter mapping processing, not only can the initial quantization parameter of the target video frame be adapted to the video attribute features of the target video, but it is also beneficial for normalization in bitrate control.
S405,对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数。S405, adjust the initial quantization parameters of the target video frame to obtain the encoded quantization parameters of the target video frame.
在根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数之后,还可以对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数。After estimating the quantization parameters of the target video frame based on the coding offset parameters to obtain the initial quantization parameters of the target video frame, the initial quantization parameters of the target video frame can be adjusted to obtain the coding quantization parameters of the target video frame.
S406,根据目标视频帧的编码量化参数对目标视频帧进行编码处理。S406: Encode the target video frame according to the coding quantization parameters of the target video frame.
在对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数之后,可以根据目标视频帧的编码量化参数对目标视频帧进行编码处理。根据目标视频帧的编码量化参数对目标视频帧进行编码处理可以包括两个阶段,第一阶段是根据目标视频帧的编码量化参数对目标视频帧进行量化处理,得到量化处理后的目标视频帧,第二个阶段是对量化处理后的目标视频帧进行编码处理。After adjusting the initial quantization parameters of the target video frame to obtain its encoded quantization parameters, the target video frame can be encoded based on these parameters. Encoding the target video frame using its encoded quantization parameters can involve two stages: the first stage is quantizing the target video frame according to these parameters to obtain the quantized target video frame; the second stage is encoding the quantized target video frame.
本申请实施例中,目标视频的视频属性特征可以是从目标视频中获取到待编码的目标视频帧时获取的,这样可以使得目标视频帧的编码量化参数与目标视频当前的视频属性特征的适配度更高,采用适配度更高的编码量化参数对目标视频帧进行编码处理,有利于提升视频消费端的QoE指标和视频观看体验。当目标视频的视频属性特征包括目标视频的分辨率信息时,可以使得目标视频帧的编码量化参数与目标视频的视频播放条件进行适配,当目标视频的视频属性特征包括目标视频的码率信息时,可以使得目标视频帧的编码量化参数与目标视频的网络环境进行适配,当目标视频的视频属性特征包括目标视频所属的视频类型信息时,可以使得目标视频帧的编码量化参数与目标视频的视频类型进行适配,当目标视频的视频属性特征包括目标视频的播放效果参考信息时,可以使得目标视频帧的编码量化参数与目标视频的期望播放效果进行适配,也就是说,本申请实施例中确定出目标视频帧的编码量化参数可以从视频业务的不同角度进行适配,其目的都是为了提升视频编码效果,使得目标视频在视频消费端的视频呈现质量与QoE指标之间的达到最佳平衡。In this embodiment of the application, the video attribute features of the target video can be obtained when the target video frame to be encoded is obtained from the target video. This can make the encoding quantization parameters of the target video frame more compatible with the current video attribute features of the target video. Using encoding quantization parameters with higher compatibility to encode the target video frame is beneficial to improving the QoE index and video viewing experience on the video consumer side. When the video attribute features of the target video include the resolution information of the target video, the encoding quantization parameters of the target video frame can be adapted to the video playback conditions of the target video. When the video attribute features of the target video include the bitrate information of the target video, the encoding quantization parameters of the target video frame can be adapted to the network environment of the target video. When the video attribute features of the target video include the video type information of the target video, the encoding quantization parameters of the target video frame can be adapted to the video type of the target video. When the video attribute features of the target video include the playback effect reference information of the target video, the encoding quantization parameters of the target video frame can be adapted to the expected playback effect of the target video. In other words, the encoding quantization parameters of the target video frame determined in this application embodiment can be adapted from different perspectives of video services, all with the aim of improving the video encoding effect and achieving the best balance between the video presentation quality and QoE index of the target video at the video consumption end.
本申请实施例提供一种视频处理方法,该视频处理方法主要介绍当目标视频帧为P帧时初始量化参数的确定过程,对目标视频帧的初始量化参数进行调整的过程等内容。该视频处理方法可以由上述提及的视频处理系统中的视频制作设备301来执行,请参见图5,该视频处理方法可以包括以下步骤S501-步骤S509:This application provides a video processing method, which mainly describes the process of determining the initial quantization parameters when the target video frame is a P-frame, and the process of adjusting the initial quantization parameters of the target video frame. This video processing method can be executed by the video production device 301 in the aforementioned video processing system. Referring to Figure 5, the video processing method may include the following steps S501-S509:
S501,从目标视频中获取待编码的目标视频帧。S501: Obtain the target video frame to be encoded from the target video.
本申请实施例中步骤S501的执行过程与上述图4所示实施例中步骤S401的执行过程相同,具体可参见上述图4所示实施例中步骤S401的相关描述,在此不再赘述。The execution process of step S501 in this embodiment is the same as that of step S401 in the embodiment shown in Figure 4 above. For details, please refer to the relevant description of step S401 in the embodiment shown in Figure 4 above, which will not be repeated here.
S502,对目标视频帧进行类型检测;S502, perform type detection on the target video frame;
从目标视频中获取待编码的目标视频帧之后,可以对目标视频帧的进行类型检测,目标视频帧的类型可以为关键帧类型、前向差别帧类型或双向差别帧类型中的任一种。若目标视频帧的类型为关键帧类型或双向差别帧类型,则可以触发执行步骤S503-步骤S505,步骤S505执行结束后可以执行步骤S508-步骤S509;若目标视频帧的类型为前向差别帧类型,则可以触发执行步骤S506-步骤S507,步骤S507执行结束后可以执行步骤S508-步骤S509。After obtaining the target video frame to be encoded from the target video, the type of the target video frame can be detected. The type of the target video frame can be any one of keyframe type, forward difference frame type, or bidirectional difference frame type. If the type of the target video frame is keyframe type or bidirectional difference frame type, steps S503-S505 can be triggered. After step S505 is executed, steps S508-S509 can be executed. If the type of the target video frame is forward difference frame type, steps S506-S507 can be triggered. After step S507 is executed, steps S508-S509 can be executed.
S503,获取目标视频的视频属性特征。S503, obtain the video attribute features of the target video.
S504,确定与视频属性特征相匹配的编码偏移参数。S504, determine the encoding offset parameters that match the video attribute features.
S505,根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数。S505: Estimate the quantization parameters of the target video frame based on the coding offset parameters to obtain the initial quantization parameters of the target video frame.
本申请实施例中步骤S503的执行过程与上述图4所示实施例中步骤S402的执行过程相同,步骤S504的执行过程与上述图4所示实施例中步骤S403的执行过程相同,步骤S505的执行过程与上述图4所示实施例中步骤S404的执行过程相同,具体可参见上述图4所示实施例中的相关描述,在此不再赘述。The execution process of step S503 in this embodiment is the same as the execution process of step S402 in the embodiment shown in Figure 4 above. The execution process of step S504 is the same as the execution process of step S403 in the embodiment shown in Figure 4 above. The execution process of step S505 is the same as the execution process of step S404 in the embodiment shown in Figure 4 above. For details, please refer to the relevant description in the embodiment shown in Figure 4 above, which will not be repeated here.
S506,获取目标视频帧的模糊复杂度参数。S506, obtain the fuzziness complexity parameter of the target video frame.
获取目标视频帧的复杂度参数的过程可以包括:获取目标视频帧的预测残差参数(SATD);根据目标视频的N个已编码视频帧的累积复杂度参数、N个已编码视频帧的累积帧数和目标视频帧的预测残差参数,确定目标视频帧的模糊复杂度参数,N个已编码视频帧是目标视频中编码顺序位于目标视频帧之前的N个已编码的视频帧,N为正整数。The process of obtaining the complexity parameters of the target video frame may include: obtaining the prediction residual parameter (SATD) of the target video frame; determining the fuzzy complexity parameter of the target video frame based on the cumulative complexity parameters of the N encoded video frames of the target video, the cumulative number of frames of the N encoded video frames, and the prediction residual parameter of the target video frame. The N encoded video frames are the N encoded video frames in the target video whose encoding order is before the target video frame, and N is a positive integer.
其中,目标视频帧的预测残差参数的确定过程可以包括:对目标视频帧进行下采样处理,得到下采样视频帧,然后可以对下采样视频帧进行预测处理,得到预测视频帧,并计算预测视频帧与目标视频帧之间的残差,然后可以对预测视频帧与目标视频帧之间的残差进行变换处理后再进行绝对值求和,得到目标视频帧的预测残差参数;预测处理可以包括inter预测处理(即帧间预测处理)和intra预测处理(即帧内预测处理),intra预测处理是指视频帧内的预测块是基于已编码重建块和当前块形成的块,inter预测处理主要可以包括运动估计(例如运动搜索方法、运动估计准则、亚像素插值和运动矢量估计等)和运动补偿,是GOP粒度时序上的参考和预测插值补偿;变换处理具体可以是指对预测视频帧与目标视频帧之间的残差进行Hadamard变换(阿达马变换)。N个已编码视频帧的累积复杂度参数可以是对N个已编码视频帧的复杂度参数进行加权累积得到的,此处累积的含义可以理解为第二个已编码视频帧的复杂度参数等于第一个已编码视频帧的复杂度参数(例如可以是时间复杂度或空间复杂度中的任意一种或两种)乘以0.5加上第二个已编码视频帧的预测残差参数,第三个已编码视频帧的复杂度参数等于第二个已编码视频帧的复杂度参数乘以0.5加上第三个已编码视频帧的预测残差参数,以此类推得到N个已编码视频帧的累积复杂度参数;N个已编码视频帧的累积帧数可以是对N个已编码视频帧的帧数进行加权累积得到的。目标视频帧的复杂度参数的具体计算过程可参见下述公式3-公式5:The process of determining the prediction residual parameters of the target video frame can include: downsampling the target video frame to obtain a downsampled video frame; then, predicting the downsampled video frame to obtain a predicted video frame; calculating the residual between the predicted video frame and the target video frame; then, transforming the residual between the predicted video frame and the target video frame and summing the absolute values to obtain the prediction residual parameters of the target video frame; the prediction processing can include inter-prediction processing (i.e., inter-frame prediction processing) and intra-prediction processing (i.e., intra-frame prediction processing). Intra-prediction processing refers to the prediction blocks within a video frame being formed based on the coded reconstructed blocks and the current block. Inter-prediction processing mainly includes motion estimation (e.g., motion search methods, motion estimation criteria, sub-pixel interpolation, and motion vector estimation, etc.) and motion compensation, which are references and prediction interpolation compensations at the GOP granularity temporal level; the transformation processing specifically refers to performing a Hadamard transform on the residual between the predicted video frame and the target video frame. The cumulative complexity parameter of N encoded video frames can be obtained by weighted summation of the complexity parameters of the N encoded video frames. Here, summation can be understood as follows: the complexity parameter of the second encoded video frame equals the complexity parameter of the first encoded video frame (e.g., any one or both of time complexity and space complexity) multiplied by 0.5 plus the prediction residual parameter of the second encoded video frame; the complexity parameter of the third encoded video frame equals the complexity parameter of the second encoded video frame multiplied by 0.5 plus the prediction residual parameter of the third encoded video frame, and so on, to obtain the cumulative complexity parameter of the N encoded video frames. The cumulative frame count of the N encoded video frames can be obtained by weighted summation of the frame counts of the N encoded video frames. The specific calculation process for the complexity parameter of the target video frame can be found in Formulas 3-5 below.
cplxsum[i]=cplxsum[i-1]×0.5+SATD[i]公式3cplxsum[i]=cplxsum[i-1]×0.5+SATD[i] Formula 3
cplxcount[i]=cplxcount[i-1]×0.5+1公式4cplxcount[i] = cplxcount[i-1] × 0.5 + 1 (Formula 4)
blurred_complexity[i]=cplxsum[i]/cplxcount[i]公式5blurred_complexity[i]=cplxsum[i]/cplxcount[i]Formula 5
在此对上述公式3-公式5中的参数进行解释:i表示目标视频帧;SATD[i]表示目标视频帧的预测残差参数;cplxsum[i-1]表示N个已编码视频帧的累积复杂度参数,cplxsum的初始值为0,cplxsum[i-1]是对N个已编码视频帧的复杂度参数进行加权累积得到,常数0.5为加权所采用的权重;cplxsum[i]表示目标视频帧的累积复杂度参数,是根据cplxsum[i-1]和SATD[i]确定的;cplxcount[i-1]表示N个已编码视频帧的累积帧数,cplxcount的初始值为0,是对N个已编码视频帧的帧数进行加权累积得到,常数0.5为加权所采用的权重;cplxcount[i]表示目标视频帧的累积帧数,是根据cplxcount[i-1]确定的,blurred_complexity[i]表示目标视频帧的模糊复杂度参数,是根据cplxsum[i]和cplxcount[i]确定的。Here is an explanation of the parameters in Formulas 3-5: i represents the target video frame; SATD[i] represents the prediction residual parameter of the target video frame; cplxsum[i-1] represents the cumulative complexity parameter of N encoded video frames, with an initial value of 0. cplxsum[i-1] is obtained by weighted accumulation of the complexity parameters of N encoded video frames, and the constant 0.5 is the weight used for weighting; cplxsum[i] represents the cumulative complexity parameter of the target video frame, which is determined based on cplxsum[i-1] and SATD[i]. The values are fixed; cplxcount[i-1] represents the cumulative frame count of N encoded video frames. The initial value of cplxcount is 0. It is obtained by weighted accumulation of the frame counts of N encoded video frames. The constant 0.5 is the weight used for weighting; cplxcount[i] represents the cumulative frame count of the target video frame, which is determined based on cplxcount[i-1]. blurred_complexity[i] represents the blur complexity parameter of the target video frame, which is determined based on cplxsum[i] and cplxcount[i].
S507,根据目标视频帧的模糊复杂度参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数。S507, Estimate the quantization parameters of the target video frame based on the fuzziness complexity parameter of the target video frame to obtain the initial quantization parameters of the target video frame.
在获取到目标视频帧的模糊复杂度参数之后,可以根据目标视频帧的模糊复杂度参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数。根据目标视频帧的模糊复杂度参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数可以包括:①获取目标视频帧的压缩因子,根据目标视频帧的模糊复杂度参数和压缩因子确定目标视频帧的量化等级参数。②获取目标视频帧的累计分配信息量和目标视频帧的累积复杂度参数;目标视频帧的累计分配信息量是对目标视频帧的分配信息量和N个已编码视频帧的分配信息量进行累计得到的,此处的累计可以理解为目标视频帧的累计分配信息量等于目标视频帧的分配信息量和N个已编码视频帧的分配信息量相加得到的总和;目标视频帧的分配信息量是指为目标视频帧预分配的比特数目,已编码视频帧的分配信息量是指为已编码视频帧预分配的比特数目;目标视频帧的累积复杂度参数(即前述cplxsum[i])是根据N个已编码视频帧的累积复杂度参数(即前述cplxsum[i-1])和目标视频帧的预测残差参数(即前述SATD[i])确定的。③根据目标视频帧的累计分配信息量和目标视频帧的累积复杂度参数,确定量化等级参数的优化因子。④根据优化因子对量化等级参数进行优化,得到目标视频帧的初始量化参数。根据目标视频帧的模糊复杂度参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数的过程具体可参见下述公式6-公式8:After obtaining the fuzzy complexity parameters of the target video frame, quantization parameters can be estimated based on these parameters to obtain the initial quantization parameters. Estimating the initial quantization parameters based on the fuzzy complexity parameters can include: ① Obtaining the compression factor of the target video frame, and determining the quantization level parameters based on the fuzzy complexity parameters and the compression factor. ② Obtain the cumulative allocation information and cumulative complexity parameter of the target video frame. The cumulative allocation information of the target video frame is obtained by accumulating the allocation information of the target video frame and the allocation information of N encoded video frames. Here, the accumulation can be understood as the cumulative allocation information of the target video frame being equal to the sum of the allocation information of the target video frame and the allocation information of the N encoded video frames. The allocation information of the target video frame refers to the number of bits pre-allocated to the target video frame, and the allocation information of the encoded video frame refers to the number of bits pre-allocated to the encoded video frame. The cumulative complexity parameter of the target video frame (i.e., the aforementioned cplxsum[i]) is determined based on the cumulative complexity parameters of the N encoded video frames (i.e., the aforementioned cplxsum[i-1]) and the prediction residual parameter of the target video frame (i.e., the aforementioned SATD[i]). ③ Determine the optimization factor of the quantization level parameter based on the cumulative allocation information and cumulative complexity parameter of the target video frame. ④ Optimize the quantization level parameter based on the optimization factor to obtain the initial quantization parameter of the target video frame. The process of estimating the quantization parameters of the target video frame based on its fuzziness complexity parameter, and obtaining the initial quantization parameters of the target video frame, can be found in Formulas 6-8 below:
qscale_raw[i]=blurred_complexity[i](1-qcompres0) 公式6qscale_raw[i]=blurred_complexity[i] (1-qcompres0) Formula 6
rate_factor[i]=wanted_bits_window[i]/cplxsum[i] 公式7rate_factor[i]=wanted_bits_window[i]/cplxsum[i] Formula 7
qscale_adjust[i]=qscale_raw[i]/rate_factor[i] 公式8qscale_adjust[i]=qscale_raw[i]/rate_factor[i] Formula 8
在此对上述公式6-公式8中的参数进行解释:i表示目标视频帧;qcompress表示压缩因子,在ABR模式中默认为0.6,可以表征目标视频帧的模糊复杂度参数与目标视频帧的量化等级参数之间的关系,用于调控目标视频帧的量化等级参数的幅度;blurred_complexity[i]表示目标视频帧的模糊复杂度参数;qscale_raw[i]表示目标视频帧的量化等级参数;rate_factor[i]表示量化等级参数的优化因子,wanted_bits_window[i]表示目标视频帧的累计分配信息量,cplxsum[i]表示目标视频帧的累积复杂度参数,rate_factor[i]等于wanted_bits_window[i]与cplxsum[i]之间的比值;qscale_adjust[i]表示目标视频帧的初始量化参数,qscale_adjust[i]等于qscale_raw[i]与rate_factor[i]之间的比值。Here is an explanation of the parameters in Formulas 6-8: i represents the target video frame; qcompress represents the compression factor, which defaults to 0.6 in ABR mode. It characterizes the relationship between the blur complexity parameter and the quantization level parameter of the target video frame and is used to adjust the magnitude of the quantization level parameter; blurred_complexity[i] represents the blur complexity parameter of the target video frame; qscale_raw[i] represents the quantization level parameter of the target video frame; rate_factor[i] represents the optimization factor of the quantization level parameter; wanted_bits_window[i] represents the cumulative allocated information of the target video frame; cplxsum[i] represents the cumulative complexity parameter of the target video frame; rate_factor[i] is equal to the ratio between wanted_bits_window[i] and cplxsum[i]; qscale_adjust[i] represents the initial quantization parameter of the target video frame; qscale_adjust[i] is equal to the ratio between qscale_raw[i] and rate_factor[i].
S508,对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数。S508 adjusts the initial quantization parameters of the target video frame to obtain the encoded quantization parameters of the target video frame.
由前述内容可知,目标视频帧的类型可以为关键帧类型、前向差别帧类型、双向差别帧类型中的任一种,当目标视频帧的类型为关键帧类型、前向差别帧类型、双向差别帧类型中的任一种时,都需要对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数。对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数的过程可以包括:As mentioned above, the target video frame can be any of the following types: keyframe, forward difference frame, or bidirectional difference frame. When the target video frame is any of these types, the initial quantization parameters of the target video frame need to be adjusted to obtain the encoded quantization parameters. The process of adjusting the initial quantization parameters of the target video frame to obtain the encoded quantization parameters may include:
(1)根据目标视频中的N个已编码视频帧的累计编码信息量和N个已编码视频帧的累计分配信息量,确定对目标视频帧的初始量化参数的调整因子。N个已编码视频帧的累计编码信息量是对N个已编码视频帧的编码信息量进行累计得到的,已编码视频帧的编码信息量是指对已编码视频帧实际编码产生的比特数目;N个已编码视频帧的累计分配信息量是对N个已编码视频帧的分配信息量进行累计得到的。(1) Determine the adjustment factor for the initial quantization parameters of the target video frame based on the cumulative encoded information and the cumulative allocated information of the N encoded video frames in the target video. The cumulative encoded information of the N encoded video frames is obtained by accumulating the encoded information of the N encoded video frames, where the encoded information of the encoded video frame refers to the number of bits actually generated by encoding the encoded video frame; the cumulative allocated information of the N encoded video frames is obtained by accumulating the allocated information of the N encoded video frames.
其中,根据目标视频中的N个已编码视频帧的累计编码信息量和N个已编码视频帧的累计分配信息量,确定对目标视频帧的初始量化参数的调整因子的过程可以包括:获取目标视频的码率信息和N个已编码视频帧的编码总时间,N个已编码视频帧的编码总时间可以是根据N个已编码视频帧的帧数和目标视频的帧率信息确定的,目标视频的帧率信息是指单位时间内传输的视频帧的数量;根据目标视频的码率信息和N个已编码视频帧的编码总时间,确定N个已编码视频帧的平均缓冲区信息;根据N个已编码视频帧的累计编码信息量、N个已编码视频帧的累计分配信息量和N个已编码视频帧的平均缓冲区信息,确定对目标视频帧的初始量化参数的调整因子。The process of determining the adjustment factor for the initial quantization parameters of the target video frame based on the cumulative encoded information and cumulative allocation information of the N encoded video frames in the target video may include: obtaining the bitrate information of the target video and the total encoding time of the N encoded video frames, where the total encoding time of the N encoded video frames can be determined based on the number of frames of the N encoded video frames and the frame rate information of the target video, where the frame rate information of the target video refers to the number of video frames transmitted per unit time; determining the average buffer information of the N encoded video frames based on the bitrate information of the target video and the total encoding time of the N encoded video frames; and determining the adjustment factor for the initial quantization parameters of the target video frame based on the cumulative encoded information, cumulative allocation information, and average buffer information of the N encoded video frames.
(2)根据调整因子对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数。其中,根据调整因子对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数的过程可以包括:根据调整因子对目标视频帧的初始量化参数进行调整,得到目标视频帧的调整量化参数;根据目标视频帧的调整量化参数确定目标视频帧的编码量化参数。(2) Adjust the initial quantization parameters of the target video frame according to the adjustment factor to obtain the encoded quantization parameters of the target video frame. The process of adjusting the initial quantization parameters of the target video frame according to the adjustment factor to obtain the encoded quantization parameters of the target video frame may include: adjusting the initial quantization parameters of the target video frame according to the adjustment factor to obtain the adjusted quantization parameters of the target video frame; and determining the encoded quantization parameters of the target video frame according to the adjusted quantization parameters of the target video frame.
上述(1)-(2)的过程具体可参见下述公式9-公式12:For details of the processes described in (1)-(2) above, please refer to Formulas 9-12 below:
abr_buffer[i-1]=2×RT×sqrt(Ttotal) 公式9abr_buffer[i-1]=2×R T ×sqrt(T total ) Formula 9
overflow[i]=overflow[i] =
clip3(0.5,2,1.0+(total_bits[i-1]-wanted_bits[i-1])/abr_buffer[i-1])公式10clip3(0.5, 2, 1.0+(total_bits[i-1]-wanted_bits[i-1])/abr_buffer[i-1]) Formula 10
qscale_adjust[i]=qscale_adjust[i]×overflow[i] 公式11qscale_adjust[i]=qscale_adjust[i]×overflow[i] Formula 11
QP[i]=12+6×log2(qscale_adjust[i]/0.85) 公式12QP[i]=12+6×log 2 (qscale_adjust[i]/0.85) Formula 12
在此对上述公式9-公式12中的参数进行解释:RT表示目标视频的码率信息;Ttotal表示N个已编码视频帧的编码总时间;sqrt(Ttotal)表示Ttotal的平方根;abr_buffer[i-1]表示N个已编码视频帧的平均缓冲区信息;total_bits[i-1]表示N个已编码视频帧的累计编码信息量;wanted_bits[i-1]表示N个已编码视频帧的累计分配信息量;clip3表示clip3函数;overflow[i]表示目标视频帧的初始量化参数调整因子;公式11中等式右边的qscale_adjust[i]表示目标视频帧的初始量化参数;公式11中等式左边的qscale_adjust[i]表示目标视频帧的调整量化参数;公式12中等式右边的qscale_adjust[i]表示目标视频帧的调整量化参数;QP[i]表示目标视频帧的编码量化参数。Here is an explanation of the parameters in Formulas 9-12: RT represents the bitrate information of the target video; T total represents the total encoding time of N encoded video frames; sqrt(T total ) represents the square root of T total ; abr_buffer[i-1] represents the average buffer information of N encoded video frames; total_bits[i-1] represents the cumulative encoded information of N encoded video frames; wanted_bits[i-1] represents the cumulative allocated information of N encoded video frames; clip3 represents the clip3 function; overflow[i] represents the initial quantization parameter adjustment factor of the target video frame; qscale_adjust[i] on the right side of Formula 11 represents the initial quantization parameter of the target video frame; qscale_adjust[i] on the left side of Formula 11 represents the adjusted quantization parameter of the target video frame; qscale_adjust[i] on the right side of Formula 12 represents the adjusted quantization parameter of the target video frame; QP[i] represents the encoded quantization parameter of the target video frame.
S509,根据目标视频帧的编码量化参数对目标视频帧进行编码处理。S509: Encode the target video frame according to the coding quantization parameters of the target video frame.
本申请实施例中步骤S509的执行过程与上述图4所示实施例中步骤S406的执行过程相同,具体可参见上述图4所示实施例中步骤S406的相关描述,在此不再赘述。在对目标视频帧进行编码处理后,可以按照本申请实施例提供的视频处理方法继续确定目标视频中编码顺序位于目标视频帧之后的视频帧的编码量化参数,以进行编码处理,直至对目标视频中的所有视频帧处理完成为止。The execution process of step S509 in this embodiment is the same as that of step S406 in the embodiment shown in Figure 4 above. For details, please refer to the relevant description of step S406 in the embodiment shown in Figure 4 above, which will not be repeated here. After encoding the target video frame, the encoding quantization parameters of video frames whose encoding order follows the target video frame can be determined according to the video processing method provided in this embodiment for encoding processing, until all video frames in the target video have been processed.
本申请实施例中,当目标视频帧的类型为前向差别帧类型时,可以根据目标视频帧的模糊复杂度参数估计目标视频帧的初始量化参数,使得目标视频帧的初始量化参数与目标视频帧的复杂度相适配。可以根据编码顺序位于目标视频帧之前的所有已编码视频帧的累计编码信息量和所有已编码视频帧的累计分配信息量来对目标视频帧的初始量化参数进行调整,可以保证整个编码过程中实际编码产生的编码信息量与预分配的编码信息量接近,提升整体编码效果。In this embodiment, when the target video frame is a forward difference frame, the initial quantization parameters of the target video frame can be estimated based on its fuzzy complexity parameters, ensuring that the initial quantization parameters match the complexity of the target video frame. The initial quantization parameters of the target video frame can be adjusted based on the cumulative encoded information of all encoded video frames preceding the target video frame and the cumulative allocated information of all encoded video frames. This ensures that the actual encoded information generated during the entire encoding process is close to the pre-allocated encoded information, improving the overall encoding effect.
上述图4和图5所示的视频处理方法可总结为图6所示的流程示意图,视频处理方法可以包括:The video processing methods shown in Figures 4 and 5 above can be summarized as the flowchart shown in Figure 6. The video processing methods may include:
(1)从目标视频中确定待编码的目标视频帧,对目标视频帧进行类型检测,目标视频帧的类型可以包括关键帧类型、前向差别帧类型或双向差别帧类型中的任一种。(1) Determine the target video frame to be encoded from the target video, and perform type detection on the target video frame. The type of the target video frame may include any one of key frame type, forward difference frame type or bidirectional difference frame type.
(2)当目标视频帧的类型为关键帧类型时,可以先进行重置判断;若确定需要进行重置,则可以对码率控制模型的模型参数进行重置(即初始化);若确定不需要进行重置,或者对码率控制模型的模型参数进行重置完成后,可以根据编码偏移参数将目标视频中编码顺序位于目标视频帧之前的N个已编码视频帧的编码量化参数映射至相同的帧类型(例如可以是前向差别帧类型)后叠加求取总和,得到统计参数,进一步采用统计参数除以N个已编码视频帧的数量,得到目标视频帧的初始量化参数;在确定出目标视频帧的初始量化参数后,可以采用调整因子(即前述提及的overflow[i])对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数。(2) When the target video frame is a keyframe type, a reset judgment can be performed first. If it is determined that a reset is needed, the model parameters of the bitrate control model can be reset (i.e., initialized). If it is determined that a reset is not needed, or after the model parameters of the bitrate control model are reset, the coding quantization parameters of the N encoded video frames in the target video whose coding order is before the target video frame can be mapped to the same frame type (e.g., forward difference frame type) according to the coding offset parameter and then summed to obtain statistical parameters. The statistical parameters are further divided by the number of N encoded video frames to obtain the initial quantization parameters of the target video frame. After the initial quantization parameters of the target video frame are determined, the initial quantization parameters of the target video frame can be adjusted using the adjustment factor (i.e., the overflow[i] mentioned above) to obtain the coding quantization parameters of the target video frame.
(3)当目标视频帧的类型为前向差别帧类型时,可以先计算目标视频帧的模糊复杂度参数;然后可以进行重置判断,若确定需要进行重置,则可以对码率控制模型的模型参数进行重置(即初始化);若确定不需要进行重置,或者对码率控制模型的模型参数进行重置完成后,可以根据目标视频帧的模糊复杂度参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数;在确定出目标视频帧的初始量化参数后,可以采用调整因子(即前述提及的overflow[i])对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数。可选的,在确定目标视频帧的编码量化参数后,可以根据目标视频中编码顺序与目标视频帧相邻的视频帧的编码量化参数,对目标视频帧的编码量化参数进行限制处理,例如,若相邻的视频帧的编码量化参数与目标视频帧的编码量化参数之间的差值的绝对值大于限制阈值,则可以对目标视频帧的编码量化参数进行限制处理,使得相邻的视频帧的编码量化参数与限制处理后的目标视频帧的编码量化参数之间的差值的绝对值小于或等于限制阈值,这样可以避免视频消费端在播放目标视频时视频质量大幅度变化,从而影响视频消费端的视频消费体验。(3) When the target video frame is a forward difference frame type, the fuzzy complexity parameter of the target video frame can be calculated first; then a reset judgment can be made. If it is determined that a reset is needed, the model parameters of the bitrate control model can be reset (i.e., initialized); if it is determined that a reset is not needed, or after the model parameters of the bitrate control model have been reset, the quantization parameters of the target video frame can be estimated based on the fuzzy complexity parameter of the target video frame to obtain the initial quantization parameters of the target video frame; after the initial quantization parameters of the target video frame are determined, the initial quantization parameters of the target video frame can be adjusted using the adjustment factor (i.e., the overflow[i] mentioned above) to obtain the encoded quantization parameters of the target video frame. Optionally, after determining the coding quantization parameters of the target video frame, the coding quantization parameters of the target video frame can be restricted based on the coding quantization parameters of video frames adjacent to the target video frame in the coding order. For example, if the absolute value of the difference between the coding quantization parameters of the adjacent video frames and the coding quantization parameters of the target video frame is greater than a restriction threshold, the coding quantization parameters of the target video frame can be restricted so that the absolute value of the difference between the coding quantization parameters of the adjacent video frames and the restricted coding quantization parameters of the target video frame is less than or equal to the restriction threshold. This can prevent the video quality from changing drastically when the video consumer plays the target video, thereby affecting the video consumption experience of the video consumer.
(4)当目标视频的类型为双向差别帧类型时,可以根据编码偏移参数将目标视频帧的参考视频帧的编码量化参数映射至相同的帧类型(例如可以是前向差别帧类型)后,根据映射后的参考视频帧的编码量化参数确定目标视频帧的初始量化参数;例如,可以将映射后的参考视频帧的编码量化参数确定为目标视频帧的初始量化参数(当参考视频帧的数量为一个时),或者,可以按照参考视频帧的复杂度参数对参考视频帧的编码量化参数进行加权求和,得到目标视频帧的初始量化参数(当参考视频帧的数量为两个时)。在确定目标视频帧的初始量化参数后,可以判断是否设置目标码率(即前述提及的码率信息),若设置目标码率,则可以采用调整因子(即前述提及的overflow[i])对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数;否则,可以将目标视频帧的初始量化参数确定为目标视频帧的编码量化参数。(4) When the target video is a bidirectional difference frame type, the coding quantization parameters of the reference video frame of the target video frame can be mapped to the same frame type (e.g., a forward difference frame type) according to the coding offset parameter. Then, the initial quantization parameters of the target video frame can be determined according to the coding quantization parameters of the mapped reference video frame. For example, the coding quantization parameters of the mapped reference video frame can be determined as the initial quantization parameters of the target video frame (when there is one reference video frame), or the coding quantization parameters of the reference video frame can be weighted and summed according to the complexity parameter of the reference video frame to obtain the initial quantization parameters of the target video frame (when there are two reference video frames). After determining the initial quantization parameters of the target video frame, it can be determined whether to set the target bitrate (i.e., the bitrate information mentioned above). If the target bitrate is set, the initial quantization parameters of the target video frame can be adjusted using the adjustment factor (i.e., the overflow[i] mentioned above) to obtain the coding quantization parameters of the target video frame; otherwise, the initial quantization parameters of the target video frame can be determined as the coding quantization parameters of the target video frame.
(5)在确定出目标视频帧的编码量化参数后,还可以采用视频缓冲校验(即VBV)的方式进一步调整目标视频帧的编码量化参数,并输出进一步调整后的目标视频帧的编码量化参数,然后可以根据目标视频帧的编码量化参数对目标视频帧进行编码处理,还可以根据目标视频帧的编码结果调整例如关键帧的补偿窗口、码率控制模型的模型参数、缓存器状态、信息量估计模型的模型参数等等。(5) After determining the coding and quantization parameters of the target video frame, the coding and quantization parameters of the target video frame can be further adjusted by using video buffer verification (VBV) and the further adjusted coding and quantization parameters of the target video frame can be output. Then, the target video frame can be encoded according to the coding and quantization parameters of the target video frame. The compensation window of the key frame, the model parameters of the bit rate control model, the buffer state, the model parameters of the information content estimation model, etc. can also be adjusted according to the coding result of the target video frame.
在图6所示的视频处理方案中,通过在确定目标视频帧的初始量化参数的过程中引入与目标视频的视频特征属性相匹配的编码偏移参数,可以使得确定得到的目标视频帧的初始量化参数与目标视频的视频属性特征相适配,这样可以在编码得到的视频码率满足目标带宽的前提下,使得视频消费端的视频呈现质量与QoE(Quality of Experience,体验质量)指标之间的达到最佳平衡,提升视频编码效果。In the video processing scheme shown in Figure 6, by introducing an encoding offset parameter that matches the video feature attributes of the target video during the process of determining the initial quantization parameters of the target video frame, the initial quantization parameters of the determined target video frame can be adapted to the video attribute features of the target video. In this way, under the premise that the bitrate of the encoded video meets the target bandwidth, the video presentation quality and QoE (Quality of Experience) index at the video consumer end can be optimally balanced, thereby improving the video encoding effect.
为了更加直观地表达编码偏移参数与视频码率之间的关系,在此将不同的编码偏移参数(ipratio/pbratio)下的视频编码过程中的码率分布情况进行统计展示:图7a示出了ipratio(1.4)、pbratio(1.3)时视频中I帧、B帧和P帧的码率分布情况,图7a中横坐标表示时间、纵坐标表示码率,深灰色柱形表示视频中I帧的码率,浅灰色柱形表示视频中P帧的码率,白色柱形表示视频中B帧的码率,黑色折线表示目标码率。图7b示出了ipratio(1.8)、pbratio(1.1)时视频中I帧、B帧和P帧的码率分布情况,同样地,图7b中横坐标表示时间、纵坐标表示码率,深灰色柱形表示视频中I帧的码率,浅灰色柱形表示视频中P帧的码率,白色柱形表示视频中B帧的码率,黑色折线表示目标码率。通过图7a和图7b的直观对比可知,通过灵活控制编码偏移参数(ipratio/pbratio),能够灵活控制视频中各个I帧、P帧和B帧的码率大小,从而控制整个视频中各帧的码率大小波动;通过确定与视频属性特征相匹配的编码偏移参数,可以在编码得到的视频码率满足目标带宽的前提下,提升视频消费端的QoE指标(例如减少卡顿感缓冲时间、减少首帧时长、提升视频观看时长等等)。To more intuitively illustrate the relationship between the encoding offset parameter and the video bitrate, the bitrate distribution during the video encoding process under different encoding offset parameters (ipratio/pbratio) is statistically displayed: Figure 7a shows the bitrate distribution of I-frames, B-frames, and P-frames in the video when ipratio (1.4) and pbratio (1.3). In Figure 7a, the horizontal axis represents time, and the vertical axis represents bitrate. Dark gray bars represent the bitrate of I-frames in the video, light gray bars represent the bitrate of P-frames, white bars represent the bitrate of B-frames, and the black line represents the target bitrate. Figure 7b shows the bitrate distribution of I-frames, B-frames, and P-frames in the video when ipratio (1.8) and pbratio (1.1). Similarly, in Figure 7b, the horizontal axis represents time, the vertical axis represents bitrate, dark gray bars represent the bitrate of I-frames, light gray bars represent the bitrate of P-frames, white bars represent the bitrate of B-frames, and the black line represents the target bitrate. A direct comparison of Figures 7a and 7b shows that by flexibly controlling the encoding offset parameters (ipratio/pbratio), the bitrate of each I-frame, P-frame, and B-frame in the video can be flexibly controlled, thereby controlling the fluctuation of the bitrate of each frame in the entire video. By determining the encoding offset parameters that match the video's attribute characteristics, the QoE index of the video consumer can be improved (e.g., reducing buffering time, reducing the duration of the first frame, and increasing the video viewing time, etc.) while ensuring that the encoded video bitrate meets the target bandwidth.
为了更加直观地表达本申请实施例提供的视频处理方法在QoE指标和QoS指标中的提升效果,在此结合图8a所示的统计图对未采用编码偏移参数进行码率控制优化和采用编码偏移参数进行码率控制优化两种方式下的QoS指标进行对比,结合图8b所示的统计图对未采用编码偏移参数进行码率控制优化和采用编码偏移参数进行码率控制优化两种方式下的QoE指标进行对比。具体来说,图8a中的横坐标表示时间,纵坐标表示QoS指标(例如是百秒渲染卡顿时长,即百秒内存在卡顿的时长),黑色实线表示未采用编码偏移参数进行码率控制优化的方式下的百秒渲染卡顿时长,黑色虚线表示采用编码偏移参数进行码率控制优化的方式下的百秒渲染卡顿时长,不难看出,相比于未采用编码偏移参数进行码率控制优化的方式,采用编码偏移参数进行码率控制优化的方式下的百秒渲染卡顿时长明显降低。图8b中的横坐标表示时间,纵坐标表示QoE指标(例如是平均对象观看时长),黑色实线表示未采用编码偏移参数进行码率控制优化的方式下的平均对象观看时长,黑色虚线表示采用编码偏移参数进行码率控制优化的方式下的平均对象观看时长,不难看出,相比于未采用编码偏移参数进行码率控制优化的方式,采用编码偏移参数进行码率控制优化的方式下的平均对象观看时长明显提升。To more intuitively illustrate the improvement effect of the video processing method provided in this application embodiment on QoE and QoS metrics, the QoS metrics of the two methods—without using encoding offset parameters for bitrate control optimization and with encoding offset parameters—are compared using the statistical graph shown in Figure 8a. Similarly, the QoE metrics of the two methods are compared using the statistical graph shown in Figure 8b. Specifically, in Figure 8a, the horizontal axis represents time, and the vertical axis represents the QoS metric (e.g., the rendering stutter duration per 100 seconds, i.e., the duration of stuttering within 100 seconds). The solid black line represents the rendering stutter duration per 100 seconds without encoding offset parameters, and the dashed black line represents the rendering stutter duration per 100 seconds with encoding offset parameters. It is easy to see that the rendering stutter duration per 100 seconds is significantly reduced compared to the method without encoding offset parameters. In Figure 8b, the horizontal axis represents time, and the vertical axis represents the QoE metric (e.g., average viewing time). The solid black line represents the average viewing time without bitrate control optimization using the encoding offset parameter, and the dashed black line represents the average viewing time with bitrate control optimization using the encoding offset parameter. It is easy to see that the average viewing time with bitrate control optimization using the encoding offset parameter is significantly improved compared to the method without bitrate control optimization.
上述详细阐述了本申请实施例的方法,为了便于更好地实施本申请实施例的上述方案,相应地,下面提供了本申请实施例的装置。The methods of the embodiments of this application have been described in detail above. In order to facilitate better implementation of the above solutions of the embodiments of this application, the apparatus of the embodiments of this application is provided below.
请参见图9,图9是本申请实施例提供的一种视频处理装置的结构示意图,该视频处理装置可以设置于本申请实施例提供的计算机设备中。该视频处理装置可以是运行于计算机设备中的一个计算机程序(包括程序代码),该计算机设备可以是前述所提及的视频制作设备,该视频处理装置可以用于执行图4、图5或图6所示的方法实施例中的相应步骤。请参见图9,该视频处理装置可以包括如下单元:Please refer to Figure 9, which is a schematic diagram of a video processing apparatus provided in an embodiment of this application. This video processing apparatus can be installed in the computer device provided in this embodiment. The video processing apparatus can be a computer program (including program code) running on the computer device, which can be the aforementioned video production device. The video processing apparatus can be used to execute the corresponding steps in the method embodiments shown in Figures 4, 5, or 6. Please refer to Figure 9; the video processing apparatus may include the following units:
获取单元901,用于从目标视频中获取待编码的目标视频帧;获取目标视频的视频属性特征;The acquisition unit 901 is used to acquire the target video frame to be encoded from the target video; and to acquire the video attribute features of the target video;
处理单元902,用于确定与视频属性特征相匹配的编码偏移参数;根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数;对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数;根据目标视频帧的编码量化参数对目标视频帧进行编码处理。The processing unit 902 is used to determine the coding offset parameter that matches the video attribute features; to estimate the quantization parameters of the target video frame based on the coding offset parameter to obtain the initial quantization parameters of the target video frame; to adjust the initial quantization parameters of the target video frame to obtain the coding quantization parameters of the target video frame; and to perform coding processing on the target video frame based on the coding quantization parameters of the target video frame.
在一种实现方式中,视频属性特征包括目标视频的分辨率信息、目标视频所属的视频类型信息、目标视频的码率信息、以及目标视频的播放效果参考信息中的任一种或多种;其中,不同的视频属性特征所匹配的编码偏移参数不相同。In one implementation, the video attribute features include one or more of the following: resolution information of the target video, video type information of the target video, bitrate information of the target video, and playback effect reference information of the target video; wherein, the encoding offset parameters matched with different video attribute features are different.
在一种实现方式中,处理单元902,用于确定与视频属性特征相匹配的编码偏移参数时,具体用于执行如下步骤:In one implementation, when determining the encoding offset parameter that matches the video attribute features, the processing unit 902 specifically performs the following steps:
在参数匹配关系中确定与视频属性特征相匹配的属性特征指示信息,参数匹配关系包括多个属性特征指示信息和每个属性特征指示信息对应的参考偏移参数;将相匹配的属性特征指示信息对应的参考偏移参数,确定为与视频属性特征相匹配的编码偏移参数。In the parameter matching relationship, the attribute feature indication information that matches the video attribute feature is determined. The parameter matching relationship includes multiple attribute feature indication information and a reference offset parameter corresponding to each attribute feature indication information. The reference offset parameter corresponding to the matching attribute feature indication information is determined as the encoding offset parameter that matches the video attribute feature.
在一种实现方式中,目标视频帧的类型为关键帧类型;处理单元902,用于根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数时,具体用于执行如下步骤:In one implementation, the target video frame is a keyframe type; the processing unit 902 is used to estimate the quantization parameters of the target video frame based on the coding offset parameters. Specifically, when obtaining the initial quantization parameters of the target video frame, it performs the following steps:
根据编码偏移参数对目标视频的N个已编码视频帧中指定类型的已编码视频帧的编码量化参数进行参数映射处理,得到指定类型的已编码视频帧的偏移量化参数,N为正整数;根据指定类型的已编码视频帧的偏移量化参数和N个已编码视频帧中其他类型的已编码视频帧的编码量化参数,确定N个已编码视频帧的统计参数;其他类型的已编码视频帧是指:N个已编码视频帧中除指定类型的已编码视频帧外的其他已编码视频帧;根据N个已编码视频帧的统计参数和N个已编码视频帧的数量,确定目标视频帧的初始量化参数。Based on the coding offset parameters, the coding quantization parameters of the specified type of encoded video frames among the N encoded video frames of the target video are mapped to obtain the offset quantization parameters of the specified type of encoded video frames, where N is a positive integer. Based on the offset quantization parameters of the specified type of encoded video frames and the coding quantization parameters of other types of encoded video frames among the N encoded video frames, the statistical parameters of the N encoded video frames are determined. Other types of encoded video frames refer to: other encoded video frames among the N encoded video frames besides the specified type of encoded video frames. Based on the statistical parameters of the N encoded video frames and the number of N encoded video frames, the initial quantization parameters of the target video frame are determined.
在一种实现方式中,编码偏移参数包括第一编码偏移参数和第二编码偏移参数;处理单元902,用于根据编码偏移参数对目标视频的N个已编码视频帧中指定类型的已编码视频帧的编码量化参数进行参数映射处理,得到指定类型的已编码视频帧的偏移量化参数时,具体用于执行如下步骤:In one implementation, the encoding offset parameter includes a first encoding offset parameter and a second encoding offset parameter; the processing unit 902 is used to perform parameter mapping processing on the encoding quantization parameters of a specified type of encoded video frames among N encoded video frames of the target video according to the encoding offset parameter, and to obtain the offset quantization parameter of the specified type of encoded video frames, specifically to perform the following steps:
若指定类型为关键帧类型,则根据第一编码偏移参数对关键帧类型的已编码视频帧的编码量化参数进行参数映射处理,得到关键帧类型的已编码视频帧的偏移量化参数;若指定类型为双向差别帧类型,则根据第二编码偏移参数对双向差别帧类型的已编码视频帧的编码量化参数进行参数映射处理,得到双向差别帧类型的已编码视频帧的偏移量化参数。If the specified type is a keyframe type, then the encoding quantization parameters of the encoded video frames of the keyframe type are mapped according to the first encoding offset parameter to obtain the offset quantization parameters of the encoded video frames of the keyframe type; if the specified type is a bidirectional difference frame type, then the encoding quantization parameters of the encoded video frames of the bidirectional difference frame type are mapped according to the second encoding offset parameter to obtain the offset quantization parameters of the encoded video frames of the bidirectional difference frame type.
在一种实现方式中,目标视频帧的类型为双向差别帧类型;处理单元902,用于根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数时,具体用于执行如下步骤:In one implementation, the target video frame is a bidirectional difference frame type; the processing unit 902 is used to estimate the quantization parameters of the target video frame based on the coding offset parameters, and to obtain the initial quantization parameters of the target video frame, specifically performs the following steps:
在目标视频中确定目标视频帧的参考视频帧;若参考视频帧的数量为一个,则将参考视频帧的参考量化参数确定为目标视频帧的初始量化参数;若参考视频帧的数量为M个,则获取M个参考视频帧中的每个参考视频帧的复杂度参数,并根据M个参考视频帧的复杂度参数对M个参考视频帧的参考量化参数进行加权求和计算,得到目标视频帧的初始量化参数,M为大于1的整数;其中,参考视频帧中的指定类型的参考视频帧的参考量化参数,是根据编码偏移参数对指定类型的参考视频帧的编码量化参数进行参数映射处理得到的;参考视频帧中的其他类型的参考视频帧的参考量化参数,是其他类型的参考视频帧的编码量化参数;其他类型的参考视频帧是指:参考视频帧中除指定类型的参考视频帧外的其他参考视频帧。In the target video, a reference video frame is determined. If there is only one reference video frame, its reference quantization parameter is used as the initial quantization parameter of the target video frame. If there are M reference video frames, the complexity parameter of each of the M reference video frames is obtained, and the reference quantization parameters of the M reference video frames are weighted and summed according to their complexity parameters to obtain the initial quantization parameter of the target video frame, where M is an integer greater than 1. The reference quantization parameter of a specified type of reference video frame is obtained by mapping the encoded quantization parameter of the specified type of reference video frame to the encoded quantization parameter based on the encoded offset parameter. The reference quantization parameter of other types of reference video frames is the encoded quantization parameter of those other types. Other types of reference video frames refer to all reference video frames other than those of the specified type.
在一种实现方式中,处理单元902,还用于执行如下步骤:In one implementation, the processing unit 902 is further configured to perform the following steps:
对目标视频帧进行类型检测;若目标视频帧的类型为关键帧类型或双向差别帧类型,则触发执行获取目标视频的视频属性特征,确定与视频属性特征相匹配的编码偏移参数的步骤;若目标视频帧的类型为前向差别帧类型,则获取目标视频帧的模糊复杂度参数,根据目标视频帧的模糊复杂度参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数。Type detection is performed on the target video frame; if the target video frame is a keyframe type or a bidirectional difference frame type, the step of obtaining the video attribute features of the target video and determining the encoding offset parameters that match the video attribute features is triggered; if the target video frame is a forward difference frame type, the fuzzy complexity parameter of the target video frame is obtained, and the quantization parameter of the target video frame is estimated based on the fuzzy complexity parameter of the target video frame to obtain the initial quantization parameters of the target video frame.
在一种实现方式中,处理单元902,用于获取目标视频帧的模糊复杂度参数时,具体用于执行如下步骤:In one implementation, when processing unit 902 obtains the fuzziness complexity parameter of the target video frame, it specifically performs the following steps:
获取目标视频帧的预测残差参数;根据目标视频的N个已编码视频帧的累积复杂度参数、N个已编码视频帧的累积帧数和目标视频帧的预测残差参数,确定目标视频帧的模糊复杂度参数,N为正整数;其中,累积复杂度参数是对N个已编码视频帧的复杂度参数进行加权累积得到的;累积帧数是对N个已编码视频帧的帧数进行加权累积得到的。Obtain the prediction residual parameters of the target video frame; determine the fuzzy complexity parameters of the target video frame based on the cumulative complexity parameters of the N encoded video frames, the cumulative frame count of the N encoded video frames, and the prediction residual parameters of the target video frame, where N is a positive integer; where the cumulative complexity parameter is obtained by weighted accumulation of the complexity parameters of the N encoded video frames; and the cumulative frame count is obtained by weighted accumulation of the frame counts of the N encoded video frames.
在一种实现方式中,处理单元902,用于根据目标视频帧的模糊复杂度参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数时,具体用于执行如下步骤:In one implementation, the processing unit 902 is used to estimate the quantization parameters of the target video frame based on the fuzziness complexity parameter of the target video frame, and to obtain the initial quantization parameters of the target video frame, specifically by performing the following steps:
获取目标视频帧的压缩因子,根据目标视频帧的模糊复杂度参数和所述压缩因子确定所述目标视频帧的量化等级参数;获取目标视频帧的累计分配信息量和目标视频帧的累积复杂度参数;目标视频帧的累计分配信息量是对目标视频帧的分配信息量和N个已编码视频帧的分配信息量进行累计得到的;目标视频帧的累积复杂度参数是根据N个已编码视频帧的累积复杂度参数和目标视频帧的预测残差参数确定的;根据目标视频帧的累计分配信息量和目标视频帧的累积复杂度参数,确定量化等级参数的优化因子;根据优化因子对量化等级参数进行优化,得到目标视频帧的初始量化参数。The compression factor of the target video frame is obtained, and the quantization level parameter of the target video frame is determined based on the fuzziness complexity parameter of the target video frame and the compression factor. The cumulative allocation information and cumulative complexity parameter of the target video frame are obtained. The cumulative allocation information is obtained by accumulating the allocation information of the target video frame and the allocation information of N encoded video frames. The cumulative complexity parameter of the target video frame is determined based on the cumulative complexity parameters of the N encoded video frames and the prediction residual parameter of the target video frame. An optimization factor for the quantization level parameter is determined based on the cumulative allocation information and cumulative complexity parameter of the target video frame. The quantization level parameter is optimized based on the optimization factor to obtain the initial quantization parameters of the target video frame.
在一种实现方式中,处理单元902,用于对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数时,具体用于执行如下步骤:In one implementation, the processing unit 902, when adjusting the initial quantization parameters of the target video frame to obtain the encoded quantization parameters of the target video frame, specifically performs the following steps:
根据目标视频中的N个已编码视频帧的累计编码信息量和N个已编码视频帧的累计分配信息量,确定对目标视频帧的初始量化参数的调整因子;N个已编码视频帧的累计编码信息量是对N个已编码视频帧的编码信息量进行累计得到的,N个已编码视频帧的累计分配信息量是对N个已编码视频帧的分配信息量进行累计得到的,N为正整数;根据调整因子对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数。Based on the cumulative encoded information and cumulative allocated information of N encoded video frames in the target video, an adjustment factor for the initial quantization parameters of the target video frame is determined. The cumulative encoded information of the N encoded video frames is obtained by accumulating the encoded information of the N encoded video frames, and the cumulative allocated information of the N encoded video frames is obtained by accumulating the allocated information of the N encoded video frames, where N is a positive integer. The initial quantization parameters of the target video frame are adjusted according to the adjustment factor to obtain the encoded quantization parameters of the target video frame.
根据本申请的另一个实施例,图9所示的视频处理装置中的各个单元可以分别或全部合并为一个或若干个另外的单元来构成,或者其中的某个(些)单元还可以再拆分为功能上更小的多个单元来构成,这可以实现同样的操作,而不影响本申请的实施例的技术效果的实现。上述单元是基于逻辑功能划分的,在实际应用中,一个单元的功能也可以由多个单元来实现,或者多个单元的功能由一个单元实现。在本申请的其它实施例中,资源处理装置也可以包括其它单元,在实际应用中,这些功能也可以由其它单元协助实现,并且可以由多个单元协作实现。According to another embodiment of this application, the various units in the video processing apparatus shown in FIG9 can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This can achieve the same operation without affecting the technical effect of the embodiments of this application. The above-mentioned units are based on logical function division. In practical applications, the function of one unit can also be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the resource processing apparatus may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.
根据本申请的另一个实施例,可以通过在包括中央处理单元(CPU)、随机存取存储介质(RAM)、只读存储介质(ROM)等处理元件和存储元件的例如计算机的通用计算设备上运行能够执行如图4、图5或图6所示的相应方法所涉及的各步骤的计算机程序(包括程序代码)来构造如图9中所示的视频处理装置,以及来实现本申请实施例的视频处理方法。计算机程序可以记载于例如计算机可读存储介质上,并通过计算机可读存储介质装载于上述计算设备中,并在其中运行。According to another embodiment of this application, the video processing apparatus shown in FIG9, and the video processing method of the embodiments of this application, can be constructed and implemented by running a computer program (including program code) capable of performing the steps involved in the corresponding methods shown in FIG4, 5, or 6 on a general-purpose computing device, such as a computer, which includes processing elements and storage elements such as a central processing unit (CPU), random access storage medium (RAM), and read-only storage medium (ROM). The computer program can be recorded on, for example, a computer-readable storage medium, loaded into the aforementioned computing device through the computer-readable storage medium, and run therein.
本申请实施例中,可以获取目标视频的视频属性特征,确定与视频属性特征相匹配的编码偏移参数,然后可以根据编码偏移参数对目标视频中待编码的目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数,然后可以对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数,从而可以根据目标视频帧的编码量化参数对目标视频帧进行编码处理;可见,本申请实施例中确定出的目标视频帧的编码量化参数与目标视频的视频属性特征相适配,也就是说,可以根据目标视频的视频属性特征针对性地确定出用于对目标视频帧进行编码处理的编码量化参数,这样可以在编码得到的视频码率满足目标带宽的前提下,使得视频消费端的视频呈现质量与QoE(Quality ofExperience,体验质量)指标之间的达到最佳平衡,提升视频编码效果。In this embodiment, video attribute features of the target video can be obtained, and encoding offset parameters matching the video attribute features can be determined. Then, quantization parameters of the target video frame to be encoded in the target video can be estimated based on the encoding offset parameters to obtain the initial quantization parameters of the target video frame. The initial quantization parameters of the target video frame can then be adjusted to obtain the encoding quantization parameters of the target video frame. Thus, the target video frame can be encoded based on the encoding quantization parameters. It can be seen that the encoding quantization parameters of the target video frame determined in this embodiment are compatible with the video attribute features of the target video. In other words, encoding quantization parameters for encoding the target video frame can be specifically determined based on the video attribute features of the target video. This allows for the optimal balance between the video presentation quality and the QoE (Quality of Experience) index at the video consumer end, while ensuring that the bitrate of the encoded video meets the target bandwidth, thereby improving the video encoding effect.
基于上述方法以及装置实施例,本申请实施例提供了一种计算机设备,请参见图10,图10是本申请实施例提供的一种计算机设备的结构示意图。图10所示的计算机设备至少包括处理器1001、输入接口1002、输出接口1003以及计算机可读存储介质1004。其中,处理器1001、输入接口1002、输出接口1003以及计算机可读存储介质1004可通过总线或其他方式连接。Based on the above methods and apparatus embodiments, this application provides a computer device. Please refer to FIG10, which is a schematic diagram of the structure of a computer device provided in this application embodiment. The computer device shown in FIG10 includes at least a processor 1001, an input interface 1002, an output interface 1003, and a computer-readable storage medium 1004. The processor 1001, input interface 1002, output interface 1003, and computer-readable storage medium 1004 can be connected via a bus or other means.
输入接口1002可以用于获取目标视频、获取目标视频的视频属性特征等等;输出接口1003可以用于输出编码处理得到的目标视频帧、编码处理得到的目标视频等等。The input interface 1002 can be used to acquire the target video, acquire the video attribute features of the target video, etc.; the output interface 1003 can be used to output the target video frame obtained by encoding processing, the target video obtained by encoding processing, etc.
计算机可读存储介质1004可以存储在计算机设备的存储器中,计算机可读存储介质1004用于存储计算机程序,计算机程序包括计算机指令,处理器1001用于执行计算机可读存储介质1004存储的程序指令。处理器1001(或称CPU(Central Processing Unit,中央处理器))是计算机设备的计算核心以及控制核心,其适于实现一条或多条计算机指令,具体适于加载并执行一条或多条计算机指令从而实现相应方法流程或相应功能。The computer-readable storage medium 1004 can be stored in the memory of a computer device. The computer-readable storage medium 1004 is used to store computer programs, including computer instructions. The processor 1001 is used to execute the program instructions stored in the computer-readable storage medium 1004. The processor 1001 (or CPU (Central Processing Unit)) is the computing and control core of the computer device, suitable for implementing one or more computer instructions, specifically suitable for loading and executing one or more computer instructions to achieve corresponding method flows or corresponding functions.
本申请实施例还提供了一种计算机可读存储介质(Memory),计算机可读存储介质是计算机设备中的记忆设备,用于存放程序和数据。可以理解的是,此处的计算机可读存储介质既可以包括计算机设备中的内置存储介质,当然也可以包括计算机设备支持的扩展存储介质。计算机可读存储介质提供存储空间,该存储空间存储了计算机设备的操作系统。并且,在该存储空间中还存放了适于被处理器加载并执行的一条或多条的计算机指令,这些计算机指令可以是一个或一个以上的计算机程序(包括程序代码)。需要说明的是,此处的计算机可读存储介质可以是高速RAM存储器,也可以是非不稳定的存储器(Non-VolatileMemory),例如至少一个磁盘存储器;可选的还可以是至少一个位于远离前述处理器的计算机可读存储介质。This application also provides a computer-readable storage medium (Memory), which is a memory device in a computer device used to store programs and data. It is understood that the computer-readable storage medium here can include both built-in storage media in the computer device and extended storage media supported by the computer device. The computer-readable storage medium provides storage space that stores the operating system of the computer device. Furthermore, the storage space also stores one or more computer instructions suitable for loading and execution by a processor. These computer instructions can be one or more computer programs (including program code). It should be noted that the computer-readable storage medium here can be high-speed RAM or non-volatile memory, such as at least one disk storage device; optionally, it can also be at least one computer-readable storage medium located remotely from the aforementioned processor.
计算机设备可以是前述提及的视频制作设备,可由处理器1001加载并执行计算机可读存储介质1004中存放的一条或多条计算机指令,以实现上述有关图4、图5或图6所示的视频处理方法的相应步骤。具体实现中,计算机可读存储介质1004中的计算机指令由处理器1001加载并执行如下步骤:The computer device can be the aforementioned video production device, which can load and execute one or more computer instructions stored in the computer-readable storage medium 1004 by the processor 1001 to implement the corresponding steps of the video processing method shown in Figures 4, 5, or 6. Specifically, the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 in the following steps:
从目标视频中获取待编码的目标视频帧;获取目标视频的视频属性特征,确定与视频属性特征相匹配的编码偏移参数;根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数;对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数;根据目标视频帧的编码量化参数对目标视频帧进行编码处理。The process involves: acquiring the target video frame to be encoded from the target video; obtaining the video attribute features of the target video and determining the encoding offset parameters that match the video attribute features; estimating the quantization parameters of the target video frame based on the encoding offset parameters to obtain the initial quantization parameters of the target video frame; adjusting the initial quantization parameters of the target video frame to obtain the encoded quantization parameters of the target video frame; and encoding the target video frame based on the encoded quantization parameters of the target video frame.
在一种实现方式中,视频属性特征包括目标视频的分辨率信息、目标视频所属的视频类型信息、目标视频的码率信息、以及目标视频的播放效果参考信息中的任一种或多种;其中,不同的视频属性特征所匹配的编码偏移参数不相同。In one implementation, the video attribute features include one or more of the following: resolution information of the target video, video type information of the target video, bitrate information of the target video, and playback effect reference information of the target video; wherein, the encoding offset parameters matched with different video attribute features are different.
在一种实现方式中,计算机可读存储介质1004中的计算机指令由处理器1001加载并执行确定与视频属性特征相匹配的编码偏移参数时,具体用于执行如下步骤:In one implementation, when the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to determine the encoding offset parameters that match the video attribute features, they are specifically used to perform the following steps:
在参数匹配关系中确定与视频属性特征相匹配的属性特征指示信息,参数匹配关系包括多个属性特征指示信息和每个属性特征指示信息对应的参考偏移参数;将相匹配的属性特征指示信息对应的参考偏移参数,确定为与视频属性特征相匹配的编码偏移参数。In the parameter matching relationship, the attribute feature indication information that matches the video attribute feature is determined. The parameter matching relationship includes multiple attribute feature indication information and a reference offset parameter corresponding to each attribute feature indication information. The reference offset parameter corresponding to the matching attribute feature indication information is determined as the encoding offset parameter that matches the video attribute feature.
在一种实现方式中,目标视频帧的类型为关键帧类型;计算机可读存储介质1004中的计算机指令由处理器1001加载并执行根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数时,具体用于执行如下步骤:In one implementation, the target video frame is a keyframe type; when the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to estimate the quantization parameters of the target video frame based on the encoding offset parameters and obtain the initial quantization parameters of the target video frame, the instructions specifically perform the following steps:
根据编码偏移参数对目标视频的N个已编码视频帧中指定类型的已编码视频帧的编码量化参数进行参数映射处理,得到指定类型的已编码视频帧的偏移量化参数,N为正整数;根据指定类型的已编码视频帧的偏移量化参数和N个已编码视频帧中其他类型的已编码视频帧的编码量化参数,确定N个已编码视频帧的统计参数;其他类型的已编码视频帧是指:N个已编码视频帧中除指定类型的已编码视频帧外的其他已编码视频帧;根据N个已编码视频帧的统计参数和N个已编码视频帧的数量,确定目标视频帧的初始量化参数。Based on the coding offset parameters, the coding quantization parameters of the specified type of encoded video frames among the N encoded video frames of the target video are mapped to obtain the offset quantization parameters of the specified type of encoded video frames, where N is a positive integer. Based on the offset quantization parameters of the specified type of encoded video frames and the coding quantization parameters of other types of encoded video frames among the N encoded video frames, the statistical parameters of the N encoded video frames are determined. Other types of encoded video frames refer to: other encoded video frames among the N encoded video frames besides the specified type of encoded video frames. Based on the statistical parameters of the N encoded video frames and the number of N encoded video frames, the initial quantization parameters of the target video frame are determined.
在一种实现方式中,编码偏移参数包括第一编码偏移参数和第二编码偏移参数;计算机可读存储介质1004中的计算机指令由处理器1001加载并执行根据编码偏移参数对目标视频的N个已编码视频帧中指定类型的已编码视频帧的编码量化参数进行参数映射处理,得到指定类型的已编码视频帧的偏移量化参数时,具体用于执行如下步骤:In one implementation, the encoding offset parameter includes a first encoding offset parameter and a second encoding offset parameter; when the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to perform parameter mapping processing on the encoding quantization parameters of the specified type of encoded video frames among the N encoded video frames of the target video according to the encoding offset parameter, and to obtain the offset quantization parameters of the specified type of encoded video frames, the instructions are specifically used to perform the following steps:
若指定类型为关键帧类型,则根据第一编码偏移参数对关键帧类型的已编码视频帧的编码量化参数进行参数映射处理,得到关键帧类型的已编码视频帧的偏移量化参数;若指定类型为双向差别帧类型,则根据第二编码偏移参数对双向差别帧类型的已编码视频帧的编码量化参数进行参数映射处理,得到双向差别帧类型的已编码视频帧的偏移量化参数。If the specified type is a keyframe type, then the encoding quantization parameters of the encoded video frames of the keyframe type are mapped according to the first encoding offset parameter to obtain the offset quantization parameters of the encoded video frames of the keyframe type; if the specified type is a bidirectional difference frame type, then the encoding quantization parameters of the encoded video frames of the bidirectional difference frame type are mapped according to the second encoding offset parameter to obtain the offset quantization parameters of the encoded video frames of the bidirectional difference frame type.
在一种实现方式中,目标视频帧的类型为双向差别帧类型;计算机可读存储介质1004中的计算机指令由处理器1001加载并执行根据编码偏移参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数时,具体用于执行如下步骤:In one implementation, the target video frame is a bidirectional difference frame type; when the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to estimate the quantization parameters of the target video frame based on the coding offset parameters and obtain the initial quantization parameters of the target video frame, they are specifically used to perform the following steps:
在目标视频中确定目标视频帧的参考视频帧;若参考视频帧的数量为一个,则将参考视频帧的参考量化参数确定为目标视频帧的初始量化参数;若参考视频帧的数量为M个,则获取M个参考视频帧中的每个参考视频帧的复杂度参数,并根据M个参考视频帧的复杂度参数对M个参考视频帧的参考量化参数进行加权求和计算,得到目标视频帧的初始量化参数,M为大于1的整数;其中,参考视频帧中的指定类型的参考视频帧的参考量化参数,是根据编码偏移参数对指定类型的参考视频帧的编码量化参数进行参数映射处理得到的;参考视频帧中的其他类型的参考视频帧的参考量化参数,是其他类型的参考视频帧的编码量化参数;其他类型的参考视频帧是指:参考视频帧中除指定类型的参考视频帧外的其他参考视频帧。In the target video, a reference video frame is determined. If there is only one reference video frame, its reference quantization parameter is used as the initial quantization parameter of the target video frame. If there are M reference video frames, the complexity parameter of each of the M reference video frames is obtained, and the reference quantization parameters of the M reference video frames are weighted and summed according to their complexity parameters to obtain the initial quantization parameter of the target video frame, where M is an integer greater than 1. The reference quantization parameter of a specified type of reference video frame is obtained by mapping the encoded quantization parameter of the specified type of reference video frame to the encoded quantization parameter based on the encoded offset parameter. The reference quantization parameter of other types of reference video frames is the encoded quantization parameter of those other types. Other types of reference video frames refer to all reference video frames other than those of the specified type.
在一种实现方式中,计算机可读存储介质1004中的计算机指令由处理器1001加载并还用于执行如下步骤:In one implementation, the computer instructions in the computer-readable storage medium 1004 are loaded by the processor 1001 and are also used to perform the following steps:
对目标视频帧进行类型检测;若目标视频帧的类型为关键帧类型或双向差别帧类型,则触发执行获取目标视频的视频属性特征,确定与视频属性特征相匹配的编码偏移参数的步骤;若目标视频帧的类型为前向差别帧类型,则获取目标视频帧的模糊复杂度参数,根据目标视频帧的模糊复杂度参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数。Type detection is performed on the target video frame; if the target video frame is a keyframe type or a bidirectional difference frame type, the step of obtaining the video attribute features of the target video and determining the encoding offset parameters that match the video attribute features is triggered; if the target video frame is a forward difference frame type, the fuzzy complexity parameter of the target video frame is obtained, and the quantization parameter of the target video frame is estimated based on the fuzzy complexity parameter of the target video frame to obtain the initial quantization parameters of the target video frame.
在一种实现方式中,计算机可读存储介质1004中的计算机指令由处理器1001加载并执行获取目标视频帧的模糊复杂度参数时,具体用于执行如下步骤:In one implementation, when the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to obtain the fuzzy complexity parameter of the target video frame, they are specifically used to perform the following steps:
获取目标视频帧的预测残差参数;根据目标视频的N个已编码视频帧的累积复杂度参数、N个已编码视频帧的累积帧数和目标视频帧的预测残差参数,确定目标视频帧的模糊复杂度参数,N为正整数;其中,累积复杂度参数是对N个已编码视频帧的复杂度参数进行加权累积得到的;累积帧数是对N个已编码视频帧的帧数进行加权累积得到的。Obtain the prediction residual parameters of the target video frame; determine the fuzzy complexity parameters of the target video frame based on the cumulative complexity parameters of the N encoded video frames, the cumulative frame count of the N encoded video frames, and the prediction residual parameters of the target video frame, where N is a positive integer; where the cumulative complexity parameter is obtained by weighted accumulation of the complexity parameters of the N encoded video frames; and the cumulative frame count is obtained by weighted accumulation of the frame counts of the N encoded video frames.
在一种实现方式中,计算机可读存储介质1004中的计算机指令由处理器1001加载并执行根据目标视频帧的模糊复杂度参数对目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数时,具体用于执行如下步骤:In one implementation, when the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to estimate the quantization parameters of the target video frame based on the fuzziness complexity parameter of the target video frame, and obtain the initial quantization parameters of the target video frame, the instructions specifically perform the following steps:
获取目标视频帧的压缩因子,根据目标视频帧的模糊复杂度参数和所述压缩因子确定所述目标视频帧的量化等级参数;获取目标视频帧的累计分配信息量和目标视频帧的累积复杂度参数;目标视频帧的累计分配信息量是对目标视频帧的分配信息量和N个已编码视频帧的分配信息量进行累计得到的;目标视频帧的累积复杂度参数是根据N个已编码视频帧的累积复杂度参数和目标视频帧的预测残差参数确定的;根据目标视频帧的累计分配信息量和目标视频帧的累积复杂度参数,确定量化等级参数的优化因子;根据优化因子对量化等级参数进行优化,得到目标视频帧的初始量化参数。The compression factor of the target video frame is obtained, and the quantization level parameter of the target video frame is determined based on the fuzziness complexity parameter of the target video frame and the compression factor. The cumulative allocation information and cumulative complexity parameter of the target video frame are obtained. The cumulative allocation information is obtained by accumulating the allocation information of the target video frame and the allocation information of N encoded video frames. The cumulative complexity parameter of the target video frame is determined based on the cumulative complexity parameters of the N encoded video frames and the prediction residual parameter of the target video frame. An optimization factor for the quantization level parameter is determined based on the cumulative allocation information and cumulative complexity parameter of the target video frame. The quantization level parameter is optimized based on the optimization factor to obtain the initial quantization parameters of the target video frame.
在一种实现方式中,计算机可读存储介质1004中的计算机指令由处理器1001加载并执行对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数时,具体用于执行如下步骤:In one implementation, when the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to adjust the initial quantization parameters of the target video frame and obtain the encoded quantization parameters of the target video frame, they are specifically used to perform the following steps:
根据目标视频中的N个已编码视频帧的累计编码信息量和N个已编码视频帧的累计分配信息量,确定对目标视频帧的初始量化参数的调整因子;N个已编码视频帧的累计编码信息量是对N个已编码视频帧的编码信息量进行累计得到的,N个已编码视频帧的累计分配信息量是对N个已编码视频帧的分配信息量进行累计得到的,N为正整数;根据调整因子对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数。Based on the cumulative encoded information and cumulative allocated information of N encoded video frames in the target video, an adjustment factor for the initial quantization parameters of the target video frame is determined. The cumulative encoded information of the N encoded video frames is obtained by accumulating the encoded information of the N encoded video frames, and the cumulative allocated information of the N encoded video frames is obtained by accumulating the allocated information of the N encoded video frames, where N is a positive integer. The initial quantization parameters of the target video frame are adjusted according to the adjustment factor to obtain the encoded quantization parameters of the target video frame.
本申请实施例中,可以获取目标视频的视频属性特征,确定与视频属性特征相匹配的编码偏移参数,然后可以根据编码偏移参数对目标视频中待编码的目标视频帧进行量化参数估计,得到目标视频帧的初始量化参数,然后可以对目标视频帧的初始量化参数进行调整,得到目标视频帧的编码量化参数,从而可以根据目标视频帧的编码量化参数对目标视频帧进行编码处理;可见,本申请实施例中确定出的目标视频帧的编码量化参数与目标视频的视频属性特征相适配,也就是说,可以根据目标视频的视频属性特征针对性地确定出用于对目标视频帧进行编码处理的编码量化参数,这样可以在编码得到的视频码率满足目标带宽的前提下,使得视频消费端的视频呈现质量与QoE(Quality ofExperience,体验质量)指标之间的达到最佳平衡,提升视频编码效果。In this embodiment, video attribute features of the target video can be obtained, and encoding offset parameters matching the video attribute features can be determined. Then, quantization parameters of the target video frame to be encoded in the target video can be estimated based on the encoding offset parameters to obtain the initial quantization parameters of the target video frame. The initial quantization parameters of the target video frame can then be adjusted to obtain the encoding quantization parameters of the target video frame. Thus, the target video frame can be encoded based on the encoding quantization parameters. It can be seen that the encoding quantization parameters of the target video frame determined in this embodiment are compatible with the video attribute features of the target video. In other words, encoding quantization parameters for encoding the target video frame can be specifically determined based on the video attribute features of the target video. This allows for the optimal balance between the video presentation quality and the QoE (Quality of Experience) index at the video consumer end, while ensuring that the bitrate of the encoded video meets the target bandwidth, thereby improving the video encoding effect.
根据本申请的一个方面,提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行上述各种可选方式中提供的视频处理方法。According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the video processing methods provided in the various alternative embodiments described above.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims (14)
Publications (1)
| Publication Number | Publication Date |
|---|---|
| HK40091101A true HK40091101A (en) | 2023-12-01 |
Family
ID=
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11659212B1 (en) | Content delivery of live streams with playback-conditions-adaptive encoding | |
| US9398301B2 (en) | Parallel video encoding based on complexity analysis | |
| CN116634151A (en) | Video processing method, device, computer equipment, storage medium and program product | |
| CN113766226A (en) | Image encoding method, apparatus, device and storage medium | |
| US10129552B2 (en) | Method and system for rate control during video transcoding | |
| JP5180294B2 (en) | Buffer-based rate control that utilizes frame complexity, buffer level, and intra-frame location in video encoding | |
| US9071841B2 (en) | Video transcoding with dynamically modifiable spatial resolution | |
| EP2441265B1 (en) | Motion based dynamic resolution multiple bit rate video encoding | |
| US10356448B2 (en) | Multi representation edge server with enhanced open-GOP compression | |
| JP7012747B2 (en) | Video frame coding method, terminal, and storage medium | |
| CN107846590B (en) | Video coding method and video coder | |
| US10616590B1 (en) | Optimizing streaming video encoding profiles | |
| KR20050013619A (en) | Fgs decoder based on quality estimated at the decoder | |
| CN103402099A (en) | Picture-level rate control for video encoding | |
| US20090074075A1 (en) | Efficient real-time rate control for video compression processes | |
| CN113973202B (en) | Video encoding method, device, equipment and storage medium | |
| US20190238856A1 (en) | Estimating video quality of experience | |
| CN116055726A (en) | A low-delay layered video coding method, computer equipment and medium | |
| CN117956167A (en) | Code rate control method and device for video coding and computer readable storage medium | |
| CN114745590B (en) | Video frame coding method, device, electronic equipment and medium | |
| WO2023071469A1 (en) | Video processing method, electronic device and storage medium | |
| HK40091101A (en) | Video processing method, apparatus, computer device, storage medium and program product | |
| CN119815115A (en) | Video encoding method and device, method for generating bit stream, electronic device, storage medium and program product | |
| CN117478881B (en) | Video information processing method, system, device and storage medium | |
| CN110971900A (en) | Code rate control method suitable for 4K and 8K ultrahigh-definition motion flat video |