WO2024108950A1 - 一种码流控制方法、装置及电子设备 - Google Patents

一种码流控制方法、装置及电子设备 Download PDF

Info

Publication number
WO2024108950A1
WO2024108950A1 PCT/CN2023/096814 CN2023096814W WO2024108950A1 WO 2024108950 A1 WO2024108950 A1 WO 2024108950A1 CN 2023096814 W CN2023096814 W CN 2023096814W WO 2024108950 A1 WO2024108950 A1 WO 2024108950A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
data
cache
feature
cache queue
Prior art date
Application number
PCT/CN2023/096814
Other languages
English (en)
French (fr)
Inventor
薛超
张鹏超
王洪涛
唐波
田杰
汤瑞宝
陈澎祥
Original Assignee
天地伟业技术有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 天地伟业技术有限公司 filed Critical 天地伟业技术有限公司
Publication of WO2024108950A1 publication Critical patent/WO2024108950A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/136Incoming video signal characteristics or properties
    • H04N19/14Coding unit complexity, e.g. amount of activity or edge presence estimation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/146Data rate or code amount at the encoder output
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/42Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
    • H04N19/423Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation characterised by memory arrangements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N7/00Television systems
    • H04N7/18Closed-circuit television [CCTV] systems, i.e. systems in which the video signal is not broadcast

Definitions

  • the present invention relates to the field of video coding technology, and in particular to a code stream control method, device and electronic equipment.
  • bitrate control methods are based on historical information before the current encoding frame. Such a bitrate control strategy will result in a large image frame difference when there is a sudden large movement in the scene, such as the movement of people or vehicles, causing the bitrate to suddenly increase, and quickly triggering the bitrate upper limit.
  • the encoder has to use a higher compression rate to ensure the stability of the bitrate. The higher the image compression rate, the more serious the image quality declines, and the bitrate cannot be reasonably distributed, resulting in poor image quality.
  • the existing technology has the problem of being unable to reasonably distribute the code stream.
  • the purpose of the present invention is to provide a code stream control method, device and electronic device to alleviate the technical problem that the prior art cannot reasonably distribute the code stream.
  • the present invention provides a code stream control method, comprising:
  • the encoder is called, and the encoder encodes the image buffer data according to the bit stream control parameters to obtain bit stream data.
  • the step of extracting features from the image data to obtain image feature data includes:
  • the step of extracting the image complexity and motion complexity of the grayscale image to obtain image feature data includes:
  • the motion complexity data is obtained by calculating the frame difference between the current frame and the previous frame of the grayscale image
  • image feature data is obtained
  • N is the number of pixels
  • Xi is the value of each pixel
  • is the mean of the pixel
  • is the mean square error of the image
  • the image cache queue and the feature cache queue have the same length.
  • the lengths of the image cache queue and the feature cache queue are both buf_len.
  • the length of the image cache queue is the length of the group of pictures gop.
  • the step of updating the bit stream control parameters in real time according to the characteristic cache data further includes:
  • bit stream control parameter is a compression rate parameter
  • the compression rate parameter is controlled by adjusting the quantization parameter
  • the quantization parameters include frame-level encoding parameters and macroblock-level encoding parameters.
  • the present invention further provides a bit stream control device, comprising:
  • Receiving module used to receive image data
  • Image cache module used to create an image cache queue, cache image data, and obtain image cache data
  • Feature extraction module used to extract features from image data to obtain image feature data
  • Feature cache module used to create a feature cache queue, cache image feature data, and obtain feature cache data
  • Stream control module used to cache data based on features and update stream control parameters in real time
  • Encoding module used to call the encoder, which encodes the image cache data according to the bit stream control parameters to obtain bit stream data.
  • the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, and when the processor executes the computer program, the steps of the method described in the first aspect are implemented.
  • the present invention provides a code stream control method, comprising: receiving image data; creating an image cache queue, caching the image data, and obtaining image cache data; extracting features from the image data, and obtaining image feature data; creating a feature cache queue, caching the image feature data, and obtaining feature cache data; updating code stream control parameters in real time according to the feature cache data; calling an encoder, and the encoder encodes the image cache data according to the code stream control parameters to obtain code stream data.
  • the code stream control method provided by the present invention, by creating an image cache queue, it is possible to detect the image feature data after the current encoding frame in advance, use the feature cache queue to cache the image feature data, predict changes in the subsequent image queue in advance, respond in advance, and update the code stream control parameters in real time according to the feature cache data.
  • the encoder encodes the image cache data according to the code stream control parameters. When a large movement suddenly occurs in the scene, the code stream control parameters can be adjusted in advance according to the feature cache data (that is, the compression rate is increased in advance).
  • the average compression rate of each frame will not be too high, and the limited code stream can be reasonably allocated to each image frame, thereby improving the overall image quality, thereby effectively solving the problem of being unable to reasonably allocate the code stream, and ensuring the output of a code stream with constant quality.
  • a code stream control device and electronic device provided by the present invention also have the above technical effects.
  • FIG1 is a flow chart of a code stream control method provided by an embodiment of the present invention.
  • FIG. 2 is a schematic diagram of a bit stream control device in an embodiment of the present invention.
  • bitrate control methods are based on historical information before the current encoding frame. Such a bitrate control strategy will result in a large image frame difference when there is a sudden large movement in the scene, such as the movement of people or vehicles, causing the bitrate to suddenly increase, and quickly triggering the bitrate upper limit.
  • the encoder has to use a higher compression rate to ensure the stability of the bitrate. The higher the image compression rate, the more serious the image quality declines, and the bitrate cannot be reasonably distributed, resulting in poor image quality.
  • the existing technology has the problem of being unable to reasonably distribute the code stream.
  • an embodiment of the present invention provides a code stream control method.
  • an embodiment of the present invention provides a code stream control method, including:
  • S2 Create an image cache queue, cache the image data, and obtain image cache data
  • the image feature data after the current encoding frame can be detected in advance, and the image feature data can be processed by using the feature cache queue.
  • the data is cached, and changes in the subsequent image queues are predicted in advance, and responses are made in advance.
  • the bitstream control parameters are updated in real time.
  • the encoder encodes the image cache data according to the bitstream control parameters. When a large movement suddenly occurs in the scene, the bitstream control parameters can be adjusted in advance according to the feature cache data (that is, the compression rate is increased in advance).
  • the average compression rate of each frame will not be too high, and the limited bitstream can be reasonably allocated to each image frame, which improves the overall image quality, thereby effectively solving the problem of being unable to reasonably allocate the bitstream and ensuring the output of a bitstream with constant quality.
  • step S3 specifically includes:
  • the image data is gray-processed to reduce the computational complexity of the subsequent extraction of image complexity and motion complexity.
  • the gray-scale image is sent to the feature extraction module to extract image complexity and motion complexity.
  • step S32 specifically includes:
  • S322 obtaining motion complexity data by calculating the frame difference between the current frame and the previous frame of the grayscale image
  • the formula for the mean square error of the image is: Where N is the number of pixels, Xi is the value of each pixel, ⁇ is the mean of the pixel, and ⁇ is the mean square error of the image;
  • I diff I cur - I pre , where I diff is the image frame difference, I cur is the current frame image, and I pre is the previous frame image.
  • I diff refers to the difference between two frames. Each pixel in I diff can be summed up, and this sum can be used to evaluate the intensity of motion. The more intense the motion, the greater the sum value.
  • Image complexity can be characterized by the image mean square error. The larger the mean square error, the higher the image complexity.
  • Motion complexity can be characterized by the frame difference between the current frame and the previous frame. The larger the frame difference, the higher the motion complexity.
  • Image feature data is generated based on the obtained image complexity value and motion complexity value, which is used to update the bitrate control parameters in real time based on the feature cache data.
  • the feature cache data provides future image information. Both historical image information and future image information can be used as basic data to update the bitrate control parameters in real time, thereby improving the accuracy of the bitrate control parameters and facilitating the output of stable and high-quality images.
  • the length of the image cache queue is the same as that of the feature cache queue.
  • the image cache queue and the feature cache queue are set to have the same length, so that image feature extraction and image caching can be performed synchronously.
  • the code stream control parameters are updated according to the feature cache data.
  • the H264 or H265 encoder starts to encode the image and outputs the code stream encoded by the encoder.
  • the lengths of the image cache queue and the feature cache queue are both buf_len.
  • the length of the image cache queue is the length of the image group gop.
  • one gop of image frames is cached.
  • one gop is generally 25 or 50 frames. That is to say, if 1 to 2 seconds of data are cached in advance, I can predict the image scene changes after 1 to 2 seconds, and I can increase or decrease the compression rate 1 to 2 seconds in advance.
  • the advance time is proportional to the length of the cache queue. The more data is cached, the earlier the time can be advanced.
  • the longer the image cache queue the richer the image information that the code stream control module predicts in advance, the earlier the response is made, and the more obvious the improvement in encoding quality is. However, this also causes an increase in code stream delay. Therefore, to balance the selection of the length of the image cache queue, the length of the image group gop can generally be selected. In addition, for scenes such as video transcoding that do not require high real-time performance, a longer image cache queue can be selected as much as possible to maximize the encoding quality.
  • step S5 the method further includes:
  • step S5 If yes, execute step S5; if no, return to step S501.
  • the step of updating the bitrate control parameters in real time according to the feature cache data is executed. That is, only when the feature cache data is cached completely can the corresponding bitrate control parameters be generated according to all the data in the complete feature cache queue.
  • the code stream control parameter is a compression rate parameter; the compression rate parameter is controlled by adjusting the quantization parameter; the quantization parameter includes a frame-level coding parameter and a macroblock-level coding parameter.
  • the compression rate is the result of the action of all code stream control parameters.
  • Video code rate image information amount x image compression rate.
  • Image coding is mainly divided into four steps: prediction, transformation, quantization, and entropy coding.
  • the quantization step is lossy compression with precision loss
  • the other steps are lossless compression.
  • lossy compression has a loss of precision, but the compression rate can be higher. Therefore, the compression rate is generally affected by adjusting the quantization parameter, or in other words, all bitstream parameters are ultimately affected by adjusting the quantization parameter.
  • the quantization parameter is divided into frame-level coding parameters and macroblock-level coding parameters: (1) Frame-level coding parameters. Frame-level parameters are used to adjust the ratio of I frames and P frames. The larger the I frame, the smaller the P frame, and the clearer the image, but the motion scene will be worse; conversely, the smaller the I frame, the larger the P frame, the better the motion image, but because the quality of the I frame is not high, the overall image will be worse.
  • (2) Macroblock-level coding parameters Macroblock-level coding is used to adjust the coding ratio of flat areas and complex areas in the same frame. The human eye is more sensitive to the quality of flat areas than complex areas. If there are many complex areas in the scene, the quality of complex areas can be sacrificed to ensure the coding quality of flat areas.
  • the embodiment of the present invention further provides a bit stream control device, as shown in FIG2 , comprising:
  • Receiving module 1 used to receive image data
  • Image cache module 2 used to create an image cache queue, cache image data, and obtain image cache data
  • Feature extraction module 3 used to extract features from image data to obtain image feature data
  • Feature cache module 4 used to create a feature cache queue, cache image feature data, and obtain feature cache data;
  • Stream control module 5 used to update stream control parameters in real time according to feature cache data
  • Coding module 6 used to call the encoder, the encoder encodes the image cache data according to the code stream control parameters to obtain code stream data.
  • An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the computer program, the steps of the method provided in the above embodiment are implemented.
  • a bit stream control device and an electronic device provided in an embodiment of the present invention have the same technical features as a bit stream control method provided in the above embodiment, and thus can solve the same technical problems and achieve the same technical effects.
  • an embodiment of the present invention further provides a computer-readable storage medium, which stores machine-executable instructions.
  • the computer-executable instructions When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to execute the steps of the above method.
  • the device provided in the embodiment of the present invention may be specific hardware on the device or software or firmware installed on the device.
  • the implementation principle and technical effects of the device provided in the embodiment of the present invention are the same as those of the aforementioned method embodiment.
  • the specific working processes of the systems, devices and units described above can all refer to the corresponding processes in the aforementioned method embodiment, and will not be repeated here.
  • each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions.
  • the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings.
  • each box in the block diagram and/or flowchart, and the combination of boxes in the block diagram and/or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
  • the division of the units is only a logical function division, and there may be other division methods in actual implementation.
  • multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some communication interface, device or unit, which can be electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in the embodiment provided by the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium.
  • the technical solution of the invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the invention.
  • the aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc., various media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

本发明提供了一种码流控制方法、装置及电子设备,属于视频编码的技术领域,解决了现有技术存在无法对码流进行合理分配的问题。一种码流控制方法,其特征在于,包括:接收图像数据;创建图像缓存队列,对图像数据进行缓存,得到图像缓存数据;对图像数据进行特征提取,得到图像特征数据;创建特征缓存队列,对图像特征数据进行缓存,得到特征缓存数据;根据特征缓存数据,实时更新码流控制参数;调用编码器,编码器根据码流控制参数对图像缓存数据进行编码,得到码流数据。

Description

一种码流控制方法、装置及电子设备 技术领域
本发明涉及视频编码技术领域,尤其是涉及一种码流控制方法、装置及电子设备。
背景技术
对于视频监控而言,出于网络带宽有限的原因,为了保证通道带宽的充分利用,需要对视频编码的码流进行控制,希望能够以更小的带宽传输更高质量的视频。
现有的码流控制方法大都是基于当前编码帧之前的历史信息,这样的码流控制策略会导致场景内突然发生较大的运动时,如人物或车辆的移动等,图像帧差较大,使得码率突然升高,很快触发了码率上限的限制,编码器不得不采用较高的压缩率来保证码率的稳定,图像压缩率提得越高,图像质量就下降得越严重,无法将码流进行合理的分配,从而导致图像质量不佳。
因此,现有技术存在无法对码流进行合理分配的问题。
发明内容
本发明的目的在于提供一种码流控制方法、装置及电子设备,以缓解了现有技术存在无法对码流进行合理分配的技术问题。
第一方面,本发明提供的一种码流控制方法,包括:
接收图像数据;
创建图像缓存队列,对图像数据进行缓存,得到图像缓存数据;
对图像数据进行特征提取,得到图像特征数据;
创建特征缓存队列,对图像特征数据进行缓存,得到特征缓存数据;
根据特征缓存数据,实时更新码流控制参数;
调用编码器,编码器根据码流控制参数对图像缓存数据进行编码,得到码流数据。
进一步的,所述对图像数据进行特征提取,得到图像特征数据的步骤,包括:
对图像数据进行灰度处理,得到灰度图;
提取灰度图的图像复杂度和运动复杂度,得到图像特征数据。
进一步的,所述提取灰度图的图像复杂度和运动复杂度,得到图像特征数据的步骤包括:
通过计算灰度图的图像均方差,得到图像复杂度数据;
通过计算灰度图当前帧与前一帧的帧差,得到运动复杂度数据;
基于图像复杂度数据和运动复杂度数据,得到图像特征数据;
所述图像均方差的算式为其中,N为像素数量,Xi为每个像素的值,μ为像素的均值,σ为图像均方差;
所述帧差的算式为Idiff=Icur-Ipre,其中,Idiff为图像帧差,Icur为当前帧图像,Ipre为前一帧图像。
进一步的,所述图像缓存队列与所述特征缓存队列的长度相同。
进一步的,所述图像缓存队列和所述特征缓存队列的长度均为buf_len。
进一步的,所述图像缓存队列的长度为图像组gop的长度。
进一步的,所述根据特征缓存数据,实时更新码流控制参数的步骤之前,还包括:
判断图像缓存队列和特征缓存队列是否已满;
若是,则执行根据特征缓存数据,实时更新码流控制参数的步骤;
若否,则返回判断图像缓存队列和特征缓存队列是否已满的步骤。
进一步的,所述码流控制参数为压缩率参数;
所述压缩率参数通过调节量化参数进行控制;
所述量化参数包含帧级编码参数和宏块级编码参数。
第二方面,本发明还提供一种码流控制装置,包括:
接收模块:用于接收图像数据;
图像缓存模块:用于创建图像缓存队列,对图像数据进行缓存,得到图像缓存数据;
特征提取模块:用于对图像数据进行特征提取,得到图像特征数据;
特征缓存模块:用于创建特征缓存队列,对图像特征数据进行缓存,得到特征缓存数据;
码流控制模块:用于根据特征缓存数据,实时更新码流控制参数;
编码模块:用于调用编码器,编码器根据码流控制参数对图像缓存数据进行编码,得到码流数据。
第三方面,本发明还提供一种电子设备,包括存储器、处理器,所述存储器中存储有可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现第一方面所述的方法的步骤。
本发明提供一种码流控制方法,包括:接收图像数据;创建图像缓存队列,对图像数据进行缓存,得到图像缓存数据;对图像数据进行特征提取,得到图像特征数据;创建特征缓存队列,对图像特征数据进行缓存,得到特征缓存数据;根据特征缓存数据,实时更新码流控制参数;调用编码器,编码器根据码流控制参数对图像缓存数据进行编码,得到码流数据。
采用本发明提供的码流控制方法,通过创建图像缓存队列,可以提前去侦测当前编码帧之后的图像特征数据,利用特征缓存队列对图像特征数据进行缓存,提前预知后续图像队列发生的变化,提前做出响应,根据特征缓存数据,实时更新码流控制参数,编码器根据码流控制参数对图像缓存数据进行编码,在场景内突然发生较大运动时,可根据特征缓存数据提前调整码流控制参缩数(即提前进行压率的提高),这样平均在每一帧的压缩率就不会过高,把有限的码流合理地分配给各图像帧,提升了总体的图像质量,从而有效解决了无法对码流进行合理分配的问题,确保输出质量恒定的码流。
相应地,本发明提供的一种码流控制装置及电子设备,也同样具有上述技术效果。
附图说明
为了更清楚地说明本发明具体实施方式或现有技术中的技术方案,下面将对具体实施方式或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种码流控制方法流程图;
图2为本发明实施例中的码流控制装置示意图。
具体实施方式
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合附图对本发明的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本 领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
本发明实施例中所提到的术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括其他没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。
现有的码流控制方法大都是基于当前编码帧之前的历史信息,这样的码流控制策略会导致场景内突然发生较大的运动时,如人物或车辆的移动等,图像帧差较大,使得码率突然升高,很快触发了码率上限的限制,编码器不得不采用较高的压缩率来保证码率的稳定,图像压缩率提得越高,图像质量就下降得越严重,无法将码流进行合理的分配,从而导致图像质量不佳。
因此,现有技术存在无法对码流进行合理分配的问题。
为解决以上问题,本发明实施例实施例提供一种码流控制方法。
如图1所示,本发明实施例提供一种码流控制方法,包括:
S1:接收图像数据;
S2:创建图像缓存队列,对图像数据进行缓存,得到图像缓存数据;
S3:对图像数据进行特征提取,得到图像特征数据;
S4:创建特征缓存队列,对图像特征数据进行缓存,得到特征缓存数据;
S5:根据特征缓存数据,实时更新码流控制参数;
S6:调用编码器,编码器根据码流控制参数对图像缓存数据进行编码,得到码流数据。
采用本发明提供的码流控制方法,通过创建图像缓存队列,可以提前去侦测当前编码帧之后的图像特征数据,利用特征缓存队列对图像特征数 据进行缓存,提前预知后续图像队列发生的变化,提前做出响应,根据特征缓存数据,实时更新码流控制参数,编码器根据码流控制参数对图像缓存数据进行编码,在场景内突然发生较大运动时,可根据特征缓存数据提前调整码流控制参缩数(即提前进行压率的提高),这样平均在每一帧的压缩率就不会过高,把有限的码流合理地分配给各图像帧,提升了总体的图像质量,从而有效解决了无法对码流进行合理分配的问题,确保输出质量恒定的码流。
在一种可能的实施方式中,步骤S3,具体包括:
S31:对图像数据进行灰度处理,得到灰度图;
S32:提取灰度图的图像复杂度和运动复杂度,得到图像特征数据。
对图像数据进行灰度处理,降低后期提取图像复杂度和运动复杂度的计算量,将图像的灰度图送入特征提取模块,提取图像复杂度和运动复杂度。
在一种可能的实施方式中,步骤S32,具体包括:
S321:通过计算灰度图的图像均方差,得到图像复杂度数据;
S322:通过计算灰度图当前帧与前一帧的帧差,得到运动复杂度数据;
S323:基于图像复杂度数据和运动复杂度数据,得到图像特征数据;
图像均方差的算式为其中,N为像素数量,Xi为每个像素的值,μ为像素的均值,σ为图像均方差;
帧差的算式为Idiff=Icur-Ipre,其中,Idiff为图像帧差,Icur为当前帧图像,Ipre为前一帧图像。Idiff是指的两帧之间的差异,可以将Idiff中每个像素求和,这个求和就可以运动剧烈程度的评估量,运动越剧烈,求和值就越大。
图像复杂度可以用图像均方差来表征,均方差越大,则图像复杂度越高;运动复杂度可以用当前帧和上一帧的帧差来表征,帧差越大,则运动复杂度越高:根据得到的图像复杂度数值和运动复杂度数值,生成图像特征数据,用于后续根据特征缓存数据,实时更新码流控制参数,特征缓存数据提供了未来的图像信息,可以同时以历史图像信息和未来图像信息作为基础数据,实时更新码流控制参数,提高了码流控制参数的精准性,利于输出稳定且高质量的图像。
在一种可能的实施方式中,图像缓存队列与特征缓存队列的长度相同。设置相同长度的图像缓存队列和特征缓存队列,使得图像特征提取与图像缓存达到同步进行的效果,待图像缓存队列和特征缓存队列满了以后,根据特征缓存数据完成对码流控制参数的更新,此时H264或H265编码器开始进行图像编码,并将编码器编出的码流对外输出。
在一种可能的实施方式中,图像缓存队列和特征缓存队列的长度均为buf_len。图像缓存队列的长度为图像组gop的长度。通常的图像缓存队列里缓存一个gop的图像帧,安防监控录像普遍是1个gop是25或50帧,也就是说事先缓存了1~2秒的数据,我就能够预知1~2秒之后的图像场景变化,便可提前1~2秒去提高或降低压缩率。提前的时间和缓存队列的长度是成正比的,缓的数据越多,时间就可以越提前一些。图像缓存队列越长,码流控制模块提前预知的图像信息也就越丰富,做出的响应也就越提前,对编码质量的提高程度也就越明显。但是,这样也造成了码流延迟的增加,因此要平衡图像缓存队列的长度选择,一般可以选择图像组gop的长度,另外针对视频转码等对实时性要求不高的场景,可尽量选择较长的图像缓存队列,能够最大化提高编码质量。
在一种可能的实施方式中,步骤S5之前,还包括:
S501:判断图像缓存队列和特征缓存队列是否已满;
若是,则执行步骤S5;若否,则返回步骤S501。
只有当图像缓存队列和特征缓存队列都已满的情况下,才执行根据特征缓存数据,实时更新码流控制参数的步骤,也就是只有特征缓存数据缓存完整,才能够根据完整的特征缓存队列中的所有数据,生成对应的码流控制参数。
在一种可能的实施方式中,码流控制参数为压缩率参数;压缩率参数通过调节量化参数进行控制;量化参数包含帧级编码参数和宏块级编码参数。压缩率是所有码流控制参数作用的结果,视频码率=图像信息量x图像压缩率,首先我们希望视频码率,也就是每秒所产生的视频大小是恒定的,或者是越小越好,但是图像信息量是不断变化的,有时相对大一点,有时相对小一点,要想保证视频码率固定,根据公式,我们只能通过调节图像压缩率去保证码流大小的恒定。但是压缩率高了,图像质量就会变差。在这种情况下,我们可以根据人眼对平坦区域敏感,对复杂区域不敏感的特性,提高复杂区域的压缩率,来提高图像的主观质量感受。即对不同的区域的,不同的图像帧,采用不同的压缩率,这个调的就比较细了。图像编码主要分为预测、变换、量化、熵编码四步,其中量化这一步是有损压缩,是有精度损失的,其他步骤都是无损压缩。有损压缩比起无损压缩,虽然有精度损失,但是压缩率能够更大。所以一般都是通过调节量化参数来影响压缩率的,或者说所有的码流参数都是通过调整量化参数,去最终影响压缩率的。量化值越大,图像压缩率越大,量化值越小,图像压缩率越小。量化参数分为帧级编码参数和宏块级编码参数:(1)帧级编码参数,帧级参数用于调节I帧、P帧的比例,I帧越大,P帧越小,图像越清晰,但是运动场景就会变差一些;反之I帧越小,P帧越大,运动图像会好一些,但是因I帧质量不高,图像整体也会变差。(2)宏块级编码参数宏块级编码用于调节同一帧内,平坦区域与复杂区域的编码比例;人眼对平坦区域的质量比复杂区域更敏感,如果场景内复杂区域比较多的时候,可以牺牲复杂区域的质量,来保证平坦区域的编码质量。
本发明实施例还提供一种码流控制装置,如图2所示,包括:
接收模块1:用于接收图像数据;
图像缓存模块2:用于创建图像缓存队列,对图像数据进行缓存,得到图像缓存数据;
特征提取模块3:用于对图像数据进行特征提取,得到图像特征数据;
特征缓存模块4:用于创建特征缓存队列,对图像特征数据进行缓存,得到特征缓存数据;
码流控制模块5:用于根据特征缓存数据,实时更新码流控制参数;
编码模块6:用于调用编码器,编码器根据码流控制参数对图像缓存数据进行编码,得到码流数据。
本发明实施例还提供一种电子设备,包括存储器、处理器,存储器中存储有可在处理器上运行的计算机程序,处理器执行计算机程序时实现上述实施例提供的方法的步骤。
本发明实施例提供的一种码流控制装置和电子设备与上述实施例提供的一种码流控制方法具有相同的技术特征,因此能够解决相同的技术问题,达到相同的技术效果。
对应于上述方法,本发明实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有机器可运行指令,所述计算机可运行指令在被处理器调用和运行时,所述计算机可运行指令促使所述处理器运行上述方法的步骤。
本发明实施例所提供的装置可以为设备上的特定硬件或者安装于设备上的软件或固件等。本发明实施例所提供的装置,其实现原理及产生的技术效果和前述方法实施例相同,为简要描述,装置实施例部分未提及之处,可参考前述方法实施例中相应内容。所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,前述描述的系统、装置和单元的具体工作过程,均可以参考上述方法实施例中的对应过程,在此不再赘述。
在本发明所提供的几个实施例中,应该理解到,所揭露的装置和方法,也可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,附图中的流程图和框图显示了根据本发明的多个实施例的装置、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,所述模块、程序段或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现方式中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
又例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,再例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本发明提供的实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发 明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,简称ROM)、随机存取存储器(Random Access Memory,简称RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释,此外,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。
最后应说明的是:以上所述实施例,仅为本发明的具体实施方式,用以说明本发明的技术方案,而非对其限制,本发明的保护范围并不局限于此,尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本发明实施例技术方案的范围。都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以权利要求的保护范围为准。

Claims (10)

  1. 一种码流控制方法,其特征在于,包括:
    接收图像数据;
    创建图像缓存队列,对图像数据进行缓存,得到图像缓存数据;
    对图像数据进行特征提取,得到图像特征数据;
    创建特征缓存队列,对图像特征数据进行缓存,得到特征缓存数据;
    根据特征缓存数据,实时更新码流控制参数;
    调用编码器,编码器根据码流控制参数对图像缓存数据进行编码,得到码流数据。
  2. 根据权利要求1所述的码流控制方法,其特征在于,所述对图像数据进行特征提取,得到图像特征数据的步骤,包括:
    对图像数据进行灰度处理,得到灰度图;
    提取灰度图的图像复杂度和运动复杂度,得到图像特征数据。
  3. 根据权利要求1所述的码流控制方法,其特征在于,所述提取灰度图的图像复杂度和运动复杂度,得到图像特征数据的步骤包括:
    通过计算灰度图的图像均方差,得到图像复杂度数据;
    通过计算灰度图当前帧与前一帧的帧差,得到运动复杂度数据;
    基于图像复杂度数据和运动复杂度数据,得到图像特征数据;
    所述图像均方差的算式为其中,N为像素数量,Xi为每个像素的值,μ为像素的均值,σ为图像均方差;
    所述帧差的算式为Idiff=Icur-Ipre,其中,Idiff为图像帧差,Icur为当前帧图像,Ipre为前一帧图像。
  4. 根据权利要求1所述的码流控制方法,其特征在于,所述图像缓存队列与所述特征缓存队列的长度相同。
  5. 根据权利要求4所述的码流控制方法,其特征在于,所述图像缓存队列和所述特征缓存队列的长度均为buf_len。
  6. 根据权利要求1所述的码流控制方法,其特征在于,所述图像缓存队列的长度为图像组gop的长度。
  7. 根据权利要求1所述的码流控制方法,其特征在于,所述根据特征缓存数据,实时更新码流控制参数的步骤之前,还包括:
    判断图像缓存队列和特征缓存队列是否已满;
    若是,则执行根据特征缓存数据,实时更新码流控制参数的步骤;
    若否,则返回判断图像缓存队列和特征缓存队列是否已满的步骤。
  8. 根据权利要求1所述的码流控制方法,其特征在于,所述码流控制参数为压缩率参数;
    所述压缩率参数通过调节量化参数进行控制;
    所述量化参数包含帧级编码参数和宏块级编码参数。
  9. 一种码流控制装置,其特征在于,包括:
    接收模块:用于接收图像数据;
    图像缓存模块:用于创建图像缓存队列,对图像数据进行缓存,得到图像缓存数据;
    特征提取模块:用于对图像数据进行特征提取,得到图像特征数据;
    特征缓存模块:用于创建特征缓存队列,对图像特征数据进行缓存,得到特征缓存数据;
    码流控制模块:用于根据特征缓存数据,实时更新码流控制参数;
    编码模块:用于调用编码器,编码器根据码流控制参数对图像缓存数据进行编码,得到码流数据。
  10. 一种电子设备,包括存储器、处理器,所述存储器中存储有可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现上述权利要求1至8任一项所述的方法的步骤。
PCT/CN2023/096814 2022-11-22 2023-05-29 一种码流控制方法、装置及电子设备 WO2024108950A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211468455.7A CN115733981A (zh) 2022-11-22 2022-11-22 一种码流控制方法、装置及电子设备
CN202211468455.7 2022-11-22

Publications (1)

Publication Number Publication Date
WO2024108950A1 true WO2024108950A1 (zh) 2024-05-30

Family

ID=85297605

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/096814 WO2024108950A1 (zh) 2022-11-22 2023-05-29 一种码流控制方法、装置及电子设备

Country Status (2)

Country Link
CN (1) CN115733981A (zh)
WO (1) WO2024108950A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115733981A (zh) * 2022-11-22 2023-03-03 天地伟业技术有限公司 一种码流控制方法、装置及电子设备

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05300492A (ja) * 1991-12-18 1993-11-12 Victor Co Of Japan Ltd 動画像符号化装置
CN101895758A (zh) * 2010-07-23 2010-11-24 南京信息工程大学 基于帧复杂度的h.264码率控制方法
CN101895759A (zh) * 2010-07-28 2010-11-24 南京信息工程大学 一种h.264码率控制方法
KR20100129091A (ko) * 2009-05-29 2010-12-08 서울대학교산학협력단 H.264를 위한 프레임 단위 비트율 제어 방법
CN105744342A (zh) * 2016-01-28 2016-07-06 腾讯科技(深圳)有限公司 移动终端的数据传输方法和装置
CN113473131A (zh) * 2021-07-01 2021-10-01 成都国科微电子有限公司 视频编码码率动态调节方法、装置、电子设备及存储介质
CN114979726A (zh) * 2022-06-30 2022-08-30 重庆紫光华山智安科技有限公司 码率调整方法、装置、服务器和存储介质
CN115733981A (zh) * 2022-11-22 2023-03-03 天地伟业技术有限公司 一种码流控制方法、装置及电子设备

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05300492A (ja) * 1991-12-18 1993-11-12 Victor Co Of Japan Ltd 動画像符号化装置
KR20100129091A (ko) * 2009-05-29 2010-12-08 서울대학교산학협력단 H.264를 위한 프레임 단위 비트율 제어 방법
CN101895758A (zh) * 2010-07-23 2010-11-24 南京信息工程大学 基于帧复杂度的h.264码率控制方法
CN101895759A (zh) * 2010-07-28 2010-11-24 南京信息工程大学 一种h.264码率控制方法
CN105744342A (zh) * 2016-01-28 2016-07-06 腾讯科技(深圳)有限公司 移动终端的数据传输方法和装置
CN113473131A (zh) * 2021-07-01 2021-10-01 成都国科微电子有限公司 视频编码码率动态调节方法、装置、电子设备及存储介质
CN114979726A (zh) * 2022-06-30 2022-08-30 重庆紫光华山智安科技有限公司 码率调整方法、装置、服务器和存储介质
CN115733981A (zh) * 2022-11-22 2023-03-03 天地伟业技术有限公司 一种码流控制方法、装置及电子设备

Also Published As

Publication number Publication date
CN115733981A (zh) 2023-03-03

Similar Documents

Publication Publication Date Title
US11412229B2 (en) Method and apparatus for video encoding and decoding
CN114071189B (zh) 视频处理装置及视频串流的处理方法
WO2021244341A1 (zh) 图像编码方法及装置、电子设备及计算机可读存储介质
US10587874B2 (en) Real-time video denoising method and terminal during coding, and non-volatile computer readable storage medium
KR100307618B1 (ko) 영상부호화방법및장치
KR20200044665A (ko) 부호화 방법 및 그 장치, 복호화 방법 및 그 장치
JPH08181992A (ja) 動画像符号化装置および領域抽出装置
US20210152621A1 (en) System and methods for bit rate control
US12022096B2 (en) Human visual system adaptive video coding
US11190775B2 (en) System and method for reducing video coding fluctuation
US11134250B2 (en) System and method for controlling video coding within image frame
WO2019104635A1 (en) System and method for controlling video coding at frame level
WO2018161867A1 (zh) 码率分配方法、设备及存储介质
US11012698B2 (en) Image encoding apparatus and method for controlling the same
JP3703299B2 (ja) ピクチャ中央の画質を最適化するためのビデオ符号化方法、システムおよびコンピュータ・プログラム製品
WO2024108950A1 (zh) 一种码流控制方法、装置及电子设备
TW201349877A (zh) 影像編碼裝置、影像編碼方法、影像編碼程式、送訊裝置、送訊方法、送訊程式、以及影像解碼裝置、影像解碼方法、影像解碼程式、收訊裝置、收訊方法及收訊程式
JP2020198463A (ja) 符号化プログラム、復号プログラム、符号化装置、復号装置、符号化方法及び復号方法
WO2019001283A1 (zh) 编码分辨率控制方法及装置
CN101390389A (zh) 用于在双通道编码中选择比特预算调节的方法与设备
US11145030B2 (en) Method of controlling encoding of display data
US20200084467A1 (en) Low light compression
JP4942208B2 (ja) 符号化装置
WO2024082971A1 (zh) 一种视频处理方法及相关装置
JP2014003587A (ja) 画像符号化装置及びその方法