CN115955564A - Video coding method, device, equipment and medium - Google Patents
Video coding method, device, equipment and medium Download PDFInfo
- Publication number
- CN115955564A CN115955564A CN202211731021.1A CN202211731021A CN115955564A CN 115955564 A CN115955564 A CN 115955564A CN 202211731021 A CN202211731021 A CN 202211731021A CN 115955564 A CN115955564 A CN 115955564A
- Authority
- CN
- China
- Prior art keywords
- video frame
- target
- video
- image block
- ratio
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
Description
技术领域technical field
本发明涉及视频编解码技术领域,尤其涉及一种视频编码方法、装置、设备和介质。The present invention relates to the technical field of video encoding and decoding, in particular to a video encoding method, device, equipment and medium.
背景技术Background technique
视频编解码技术旨在将对采集到的视频压缩成不同的标准格式的数据,用于传输或存储,视频编解码的标准有H.264/先进视频编码标准(Advanced Video Coding,AVC)、H.265/高性能视频编码标准(High Efficiency Video Coding,HEVC)、H.266/通用视频编码标准(Versatile Video Coding,VVC)等。Video codec technology aims to compress the collected video into data in different standard formats for transmission or storage. Video codec standards include H.264/Advanced Video Coding (AVC), H. .265/High Efficiency Video Coding (HEVC), H.266/Versatile Video Coding (VVC), etc.
码率控制是视频编码标准的关键技术之一,通过对编码过程中的编码参数进行调节,可以对视频数据进行数据压缩,进而控制各个时刻的码率大小。视频中的每一幅图片被称为一帧,一帧压缩后的大小与编码器在编码过程中的参数相关,这些参数包括帧的类型、运动信息、量化参数(Quanlization Parameter,QP)等。上述参数中的量化参数控制的是有损量化处理过程中损失数据量的大小,对编码帧的大小有直接影响。Bit rate control is one of the key technologies of video coding standards. By adjusting the coding parameters in the coding process, video data can be compressed, and then the bit rate at each moment can be controlled. Each picture in the video is called a frame, and the compressed size of a frame is related to the parameters of the encoder during the encoding process. These parameters include frame type, motion information, quantization parameter (Quanlization Parameter, QP), etc. The quantization parameter in the above parameters controls the amount of data lost during the lossy quantization process, and has a direct impact on the size of the encoded frame.
现有技术中基于量化参数进行码率控制的常用方式有:固定码率(Constant BitRate,CBR)和可变码率(Variable Bit Rate,VBR)。CBR对码率控制的要求相比VBR更加严格,因为CBR要求局部码率保持恒定,而VBR允许局部码率在一定范围内浮动,而保持主观质量的稳定。随着多媒体技术的发展,对视频流的码率控制的性能要求也提高,对CBR而言,一个准确的码率控制,可以最大限度的满足不浪费带宽传输的数据,对VBR而言,则能够在保持主观质量的前提下尽可能的节省码率。In the prior art, the commonly used ways of performing bit rate control based on quantization parameters are: constant bit rate (Constant Bit Rate, CBR) and variable bit rate (Variable Bit Rate, VBR). CBR has stricter requirements on bit rate control than VBR, because CBR requires local bit rates to remain constant, while VBR allows local bit rates to fluctuate within a certain range while maintaining the stability of subjective quality. With the development of multimedia technology, the performance requirements for bit rate control of video streams have also increased. For CBR, an accurate bit rate control can satisfy the data transmitted without wasting bandwidth to the greatest extent. For VBR, then It can save the bit rate as much as possible while maintaining the subjective quality.
码率控制一般会从三个层面对码率进行控制,分别为:图片组(Group ofPicture,GOP)级、帧级、宏块级;GOP级码控是指视频在编码时通常被划分为多个连续的GOP,是码率控制过程中进行处理的最大单元,GOP级码控过程会根据目标码率以及缓冲区状态为每个GOP合理地分配目标比特数;帧级码控是指每个GOP中又会包含多个视频帧,帧级码控过程则会根据该GOP总的目标比特数以及视频帧的特性为每帧图像分配目标比特数;宏块级码控过程对整帧视频中的每个编码宏块单独进行分析,根据每个编码宏块的特性得到宏块的比特;在根据GOP级、帧级、宏块级的比特计算量化参数时,采用的是率失真理论,率失真理论在数据压缩中,为数据压缩的性能提供理论极限和比较标准,依靠率失真理论提高视频压缩质量的方法被称为率失真优化(Rate-distortion optimization,RDO);R-λ模型作为码率控制模型中的一种,使用的就是率失真优化,通过R-λ模型构建了分配比特(R)与率失真参数(λ)之间的数学关系模型,再通过率失真参数(λ)与量化参数(QP)之间的映射关系,求出量化参数,从而控制码率的大小。而R-Q模型则直接构建了分配比特(R)与量化因子(Qscale)之间的数学关系模型,再由Qscale计算得到QP。Code rate control generally controls the code rate from three levels, namely: Group of Picture (GOP) level, frame level, and macroblock level; GOP level code control means that video is usually divided into multiple levels during encoding. A continuous GOP is the largest unit for processing in the rate control process. The GOP-level code control process will reasonably allocate the target number of bits for each GOP according to the target code rate and buffer status; frame-level code control refers to each Multiple video frames will be included in the GOP, and the frame-level code control process will allocate the target number of bits for each frame of image according to the total target number of bits of the GOP and the characteristics of the video frame; Each coded macroblock is analyzed separately, and the bits of the macroblock are obtained according to the characteristics of each coded macroblock; when the quantization parameters are calculated according to the bits of the GOP level, frame level, and macroblock level, the rate-distortion theory is used. In data compression, distortion theory provides a theoretical limit and comparison standard for the performance of data compression. The method of improving video compression quality by relying on rate-distortion theory is called rate-distortion optimization (RDO); R-λ model is used as a code One of the rate control models uses rate-distortion optimization. The mathematical relationship model between the allocated bits (R) and the rate-distortion parameter (λ) is constructed through the R-λ model, and then the rate-distortion parameter (λ) and the The mapping relationship between quantization parameters (QP) is calculated to obtain the quantization parameters, thereby controlling the size of the code rate. The R-Q model directly constructs the mathematical relationship model between the allocated bit (R) and the quantization factor (Qscale), and then calculates the QP by Qscale.
现有技术中的视频监控场景判别方法及其监控图像编码方法、及装置中,将监控得到的前一视频帧以及当前视频帧相减得到残差帧,然后统计残差帧非零像素点数目与残差帧所有像素点的比值,若比值大于设定的阈值,则认为当前场景为运动场景,否则为静止场景,针对识别到的运动场景或静止场景,采用运动场景或静止场景的图像编码方法,从而实现了监控图像编码。In the video monitoring scene discrimination method and its monitoring image encoding method and device in the prior art, the previous video frame and the current video frame obtained by monitoring are subtracted to obtain a residual frame, and then the number of non-zero pixels in the residual frame is counted The ratio of all pixels to the residual frame. If the ratio is greater than the set threshold, the current scene is considered to be a motion scene, otherwise it is a static scene. For the identified motion scene or static scene, the image encoding of the motion scene or static scene is used method, thereby realizing the monitoring image coding.
但是现有技术在静态场景下,两帧之间的像素值基本仍会存在部分的差异,直接用非零像素与所有像素的比值来确定其是否为运动场景或者静态场景,容易产生误判;并且对于一个场景,只粗略的分为运动场景和静止场景,而在实际应用中,存在多种情况,例如大运动场景、中等运动场景、小运动场景、静止场景等;因此的视频编码方法节省码率的效果较差。However, in the prior art, in a static scene, the pixel values between two frames basically still have partial differences, and the ratio of non-zero pixels to all pixels is directly used to determine whether it is a moving scene or a static scene, which is prone to misjudgment; And for a scene, it is only roughly divided into a motion scene and a static scene, and in practical applications, there are many situations, such as a large motion scene, a medium motion scene, a small motion scene, a static scene, etc.; therefore, the video coding method saves Bit rate is less effective.
发明内容Contents of the invention
本发明提供了一种视频编码方法、装置、设备和介质,用以解决现有的视频编码方法节省码率的效果较差的问题。The present invention provides a video coding method, device, equipment and medium to solve the problem that the existing video coding method has poor bit rate saving effect.
本发明提供了一种视频编码方法,所述方法包括:The present invention provides a video encoding method, the method comprising:
获取目标视频中的每个视频帧;Get each video frame in the target video;
针对所述每个视频帧,将该视频帧划分为预设大小的每个图像块,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值,根据所述目标比值、以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的运动等级为该视频帧的目标运动等级,其中所述预设大小为单个像素点大小或预设边长的矩形大小;For each video frame, divide the video frame into each image block of a preset size, determine the target ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame, according to the target Ratio, and the corresponding relationship between the numerical range and the motion level, determine that the motion level corresponding to the target numerical range where the target ratio is located is the target motion level of the video frame, wherein the preset size is the size of a single pixel point or the preset side length the size of the rectangle;
针对所述每个视频帧,根据该视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数;For each video frame, determine the target bit rate coefficient of the video frame according to the target motion level of the video frame and the first mapping relationship between the bit rate coefficient and the motion level;
针对所述每个视频帧,将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特;For each video frame, input the target code rate coefficient of the video frame, the maximum bit of the group of pictures and the number of frames contained in the group of pictures into the bit determination function of the video frame, and determine the target bit of the output video frame;
针对所述每个视频帧,将该视频帧的目标比特输入到码率控制模型,得到输出的该视频帧的量化参数;For each video frame, the target bit of the video frame is input to the code rate control model to obtain the quantization parameter of the video frame output;
根据所述目标视频中所述每个视频帧的量化参数,对所述目标视频中所述每个视频帧进行编码,得到压缩后的码流。Encoding each video frame in the target video according to the quantization parameter of each video frame in the target video to obtain a compressed code stream.
进一步地,所述确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值包括:Further, the determination of the target ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame includes:
确定该视频帧的前背景掩膜图像,根据所述前背景掩膜图像确定该视频帧中的前景图像块,根据该视频帧中前景图像块的第一数量以及该视频帧中图像块的总数量,得到所述第一数量与所述总数量的目标比值。Determine the front background mask image of the video frame, determine the foreground image blocks in the video frame according to the front background mask image, and determine the foreground image blocks in the video frame according to the first number of foreground image blocks in the video frame and the total number of image blocks in the video frame Quantity, to obtain a target ratio of the first quantity to the total quantity.
进一步地,所述对该视频帧进行检测确定该视频帧的前背景掩膜图像之后,所述根据所述前背景掩膜图像确定该视频帧中的前景图像块之前,所述方法还包括:Further, after the video frame is detected to determine the foreground background mask image of the video frame, before the foreground image block in the video frame is determined according to the foreground background mask image, the method further includes:
对所述前背景掩膜图像进行连通域标记,确定每个连通域的预设参数的第一参数值,其中所述预设参数为连通域面积或连通域内像素点个数,针对每个连通域,判断该连通域的第一参数值是否小于第一预设阈值,若是将该连通域内所有像素点的掩膜值均填充为背景掩膜值,若否将该连通域内所有像素点的掩膜值均填充为前景掩膜值,得到更新后的前背景掩膜图像;Mark the connected domains on the foreground and background mask images, and determine the first parameter value of the preset parameters of each connected domain, wherein the preset parameters are the area of the connected domain or the number of pixels in the connected domain, for each connected domain Domain, judge whether the first parameter value of the connected domain is less than the first preset threshold, if it is filled with the mask values of all pixels in the connected domain as the background mask value, if not, the mask values of all pixels in the connected domain The film values are all filled as the foreground mask value, and the updated foreground and background mask image is obtained;
根据更新后的前背景掩膜图像,确定该视频帧中更新后的前景图像块。An updated foreground image block in the video frame is determined according to the updated foreground and background mask image.
进一步地,所述对所述前背景掩膜图像进行连通域标记之前,所述方法还包括:Further, before performing connected domain marking on the foreground and background mask image, the method further includes:
根据所述前背景掩膜图像,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的第一比值,根据所述第一比值、第二预设阈值以及第三预设阈值,判断所述第一比值是否小于所述第二预设阈值,其中所述第三预设阈值大于所述第二预设阈值,若是,对所述前背景掩膜图像进行先膨胀后腐蚀的处理;若否,判断所述第一比值是否大于所述第三预设阈值,若是,对所述前背景掩膜图像进行先腐蚀后膨胀的处理,若否,不进行处理。According to the foreground and background mask image, determine the first ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame, according to the first ratio, the second preset threshold and the third preset Threshold, judging whether the first ratio is less than the second preset threshold, wherein the third preset threshold is greater than the second preset threshold, if so, first expand and then corrode the front and background mask image If not, judge whether the first ratio is greater than the third preset threshold, if yes, perform erosion and then dilation processing on the foreground and background mask image, if not, do not perform processing.
进一步地,所述将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特包括:Further, inputting the target code rate coefficient of the video frame, the maximum bit of the picture group and the number of frames contained in the picture group into the bit determination function of the video frame, and determining the output target bit of the video frame includes:
若该视频帧为关键帧,判断该视频帧是否为第一个关键帧,若是,则确定图片组的最大比特与预设系数的第一乘积值,将所述第一乘积值确定为该视频帧的目标比特,若否,则确定该视频帧的所述目标码率系数与该视频帧的上一帧的码率系数的第二比值,并确定所述第二比值与该视频帧的上一帧的比特的第二乘积值,将所述第二乘积值确定为该视频帧的目标比特;If the video frame is a key frame, judge whether the video frame is the first key frame, if so, determine the first product value of the maximum bit of the picture group and the preset coefficient, and determine the first product value as the video frame The target bit of the frame, if not, then determine the second ratio of the target code rate coefficient of the video frame and the code rate coefficient of the last frame of the video frame, and determine the second ratio and the last ratio of the video frame A second product value of the bits of a frame, determining the second product value as the target bit of the video frame;
若该视频帧为非关键帧,则确定所述最大比特减第一个关键帧的比特的第一差值,并确定图片组包含的视频帧数量减预设数量的第二差值,根据所述第一差值和所述第二差值的第三比值、以及所述目标码率系数,确定所述第三比值与该视频帧的所述目标码率系数的第三乘积值,将所述第三乘积值确定为该视频帧的目标比特。If the video frame is a non-key frame, then determine the first difference between the maximum bit minus the bit of the first key frame, and determine the second difference between the number of video frames included in the group of pictures minus the preset number, according to the determined The third ratio between the first difference and the second difference, and the target code rate coefficient, determine the third product value of the third ratio and the target code rate coefficient of the video frame, and convert the The third product value is determined as the target bit of the video frame.
相应地,本发明提供了一种视频编码方法,所述方法包括:Correspondingly, the present invention provides a video encoding method, the method comprising:
获取目标视频中的每个视频帧;Get each video frame in the target video;
针对所述每个视频帧,将该视频帧划分为预设大小的每个图像块,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值,根据所述目标比值、以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的运动等级为该视频帧的目标运动等级,其中所述预设大小为单个像素点大小或预设边长的矩形大小;For each video frame, divide the video frame into each image block of a preset size, determine the target ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame, according to the target Ratio, and the corresponding relationship between the numerical range and the motion level, determine that the motion level corresponding to the target numerical range where the target ratio is located is the target motion level of the video frame, wherein the preset size is the size of a single pixel point or the preset side length the size of the rectangle;
针对所述每个视频帧,根据该视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数;For each video frame, determine the target bit rate coefficient of the video frame according to the target motion level of the video frame and the first mapping relationship between the bit rate coefficient and the motion level;
针对所述每个视频帧,将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特,根据该视频帧的每个像素点的像素值,确定该视频帧和该视频帧的每个图像块的纹理复杂度的每个第二参数值,其中所述纹理复杂度为梯度、方差、平均绝对差和绝对误差和等参数中的任一种;For each video frame, the target code rate coefficient of the video frame, the maximum bit of the group of pictures and the number of frames included in the group of pictures are input into the bit determination function of the video frame, and the target bit of the output video frame is determined, According to the pixel value of each pixel of the video frame, determine each second parameter value of the texture complexity of the video frame and each image block of the video frame, wherein the texture complexity is gradient, variance, average Any of the parameters such as absolute difference and absolute error sum;
针对该视频帧的每个图像块,确定该图像块的第二参数值和该视频帧的第二参数值的第四比值,并确定所述第四比值与该视频帧的所述目标比特的第四乘积值为该图像块的第一比特,将该图像块的第一比特输入到码率控制模型,得到输出的该图像块的候选量化参数;For each image block of the video frame, determine a fourth ratio between the second parameter value of the image block and the second parameter value of the video frame, and determine the ratio between the fourth ratio and the target bit of the video frame The fourth product value is the first bit of the image block, and the first bit of the image block is input to the code rate control model to obtain the output candidate quantization parameter of the image block;
若该图像块为前景图像块,根据预先保存的第二映射关系,确定该图像块的所述候选量化参数在所述第二映射关系中对应的目标量化参数,若该图像块为背景图像块,根据预先保存的第三映射关系,确定该图像块的所述候选量化参数在所述第三映射关系中对应的目标量化参数;If the image block is a foreground image block, according to the pre-saved second mapping relationship, determine the target quantization parameter corresponding to the candidate quantization parameter of the image block in the second mapping relationship, if the image block is a background image block , according to a pre-stored third mapping relationship, determine a target quantization parameter corresponding to the candidate quantization parameter of the image block in the third mapping relationship;
根据所述目标视频中所述每个视频帧的每个图像块的目标量化参数,对所述目标视频中所述每个视频帧的每个图像块进行编码。Encoding each image block of each video frame in the target video according to the target quantization parameter of each image block in each video frame in the target video.
相应地,本发明提供了一种视频编码装置,所述装置包括:Correspondingly, the present invention provides a video encoding device, the device comprising:
获取模块,用于获取目标视频中的每个视频帧;Obtain module, be used for obtaining each video frame in target video;
第一确定模块,用于针对所述每个视频帧,将该视频帧划分为预设大小的每个图像块,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值,根据所述目标比值、以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的运动等级为该视频帧的目标运动等级,其中所述预设大小为单个像素点大小或预设边长的矩形大小;The first determining module is used to divide the video frame into each image block of a preset size for each video frame, and determine that the number of foreground image blocks in the video frame accounts for the total number of image blocks in the video frame Target ratio, according to the corresponding relationship between the target ratio and the value range and the motion level, determine that the motion level corresponding to the target value range where the target ratio is located is the target motion level of the video frame, wherein the preset size is a single pixel point size or rectangle size with preset side lengths;
第二确定模块,用于针对所述每个视频帧,根据该视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数;The second determination module is used to determine the target code rate coefficient of the video frame according to the target motion level of the video frame and the first mapping relationship between the code rate coefficient and the motion level for each video frame;
第三确定模块,用于针对所述每个视频帧,将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特;The third determining module is used to input the target code rate coefficient of the video frame, the maximum bit of the picture group and the number of frames contained in the picture group into the bit determination function of the video frame for each video frame, and determine the output the target bits for the video frame;
第四确定模块,用于针对所述每个视频帧,将该视频帧的目标比特输入到码率控制模型,得到输出的该视频帧的量化参数;The fourth determining module is used for each video frame, inputting the target bit of the video frame into the code rate control model to obtain the output quantization parameter of the video frame;
编码模块,用于根据所述目标视频中所述每个视频帧的量化参数,对所述目标视频中所述每个视频帧进行编码,得到压缩后的码流。An encoding module, configured to encode each video frame in the target video according to the quantization parameter of each video frame in the target video to obtain a compressed code stream.
进一步地,所述第一确定模块,具体用于确定该视频帧的前背景掩膜图像,根据所述前背景掩膜图像确定该视频帧中的前景图像块,根据该视频帧中前景图像块的第一数量以及该视频帧中图像块的总数量,得到所述第一数量与所述总数量的目标比值。Further, the first determination module is specifically configured to determine the foreground background mask image of the video frame, determine the foreground image block in the video frame according to the foreground background mask image, and determine the foreground image block in the video frame according to the foreground image block in the video frame. and the total number of image blocks in the video frame to obtain a target ratio of the first number to the total number.
进一步地,所述第一确定模块,还用于所述对该视频帧进行检测确定该视频帧的前背景掩膜图像之后,所述根据所述前背景掩膜图像确定该视频帧中的前景图像块之前,对所述前背景掩膜图像进行连通域标记,确定每个连通域的预设参数的第一参数值,其中所述预设参数为连通域面积或连通域内像素点个数,针对每个连通域,判断该连通域的第一参数值是否小于第一预设阈值,若是将该连通域内所有像素点的掩膜值均填充为背景掩膜值,若否将该连通域内所有像素点的掩膜值均填充为前景掩膜值,得到更新后的前背景掩膜图像;根据更新后的前背景掩膜图像,确定该视频帧中更新后的前景图像块。Further, the first determining module is also used for determining the foreground in the video frame according to the foreground and background mask image after the detection of the video frame and determining the foreground and background mask image of the video frame Before the image block, mark the connected domains on the foreground and background mask image, and determine the first parameter value of the preset parameter of each connected domain, wherein the preset parameter is the area of the connected domain or the number of pixels in the connected domain, For each connected domain, it is judged whether the first parameter value of the connected domain is less than the first preset threshold, if the mask values of all pixels in the connected domain are filled with the background mask value, if not, all pixel points in the connected domain are The mask values of the pixels are filled with foreground mask values to obtain an updated foreground and background mask image; according to the updated foreground and background mask image, an updated foreground image block in the video frame is determined.
进一步地,所述第一确定模块,还用于所述对所述前背景掩膜图像进行连通域标记之前,根据所述前背景掩膜图像,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的第一比值,根据所述第一比值、第二预设阈值以及第三预设阈值,判断所述第一比值是否小于所述第二预设阈值,其中所述第三预设阈值大于所述第二预设阈值,若是,对所述前背景掩膜图像进行先膨胀后腐蚀的处理;若否,判断所述第一比值是否大于所述第三预设阈值,若是,对所述前背景掩膜图像进行先腐蚀后膨胀的处理,若否,不进行处理。Further, the first determination module is also used to determine the number of foreground image blocks in the video frame according to the foreground and background mask images before performing connected domain marking on the foreground and background mask images. According to the first ratio of the total number of image blocks in the video frame, according to the first ratio, the second preset threshold and the third preset threshold, it is judged whether the first ratio is smaller than the second preset threshold, wherein the The third preset threshold is greater than the second preset threshold, if yes, first expand and then corrode the front and background mask image; if not, judge whether the first ratio is greater than the third preset threshold , if yes, first corrode and then dilate the foreground and background mask image, if not, do not process.
进一步地,所述第三确定模块,具体用于若该视频帧为关键帧,判断该视频帧是否为第一个关键帧,若是,则确定图片组的最大比特与预设系数的第一乘积值,将所述第一乘积值确定为该视频帧的目标比特,若否,则确定该视频帧的所述目标码率系数与该视频帧的上一帧的码率系数的第二比值,并确定所述第二比值与该视频帧的上一帧的比特的第二乘积值,将所述第二乘积值确定为该视频帧的目标比特;若该视频帧为非关键帧,则确定所述最大比特减第一个关键帧的比特的第一差值,并确定图片组包含的视频帧数量减预设数量的第二差值,根据所述第一差值和所述第二差值的第三比值、以及所述目标码率系数,确定所述第三比值与该视频帧的所述目标码率系数的第三乘积值,将所述第三乘积值确定为该视频帧的目标比特。Further, the third determination module is specifically used to determine whether the video frame is the first key frame if the video frame is a key frame, and if so, determine the first product of the maximum bit of the picture group and the preset coefficient value, determining the first product value as the target bit of the video frame, if not, determining the second ratio of the target bit rate coefficient of the video frame to the bit rate coefficient of the previous frame of the video frame, And determine the second product value of the second ratio and the bit of the previous frame of the video frame, and determine the second product value as the target bit of the video frame; if the video frame is a non-key frame, then determine The first difference value of the maximum bit minus the bit of the first key frame, and determine the second difference value of the number of video frames contained in the group of pictures minus the preset number, according to the first difference value and the second difference value The third ratio of the value, and the target code rate coefficient, determine the third product value of the third ratio and the target code rate coefficient of the video frame, and determine the third product value as the video frame target bits.
相应地,本发明提供了一种视频编码装置,所述装置包括:Correspondingly, the present invention provides a video encoding device, the device comprising:
获取模块,用于获取目标视频中的每个视频帧;Obtain module, be used for obtaining each video frame in target video;
第一确定模块,用于针对所述每个视频帧,将该视频帧划分为预设大小的每个图像块,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值,根据所述目标比值、以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的运动等级为该视频帧的目标运动等级,其中所述预设大小为单个像素点大小或预设边长的矩形大小;The first determining module is used to divide the video frame into each image block of a preset size for each video frame, and determine that the number of foreground image blocks in the video frame accounts for the total number of image blocks in the video frame Target ratio, according to the corresponding relationship between the target ratio and the value range and the motion level, determine that the motion level corresponding to the target value range where the target ratio is located is the target motion level of the video frame, wherein the preset size is a single pixel point size or rectangle size with preset side lengths;
第二确定模块,用于针对所述每个视频帧,根据该视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数;The second determination module is used to determine the target code rate coefficient of the video frame according to the target motion level of the video frame and the first mapping relationship between the code rate coefficient and the motion level for each video frame;
第三确定模块,用于针对所述每个视频帧,将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特,根据该视频帧的每个像素点的像素值,确定该视频帧和该视频帧的每个图像块的纹理复杂度的每个第二参数值,其中所述纹理复杂度为梯度、方差、平均绝对差和绝对误差和等参数中的任一种;The third determining module is used to input the target code rate coefficient of the video frame, the maximum bit of the picture group and the number of frames contained in the picture group into the bit determination function of the video frame for each video frame, and determine the output The target bit of the video frame determines each second parameter value of the texture complexity of the video frame and each image block of the video frame according to the pixel value of each pixel of the video frame, wherein the texture complexity The degree is any one of parameters such as gradient, variance, mean absolute difference and absolute error sum;
第四确定模块,用于针对该视频帧的每个图像块,确定该图像块的第二参数值和该视频帧的第二参数值的第四比值,并确定所述第四比值与该视频帧的所述目标比特的第四乘积值为该图像块的第一比特,将该图像块的第一比特输入到码率控制模型,得到输出的该图像块的候选量化参数;The fourth determination module is used to determine, for each image block of the video frame, a fourth ratio between the second parameter value of the image block and the second parameter value of the video frame, and determine the ratio between the fourth ratio and the video frame The fourth product value of the target bit of the frame is the first bit of the image block, and the first bit of the image block is input to the code rate control model to obtain the output candidate quantization parameter of the image block;
第五确定模块,用于若该图像块为前景图像块,根据预先保存的第二映射关系,确定该图像块的所述候选量化参数在所述第二映射关系中对应的目标量化参数,若该图像块为背景图像块,根据预先保存的第三映射关系,确定该图像块的所述候选量化参数在所述第三映射关系中对应的目标量化参数;The fifth determination module is configured to determine, if the image block is a foreground image block, the target quantization parameter corresponding to the candidate quantization parameter of the image block in the second mapping relationship according to the pre-stored second mapping relationship, if The image block is a background image block, and according to a pre-stored third mapping relationship, determine a target quantization parameter corresponding to the candidate quantization parameter of the image block in the third mapping relationship;
编码模块,具体用于根据所述目标视频中所述每个视频帧的每个图像块的目标量化参数,对所述目标视频中所述每个视频帧的每个图像块进行编码,得到压缩后的码流。The encoding module is specifically configured to encode each image block of each video frame in the target video according to the target quantization parameter of each image block of each video frame in the target video to obtain compressed subsequent code stream.
相应地,本发明提供了一种电子设备,包括:处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;Correspondingly, the present invention provides an electronic device, including: a processor, a communication interface, a memory, and a communication bus, wherein, the processor, the communication interface, and the memory complete mutual communication through the communication bus;
所述存储器中存储有计算机程序,当所述程序被所述处理器执行时,使得所述处理器实现上述视频编码方法中任一所述方法的步骤。A computer program is stored in the memory, and when the program is executed by the processor, the processor is made to implement the steps of any one of the above video encoding methods.
相应地,本发明提供了一种计算机可读存储介质,其存储有计算机程序,所述计算机程序被处理器执行时实现上述视频编码方法中任一所述方法的步骤。Correspondingly, the present invention provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the steps of any one of the above video encoding methods are implemented.
本发明提供了一种视频编码方法、装置、设备和介质,本发明中针对每个视频帧,将该视频帧划分为预设大小的每个图像块,通过检测视频帧中前景图像块的个数占图像块总数的目标比值,根据目标比值以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的目标运动等级,并根据视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数,将目标码率系数、图片组的最大比特和图片组包含的帧数量输入视频帧的比特确定函数,确定视频帧的目标比特输入到图片组的最大比特,确定所述视频帧的目标比特输入到码率控制模型,得到输出的量化参数,基于目标视频中每个视频帧的量化参数,对目标视频中每个视频帧进行编码,得到压缩后的码流,由于本发明获取每一视频帧的运动情况确定运动等级,并基于运动等级确定当前视频帧的目标码率,根据目标码率确定视频帧分配的目标比特,根据目标比特映射得到视频帧的量化参数,根据目标视频中每个视频帧的量化参数,对目标视频中每个视频帧进行编码,得到压缩后的码流,相比现有技术简单的将视频帧中的场景分为运动场景和静止场景,进而采用对应地固定编码方式进行编码的方法,本发明实现了在运动时用较高的目标码率,在静止时主动降低目标码率,进而节省整体码率的目的。The present invention provides a video coding method, device, device and medium. In the present invention, for each video frame, the video frame is divided into each image block of a preset size, and by detecting individual foreground image blocks in the video frame Number accounts for the target ratio of the total number of image blocks, according to the corresponding relationship between the target ratio and the numerical range and the motion level, determine the target motion level corresponding to the target numerical range where the target ratio is located, and according to the target motion level of the video frame and the code rate coefficient The first mapping relationship with the motion level determines the target code rate coefficient of the video frame, and inputs the target code rate coefficient, the maximum bit of the picture group and the number of frames contained in the picture group into the bit determination function of the video frame to determine the target of the video frame The bit is input to the maximum bit of the picture group, and the target bit of the video frame is determined to be input to the code rate control model to obtain the output quantization parameter, based on the quantization parameter of each video frame in the target video, for each video frame in the target video Encoding is performed to obtain the compressed code stream. Since the present invention obtains the motion of each video frame to determine the motion level, and determines the target code rate of the current video frame based on the motion level, and determines the target bits allocated by the video frame according to the target code rate, The quantization parameter of the video frame is obtained according to the target bitmap, and each video frame in the target video is encoded according to the quantization parameter of each video frame in the target video to obtain a compressed code stream. Compared with the prior art, the video is simply encoded The scenes in the frame are divided into moving scenes and static scenes, and then adopt the corresponding fixed encoding method for encoding. The present invention realizes using a higher target bit rate when moving, and actively reducing the target bit rate when still, thereby saving The purpose of the overall code rate.
附图说明Description of drawings
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings that need to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For Those of ordinary skill in the art can also obtain other drawings based on these drawings without any creative effort.
图1为本发明实施例提供的一种视频编码方法的过程示意图;FIG. 1 is a schematic diagram of a process of a video encoding method provided by an embodiment of the present invention;
图2为本发明实施例提供的一种目标运动等级与码率系数的线性关系的示意图;FIG. 2 is a schematic diagram of a linear relationship between a target motion level and a code rate coefficient provided by an embodiment of the present invention;
图3为本发明实施例提供的一种视频编码装置的结构示意图;FIG. 3 is a schematic structural diagram of a video encoding device provided by an embodiment of the present invention;
图4为本发明实施例提供的一种视频编码装置的结构示意图;FIG. 4 is a schematic structural diagram of a video encoding device provided by an embodiment of the present invention;
图5为本发明实施例提供的一种视频编码装置的结构示意图;FIG. 5 is a schematic structural diagram of a video encoding device provided by an embodiment of the present invention;
图6为本发明实施例提供的一种电子设备的结构示意图。FIG. 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention.
具体实施方式Detailed ways
为了使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明作进一步地详细描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only some of the embodiments of the present invention, rather than all of them. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
为了在进行视频编码时,提高码率控制的精准度较差以节省码率,本发明实施例提供了一种视频编码方法、装置、设备和介质。In order to improve the accuracy of bit rate control to save bit rate during video encoding, the embodiments of the present invention provide a video encoding method, device, device and medium.
实施例1:Example 1:
图1为本发明实施例提供的一种视频编码方法的过程示意图,该过程包括以下步骤:Fig. 1 is a schematic diagram of the process of a video coding method provided by an embodiment of the present invention, the process includes the following steps:
S101:获取目标视频中的每个视频帧。S101: Obtain each video frame in the target video.
为了在进行视频编码时,提高码率控制的精准度较差以节省码率,本发明实施例提供的一种视频编码方法应用于电子设备,该视频编码方法为对视频的帧级编码方法,即通过确定视频中的每一视频帧的量化参数,确定视频压缩后的码流;该电子设备可以是主机、平板电脑、笔记本电脑、智能手机等智能终端设备,也可以是服务器,该服务器可以是本地服务器,也可以是云端服务器,本发明实施例对此不做限制。In order to improve the accuracy of bit rate control to save bit rate during video encoding, a video encoding method provided by an embodiment of the present invention is applied to electronic equipment. The video encoding method is a frame-level encoding method for video. That is, by determining the quantization parameters of each video frame in the video, the code stream after video compression is determined; the electronic device can be a smart terminal device such as a host, a tablet computer, a notebook computer, a smart phone, or a server, and the server can It may be a local server or a cloud server, which is not limited in this embodiment of the present invention.
该电子设备获取目标视频,具体可以是通过该电子设备自身的图像采集装置采集到目标视频,也可以是通过与该电子设备连接其他设备接收到目标视频,还可以是获取该电子设备自身预先保存的目标视频,本发明实施例中对此不做限制;在获取到目标视频后,该电子设备从目标视频帧中获取到每个视频帧。The electronic device obtains the target video, specifically, it may collect the target video through the image acquisition device of the electronic device itself, or receive the target video by connecting other devices with the electronic device, or obtain the electronic device itself to save the target video in advance. The target video is not limited in this embodiment of the present invention; after the target video is acquired, the electronic device acquires each video frame from the target video frame.
S102:针对所述每个视频帧,将该视频帧划分为预设大小的每个图像块,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值,根据所述目标比值、以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的运动等级为该视频帧的目标运动等级,其中所述预设大小为单个像素点大小或预设边长的矩形大小。S102: For each video frame, divide the video frame into each image block of a preset size, determine the target ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame, according to the The target ratio, and the corresponding relationship between the numerical range and the motion level, determine that the motion level corresponding to the target numerical range where the target ratio is located is the target motion level of the video frame, wherein the preset size is the size of a single pixel point or a preset The size of the rectangle with side length.
针对每个视频帧,该电子设备将该视频帧划分为预设大小的每个图像块,其中预设大小是用户预先设置的,其中,预设大小为单个像素点大小或预设边长的矩形大小,若希望提高码率控制的精准度,则可以将预设边长设置地较小一些,若希望提高进行图像编码的效率,则可以将预设边长设置地较小一些;例如将宽度为W高度为H的视频帧划分为互不重叠的图像块,图像块的大小为MxN。For each video frame, the electronic device divides the video frame into each image block of a preset size, wherein the preset size is preset by the user, wherein the preset size is the size of a single pixel or a preset side length Rectangle size, if you want to improve the accuracy of bit rate control, you can set the preset side length to be smaller, if you want to improve the efficiency of image encoding, you can set the preset side length to be smaller; for example, set A video frame with a width of W and a height of H is divided into non-overlapping image blocks, and the size of the image blocks is MxN.
该电子设备对该视频帧进行检测确定每个图像块中的前景图像块,前景是指在主题前面或靠近镜头位置的人物或景物,也可以将前景图像块称为运动图像块;根据前景图像块的个数、以及该视频帧的图像块总数,确定前景图像块的个数占图像块总数的目标比值。The electronic device detects the video frame to determine the foreground image block in each image block. The foreground refers to the person or scene in front of the subject or close to the lens position, and the foreground image block can also be called a moving image block; according to the foreground image The number of blocks and the total number of image blocks in the video frame determine the target ratio of the number of foreground image blocks to the total number of image blocks.
为了确定出该视频帧的运动等级,该电子设备预先保存有数值范围与运动等级的对应关系,根据确定出的目标比值,确定目标比值所在的目标数值范围;根据目标数值范围、以及数值范围与运动等级的对应关系,确定目标数值范围对应的运动等级为目标运动等级;目标运动等级越小,表示该视频帧越接近静态场景,可以分配较少的比特,目标运动等级越高表示该视频帧越接近运动场景,需要分配较多比特。In order to determine the motion level of the video frame, the electronic device pre-stores the corresponding relationship between the numerical range and the motion level, and determines the target numerical range where the target ratio is located according to the determined target ratio; according to the target numerical range, and the numerical range and Correspondence between motion levels, determine the motion level corresponding to the target value range as the target motion level; the smaller the target motion level, the closer the video frame is to the static scene, less bits can be allocated, and the higher the target motion level, the video frame The closer to the motion scene, the more bits need to be allocated.
例如数值范围与运动等级的对应关系可以表示为objratio<0时,motion_grade=0;objratio<1.0时,motion_grade=1;objratio<2.0时,motion_grade=2;objratio<4.0时,motion_grade=3;objratio<8.0时,motion_grade=4;objratio<12时,motion_grade=5;objratio<16时,motion_grade=6;objratio<20时,motion_grade=7;objratio<24时,motion_grade=8;objratio≥24时,motion_grade=9;其中motion_grade表示运动等级,obj_ratio表示前景图像块占图像块总数的比值,比值小于0.5时,对应的运动等级为0;比值不小于0.5小于1.0时,对应的运动等级为1;比值不小于1.0小于2.0时,对应的运动等级为2;比值不小于2.0小于4.0时,对应的运动等级为3;比值不小于4.0小于8.0时,对应的运动等级为4;比值不小于8.0小于12时,对应的运动等级为5;比值不小于12小于16时,对应的运动等级为6;比值不小于16小于20时,对应的运动等级为7;比值不小于20小于24时,对应的运动等级为8;比值不小于24时,对应的运动等级为9。For example, the corresponding relationship between the numerical range and the motion grade can be expressed as: when obj ratio <0, motion_grade=0; when obj ratio <1.0, motion_grade=1; when obj ratio <2.0, motion_grade=2; when obj ratio <4.0, motion_grade= 3; when obj ratio <8.0, motion_grade=4; when obj ratio <12, motion_grade=5; when obj ratio <16, motion_grade=6; when obj ratio <20, motion_grade=7; when obj ratio <24, motion_grade= 8; when obj ratio ≥ 24, motion_grade=9; where motion_grade represents the motion grade, obj_ratio represents the ratio of the foreground image block to the total number of image blocks, when the ratio is less than 0.5, the corresponding motion grade is 0; when the ratio is not less than 0.5 and less than 1.0, The corresponding exercise level is 1; when the ratio is not less than 1.0 and less than 2.0, the corresponding exercise level is 2; when the ratio is not less than 2.0 and less than 4.0, the corresponding exercise level is 3; when the ratio is not less than 4.0 and less than 8.0, the corresponding exercise level is 4. When the ratio is not less than 8.0 and less than 12, the corresponding exercise level is 5; when the ratio is not less than 12 and less than 16, the corresponding exercise level is 6; when the ratio is not less than 16 and less than 20, the corresponding exercise level is 7; the ratio is not less than When 20 is less than 24, the corresponding exercise level is 8; when the ratio is not less than 24, the corresponding exercise level is 9.
S103:针对所述每个视频帧,根据该视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数。S103: For each video frame, determine a target bit rate coefficient of the video frame according to the target motion level of the video frame and a first mapping relationship between the bit rate coefficient and the motion level.
为了确定出该视频帧分配的码率系数,该电子设备预先保存有码率系数与运动等级的第一映射关系,根据确定出的目标运动等级,确定目标运动等级在第一映射关系中对应的码率系数为该视频帧的目标码率系数。In order to determine the code rate coefficient assigned to the video frame, the electronic device pre-saves the first mapping relationship between the code rate coefficient and the motion level, and determines the corresponding value of the target motion level in the first mapping relationship according to the determined target motion level. The code rate coefficient is the target code rate coefficient of the video frame.
下面通过一个具体的实施例对本发明中确定视频帧的目标比特的方法进行说明,根据目标运动等级motion_grade计算视频帧分配的码率系数rate_grade的第一映射关系以线性关系进行举例,若视频帧为关键帧:rate_grade=(a+b*motion_grade)α1;若视频帧为非关键帧:rate_grade=(a+b*motion_grade)α2,一般地,此处的a可取0.05,表示码率的下限,b可取0.1。The method for determining the target bit of the video frame in the present invention will be described below through a specific embodiment, and the first mapping relationship of the code rate coefficient rate_grade calculated according to the target motion grade motion_grade is exemplified with a linear relationship, if the video frame is Key frame: rate_grade=(a+b*motion_grade) α1 ; if the video frame is a non-key frame: rate_grade=(a+b*motion_grade) α2 , generally, a here can be taken as 0.05, indicating the lower limit of the code rate, b 0.1 is desirable.
图2为本发明实施例提供的一种目标运动等级与码率系数的线性关系的示意图,如图2所示,横轴x表示为(0.05+0.1*motion_grade),纵轴y表示为码率系数rate_grade,图2中的从上到下(图2中的上下)的每根线依次对应的α的值为1/8、1/4、1/2、1、3/2、2、4、8。对于关键帧,为了在大运动场景下尽可能多分配比特,例如x在0.7-0.9等,其系数α1可取0.5。对于非关键帧,为了在静态下尽可能少分配比特,例如x在0.1到0.5之间,选择系数α2为1.5。Figure 2 is a schematic diagram of a linear relationship between a target motion level and a code rate coefficient provided by an embodiment of the present invention. As shown in Figure 2, the horizontal axis x is expressed as (0.05+0.1*motion_grade), and the vertical axis y is expressed as code rate Coefficient rate_grade, the value of α corresponding to each line from top to bottom in Figure 2 (up and down in Figure 2) is 1/8, 1/4, 1/2, 1, 3/2, 2, 4 ,8. For key frames, in order to allocate as many bits as possible in large motion scenes, for example, x is 0.7-0.9, etc., and its coefficient α1 can be 0.5. For non-key frames, in order to allocate as few bits as possible under static conditions, for example, x is between 0.1 and 0.5, the coefficient α2 is selected to be 1.5.
假如当前帧为非关键帧,且motion_grade为3,base_ratio+0.1*motion_grade则为0.35,因此根据图2可得rate_grade为0.21。If the current frame is a non-key frame and the motion_grade is 3, the base_ratio+0.1*motion_grade is 0.35, so according to Figure 2, the rate_grade is 0.21.
S104:针对所述每个视频帧,将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特。S104: For each video frame, input the target code rate coefficient of the video frame, the maximum bit of the picture group and the number of frames contained in the picture group into the bit determination function of the video frame, and determine the output target of the video frame bit.
针对每个视频帧,根据该视频帧的目标码率系数、图片组的最大比特和图片组包含的帧数量,将目标码率系数、最大比特和帧数量输入视频帧的比特确定函数,确定输出的该视频帧被分配的目标比特。For each video frame, according to the target bit rate coefficient of the video frame, the maximum bit of the picture group and the number of frames contained in the picture group, input the target bit rate coefficient, the maximum bit and the number of frames into the bit determination function of the video frame, and determine the output The target bits for which the video frame is assigned.
S105:针对所述每个视频帧,将该视频帧的目标比特输入到码率控制模型,得到输出的该视频帧的量化参数。S105: For each video frame, input the target bits of the video frame into the rate control model to obtain an output quantization parameter of the video frame.
针对每个视频帧,将该视频帧的目标比特输入到码率控制模型,得到输出的该视频帧的量化参数;其中码率控制模型可以是R-λ模型,也可以是R-Q模型,本发明实施例对此不做限制。For each video frame, the target bit of the video frame is input to the code rate control model to obtain the quantization parameter of the output video frame; wherein the code rate control model can be an R-λ model or an R-Q model, and the present invention The embodiment does not limit this.
例如码率控制模型可以是R-λ模型时,具体公式为λ=α·Rβ,QP=4.2005·ln(λ)+13.7122;其中R表示视频帧的目标比特,λ表示率失真参数,参数α、β为映射相关的系数,且每帧会更新。For example, when the code rate control model can be an R-λ model, the specific formula is λ=α·R β , QP=4.2005·ln(λ)+13.7122; wherein R represents the target bit of the video frame, and λ represents the rate-distortion parameter, and the parameter α and β are coefficients related to mapping, and will be updated every frame.
S106:根据所述目标视频中所述每个视频帧的量化参数,对所述目标视频中所述每个视频帧进行编码,得到压缩后的码流。S106: Encode each video frame in the target video according to the quantization parameter of each video frame in the target video, to obtain a compressed code stream.
在确定出目标视频中每个视频帧的量化参数,根据每个量化参数对目标视频中的每个视频帧进行编码,得到压缩后的每个视频帧组成的压缩后的码流;具体根据量化参数对视频帧编码的方法为现有技术中,本发明实施例对此不做赘述。After determining the quantization parameters of each video frame in the target video, each video frame in the target video is encoded according to each quantization parameter, and the compressed code stream composed of each compressed video frame is obtained; specifically, according to the quantization The method for encoding video frames by parameters is in the prior art, and will not be described in detail in this embodiment of the present invention.
由于在本发明实施例中,针对每个视频帧,将该视频帧划分为预设大小的每个图像块,通过检测视频帧中前景图像块的个数占图像块总数的目标比值,根据目标比值以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的目标运动等级,并根据视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数,从而在运动等级大时用较高的目标码率系数,在静止时主动降低目标码率系数,并将目标码率系数、图片组的最大比特和图片组包含的帧数量输入视频帧的比特确定函数,确定视频帧的目标比特输入到图片组的最大比特,确定所述视频帧的目标比特输入到码率控制模型,得到输出的量化参数,基于目标视频中所述每个视频帧的量化参数,对目标视频中所述每个视频帧进行编码,得到压缩后的码流,由于本发明获取每一视频帧的运动情况确定运动等级,并基于运动等级确定当前视频帧的目标码率,根据目标码率确定视频帧分配的目标比特,根据目标比特映射得到视频帧的量化参数,根据目标视频中每个视频帧的量化参数,对目标视频中每个视频帧进行编码,得到压缩后的码流,相比现有技术简单的将视频帧中的场景分为运动场景和静止场景,进而采用对应地固定编码方式进行编码的方法,本发明实现了在运动时用较高的目标码率,在静止时主动降低目标码率,进而节省整体码率的目的。Since in the embodiment of the present invention, for each video frame, the video frame is divided into each image block of a preset size, by detecting the target ratio of the number of foreground image blocks in the video frame to the total number of image blocks, according to the target The corresponding relationship between the ratio and the value range and the motion level, determine the target motion level corresponding to the target value range where the target ratio is located, and determine the target motion level according to the target motion level of the video frame and the first mapping relationship between the bit rate coefficient and the motion level. The target bit rate coefficient of the video frame, so that a higher target bit rate coefficient is used when the motion level is large, and the target bit rate coefficient is actively reduced when it is still, and the target bit rate coefficient, the maximum bit of the picture group and the picture group include The number of frames is input to the bit determination function of the video frame, the target bit of the video frame is determined to be input to the maximum bit of the group of pictures, the target bit of the video frame is determined to be input to the code rate control model, and the output quantization parameter is obtained, based on the target bit in the target video Describe the quantization parameters of each video frame, encode each video frame in the target video, and obtain the compressed code stream, because the present invention obtains the motion of each video frame to determine the motion level, and determines the current level based on the motion level The target code rate of the video frame, according to the target code rate to determine the target bit allocation of the video frame, according to the target bit mapping to obtain the quantization parameter of the video frame, according to the quantization parameter of each video frame in the target video, for each video frame in the target video Encoding is carried out to obtain the compressed code stream. Compared with the prior art, the scene in the video frame is simply divided into a moving scene and a static scene, and then a corresponding fixed coding method is used for coding. The present invention realizes the Use a higher target bit rate, and actively reduce the target bit rate when it is still, so as to save the overall bit rate.
实施例2:Example 2:
为了确定出前景图像块的个数占图像块总数的目标比值,在上述实施例的基础上,在本发明实施例中,所述确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值包括:In order to determine the target ratio of the number of foreground image blocks to the total number of image blocks, on the basis of the above embodiments, in the embodiment of the present invention, the determination of the number of foreground image blocks in the video frame accounts for the video frame Target ratios for the total number of image blocks include:
确定该视频帧的前背景掩膜图像,根据所述前背景掩膜图像确定该视频帧中的前景图像块,根据该视频帧中前景图像块的第一数量以及该视频帧中图像块的总数量,得到所述第一数量与所述总数量的目标比值。Determine the front background mask image of the video frame, determine the foreground image blocks in the video frame according to the front background mask image, and determine the foreground image blocks in the video frame according to the first number of foreground image blocks in the video frame and the total number of image blocks in the video frame Quantity, to obtain a target ratio of the first quantity to the total quantity.
为了确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值,该电子设备对该视频帧进行检测,确定出该视频帧的前背景掩膜图像,具体可以是采用高斯混合模型、帧差法、光流法进行检测,本发明实施例中对此不做限制。In order to determine the target ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame, the electronic device detects the video frame to determine the foreground and background mask image of the video frame. The Gaussian mixture model, the frame difference method, and the optical flow method are used for detection, which are not limited in this embodiment of the present invention.
当预设大小为单个像素点大小时,检测得到前背景掩膜图像的大小与该视频帧的大小相同,当预设大小为预设边长的矩形大小时,例如预设大小为MxN的矩形大小时,当该视频帧的大小为WxH,前背景掩膜图像的长为W/M,宽为H/N。When the preset size is the size of a single pixel, the size of the detected front and background mask image is the same as the size of the video frame. When the preset size is the size of a rectangle with a preset side length, for example, a rectangle with a preset size of MxN When the size is WxH, when the size of the video frame is WxH, the length of the foreground and background mask image is W/M, and the width is H/N.
例如该电子设备采用帧差法对该视频帧进行检测时,该视频帧的大小为1920x1080,将其划分为8x8大小互不重叠的块后,计算每个图像块与前一帧对应位置的图像块的差异diff值,其中M表示为图像块的行大小,N表示为图像块的宽大小,此处均为8,Cur表示当前图像块的像素值,Pre表示前一帧对应位置的图像块的像素值。For example, when the electronic device uses the frame difference method to detect the video frame, the size of the video frame is 1920x1080, and after dividing it into 8x8 non-overlapping blocks, calculate the image corresponding to the position of each image block and the previous frame The difference diff value of the block, where M represents the row size of the image block, N represents the width of the image block, both here are 8, Cur represents the pixel value of the current image block, and Pre represents the pixel value of the image block at the corresponding position in the previous frame.
若当前块diff大于设定的阈值T1,则认为当前块为前景图像块,也可以记为运动图像块,否则当前图像块为背景图像块,也记为静止图像块,一般地,此处的T1可取值20,对该视频帧的所有图像块做同样的处理,就可得到整个帧的前背景情况,将前景图像块在前背景掩膜图像对应位置的像素点的掩膜值设置为预设前景掩膜值,将背景图像块在前背景掩膜图像对应位置的像素点的掩膜值设置为预设背景掩膜值,从而得到该视频帧的前背景掩膜图像;该视频帧的前背景掩膜图像的大小为240x135。If the current block diff is greater than the set threshold T1, the current block is considered to be a foreground image block, which can also be recorded as a moving image block, otherwise the current image block is a background image block, which is also recorded as a still image block. Generally, here T1 can take a value of 20, and do the same processing on all image blocks of the video frame to obtain the foreground and background conditions of the entire frame, and set the mask value of the pixel point of the foreground image block in the corresponding position of the foreground and background mask image to Preset the foreground mask value, set the mask value of the pixel point of the background image block in the corresponding position of the front background mask image as the preset background mask value, thereby obtaining the front background mask image of the video frame; the video frame The size of the foreground and background mask images is 240x135.
在确定出该视频帧的前背景掩膜图像后,根据前背景掩膜图像中每个像素点的掩膜值,确定掩膜值为预设前景掩膜值的像素点对应位置的图像块为前景图像块;根据前景图像块的第一数量、以及图像块的总数量,确定第一数量与总数量的目标比值。After determining the foreground and background mask image of the video frame, according to the mask value of each pixel in the foreground and background mask image, the image block at the corresponding position of the pixel whose mask value is determined to be the preset foreground mask value is Foreground image blocks: determining a target ratio of the first number to the total number according to the first number of foreground image blocks and the total number of image blocks.
实施例3:Example 3:
为了提高确定前景图像块的准确度,在上述各实施例的基础上,在本发明实施例中,所述对该视频帧进行检测确定该视频帧的前背景掩膜图像之后,所述根据所述前背景掩膜图像确定该视频帧中的前景图像块之前,所述方法还包括:In order to improve the accuracy of determining the foreground image block, on the basis of the above embodiments, in the embodiment of the present invention, after the video frame is detected to determine the foreground and background mask image of the video frame, the Before the foreground image block in the video frame is determined by the front background mask image, the method also includes:
对所述前背景掩膜图像进行连通域标记,确定每个连通域的预设参数的第一参数值,其中所述预设参数为连通域面积或连通域内像素点个数,针对每个连通域,判断该连通域的第一参数值是否小于第一预设阈值,若是将该连通域内所有像素点的掩膜值均填充为背景掩膜值,若否将该连通域内所有像素点的掩膜值均填充为前景掩膜值,得到更新后的前背景掩膜图像;Mark the connected domains on the foreground and background mask images, and determine the first parameter value of the preset parameters of each connected domain, wherein the preset parameters are the area of the connected domain or the number of pixels in the connected domain, for each connected domain Domain, judge whether the first parameter value of the connected domain is less than the first preset threshold, if it is filled with the mask values of all pixels in the connected domain as the background mask value, if not, the mask values of all pixels in the connected domain The film values are all filled as the foreground mask value, and the updated foreground and background mask image is obtained;
根据更新后的前背景掩膜图像,确定该视频帧中更新后的前景图像块。An updated foreground image block in the video frame is determined according to the updated foreground and background mask image.
该电子设备对前背景掩膜图像进行连通域标记,确定前背景掩膜图像中的每个连通域,并根据确定出的每个连通域确定预设参数的第一参数值,其中预设参数为连通域面积或连通域内像素点个数。The electronic device marks the connected domains of the front-background mask image, determines each connected domain in the front-background mask image, and determines the first parameter value of the preset parameter according to each connected domain determined, wherein the preset parameter is the connected domain area or the number of pixels in the connected domain.
针对每个连通域,该电子设备对该连通域的第一参数指进行比较,判断该连通域的第一参数值是否小于第一预设阈值,若该连通域的第一参数值小于第一预设阈值,则认为该连通域属于背景部分的边缘或噪声形成的连通域,因此将该连通域内所有像素点的掩膜值均填充为背景掩膜值;若该连通域的第一参数值不小于第一预设阈值,则将该连通域内所有像素点的掩膜值均填充为前景掩膜值,从而得到较为完整的前景图像块,提高前背景掩膜检测的完整性和准确性。For each connected domain, the electronic device compares the first parameter value of the connected domain to determine whether the first parameter value of the connected domain is less than a first preset threshold, and if the first parameter value of the connected domain is less than the first If the threshold is preset, the connected domain is considered to belong to the connected domain formed by the edge of the background or noise, so the mask values of all pixels in the connected domain are filled with the background mask value; if the first parameter value of the connected domain If it is not less than the first preset threshold, the mask values of all pixels in the connected domain are filled as foreground mask values, thereby obtaining a relatively complete foreground image block and improving the integrity and accuracy of foreground and background mask detection.
为了进一步地提高前背景掩膜检测的完整性和准确性,在本发明实施例中,所述对所述前背景掩膜图像进行连通域标记之前,所述方法还包括:In order to further improve the integrity and accuracy of foreground and background mask detection, in the embodiment of the present invention, before performing connected domain marking on the foreground and background mask image, the method further includes:
根据所述前背景掩膜图像,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的第一比值,根据所述第一比值、第二预设阈值以及第三预设阈值,判断所述第一比值是否小于所述第二预设阈值,其中所述第三预设阈值大于所述第二预设阈值,若是,对所述前背景掩膜图像进行先膨胀后腐蚀的处理;若否,判断所述第一比值是否大于所述第三预设阈值,若是,对所述前背景掩膜图像进行先腐蚀后膨胀的处理,若否,不进行处理。According to the foreground and background mask image, determine the first ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame, according to the first ratio, the second preset threshold and the third preset Threshold, judging whether the first ratio is less than the second preset threshold, wherein the third preset threshold is greater than the second preset threshold, if so, first expand and then corrode the front and background mask image If not, judge whether the first ratio is greater than the third preset threshold, if yes, perform erosion and then dilation processing on the foreground and background mask image, if not, do not perform processing.
该电子设备根据前背景掩膜图像,确定该视频帧中前景图像块的个数、以及该视频帧的图像块总数,并确定出前景图像块的个数与图像块总数的第一比值,根据该第一比值以及第二预设阈值和第三预设阈值,判断第一比值是否小于第二预设阈值,若第一比值小于第二预设阈值,则认为前景检测结果不够完整,前景中可能存在空洞等,因此对前背景掩膜图像进行先膨胀后腐蚀的形态学处理;先膨胀后腐蚀则用来填充物体内细小的空洞,连接邻近物体,平滑其边界。The electronic device determines the number of foreground image blocks in the video frame and the total number of image blocks in the video frame according to the foreground and background mask images, and determines the first ratio between the number of foreground image blocks and the total number of image blocks, according to The first ratio, the second preset threshold and the third preset threshold determine whether the first ratio is smaller than the second preset threshold, if the first ratio is smaller than the second preset threshold, it is considered that the foreground detection result is not complete enough, and the foreground There may be holes, etc., so the morphological processing of the front and background mask images is first expanded and then corroded; the first dilated and then corroded is used to fill the small holes in the object, connect adjacent objects, and smooth their boundaries.
若该第一比值不小于第二预设阈值,则判断该第一比值是否大于第三预设阈值,若第一比值大于第三预设阈值,则认为前景检测结果比较完整,可能还存在一部分背景干扰,所以对前背景掩膜图像进行先腐蚀后膨胀的形态学处理,消除背景中孤立点的影响,先腐蚀后膨胀通常用来消除小物体,在纤细点处分离物体,平滑较大的物体边界;若第一比值不大于第三预设阈值,则认为此时的前景检测结果基本完整,同时背景的干扰也可忽略不计,因此对前背景掩膜图像不做形态学处理。If the first ratio is not less than the second preset threshold, it is judged whether the first ratio is greater than the third preset threshold, if the first ratio is greater than the third preset threshold, it is considered that the foreground detection result is relatively complete, and there may be some Background interference, so the morphological processing of the front and background mask image is first corroded and then expanded to eliminate the influence of isolated points in the background. Corrosion and expansion are usually used to eliminate small objects, separate objects at slender points, and smooth larger ones. Object boundary; if the first ratio is not greater than the third preset threshold, it is considered that the foreground detection result at this time is basically complete, and the interference of the background is also negligible, so no morphological processing is performed on the front-background mask image.
其中,腐蚀算法采用一个全为1的NxN矩阵扫描前背景掩膜图像中的每一个像素点,即矩阵的中心元素与前背景掩膜图像的像素点位置对应,用该矩阵中的每一个像素与其覆盖的像素点的像素值做逻辑“与”操作,如果运算结果都为1,则该像素点的像素值为1,否则为0;膨胀运算采用一个全为1的NxN矩阵扫描前背景掩膜图像中的每一个像素点,即矩阵的中心元素与前背景掩膜图像的像素点位置对应,用该矩阵中的每一个像素与其覆盖的像素点的像素值做逻辑“或”操作,如果运算结果都为0,则该像素为0,否则为1。Among them, the erosion algorithm uses an NxN matrix of all 1s to scan each pixel in the front and background mask image, that is, the central element of the matrix corresponds to the pixel position of the front and background mask image, and each pixel in the matrix Perform a logical "AND" operation with the pixel values of the covered pixels. If the result of the operation is 1, the pixel value of the pixel is 1, otherwise it is 0; the dilation operation uses an NxN matrix of all 1s to scan the front and background mask Each pixel in the film image, that is, the central element of the matrix corresponds to the pixel position of the front-background mask image, and the logical "OR" operation is performed between each pixel in the matrix and the pixel value of the pixel it covers, if If the operation results are all 0, then the pixel is 0, otherwise it is 1.
例如,该电子设备对前背景掩膜图像进行如下处理:若P前景<T2,则先膨胀后腐蚀,若P前景>T3,则先腐蚀后膨胀,若T2<P前景<T3,则不作处理;其中P前景代表一帧中前景图像块所占的比例,介于0-1之间,具体的T2、T3的值分别取0.15和0.20,进行腐蚀膨胀时为全为1的3x3矩阵。For example, the electronic device performs the following processing on the foreground and background mask image: if P foreground < T2, first expand and then corrode; if P foreground > T3, first corrode and then expand; if T2 < P foreground < T3, then do not process ; where P foreground represents the proportion of the foreground image block in a frame, between 0-1, the specific values of T2 and T3 are 0.15 and 0.20 respectively, and it is a 3x3 matrix with all 1s during erosion and expansion.
由于本发明实施例中,对前背景掩膜贪图像进行自适应形态学处理以及连通域计算,能够去除孤立噪点,提高运动前景检测的完整性和准确性,相对于现有技术中使用预处理的帧进行判定当前场景为运动场景或者静态场景,方法更为简便,且不存在延迟问题。Since in the embodiment of the present invention, adaptive morphological processing and connected domain calculation are performed on the foreground and background mask images, it is possible to remove isolated noise points and improve the integrity and accuracy of moving foreground detection. Compared with the prior art using preprocessing The frame is used to determine whether the current scene is a motion scene or a static scene. The method is simpler and there is no delay problem.
实施例4:Example 4:
为了确定出视频帧的目标比特,在上述各实施例的基础上,在本发明实施例中,所述将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特包括:In order to determine the target bit of the video frame, on the basis of the above embodiments, in the embodiment of the present invention, the target bit rate coefficient of the video frame, the maximum bit of the picture group, and the frames included in the picture group The bit determination function of quantity input video frame, the target bit of this video frame that determines output comprises:
若该视频帧为关键帧,判断该视频帧是否为第一个关键帧,若是,则确定图片组的最大比特与预设系数的第一乘积值,将所述第一乘积值确定为该视频帧的目标比特,若否,则确定该视频帧的所述目标码率系数与该视频帧的上一帧的码率系数的第二比值,并确定所述第二比值与该视频帧的上一帧的比特的第二乘积值,将所述第二乘积值确定为该视频帧的目标比特;If the video frame is a key frame, judge whether the video frame is the first key frame, if so, determine the first product value of the maximum bit of the picture group and the preset coefficient, and determine the first product value as the video frame The target bit of the frame, if not, then determine the second ratio of the target code rate coefficient of the video frame and the code rate coefficient of the last frame of the video frame, and determine the second ratio and the last ratio of the video frame A second product value of the bits of a frame, determining the second product value as the target bit of the video frame;
若该视频帧为非关键帧,则确定所述最大比特减第一个关键帧的比特的第一差值,并确定图片组包含的视频帧数量减预设数量的第二差值,根据所述第一差值和所述第二差值的第三比值、以及所述目标码率系数,确定所述第三比值与该视频帧的所述目标码率系数的第三乘积值,将所述第三乘积值确定为该视频帧的目标比特。If the video frame is a non-key frame, then determine the first difference between the maximum bit minus the bit of the first key frame, and determine the second difference between the number of video frames included in the group of pictures minus the preset number, according to the determined The third ratio between the first difference and the second difference, and the target code rate coefficient, determine the third product value of the third ratio and the target code rate coefficient of the video frame, and convert the The third product value is determined as the target bit of the video frame.
该电子设备在确定该视频帧的目标比特时,若该视频帧为关键帧,则判断该视频帧是否为第一个关键帧,若该视频帧为第一个关键帧,则根据图片组的最大比特以及预设系数,确定最大比特与预设系数的第一乘积值,将第一乘积值确定为该视频帧的目标比特;其中图片组的最大比特计算方法为其中duration表示编码一帧的时间,bitrate表示设定的目标码率,因此duration*bitrate计算得到的一帧最大比特,SizeGop表示GOP包含的帧数量。When the electronic device determines the target bit of the video frame, if the video frame is a key frame, then judge whether the video frame is the first key frame, if the video frame is the first key frame, then according to the picture group The maximum bit and the preset coefficient determine the first product value of the maximum bit and the preset coefficient, and determine the first product value as the target bit of the video frame; wherein the maximum bit of the picture group The calculation method is Among them, duration indicates the time to encode one frame, bitrate indicates the set target bit rate, so the maximum bit of a frame calculated by duration*bitrate, and Size Gop indicates the number of frames included in the GOP.
若该视频帧分为第一个关键帧,则确定该视频帧的目标码率系数与该视频帧的上一帧的码率系数的第二比值,并根据第二比值以及该视频帧的上一帧的比特,确定第二比值与上一帧的比特的第二乘积值,将第二乘积值确定为该视频帧的目标比特。If the video frame is divided into the first key frame, then determine the second ratio of the target code rate coefficient of the video frame to the code rate coefficient of the last frame of the video frame, and according to the second ratio and the previous frame of the video frame For the bits of one frame, determine a second product value of the second ratio and the bits of the previous frame, and determine the second product value as the target bit of the video frame.
例如,当前的视频帧为关键帧时,针对第一帧:针对非第一帧:其中,α3表示比例系数,ratio_Irate表示当前关键帧的码率系数rate_grade与上一关键帧的码率系数rate_grade的比值,则表示上一关键帧的目标比特。For example, when the current video frame is a key frame, for the first frame: For non-first frames: Among them, α3 represents the proportional coefficient, and ratio_Irate represents the ratio of the bit rate coefficient rate_grade of the current key frame to the bit rate coefficient rate_grade of the previous key frame, then represents the target bit of the previous keyframe.
若该视频帧为非关键帧,则根据图片组的最大比特以及计算出第一个关键帧的比特,确定最大比特与第一个关键帧的比特的第一差值,根据图片组包含的视频帧数量、以及预设数量,其中预设数量为1,确定视频帧数量与预设数量的第二差值,根据第一差值和第二差值,确定第一差值和第二差值的第三比值,其中第三比值即表示图片组除去第一个关键帧后的剩余视频帧的平均比特;根据第三比值以及该视频帧的目标码率系数,确定第三比值与目标码率系数的第三乘积值,将第三乘积值确定为该视频帧的目标比特。If the video frame is a non-key frame, then calculate the first difference between the maximum bit and the bit of the first key frame according to the maximum bit of the group of pictures and the bit of the first key frame, and determine the first difference between the maximum bit and the bit of the first key frame, according to the The number of frames and the preset number, wherein the preset number is 1, determine the second difference between the number of video frames and the preset number, and determine the first difference and the second difference according to the first difference and the second difference The third ratio, wherein the third ratio represents the average bit of the remaining video frame after the group of pictures removes the first key frame; according to the third ratio and the target bit rate coefficient of the video frame, determine the third ratio and the target bit rate A third product value of the coefficients is determined as the target bit of the video frame.
例如,当前的视频帧为非关键帧,首先计算出图片组除去第一个关键帧后的剩余视频帧的平均比特其中表示图片组的最大比特,表示第一个关键帧的比特,SizeGop表示GOP包含的帧数量;将平均比特再乘以当前视频帧的码率系数rate_grade,得到当前的视频帧的目标比特其中 For example, if the current video frame is a non-key frame, first calculate the average bit rate of the remaining video frames after the first key frame is removed from the picture group in Indicates the maximum number of bits in a group of pictures, Represents the bit of the first key frame, Size Gop represents the number of frames contained in the GOP; the average bit Multiply by the bit rate coefficient rate_grade of the current video frame to get the target bit of the current video frame in
由于在本发明实施例中,使用比较容易获得的参数以及特征来进行调整,参数计算简单、获取简单,能够很好地满足软件视频编解码装置使用,且能很好地适配进不同视频编码标准中。Because in the embodiment of the present invention, the parameters and features that are relatively easy to obtain are used for adjustment, the calculation of the parameters is simple, and the acquisition is simple, which can well meet the needs of software video codec devices, and can be well adapted to different video codecs. standard.
实施例5:Example 5:
为了节省码率,本发明实施例提供了一种视频编码方法,该方法包括:In order to save code rate, an embodiment of the present invention provides a video encoding method, the method comprising:
获取目标视频中的每个视频帧;Get each video frame in the target video;
针对所述每个视频帧,将该视频帧划分为预设大小的每个图像块,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值,根据所述目标比值、以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的运动等级为该视频帧的目标运动等级,其中所述预设大小为单个像素点大小或预设边长的矩形大小;For each video frame, divide the video frame into each image block of a preset size, determine the target ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame, according to the target Ratio, and the corresponding relationship between the numerical range and the motion level, determine that the motion level corresponding to the target numerical range where the target ratio is located is the target motion level of the video frame, wherein the preset size is the size of a single pixel point or the preset side length the size of the rectangle;
针对所述每个视频帧,根据该视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数;For each video frame, determine the target bit rate coefficient of the video frame according to the target motion level of the video frame and the first mapping relationship between the bit rate coefficient and the motion level;
针对所述每个视频帧,将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特,根据该视频帧的每个像素点的像素值,确定该视频帧和该视频帧的每个图像块的纹理复杂度的每个第二参数值,其中所述纹理复杂度为梯度、方差、平均绝对差和绝对误差和等参数中的任一种;For each video frame, the target code rate coefficient of the video frame, the maximum bit of the group of pictures and the number of frames included in the group of pictures are input into the bit determination function of the video frame, and the target bit of the output video frame is determined, According to the pixel value of each pixel of the video frame, determine each second parameter value of the texture complexity of the video frame and each image block of the video frame, wherein the texture complexity is gradient, variance, average Any of the parameters such as absolute difference and absolute error sum;
针对该视频帧的每个图像块,确定该图像块的第二参数值和该视频帧的第二参数值的第四比值,并确定所述第四比值与该视频帧的所述目标比特的第四乘积值为该图像块的第一比特,将该图像块的第一比特输入到码率控制模型,得到输出的该图像块的候选量化参数;For each image block of the video frame, determine a fourth ratio between the second parameter value of the image block and the second parameter value of the video frame, and determine the ratio between the fourth ratio and the target bit of the video frame The fourth product value is the first bit of the image block, and the first bit of the image block is input to the code rate control model to obtain the output candidate quantization parameter of the image block;
若该图像块为前景图像块,根据预先保存的第二映射关系,确定该图像块的所述候选量化参数在所述第二映射关系中对应的目标量化参数,若该图像块为背景图像块,根据预先保存的第三映射关系,确定该图像块的所述候选量化参数在所述第三映射关系中对应的目标量化参数;If the image block is a foreground image block, according to the pre-saved second mapping relationship, determine the target quantization parameter corresponding to the candidate quantization parameter of the image block in the second mapping relationship, if the image block is a background image block , according to a pre-stored third mapping relationship, determine a target quantization parameter corresponding to the candidate quantization parameter of the image block in the third mapping relationship;
根据所述目标视频中所述每个视频帧的每个图像块的目标量化参数,对所述目标视频中所述每个视频帧的每个图像块进行编码,得到压缩后的码流。Encoding each image block of each video frame in the target video according to the target quantization parameter of each image block of each video frame in the target video to obtain a compressed code stream.
为了实现在进行视频编码时,提高码率控制的精准度较差以节省码率,本发明实施例提供的一种视频编码方法应用于电子设备,该视频编码方法为对视频的宏块级编码方法,即通过确定视频中的每一视频帧的每一图像块的量化参数,来确定视频压缩后的码流;该电子设备可以是主机、平板电脑、笔记本电脑、智能手机等智能终端设备,也可以是服务器,该服务器可以是本地服务器,也可以是云端服务器,本发明实施例对此不做限制;该电子设备可以与上述实施例1-5中执行视频编码的电子设备为同一电子设备,也可以非为同一电子设备。In order to improve the accuracy of bit rate control to save bit rate when performing video encoding, a video encoding method provided by an embodiment of the present invention is applied to electronic equipment, and the video encoding method is macroblock-level encoding of video The method is to determine the code stream after video compression by determining the quantization parameter of each image block of each video frame in the video; the electronic device can be an intelligent terminal device such as a host computer, a tablet computer, a notebook computer, or a smart phone, It can also be a server, and the server can be a local server or a cloud server, which is not limited in the embodiment of the present invention; the electronic device can be the same electronic device as the electronic device performing video encoding in the above-mentioned embodiments 1-5 , or they may not be the same electronic device.
该电子设备获取目标视频,具体可以是通过该电子设备自身的图像采集装置采集到目标视频,也可以是通过与该电子设备连接其他设备接收到目标视频,还可以是获取该电子设备自身预先保存的目标视频,本发明实施例中对此不做限制;在获取到目标视频后,该电子设备从目标视频帧中获取到每个视频帧。The electronic device obtains the target video, specifically, it may collect the target video through the image acquisition device of the electronic device itself, or receive the target video by connecting other devices with the electronic device, or obtain the electronic device itself to save the target video in advance. The target video is not limited in this embodiment of the present invention; after the target video is acquired, the electronic device acquires each video frame from the target video frame.
针对每个视频帧,该电子设备将该视频帧划分为预设大小的每个图像块,其中预设大小是用户预先设置的,其中,预设大小为单个像素点大小或预设边长的矩形大小,对该视频帧进行检测确定每个图像块中的前景图像块,根据前景图像块的个数、以及该视频帧的图像块总数,确定前景图像块的个数占图像块总数的目标比值。For each video frame, the electronic device divides the video frame into each image block of a preset size, wherein the preset size is preset by the user, wherein the preset size is the size of a single pixel or a preset side length Rectangular size, detect the video frame to determine the foreground image block in each image block, and determine the target that the number of foreground image blocks accounts for the total number of image blocks according to the number of foreground image blocks and the total number of image blocks in the video frame ratio.
为了确定出该视频帧的运动等级,该电子设备预先保存有数值范围与运动等级的对应关系,根据确定出的目标比值,确定目标比值所在的目标数值范围;根据目标数值范围、以及数值范围与运动等级的对应关系,确定目标数值范围对应的运动等级为目标运动等级;目标运动等级越小,表示该视频帧越接近静态场景,可以分配较少的比特,目标运动等级越高表示该视频帧越接近运动场景,需要分配较多比特。In order to determine the motion level of the video frame, the electronic device pre-stores the corresponding relationship between the numerical range and the motion level, and determines the target numerical range where the target ratio is located according to the determined target ratio; according to the target numerical range, and the numerical range and Correspondence between motion levels, determine the motion level corresponding to the target value range as the target motion level; the smaller the target motion level, the closer the video frame is to the static scene, less bits can be allocated, and the higher the target motion level, the video frame The closer to the motion scene, the more bits need to be allocated.
为了确定出该视频帧分配的码率系数,该电子设备预先保存有码率系数与运动等级的第一映射关系,根据确定出的目标运动等级,确定目标运动等级在第一映射关系中对应的码率系数为该视频帧的目标码率系数。In order to determine the code rate coefficient assigned to the video frame, the electronic device pre-saves the first mapping relationship between the code rate coefficient and the motion level, and determines the corresponding value of the target motion level in the first mapping relationship according to the determined target motion level. The code rate coefficient is the target code rate coefficient of the video frame.
针对每个视频帧,根据该视频帧的目标码率系数、图片组的最大比特和图片组包含的帧数量,将目标码率系数、最大比特和帧数量输入视频帧的比特确定函数,确定输出的该视频帧被分配的目标比特,根据该视频帧的每个像素点的像素值,确定该视频帧的纹理复杂度的第二参数值;根据每个图像块中的每个像素点的像素值,确定每个图像块的纹理复杂度的第二参数值,其中纹理复杂度为梯度、方差、平均绝对差和绝对误差和等参数中的任一种,例如纹理复杂度为梯度时,第二参数值即为梯度值。For each video frame, according to the target bit rate coefficient of the video frame, the maximum bit of the picture group and the number of frames contained in the picture group, input the target bit rate coefficient, the maximum bit and the number of frames into the bit determination function of the video frame, and determine the output The assigned target bit of the video frame, according to the pixel value of each pixel of the video frame, determine the second parameter value of the texture complexity of the video frame; according to the pixel of each pixel in each image block Value, to determine the second parameter value of the texture complexity of each image block, wherein the texture complexity is any one of parameters such as gradient, variance, mean absolute difference and absolute error sum, for example, when the texture complexity is gradient, the first The value of the second parameter is the gradient value.
为了实现对目标视频的宏块级编码,该电子设备针对该视频帧的每个图像块,确定出每个图像块被分配的比特,具体是该电子设备确定该图像块的第二参数值和该视频帧的第二参数值的第四比值,根据该第四比值以及该视频帧的目标比特,确定该第四比值与目标比特的第四乘积值,将第四乘积值确定为该图像块的第一比特。In order to realize the macroblock-level encoding of the target video, the electronic device determines the bits allocated to each image block for each image block of the video frame, specifically, the electronic device determines the second parameter value of the image block and The fourth ratio of the second parameter value of the video frame, according to the fourth ratio and the target bit of the video frame, determine the fourth product value of the fourth ratio and the target bit, and determine the fourth product value as the image block of the first bit.
为了实现对目标视频的宏块级编码,该电子设备将该图像块的第一比特输入到码率控制模型,得到输出的该图像块的候选量化参数;若该图像块前景图像块,则根据前景图像块的候选量化参数与目标量化参数的第二映射关系,确定该图像块的候选量化参数在第二映射关系中对应的目标量化参数;若该图像块为背景图像块,则根据背景图像块的候选量化参数与目标量化参数的第三映射关系,确定该图像块的候选量化参数在第三映射关系中对应的目标量化参数。In order to realize macroblock-level encoding of the target video, the electronic device inputs the first bit of the image block into the code rate control model to obtain the output candidate quantization parameters of the image block; if the image block is a foreground image block, then according to The second mapping relationship between the candidate quantization parameter of the foreground image block and the target quantization parameter determines the target quantization parameter corresponding to the candidate quantization parameter of the image block in the second mapping relationship; if the image block is a background image block, then according to the background image A third mapping relationship between the candidate quantization parameters of the block and the target quantization parameters is used to determine the target quantization parameters corresponding to the candidate quantization parameters of the image block in the third mapping relationship.
例如,根据视频帧的目标比特以及每个图像块的纹理复杂度的第二参数值Gmb分配得到每个图像块的比特其中其中Gmb表示每个图像块的纹理复杂度的第二参数值,Gfra表示视频帧的纹理复杂度的第二参数值,根据得到的每个图像块的比特输入R-λ模型,即可计算得到每个图像块的候选量化参数QPpre。For example, based on the target bits of a video frame And the second parameter value G mb of the texture complexity of each image block is allocated to obtain the bits of each image block in Where G mb represents the second parameter value of the texture complexity of each image block, G fra represents the second parameter value of the texture complexity of the video frame, according to the obtained bit of each image block By inputting the R-λ model, the candidate quantization parameter QP pre of each image block can be calculated.
根据当前视频帧的前背景掩膜图像判断每个图像块为静止图像块还是运动图像块,由此调整每个图像块的QP,其中当前图像块为静止图像块时,QP=f1(QPpre),当前图像块为运动图像块时,QP=f2(QPpre),f1()表示第二映射关系,f2()表示第三映射关系,其可为线性关系也可为非线性关系。例如,当f1()和f2()以线性关系时,当前图像块为静止图像块时,QP=QPpre+α4,当前图像块为运动图像块时,QP=QPpre-α5,其中α4、α5可同样取值为2,在运动块时适当降低量化QP,进而保护运动块的质量,而在静止块时,则可以适当提升量化QP,从而降低码率。Judge whether each image block is a still image block or a moving image block according to the front background mask image of the current video frame, thereby adjusting the QP of each image block, wherein when the current image block is a still image block, QP=f 1 (QP pre ), when the current image block is a moving image block, QP=f 2 (QP pre ), f 1 () represents the second mapping relationship, f 2 () represents the third mapping relationship, which can be linear or nonlinear linear relationship. For example, when f 1 () and f 2 () have a linear relationship, when the current image block is a still image block, QP=QP pre +α4, and when the current image block is a moving image block, QP=QP pre -α5, where α4 and α5 can also take the same value as 2. When the block is in motion, the quantization QP can be appropriately reduced to protect the quality of the moving block. When the block is still, the quantization QP can be appropriately increased to reduce the bit rate.
在确定出每个视频帧的每个图像块的目标量化参数后,对目标视频中每个视频帧的每个图像块进行编码,得到压缩后的每个视频帧的每个图像块组成的压缩后的码流。After determining the target quantization parameters of each image block of each video frame, each image block of each video frame in the target video is encoded to obtain a compressed image composed of each image block of each video frame after compression subsequent code stream.
实施例6:Embodiment 6:
图3为本发明实施例提供的一种视频编码装置的结构示意图,如图3所示,该装置包括:FIG. 3 is a schematic structural diagram of a video encoding device provided by an embodiment of the present invention. As shown in FIG. 3, the device includes:
获取模块301,用于获取目标视频中的每个视频帧;Obtaining
第一确定模块302,用于针对所述每个视频帧,将该视频帧划分为预设大小的每个图像块,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值,根据所述目标比值、以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的运动等级为该视频帧的目标运动等级,其中所述预设大小为单个像素点大小或预设边长的矩形大小;The first determining
第二确定模块303,用于针对所述每个视频帧,根据该视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数;The second determining
第三确定模块304,用于针对所述每个视频帧,将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特;The third determining
第四确定模块305,用于针对所述每个视频帧,将该视频帧的目标比特输入到码率控制模型,得到输出的该视频帧的量化参数;The fourth determining
编码模块306,用于根据所述目标视频中所述每个视频帧的量化参数,对所述目标视频中所述每个视频帧进行编码,得到压缩后的码流。The
进一步地,所述第一确定模块302,具体用于确定该视频帧的前背景掩膜图像,根据所述前背景掩膜图像确定该视频帧中的前景图像块,根据该视频帧中前景图像块的第一数量以及该视频帧中图像块的总数量,得到所述第一数量与所述总数量的目标比值。Further, the
进一步地,所述第一确定模块302,还用于所述对该视频帧进行检测确定该视频帧的前背景掩膜图像之后,所述根据所述前背景掩膜图像确定该视频帧中的前景图像块之前,对所述前背景掩膜图像进行连通域标记,确定每个连通域的预设参数的第一参数值,其中所述预设参数为连通域面积或连通域内像素点个数,针对每个连通域,判断该连通域的第一参数值是否小于第一预设阈值,若是将该连通域内所有像素点的掩膜值均填充为背景掩膜值,若否将该连通域内所有像素点的掩膜值均填充为前景掩膜值,得到更新后的前背景掩膜图像;根据更新后的前背景掩膜图像,确定该视频帧中更新后的前景图像块。Further, the
进一步地,所述第一确定模块302,还用于所述对所述前背景掩膜图像进行连通域标记之前,根据所述前背景掩膜图像,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的第一比值,根据所述第一比值、第二预设阈值以及第三预设阈值,判断所述第一比值是否小于所述第二预设阈值,其中所述第三预设阈值大于所述第二预设阈值,若是,对所述前背景掩膜图像进行先膨胀后腐蚀的处理;若否,判断所述第一比值是否大于所述第三预设阈值,若是,对所述前背景掩膜图像进行先腐蚀后膨胀的处理,若否,不进行处理。Further, the first determining
进一步地,所述第三确定模块304,具体用于若该视频帧为关键帧,判断该视频帧是否为第一个关键帧,若是,则确定图片组的最大比特与预设系数的第一乘积值,将所述第一乘积值确定为该视频帧的目标比特,若否,则确定该视频帧的所述目标码率系数与该视频帧的上一帧的码率系数的第二比值,并确定所述第二比值与该视频帧的上一帧的比特的第二乘积值,将所述第二乘积值确定为该视频帧的目标比特;若该视频帧为非关键帧,则确定所述最大比特减第一个关键帧的比特的第一差值,并确定图片组包含的视频帧数量减预设数量的第二差值,根据所述第一差值和所述第二差值的第三比值、以及所述目标码率系数,确定所述第三比值与该视频帧的所述目标码率系数的第三乘积值,将所述第三乘积值确定为该视频帧的目标比特。Further, the
图4为本发明实施例提供的一种视频编码装置的结构示意图,如图4所示,该装置包括:前背景分割模块401、形态学处理模块402、连通域计算模块403、运动等级分析模块404、帧级QP求取模块405、宏块级QP求取模块406、编码模块407。Fig. 4 is a schematic structural diagram of a video encoding device provided by an embodiment of the present invention. As shown in Fig. 4, the device includes: a foreground and
前背景分割模块401,用于获取到目标视频的每个视频帧,通过运动检测方法对视频帧的前背景情况进行检测,用于后续运动等级的分析;相当于上述实施例中的获取模块301和第一确定模块302。The foreground and
形态学处理模块402,用于在前背景分割模块401之后,对提取的视频帧的前背景掩膜图像进行处理,消除噪点和空洞;相当于上述实施例中的第一确定模块302。The
连通域计算模块403,用于对形态学处理模块402之后的前背景掩膜进行连通域标记;相当于上述实施例中的第一确定模块302。The connected
运动等级分析模块404,用于计算当前的视频帧的运动等级;相当于上述实施例中的第一确定模块302。The motion
帧级QP求取模块405,用于计算视频帧的量化参数;相当于上述实施例中的第二确定模块303、第三确定模块304和第四确定模块305。The frame-level
宏块级QP求取模块406,用于计算视频帧的每个图像块的量化参数;相当于上述实施例中的第四确定模块305。The macroblock-level
编码模块407,用于对目标视频中每个视频帧进行编码,得到压缩后的码流,相当于上述实施例中的编码模块306。The
实施例7:Embodiment 7:
图5为本发明实施例提供的一种视频编码装置的结构示意图,如图5所示,该装置包括:FIG. 5 is a schematic structural diagram of a video encoding device provided by an embodiment of the present invention. As shown in FIG. 5, the device includes:
获取模块501,用于获取目标视频中的每个视频帧;Obtaining
第一确定模块502,用于针对所述每个视频帧,将该视频帧划分为预设大小的每个图像块,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值,根据所述目标比值、以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的运动等级为该视频帧的目标运动等级,其中所述预设大小为单个像素点大小或预设边长的矩形大小;The first determining
第二确定模块503,用于针对所述每个视频帧,根据该视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数;The second determining
第三确定模块504,用于针对所述每个视频帧,将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特,根据该视频帧的每个像素点的像素值,确定该视频帧和该视频帧的每个图像块的纹理复杂度的每个第二参数值,其中所述纹理复杂度为梯度、方差、平均绝对差和绝对误差和等参数中的任一种;The
第四确定模块505,用于针对该视频帧的每个图像块,确定该图像块的第二参数值和该视频帧的第二参数值的第四比值,并确定所述第四比值与该视频帧的所述目标比特的第四乘积值为该图像块的第一比特,将该图像块的第一比特输入到码率控制模型,得到输出的该图像块的候选量化参数;The fourth determining
第五确定模块506,用于若该图像块为前景图像块,根据预先保存的第二映射关系,确定该图像块的所述候选量化参数在所述第二映射关系中对应的目标量化参数,若该图像块为背景图像块,根据预先保存的第三映射关系,确定该图像块的所述候选量化参数在所述第三映射关系中对应的目标量化参数;The
编码模块507,用于根据所述目标视频中所述每个视频帧的每个图像块的目标量化参数,对所述目标视频中所述每个视频帧的每个图像块进行编码,得到压缩后的码流。The
实施例8:Embodiment 8:
图6为本发明实施例提供的一种电子设备的结构示意图,在上述各实施例的基础上,本申请还提供了一种电子设备,如图6所示,包括:处理器601、通信接口602、存储器603和通信总线604,其中,处理器601,通信接口602,存储器603通过通信总线604完成相互间的通信。Fig. 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. On the basis of the above-mentioned embodiments, the present application also provides an electronic device, as shown in Fig. 6 , including: a
所述存储器603中存储有计算机程序,当所述程序被所述处理器601执行时,使得所述处理器601执行如下步骤:A computer program is stored in the
获取目标视频中的每个视频帧;Get each video frame in the target video;
针对所述每个视频帧,将该视频帧划分为预设大小的每个图像块,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值,根据所述目标比值、以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的运动等级为该视频帧的目标运动等级,其中所述预设大小为单个像素点大小或预设边长的矩形大小;For each video frame, divide the video frame into each image block of a preset size, determine the target ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame, according to the target Ratio, and the corresponding relationship between the numerical range and the motion level, determine that the motion level corresponding to the target numerical range where the target ratio is located is the target motion level of the video frame, wherein the preset size is the size of a single pixel point or the preset side length the size of the rectangle;
针对所述每个视频帧,根据该视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数;For each video frame, determine the target bit rate coefficient of the video frame according to the target motion level of the video frame and the first mapping relationship between the bit rate coefficient and the motion level;
针对所述每个视频帧,将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特;For each video frame, input the target code rate coefficient of the video frame, the maximum bit of the group of pictures and the number of frames contained in the group of pictures into the bit determination function of the video frame, and determine the target bit of the output video frame;
针对所述每个视频帧,将该视频帧的目标比特输入到码率控制模型,得到输出的该视频帧的量化参数;For each video frame, the target bit of the video frame is input to the code rate control model to obtain the quantization parameter of the video frame output;
根据所述目标视频中所述每个视频帧的量化参数,对所述目标视频中所述每个视频帧进行编码,得到压缩后的码流。Encoding each video frame in the target video according to the quantization parameter of each video frame in the target video to obtain a compressed code stream.
进一步地,所述处理器601具体用于所述确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值包括:Further, the specific use of the
确定该视频帧的前背景掩膜图像,根据所述前背景掩膜图像确定该视频帧中的前景图像块,根据该视频帧中前景图像块的第一数量以及该视频帧中图像块的总数量,得到所述第一数量与所述总数量的目标比值。Determine the front background mask image of the video frame, determine the foreground image blocks in the video frame according to the front background mask image, and determine the foreground image blocks in the video frame according to the first number of foreground image blocks in the video frame and the total number of image blocks in the video frame Quantity, to obtain a target ratio of the first quantity to the total quantity.
进一步地,所述处理器601还用于所述对该视频帧进行检测确定该视频帧的前背景掩膜图像之后,所述根据所述前背景掩膜图像确定该视频帧中的前景图像块之前,所述方法还包括:Further, the
对所述前背景掩膜图像进行连通域标记,确定每个连通域的预设参数的第一参数值,其中所述预设参数为连通域面积或连通域内像素点个数,针对每个连通域,判断该连通域的第一参数值是否小于第一预设阈值,若是将该连通域内所有像素点的掩膜值均填充为背景掩膜值,若否将该连通域内所有像素点的掩膜值均填充为前景掩膜值,得到更新后的前背景掩膜图像;Mark the connected domains on the foreground and background mask images, and determine the first parameter value of the preset parameters of each connected domain, wherein the preset parameters are the area of the connected domain or the number of pixels in the connected domain, for each connected domain Domain, judge whether the first parameter value of the connected domain is less than the first preset threshold, if it is filled with the mask values of all pixels in the connected domain as the background mask value, if not, the mask values of all pixels in the connected domain The film values are all filled as the foreground mask value, and the updated foreground and background mask image is obtained;
根据更新后的前背景掩膜图像,确定该视频帧中更新后的前景图像块。An updated foreground image block in the video frame is determined according to the updated foreground and background mask image.
进一步地,所述处理器601还用于所述对所述前背景掩膜图像进行连通域标记之前,所述方法还包括:Further, before the
根据所述前背景掩膜图像,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的第一比值,根据所述第一比值、第二预设阈值以及第三预设阈值,判断所述第一比值是否小于所述第二预设阈值,其中所述第三预设阈值大于所述第二预设阈值,若是,对所述前背景掩膜图像进行先膨胀后腐蚀的处理;若否,判断所述第一比值是否大于所述第三预设阈值,若是,对所述前背景掩膜图像进行先腐蚀后膨胀的处理,若否,不进行处理。According to the foreground and background mask image, determine the first ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame, according to the first ratio, the second preset threshold and the third preset Threshold, judging whether the first ratio is less than the second preset threshold, wherein the third preset threshold is greater than the second preset threshold, if so, first expand and then corrode the front and background mask image If not, judge whether the first ratio is greater than the third preset threshold, if yes, perform erosion and then dilation processing on the foreground and background mask image, if not, do not perform processing.
进一步地,所述处理器601具体用于所述将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特包括:Further, the
若该视频帧为关键帧,判断该视频帧是否为第一个关键帧,若是,则确定图片组的最大比特与预设系数的第一乘积值,将所述第一乘积值确定为该视频帧的目标比特,若否,则确定该视频帧的所述目标码率系数与该视频帧的上一帧的码率系数的第二比值,并确定所述第二比值与该视频帧的上一帧的比特的第二乘积值,将所述第二乘积值确定为该视频帧的目标比特;If the video frame is a key frame, judge whether the video frame is the first key frame, if so, determine the first product value of the maximum bit of the picture group and the preset coefficient, and determine the first product value as the video frame The target bit of the frame, if not, then determine the second ratio of the target code rate coefficient of the video frame and the code rate coefficient of the last frame of the video frame, and determine the second ratio and the last ratio of the video frame A second product value of the bits of a frame, determining the second product value as the target bit of the video frame;
若该视频帧为非关键帧,则确定所述最大比特减第一个关键帧的比特的第一差值,并确定图片组包含的视频帧数量减预设数量的第二差值,根据所述第一差值和所述第二差值的第三比值、以及所述目标码率系数,确定所述第三比值与该视频帧的所述目标码率系数的第三乘积值,将所述第三乘积值确定为该视频帧的目标比特。If the video frame is a non-key frame, then determine the first difference between the maximum bit minus the bit of the first key frame, and determine the second difference between the number of video frames included in the group of pictures minus the preset number, according to the determined The third ratio between the first difference and the second difference, and the target code rate coefficient, determine the third product value of the third ratio and the target code rate coefficient of the video frame, and convert the The third product value is determined as the target bit of the video frame.
或,所述处理器601用于获取目标视频中的每个视频帧;Or, the
针对所述每个视频帧,将该视频帧划分为预设大小的每个图像块,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值,根据所述目标比值、以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的运动等级为该视频帧的目标运动等级,其中所述预设大小为单个像素点大小或预设边长的矩形大小;For each video frame, divide the video frame into each image block of a preset size, determine the target ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame, according to the target Ratio, and the corresponding relationship between the numerical range and the motion level, determine that the motion level corresponding to the target numerical range where the target ratio is located is the target motion level of the video frame, wherein the preset size is the size of a single pixel point or the preset side length the size of the rectangle;
针对所述每个视频帧,根据该视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数;For each video frame, determine the target bit rate coefficient of the video frame according to the target motion level of the video frame and the first mapping relationship between the bit rate coefficient and the motion level;
针对所述每个视频帧,将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特,根据该视频帧的每个像素点的像素值,确定该视频帧和该视频帧的每个图像块的纹理复杂度的每个第二参数值,其中所述纹理复杂度为梯度、方差、平均绝对差和绝对误差和等参数中的任一种;For each video frame, the target code rate coefficient of the video frame, the maximum bit of the group of pictures and the number of frames included in the group of pictures are input into the bit determination function of the video frame, and the target bit of the output video frame is determined, According to the pixel value of each pixel of the video frame, determine each second parameter value of the texture complexity of the video frame and each image block of the video frame, wherein the texture complexity is gradient, variance, average Any of the parameters such as absolute difference and absolute error sum;
针对该视频帧的每个图像块,确定该图像块的第二参数值和该视频帧的第二参数值的第四比值,并确定所述第四比值与该视频帧的所述目标比特的第四乘积值为该图像块的第一比特,将该图像块的第一比特输入到码率控制模型,得到输出的该图像块的候选量化参数;For each image block of the video frame, determine a fourth ratio between the second parameter value of the image block and the second parameter value of the video frame, and determine the ratio between the fourth ratio and the target bit of the video frame The fourth product value is the first bit of the image block, and the first bit of the image block is input to the code rate control model to obtain the output candidate quantization parameter of the image block;
若该图像块为前景图像块,根据预先保存的第二映射关系,确定该图像块的所述候选量化参数在所述第二映射关系中对应的目标量化参数,若该图像块为背景图像块,根据预先保存的第三映射关系,确定该图像块的所述候选量化参数在所述第三映射关系中对应的目标量化参数;If the image block is a foreground image block, according to the pre-saved second mapping relationship, determine the target quantization parameter corresponding to the candidate quantization parameter of the image block in the second mapping relationship, if the image block is a background image block , according to a pre-stored third mapping relationship, determine a target quantization parameter corresponding to the candidate quantization parameter of the image block in the third mapping relationship;
根据所述目标视频中所述每个视频帧的每个图像块的目标量化参数,对所述目标视频中所述每个视频帧的每个图像块进行编码,得到压缩后的码流。Encoding each image block of each video frame in the target video according to the target quantization parameter of each image block of each video frame in the target video to obtain a compressed code stream.
上述电子设备提到的通信总线可以是外设部件互连标准(Peripheral ComponentInterconnect,PCI)总线或扩展工业标准结构(Extended Industry StandardArchitecture,EISA)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The communication bus mentioned above for the electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus or the like. The communication bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
通信接口602用于上述电子设备与其他设备之间的通信。The
存储器可以包括随机存取存储器(Random Access Memory,RAM),也可以包括非易失性存储器(Non-Volatile Memory,NVM),例如至少一个磁盘存储器。可选地,存储器还可以是至少一个位于远离前述处理器的存储装置。The memory may include a random access memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-Volatile Memory, NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
上述处理器可以是通用处理器,包括中央处理器、网络处理器(NetworkProcessor,NP)等;还可以是数字指令处理器(Digital Signal Processing,DSP)、专用集成电路、现场可编程门陈列或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (NetworkProcessor, NP), etc.; it can also be a digital instruction processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate display or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
实施例8:Embodiment 8:
在上述各实施例的基础上,本申请还提供了一种计算机可读存储介质,所述计算机可读存储介质内存储有可由处理器执行的计算机程序,当所述程序在所述处理器上运行时,使得所述处理器执行时实现如下步骤:On the basis of the above-mentioned embodiments, the present application also provides a computer-readable storage medium, wherein a computer program executable by a processor is stored in the computer-readable storage medium, and when the program is executed on the processor During operation, the following steps are implemented when the processor is executed:
获取目标视频中的每个视频帧;Get each video frame in the target video;
针对所述每个视频帧,将该视频帧划分为预设大小的每个图像块,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值,根据所述目标比值、以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的运动等级为该视频帧的目标运动等级,其中所述预设大小为单个像素点大小或预设边长的矩形大小;For each video frame, divide the video frame into each image block of a preset size, determine the target ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame, according to the target Ratio, and the corresponding relationship between the numerical range and the motion level, determine that the motion level corresponding to the target numerical range where the target ratio is located is the target motion level of the video frame, wherein the preset size is the size of a single pixel point or the preset side length the size of the rectangle;
针对所述每个视频帧,根据该视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数;For each video frame, determine the target bit rate coefficient of the video frame according to the target motion level of the video frame and the first mapping relationship between the bit rate coefficient and the motion level;
针对所述每个视频帧,将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特;For each video frame, input the target code rate coefficient of the video frame, the maximum bit of the group of pictures and the number of frames contained in the group of pictures into the bit determination function of the video frame, and determine the target bit of the output video frame;
针对所述每个视频帧,将该视频帧的目标比特输入到码率控制模型,得到输出的该视频帧的量化参数;For each video frame, the target bit of the video frame is input to the code rate control model to obtain the quantization parameter of the video frame output;
根据所述目标视频中所述每个视频帧的量化参数,对所述目标视频中所述每个视频帧进行编码,得到压缩后的码流。Encoding each video frame in the target video according to the quantization parameter of each video frame in the target video to obtain a compressed code stream.
进一步地,所述确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值包括:Further, the determination of the target ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame includes:
确定该视频帧的前背景掩膜图像,根据所述前背景掩膜图像确定该视频帧中的前景图像块,根据该视频帧中前景图像块的第一数量以及该视频帧中图像块的总数量,得到所述第一数量与所述总数量的目标比值。Determine the front background mask image of the video frame, determine the foreground image blocks in the video frame according to the front background mask image, and determine the foreground image blocks in the video frame according to the first number of foreground image blocks in the video frame and the total number of image blocks in the video frame Quantity, to obtain a target ratio of the first quantity to the total quantity.
进一步地,所述对该视频帧进行检测确定该视频帧的前背景掩膜图像之后,所述根据所述前背景掩膜图像确定该视频帧中的前景图像块之前,所述方法还包括:Further, after the video frame is detected to determine the foreground background mask image of the video frame, before the foreground image block in the video frame is determined according to the foreground background mask image, the method further includes:
对所述前背景掩膜图像进行连通域标记,确定每个连通域的预设参数的第一参数值,其中所述预设参数为连通域面积或连通域内像素点个数,针对每个连通域,判断该连通域的第一参数值是否小于第一预设阈值,若是将该连通域内所有像素点的掩膜值均填充为背景掩膜值,若否将该连通域内所有像素点的掩膜值均填充为前景掩膜值,得到更新后的前背景掩膜图像;Mark the connected domains on the foreground and background mask images, and determine the first parameter value of the preset parameters of each connected domain, wherein the preset parameters are the area of the connected domain or the number of pixels in the connected domain, for each connected domain Domain, judge whether the first parameter value of the connected domain is less than the first preset threshold, if it is filled with the mask values of all pixels in the connected domain as the background mask value, if not, the mask values of all pixels in the connected domain The film values are all filled as the foreground mask value, and the updated foreground and background mask image is obtained;
根据更新后的前背景掩膜图像,确定该视频帧中更新后的前景图像块。An updated foreground image block in the video frame is determined according to the updated foreground and background mask image.
进一步地,所述对所述前背景掩膜图像进行连通域标记之前,所述方法还包括:Further, before performing connected domain marking on the foreground and background mask image, the method further includes:
根据所述前背景掩膜图像,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的第一比值,根据所述第一比值、第二预设阈值以及第三预设阈值,判断所述第一比值是否小于所述第二预设阈值,其中所述第三预设阈值大于所述第二预设阈值,若是,对所述前背景掩膜图像进行先膨胀后腐蚀的处理;若否,判断所述第一比值是否大于所述第三预设阈值,若是,对所述前背景掩膜图像进行先腐蚀后膨胀的处理,若否,不进行处理。According to the foreground and background mask image, determine the first ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame, according to the first ratio, the second preset threshold and the third preset Threshold, judging whether the first ratio is less than the second preset threshold, wherein the third preset threshold is greater than the second preset threshold, if so, first expand and then corrode the front and background mask image If not, judge whether the first ratio is greater than the third preset threshold, if yes, perform erosion and then dilation processing on the foreground and background mask image, if not, do not perform processing.
进一步地,所述将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特包括:Further, inputting the target code rate coefficient of the video frame, the maximum bit of the picture group and the number of frames contained in the picture group into the bit determination function of the video frame, and determining the output target bit of the video frame includes:
若该视频帧为关键帧,判断该视频帧是否为第一个关键帧,若是,则确定图片组的最大比特与预设系数的第一乘积值,将所述第一乘积值确定为该视频帧的目标比特,若否,则确定该视频帧的所述目标码率系数与该视频帧的上一帧的码率系数的第二比值,并确定所述第二比值与该视频帧的上一帧的比特的第二乘积值,将所述第二乘积值确定为该视频帧的目标比特;If the video frame is a key frame, judge whether the video frame is the first key frame, if so, determine the first product value of the maximum bit of the picture group and the preset coefficient, and determine the first product value as the video frame The target bit of the frame, if not, then determine the second ratio of the target code rate coefficient of the video frame and the code rate coefficient of the last frame of the video frame, and determine the second ratio and the last ratio of the video frame A second product value of the bits of a frame, determining the second product value as the target bit of the video frame;
若该视频帧为非关键帧,则确定所述最大比特减第一个关键帧的比特的第一差值,并确定图片组包含的视频帧数量减预设数量的第二差值,根据所述第一差值和所述第二差值的第三比值、以及所述目标码率系数,确定所述第三比值与该视频帧的所述目标码率系数的第三乘积值,将所述第三乘积值确定为该视频帧的目标比特。If the video frame is a non-key frame, then determine the first difference between the maximum bit minus the bit of the first key frame, and determine the second difference between the number of video frames included in the group of pictures minus the preset number, according to the determined The third ratio between the first difference and the second difference, and the target code rate coefficient, determine the third product value of the third ratio and the target code rate coefficient of the video frame, and convert the The third product value is determined as the target bit of the video frame.
或,所述处理器执行时实现如下步骤:Or, the processor implements the following steps during execution:
获取目标视频中的每个视频帧;Get each video frame in the target video;
针对所述每个视频帧,将该视频帧划分为预设大小的每个图像块,确定该视频帧中前景图像块的个数占该视频帧的图像块总数的目标比值,根据所述目标比值、以及数值范围与运动等级的对应关系,确定所述目标比值所在目标数值范围对应的运动等级为该视频帧的目标运动等级,其中所述预设大小为单个像素点大小或预设边长的矩形大小;For each video frame, divide the video frame into each image block of a preset size, determine the target ratio of the number of foreground image blocks in the video frame to the total number of image blocks in the video frame, according to the target Ratio, and the corresponding relationship between the numerical range and the motion level, determine that the motion level corresponding to the target numerical range where the target ratio is located is the target motion level of the video frame, wherein the preset size is the size of a single pixel point or the preset side length the size of the rectangle;
针对所述每个视频帧,根据该视频帧的目标运动等级、以及码率系数与运动等级的第一映射关系,确定该视频帧的目标码率系数;For each video frame, determine the target bit rate coefficient of the video frame according to the target motion level of the video frame and the first mapping relationship between the bit rate coefficient and the motion level;
针对所述每个视频帧,将该视频帧的目标码率系数、图片组的最大比特和所述图片组包含的帧数量输入视频帧的比特确定函数,确定输出的该视频帧的目标比特,根据该视频帧的每个像素点的像素值,确定该视频帧和该视频帧的每个图像块的纹理复杂度的每个第二参数值,其中所述纹理复杂度为梯度、方差、平均绝对差和绝对误差和等参数中的任一种;For each video frame, the target code rate coefficient of the video frame, the maximum bit of the group of pictures and the number of frames included in the group of pictures are input into the bit determination function of the video frame, and the target bit of the output video frame is determined, According to the pixel value of each pixel of the video frame, determine each second parameter value of the texture complexity of the video frame and each image block of the video frame, wherein the texture complexity is gradient, variance, average Any of the parameters such as absolute difference and absolute error sum;
针对该视频帧的每个图像块,确定该图像块的第二参数值和该视频帧的第二参数值的第四比值,并确定所述第四比值与该视频帧的所述目标比特的第四乘积值为该图像块的第一比特,将该图像块的第一比特输入到码率控制模型,得到输出的该图像块的候选量化参数;For each image block of the video frame, determine a fourth ratio between the second parameter value of the image block and the second parameter value of the video frame, and determine the ratio between the fourth ratio and the target bit of the video frame The fourth product value is the first bit of the image block, and the first bit of the image block is input to the code rate control model to obtain the output candidate quantization parameter of the image block;
若该图像块为前景图像块,根据预先保存的第二映射关系,确定该图像块的所述候选量化参数在所述第二映射关系中对应的目标量化参数,若该图像块为背景图像块,根据预先保存的第三映射关系,确定该图像块的所述候选量化参数在所述第三映射关系中对应的目标量化参数;If the image block is a foreground image block, according to the pre-saved second mapping relationship, determine the target quantization parameter corresponding to the candidate quantization parameter of the image block in the second mapping relationship, if the image block is a background image block , according to a pre-stored third mapping relationship, determine a target quantization parameter corresponding to the candidate quantization parameter of the image block in the third mapping relationship;
所述根据所述目标视频中所述每个视频帧的量化参数,对所述目标视频中所述每个视频帧进行编码包括:The encoding each video frame in the target video according to the quantization parameter of each video frame in the target video includes:
根据所述目标视频中所述每个视频帧的每个图像块的目标量化参数,对所述目标视频中所述每个视频帧的每个图像块进行编码。Encoding each image block of each video frame in the target video according to the target quantization parameter of each image block in each video frame in the target video.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application may be provided as methods, systems, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本申请是参照根据本申请的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the present application. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the application without departing from the spirit and scope of the application. In this way, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application is also intended to include these modifications and variations.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211731021.1A CN115955564A (en) | 2022-12-30 | 2022-12-30 | Video coding method, device, equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211731021.1A CN115955564A (en) | 2022-12-30 | 2022-12-30 | Video coding method, device, equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115955564A true CN115955564A (en) | 2023-04-11 |
Family
ID=87291230
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211731021.1A Pending CN115955564A (en) | 2022-12-30 | 2022-12-30 | Video coding method, device, equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115955564A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118368423A (en) * | 2024-06-19 | 2024-07-19 | 摩尔线程智能科技(北京)有限责任公司 | Video encoding method, video encoder, electronic device and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1988659A (en) * | 2006-12-30 | 2007-06-27 | 清华大学 | Method for control video frequency coding rate |
US20090147853A1 (en) * | 2007-12-10 | 2009-06-11 | Qualcomm Incorporated | Resource-adaptive video interpolation or extrapolation |
CN108462878A (en) * | 2018-04-09 | 2018-08-28 | 公安海警学院 | Instructional video compression algorithm based on key frame and indicator motion model |
CN109951706A (en) * | 2019-04-22 | 2019-06-28 | 湖南国科微电子股份有限公司 | A kind of method for video coding, device and encoder |
CN114745590A (en) * | 2021-01-07 | 2022-07-12 | 阿里巴巴集团控股有限公司 | Video frame encoding method, video frame encoding device, electronic device, and medium |
-
2022
- 2022-12-30 CN CN202211731021.1A patent/CN115955564A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1988659A (en) * | 2006-12-30 | 2007-06-27 | 清华大学 | Method for control video frequency coding rate |
US20090147853A1 (en) * | 2007-12-10 | 2009-06-11 | Qualcomm Incorporated | Resource-adaptive video interpolation or extrapolation |
CN108462878A (en) * | 2018-04-09 | 2018-08-28 | 公安海警学院 | Instructional video compression algorithm based on key frame and indicator motion model |
CN109951706A (en) * | 2019-04-22 | 2019-06-28 | 湖南国科微电子股份有限公司 | A kind of method for video coding, device and encoder |
CN114745590A (en) * | 2021-01-07 | 2022-07-12 | 阿里巴巴集团控股有限公司 | Video frame encoding method, video frame encoding device, electronic device, and medium |
Non-Patent Citations (1)
Title |
---|
FABRICE LE LÉANNEC ECT.: "EE2-2.2: Motion compensated picture boundary padding", 《JOINT VIDEO EXPERTS TEAM (JVET) OF ITU-T SG 16 WP 3 AND ISO/IEC JTC 1/SC 29》, 22 July 2022 (2022-07-22) * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118368423A (en) * | 2024-06-19 | 2024-07-19 | 摩尔线程智能科技(北京)有限责任公司 | Video encoding method, video encoder, electronic device and storage medium |
CN118368423B (en) * | 2024-06-19 | 2024-10-15 | 摩尔线程智能科技(北京)有限责任公司 | Video encoding method, video encoder, electronic device and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
AU2019222715B2 (en) | Image reshaping in video coding using rate distortion optimization | |
JP5969389B2 (en) | Object recognition video coding strategy | |
JP5470405B2 (en) | Image coding apparatus and method | |
JP5496914B2 (en) | How to assess perceptual quality | |
US11070803B2 (en) | Method and apparatus for determining coding cost of coding unit and computer-readable storage medium | |
WO2018192235A1 (en) | Coding unit depth determination method and device | |
CN110062230B (en) | Image coding method and device | |
CN107454413B (en) | A Feature Preserving Video Coding Method | |
JPH08181992A (en) | Moving image coder and area extraction device | |
KR20010043760A (en) | Content-adaptive compression encoding | |
GB2459671A (en) | Scene Change Detection For Use With Bit-Rate Control Of A Video Compression System | |
Wang et al. | Semantic-aware video compression for automotive cameras | |
CN117480778A (en) | Residual coding and video coding methods, devices, equipment and systems | |
WO2019001283A1 (en) | Method and apparatus for controlling encoding resolution ratio | |
CN115955564A (en) | Video coding method, device, equipment and medium | |
JP2002252770A (en) | Classification method for image information, image coding method, and image coder | |
WO2020248715A1 (en) | Coding management method and apparatus based on high efficiency video coding | |
CN111385571A (en) | Method and device for controlling code rate of ultra-long image group | |
CN104301722A (en) | Video stream fuzzy detection method based on frequency domain | |
CN116828183A (en) | Video coding method, device, equipment and readable storage medium | |
CN109951707B (en) | A target motion vector selection method, device, electronic device and medium | |
US10848772B2 (en) | Histogram-based edge/text detection | |
CN102238382B (en) | Bit rate control method and device for image compression | |
CN113038135A (en) | CRF self-adaptive method based on block effect detection | |
CN112165619A (en) | Method for compressed storage of surveillance video |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |