CN114760475A - Video encoding method and device, storage medium and electronic equipment - Google Patents

Video encoding method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN114760475A
CN114760475A CN202110026092.0A CN202110026092A CN114760475A CN 114760475 A CN114760475 A CN 114760475A CN 202110026092 A CN202110026092 A CN 202110026092A CN 114760475 A CN114760475 A CN 114760475A
Authority
CN
China
Prior art keywords
quality
video
source video
frame
value
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
Application number
CN202110026092.0A
Other languages
Chinese (zh)
Inventor
熊宝玉
汪贤
鲁方波
樊鸿飞
蔡媛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
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 Beijing Kingsoft Cloud Network Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202110026092.0A priority Critical patent/CN114760475A/en
Publication of CN114760475A publication Critical patent/CN114760475A/en
Pending legal-status Critical Current

Links

Images

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/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/154Measured or subjectively estimated visual quality after decoding, e.g. measurement of distortion
    • 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

Abstract

The invention discloses a video coding method and device, a storage medium and electronic equipment, and belongs to the technical field of video coding. Wherein, the method comprises the following steps: acquiring a quality weight of a source video frame to be coded, wherein the quality weight is used for representing the influence degree of the source video frame on the quality of a source video; adjusting the CRF value of the original fixed code rate coefficient of the source video frame based on the quality weight to obtain a target CRF value; and encoding the source video frame according to the target CRF value. The invention solves the technical problem of poor video impression caused by adopting a fixed CRF value for coding in the related technology, improves the code rate of key frames under the condition of ensuring the integral quality of the video, and enhances the impression effect and the impression experience of a user during video playing.

Description

Video encoding method and device, storage medium and electronic equipment
Technical Field
The present invention relates to the field of video coding, and in particular, to a video coding method and apparatus, a storage medium, and an electronic device.
Background
When video encoding is performed, the related art refers to a method of converting a file in an original video format into a file in another video format through a compression technique. Common codec standards for video streaming include h.264, h.265, AVS, AV1, and the like.
In the related art, there are various code Rate control methods in video coding, including a Constant Bit Rate (CBR) mode with a Constant code Rate, and a Constant Rate Factor (CRF) mode with a Constant visual quality, where each code Rate control method finally achieves the effect of code Rate control by changing the QP value of each frame. The CRF mode uses an input CRF value as a reference QP (quantization parameter), and the mode of saving bit rate and preserving image quality of video coding is realized by optimizing an encoder or optimizing an objective index, which both adopt the objective index to guide coding, so that the compression amount of the video is increased, or the size of the video file is increased.
In the CRF method in the related technology, only objective indexes are usually considered, and the influence of the subjective quality of a single frame of a video on the subjective quality of the whole video is not considered. However, the applicant has found that different frames have different subjective feelings to the user at different rates, such as the user being more interested in the frames of the scene that are foreground, less interested in the frames that are transitions between scenes, more interested in the close-up scene, less interested in the long-range scene, etc.
In view of the above problems in the related art, no effective solution has been found so far.
Disclosure of Invention
The embodiment of the invention provides a video coding method and device, a storage medium and electronic equipment.
According to an aspect of an embodiment of the present application, there is provided a video encoding method, including: acquiring a quality weight of a source video frame to be coded, wherein the quality weight is used for representing the influence degree of the source video frame on the quality of a source video; adjusting the CRF value of the original fixed code rate coefficient of the source video frame based on the quality weight to obtain a target CRF value; and encoding the source video frame according to the target CRF value.
Further, adjusting the original CRF value of the source video frame based on the quality weight to obtain a target CRF value, including: comparing the quality weight with a preset threshold; if the quality weight is larger than the preset threshold, reducing the original CRF value of the source video frame to obtain a first target CRF value; if the quality weight is smaller than the preset threshold, increasing the original CRF value of the source video frame to obtain a second target CRF value; and if the quality weight is equal to the preset threshold value, maintaining the original CRF value of the source video frame to obtain a third target CRF value.
Further, encoding the source video frame according to the target CRF value comprises: calculating a Quantization Parameter (QP) value based on the target CRF value; and compressing the source video frame by adopting the QP value to generate a target video frame, wherein the code rate value of the target video frame is positively correlated with the quality weight.
Further, obtaining the quality weight of the source video frame to be encoded comprises: calculating a first quality value for the frames of the source video and calculating a second quality value for the source video; calculating the mass weights using the following algorithm model: vmos=FmosW; wherein, VmosIs said second quality value, FmosA one-dimensional matrix of first quality values for a plurality of source video frames, W being a quality weight, the source video comprising the plurality of source video frames.
Further, before calculating the quality weights using an algorithmic model, the method further comprises: collecting sample video data; determining video quality of sample video in the sample video data and video frame quality of each frame of the sample video; training a preset original model by taking the video frame quality as input information and the video quality as output information to obtain Vmos=FmosW。
Further, determining a video quality of a sample video in the sample video data, and a video frame quality per frame of the sample video, includes one of: calculating the video quality of the sample video in the sample video data by adopting an image quality evaluation algorithm, and calculating the video frame quality of each frame of the sample video by adopting the image quality evaluation algorithm; receiving first label information of the sample video and second label information of video frame quality of each frame of the sample video; determining the first tag information and the second tag information as the video quality and the video frame quality, respectively.
Further, obtaining the quality weight of the source video frame to be encoded comprises one of: acquiring quality weights of a plurality of continuous source video frames to be coded in the source video by taking a preset frame number as a unit, wherein the sum of the quality weights of the plurality of continuous source video frames is 1; acquiring the quality weights of all source video frames to be coded in the source video frame by frame, wherein the sum of the quality weights of all the source video frames is 1; sampling in the source video to obtain quality weights of a plurality of discrete source video frames to be coded, wherein the sum of the quality weights of the discrete source video frames is 1.
According to another aspect of the embodiments of the present application, there is also provided an apparatus for encoding a video, including: the device comprises an acquisition module, a coding module and a coding module, wherein the acquisition module is used for acquiring the quality weight of a source video frame to be coded, and the quality weight is used for representing the influence degree of the source video frame on the source video quality; the adjusting module is used for adjusting the CRF value of the original fixed code rate coefficient of the source video frame based on the quality weight to obtain a target CRF value; and the encoding module is used for encoding the source video frame according to the target CRF value.
Further, the adjustment module includes: the comparison unit is used for comparing the quality weight with a preset threshold value; the adjusting unit is used for reducing the original CRF value of the source video frame to obtain a first target CRF value if the quality weight is larger than the preset threshold; if the quality weight is smaller than the preset threshold, increasing the original CRF value of the source video frame to obtain a second target CRF value; and if the quality weight is equal to the preset threshold value, maintaining the original CRF value of the source video frame to obtain a third target CRF value.
Further, the encoding module includes: a calculation unit for calculating a quantization parameter QP value based on the target CRF value; and the compression unit is used for compressing the source video frame by adopting the QP value to generate a target video frame, wherein the code rate value of the target video frame is positively correlated with the quality weight.
Further, the obtaining module includes: a first calculating unit for calculating a first quality value of the frames of the source video and calculating a second quality value of the source video; a second calculating unit, configured to calculate the quality weight by using the following algorithm model: vmos=FmosW; wherein, VmosIs said second quality value, FmosA one-dimensional matrix of first quality values for a plurality of source video frames, W being a quality weight, the source video comprising the plurality of source video frames.
Further, the apparatus further comprises: the acquisition module is used for acquiring the quality weight of the video data; a determining module, configured to determine video quality of a sample video in the sample video data, and video frame quality of each frame of the sample video; a training module for training a preset original model by using the video frame quality as input information and the video quality as output information to obtain Vmos=FmosW。
Further, the determining module comprises one of: the computing unit is used for computing the video quality of the sample video in the sample video data by adopting an image quality evaluation algorithm and computing the video frame quality of each frame of the sample video by adopting the image quality evaluation algorithm; the determining unit is used for receiving first label information of the sample video and second label information of video frame quality of each frame of the sample video; determining the first tag information and the second tag information as the video quality and the video frame quality, respectively.
Further, the obtaining module includes one of: a first obtaining unit, configured to obtain quality weights of multiple continuous source video frames to be encoded in the source video by using a preset frame number as a unit, where a sum of the quality weights of the multiple continuous source video frames is 1; the second acquiring unit is used for acquiring the quality weights of all source video frames to be coded in the source video frame by frame, wherein the sum of the quality weights of all the source video frames is 1; and the third acquisition unit is used for sampling and acquiring the quality weights of a plurality of discrete source video frames to be encoded in the source video, wherein the sum of the quality weights of the plurality of discrete source video frames is 1.
According to another aspect of the embodiments of the present application, there is also provided a storage medium including a stored program that executes the above steps when the program is executed.
According to another aspect of the embodiments of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus; wherein: a memory for storing a computer program; a processor for executing the steps of the method by running the program stored in the memory.
Embodiments of the present application further provide a computer program product containing instructions, which when executed on a computer, cause the computer to perform the steps of the above method.
By the invention, the quality weight of the source video frame to be coded is obtained, then the CRF value of the original fixed code rate coefficient of the source video frame is adjusted based on the quality weight to obtain the target CRF value, finally the source video frame is coded according to the target CRF value, the CRF value of a single frame is adjusted based on the quality influence degree of the single frame image on the whole video, and the subjective quality evaluation method is applied to video coding so as to guide the coding of a coder, for the frames with large quality weight, the influence on the overall quality is more important to be displayed, a larger code rate value is allocated to the frames, and the frames with smaller weight, the influence on subjective quality is small, a small code rate value can be correspondingly distributed, the technical problem of poor video impression caused by the adoption of a fixed CRF value for coding in the related technology is solved, under the condition of ensuring the overall quality of the video, the code rate of the key frame is improved, and the impression effect and the impression experience of a user during video playing are enhanced.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 is a block diagram of a hardware configuration of a server according to an embodiment of the present invention;
fig. 2 is a flowchart of a video encoding method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a continuous source video frame according to an embodiment of the invention;
fig. 4 is a block diagram of a video encoding apparatus according to an embodiment of the present invention;
fig. 5 is a block diagram of an electronic device implementing an embodiment of the invention.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application. It should be noted that, in the present application, the embodiments and features of the embodiments may be combined with each other without conflict.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in sequences other than those illustrated or described herein. Moreover, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
The method provided in the first embodiment of the present application may be executed in a server, a computer, a video device, a mobile phone, a tablet, or a similar computing device. Taking an example of the server running on the server, fig. 1 is a hardware structure block diagram of a server according to an embodiment of the present invention. As shown in fig. 1, the server may include one or more (only one shown in fig. 1) processors 102 (the processors 102 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, and optionally may also include a transmission device 106 for communication functions and an input-output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration, and is not intended to limit the structure of the server. For example, the server may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store a server program, for example, a software program and a module of an application software, such as a server program corresponding to a video encoding method in an embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the server program stored in the memory 104, so as to implement the method described above. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to a server over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used to receive or transmit data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the server. In one example, the transmission device 106 includes a Network adapter (NIC) that can be connected to other Network devices through a base station to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used to communicate with the internet via wireless.
In the present embodiment, a video encoding method is provided, and fig. 2 is a flowchart of a video encoding method according to an embodiment of the present invention, where as shown in fig. 2, the flowchart includes the following steps:
step S202, obtaining a quality weight of a source video frame to be coded, wherein the quality weight is used for representing the influence degree of the source video frame on the source video quality;
the quality weight of the embodiment is a weight coefficient pre-allocated to the source video frame, the larger the influence degree of a single frame on the overall quality of the source video is, the larger the quality weight is, and conversely, the smaller the quality weight is, and meanwhile, in order to meet the constancy of the overall visual quality of the video, the quality weights of a plurality of source video frames meet the constraint condition of normalization.
Step S204, adjusting the CRF value of the original fixed code rate coefficient of the source video frame based on the quality weight to obtain a target CRF value;
in a constant visual quality (CRF) coding mode, the CRF value is related to the video code rate after the coding is completed. The code rate is the number of data bits transmitted in unit time during data transmission, the bit rate per second of the coded video is also called a sampling rate, the higher the sampling rate in unit time is, the higher the precision is, the closer the processed file is to the original file, the higher the code rate is, the clearer the distortion of the video is, and otherwise, the picture is rough and mosaic.
In step S206, the source video frame is encoded according to the target CRF value.
In the CRF mode (i.e., constant visual quality encoding mode) of the present embodiment, the adjusted target CRF is used to replace the specified original CRF value as the encoding parameter for encoding, so as to stabilize the visual quality of the output. For the video frames with smaller quality weight, the distortion is relatively difficult to be perceived by naked eyes, so that the CRF value can be increased for coding, and the code rate of the video is saved; and for the video with larger quality weight, smaller distortion is easier to be perceived by people, and the CRF value is reduced for coding, so that the code rate is increased to reduce the distortion of the video.
Through the steps, the quality weight of the source video frame to be coded is obtained, then the CRF value of the original fixed code rate coefficient of the source video frame is adjusted based on the quality weight to obtain the target CRF value, finally the source video frame is coded according to the target CRF value, the CRF value of a single frame is adjusted based on the quality influence degree of the single frame image on the whole video, and the subjective quality evaluation method is applied to video coding so as to guide the coding of a coder, for the frames with large quality weight, the influence on the overall quality is more important to be displayed, a larger code rate value is allocated to the frames, and the frames with smaller weight, the influence on subjective quality is small, a small code rate value can be correspondingly distributed, the technical problem of poor video impression caused by the adoption of a fixed CRF value for coding in the related technology is solved, under the condition of ensuring the overall quality of the video, the code rate of the key frame is improved, and the impression effect and the impression experience of a user during video playing are enhanced.
In an embodiment of this embodiment, adjusting the original CRF value of the source video frame based on the quality weight to obtain the target CRF value includes:
s11, comparing the quality weight with a preset threshold value;
optionally, the preset threshold of this embodiment is an intermediate value of the quality weight, such as 0, 0.5, and the like, if the quality weight is greater than the preset threshold, the influence degree of the source video frame on the quality of the source video is greater, otherwise, the influence degree of the source video frame on the quality of the source video is smaller than the preset threshold.
S12, if the quality weight is larger than the preset threshold, reducing the original CRF value of the source video frame to obtain a first target CRF value; if the quality weight is smaller than a preset threshold value, increasing an original CRF value of the source video frame to obtain a second target CRF value; and if the quality weight is equal to the preset threshold value, maintaining the original CRF value of the source video frame to obtain a third target CRF value.
In one embodiment of this embodiment, encoding the source video frame according to the target CRF value comprises: calculating a QP (quantization parameter) value based on the target CRF value; and compressing the source video frame by using the QP value to generate a target video frame, wherein the code rate value of the target video frame is positively correlated with the quality weight.
The larger the quality weight is, the larger the true code rate of the video after the encoding is finished is, the smaller the quality weight is, the smaller the true code rate of the video after the encoding is finished is, when the target video containing the target video frame is played, the distortion of the key frame concerned by a user is smaller, the distortion of the non-key frame concerned by the user is larger, meanwhile, the distortion is not easy to be perceived by the user, and the impression quality of the whole video is improved.
The method comprises the steps of obtaining the relation between each frame of the video and the overall quality of the video, and obtaining the importance degree of each frame according to the influence of the video frame on the overall quality of the video, thereby guiding an encoder to encode. For the frame with large weight, the influence on the overall quality is more important, so that a larger code rate value is allocated to the frame; the frame with smaller weight has smaller influence on subjectivity, and a smaller code rate value can be correspondingly allocated to save the code rate.
In one implementation of this embodiment, the quality weight of a single frame is calculated by an algorithmic model. Obtaining the quality weight of the source video frame to be encoded comprises:
s21, calculating a first quality value of the source video frames and a second quality value of the source video;
s22, calculating the mass weight by adopting the following algorithm model: vmos=FmosW;
Wherein, VmosIs of a second quality value, FmosA one-dimensional matrix of first quality values for a plurality of source video frames, W being a quality weight, the source video comprising the plurality of source video frames.
In one example based on the above algorithm model, the source video contains three source video frames, frame 1, frame 2, and frame 3, with quality weights of 1.7, 0.4, -1.1, and F, respectivelymos=[2,1,3],Vmos=0.5。
In this embodiment, the algorithm model may be obtained by pre-training based on the sample data and the basic model, or may be obtained from a third party. In one example, before the calculating the quality weight by using the algorithm model, the method further includes: collecting sample video data(ii) a Determining the video quality of the sample video in the sample video data and the video frame quality of each frame of the sample video; training a preset original model by taking the video frame quality as input information and the video quality as output information to obtain an algorithm model, namely Vmos=FmosW。
The video frame quality and the video quality are respectively input label data and output label data of a preset original model, an algorithm model capable of outputting the quality weight of a relative whole video through the video frame quality is obtained through training, as the source video frames in the source video are massive, the source video frames can correspondingly generate massive quality weights, the quality of the source video frames can be obtained through quantitative calculation, the algorithm model is adopted for automatic output, manual labeling is not needed, the automation degree of video coding is improved, the coding speed is improved, and the influence of manual distribution of the quality weights on a coding result is reduced.
In this embodiment, the image quality evaluation algorithm may be used for analyzing or manually marking to determine the quality of the sample, determine the video quality of the sample video in the sample video data, and determine the video frame quality of each frame of the sample video, which includes one of the following: calculating the video Quality of a sample video in the sample video data by adopting an Image Quality Assessment (IQA) algorithm, and calculating the video frame Quality of each frame of the sample video by adopting an Image Quality Assessment algorithm; receiving first label information of a sample video and second label information of video frame quality of each frame of the sample video; the first tag information and the second tag information are determined as video quality and video frame quality, respectively.
In this embodiment, obtaining the quality weight of the source video frame to be encoded comprises one of:
example one: acquiring quality weights of a plurality of continuous source video frames to be coded in a source video by taking the number of preset frames as a unit, wherein the sum of the quality weights of the plurality of continuous source video frames is 1;
optionally, the preset number of frames may be 16, 24, etc., fig. 3 is a schematic diagram of continuous source video frames according to an embodiment of the present invention, where continuous 16 frames of images are used as one coding unit, a source video includes a plurality of coding units, and the sum of quality weights of 16 continuous source video frames is 1;
example two: acquiring the quality weights of all source video frames to be coded in a source video frame by frame, wherein the sum of the quality weights of all the source video frames is 1;
example three: sampling in a source video to obtain quality weights of a plurality of discrete source video frames to be encoded, wherein the sum of the quality weights of the plurality of discrete source video frames is 1.
In the adoption process of the present example, sampling may be performed at a predetermined frame interval, or sampling may be performed randomly.
In an implementation scenario of this embodiment, an encoding process of an encoder is guided by an influence of subjective quality of a single frame of video on the subjective quality of the entire video, and subjective quality evaluation is applied to video encoding. The implementation process comprises the following steps:
(1) data set collection and labeling: crawling video data from a network, and scoring each frame of the video and the overall quality of the video in a manual labeling mode; in the invention, the quality of each frame of the video and the overall quality of the video are artificially marked, and a relative frame quality can be obtained by using an image quality evaluation method, so that the relationship between the relative frame quality and the overall quality of the video can be obtained finally and is also feasible;
(2) and learning the relation between each frame of the video and the overall quality of the video by using a deep learning model. The input of the model is the quality of each frame of the video, which is recorded as a one-dimensional matrix Fmos (vector), and the output is the overall quality Vmos of the video, and the relationship between Fmos and Vmos is expressed as follows:
Vmos=Fmosw; wherein W is the influence weight of each frame of video on the whole video;
(3) and mapping the weight W of each frame to the Delta crf, adding the Delta crf on the basis of the originally specified crf in the video coding process, and reallocating one corresponding crf to each frame. For the frame with large weight, the influence on the whole quality is more important, so that the delta crf value after mapping is negative, the original crf value is reduced, and a larger code rate value is distributed to the original crf value; the frame with smaller weight has smaller influence on subjectivity, the delta crf value is positive after mapping, the original crf value is increased, and a smaller code rate value can be correspondingly allocated to save the code rate.
The method comprises the steps of obtaining the relation between each frame of the video and the overall quality of the video, obtaining the importance degree of each frame according to the influence of the video frame on the overall quality of the video, and applying a subjective quality evaluation method to coding so as to guide the coding of a coder, wherein for the frame with large quality weight, the influence on the overall quality is more important, and a larger code rate value is distributed to the frame; and the frame with smaller weight has smaller influence on subjective quality, and a smaller code rate value can be correspondingly allocated to save the code rate.
Through the description of the foregoing embodiments, it is clear to those skilled in the art that the method according to the foregoing embodiments may be implemented by software plus a necessary general hardware platform, and certainly may also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
Example 2
In this embodiment, a video encoding apparatus is further provided for implementing the foregoing embodiments and preferred embodiments, which have already been described and are not repeated. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 4 is a block diagram of a video encoding apparatus according to an embodiment of the present invention, as shown in fig. 4, the apparatus including: an acquisition module 40, an adjustment module 42, an encoding module 44, wherein,
an obtaining module 40, configured to obtain a quality weight of a source video frame to be encoded, where the quality weight is used to characterize a degree of influence of the source video frame on source video quality;
an adjusting module 42, configured to adjust a CRF value of an original fixed rate coefficient of the source video frame based on the quality weight, to obtain a target CRF value;
and the encoding module 44 is configured to encode the source video frame according to the target CRF value.
Optionally, the adjusting module includes: the comparison unit is used for comparing the quality weight with a preset threshold value; the adjusting unit is used for reducing the original CRF value of the source video frame to obtain a first target CRF value if the quality weight is larger than the preset threshold; if the quality weight is smaller than the preset threshold, increasing the original CRF value of the source video frame to obtain a second target CRF value; and if the quality weight is equal to the preset threshold value, maintaining the original CRF value of the source video frame to obtain a third target CRF value.
Optionally, the encoding module includes: a calculation unit for calculating a quantization parameter QP value based on the target CRF value; and the compression unit is used for compressing the source video frame by adopting the QP value to generate a target video frame, wherein the code rate value of the target video frame is positively correlated with the quality weight.
Optionally, the obtaining module includes: a first calculating unit for calculating a first quality value of the frames of the source video and calculating a second quality value of the source video; a second calculating unit, configured to calculate the quality weight by using the following algorithm model: vmos=FmosW; wherein, VmosIs said second quality value, FmosA one-dimensional matrix of first quality values for a plurality of source video frames, W being a quality weight, the source video comprising the plurality of source video frames.
Optionally, the apparatus further comprises: the acquisition module is used for acquiring sample video data before the quality weight is calculated by the acquisition module by adopting an algorithm model; a determining module for determining the video quality of the sample video in the sample video data and the view of each frame of the sample videoA quality of a frequency frame; a training module for training a preset original model by using the video frame quality as input information and the video quality as output information to obtain Vmos=FmosW。
Optionally, the determining module includes one of: the computing unit is used for computing the video quality of the sample video in the sample video data by adopting an image quality evaluation algorithm and computing the video frame quality of each frame of the sample video by adopting the image quality evaluation algorithm; the determining unit is used for receiving first label information of the sample video and second label information of video frame quality of each frame of the sample video; determining the first tag information and the second tag information as the video quality and the video frame quality, respectively.
Optionally, the obtaining module includes one of: the first obtaining unit is used for obtaining the quality weights of a plurality of continuous source video frames to be coded in the source video by taking the number of preset frames as a unit, wherein the sum of the quality weights of the plurality of continuous source video frames is 1; the second acquiring unit is used for acquiring the quality weights of all source video frames to be coded in the source video frame by frame, wherein the sum of the quality weights of all the source video frames is 1; and the third acquisition unit is used for sampling and acquiring the quality weights of a plurality of discrete source video frames to be encoded in the source video, wherein the sum of the quality weights of the plurality of discrete source video frames is 1.
It should be noted that, the above modules may be implemented by software or hardware, and for the latter, the following may be implemented, but not limited to: the modules are all positioned in the same processor; alternatively, the modules are respectively located in different processors in any combination.
Example 3
Embodiments of the present invention also provide a storage medium having a computer program stored therein, wherein the computer program is arranged to perform the steps of any of the above method embodiments when executed.
Alternatively, in the present embodiment, the storage medium may be configured to store a computer program for executing the steps of:
s1, obtaining a quality weight of a source video frame to be coded, wherein the quality weight is used for representing the influence degree of the source video frame on the source video quality;
s2, adjusting the CRF value of the original fixed code rate coefficient of the source video frame based on the quality weight to obtain a target CRF value;
and S3, encoding the source video frame according to the target CRF value.
Optionally, in this embodiment, the storage medium may include but is not limited to: various media capable of storing computer programs, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Embodiments of the present invention also provide an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps of any of the above method embodiments.
Optionally, the electronic device may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, acquiring a quality weight of a source video frame to be coded, wherein the quality weight is used for representing the influence degree of the source video frame on the source video quality;
s2, adjusting the CRF value of the original fixed code rate coefficient of the source video frame based on the quality weight to obtain a target CRF value;
and S3, encoding the source video frame according to the target CRF value.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and this embodiment is not described herein again.
Fig. 5 is a block diagram of an electronic device implementing an embodiment of the invention. As shown in fig. 5, the device includes a processor 51 and a memory 52 for storing data, which are connected by a communication bus 54, and a communication interface 53 connected to the communication bus 54 and adapted to connect with other components or external devices.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present application, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technical content can be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, or portions or all or portions of the technical solutions that contribute to the prior art, may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk, and various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present application and it should be noted that, as will be apparent to those skilled in the art, numerous modifications and adaptations can be made without departing from the principles of the present application and such modifications and adaptations are intended to be considered within the scope of the present application.

Claims (10)

1. A method for encoding video, comprising:
acquiring a quality weight of a source video frame to be coded, wherein the quality weight is used for representing the influence degree of the source video frame on the quality of a source video;
adjusting the CRF value of the original fixed code rate coefficient of the source video frame based on the quality weight to obtain a target CRF value;
and encoding the source video frame according to the target CRF value.
2. The method of claim 1 wherein adjusting an original CRF value of the source video frame based on the quality weights to obtain a target CRF value comprises:
comparing the quality weight with a preset threshold;
if the quality weight is larger than the preset threshold, reducing the original CRF value of the source video frame to obtain a first target CRF value; if the quality weight is smaller than the preset threshold, increasing the original CRF value of the source video frame to obtain a second target CRF value; and if the quality weight is equal to the preset threshold value, maintaining the original CRF value of the source video frame to obtain a third target CRF value.
3. The method of claim 1, wherein encoding a source video frame according to the target CRF value comprises:
calculating a Quantization Parameter (QP) value based on the target CRF value;
and compressing the source video frame by adopting the QP value to generate a target video frame, wherein the code rate value of the target video frame is positively correlated with the quality weight.
4. The method of claim 1, wherein obtaining the quality weight of the source video frame to be encoded comprises:
calculating a first quality value for the frames of the source video and calculating a second quality value for the source video;
calculating the mass weights using the following algorithm model: vmos=FmosW;
Wherein, VmosIs said second quality value, FmosA one-dimensional matrix of first quality values for a plurality of source video frames, W being a quality weight, the source video comprising the plurality of source video frames.
5. The method of claim 4, wherein prior to employing an algorithmic model to compute the quality weights, the method further comprises:
collecting sample video data;
determining video quality of sample video in the sample video data and video frame quality of each frame of the sample video;
training a preset original model by taking the video frame quality as input information and the video quality as output information to obtain Vmos=FmosW。
6. The method of claim 5, wherein determining the video quality of the sample video in the sample video data and the video frame quality per frame of the sample video comprises one of:
calculating the video quality of the sample video in the sample video data by adopting an image quality evaluation algorithm, and calculating the video frame quality of each frame of the sample video by adopting the image quality evaluation algorithm;
receiving first label information of the sample video and second label information of video frame quality of each frame of the sample video; determining the first tag information and the second tag information as the video quality and the video frame quality, respectively.
7. The method of claim 1, wherein obtaining the quality weight of the source video frame to be encoded comprises one of:
acquiring quality weights of a plurality of continuous source video frames to be coded in the source video by taking a preset frame number as a unit, wherein the sum of the quality weights of the plurality of continuous source video frames is 1;
acquiring the quality weights of all source video frames to be coded in the source video frame by frame, wherein the sum of the quality weights of all the source video frames is 1;
sampling in the source video to obtain quality weights of a plurality of discrete source video frames to be coded, wherein the sum of the quality weights of the plurality of discrete source video frames is 1.
8. An apparatus for encoding video, comprising:
the device comprises an acquisition module, a coding module and a coding module, wherein the acquisition module is used for acquiring the quality weight of a source video frame to be coded, and the quality weight is used for representing the influence degree of the source video frame on the source video quality;
the adjusting module is used for adjusting the CRF value of the original fixed code rate coefficient of the source video frame based on the quality weight to obtain a target CRF value;
and the encoding module is used for encoding the source video frame according to the target CRF value.
9. A storage medium, characterized in that the storage medium comprises a stored program, wherein the program when executed performs the method steps of any of the preceding claims 1 to 7.
10. An electronic device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus; wherein:
a memory for storing a computer program;
a processor for performing the method steps of any of claims 1 to 7 by executing a program stored on a memory.
CN202110026092.0A 2021-01-08 2021-01-08 Video encoding method and device, storage medium and electronic equipment Pending CN114760475A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110026092.0A CN114760475A (en) 2021-01-08 2021-01-08 Video encoding method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110026092.0A CN114760475A (en) 2021-01-08 2021-01-08 Video encoding method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN114760475A true CN114760475A (en) 2022-07-15

Family

ID=82325084

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110026092.0A Pending CN114760475A (en) 2021-01-08 2021-01-08 Video encoding method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN114760475A (en)

Similar Documents

Publication Publication Date Title
CN109286825B (en) Method and apparatus for processing video
CN111107395B (en) Video transcoding method, device, server and storage medium
CN110662044B (en) Video coding method, video coding device and computer storage medium
CN103313047B (en) A kind of method for video coding and device
CN108337515A (en) A kind of method for video coding and device
CN110944200B (en) Method for evaluating immersive video transcoding scheme
CN112637594B (en) No-reference 3D point cloud quality assessment method based on bit stream
CN110401833A (en) Image transfer method and device
CN112165620A (en) Video encoding method and device, storage medium and electronic equipment
CN113938682A (en) Video coding method and device and electronic equipment
CN101472182B (en) Virtually lossless video data compression
CN110519607B (en) Video decoding method and device, and video encoding method and device
CN107205150A (en) Coding method and device
CN111314691B (en) Video call quality assessment method and device
CN115022629A (en) Method and device for determining optimal coding mode of cloud game video
CN114693812A (en) Video processing method and device
CN111277827B (en) Video data processing method, device, equipment and readable storage medium
CN114760475A (en) Video encoding method and device, storage medium and electronic equipment
CN110740324B (en) Coding control method and related device
CN114666584B (en) Encoding method, device, equipment and medium based on high-frequency zero setting
CN112672157B (en) Video encoding method, device, equipment and storage medium
CN114374841A (en) Optimization method and device for video coding rate control and electronic equipment
CN113949899A (en) Video quality evaluation method and device
CN112422967B (en) Video encoding method and device, storage medium and electronic equipment
CN110708548A (en) Method for bit allocation in panoramic video frame

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