CN112203096A - Video encoding method, video encoding device, computer equipment and storage medium - Google Patents

Video encoding method, video encoding device, computer equipment and storage medium Download PDF

Info

Publication number
CN112203096A
CN112203096A CN202011066044.6A CN202011066044A CN112203096A CN 112203096 A CN112203096 A CN 112203096A CN 202011066044 A CN202011066044 A CN 202011066044A CN 112203096 A CN112203096 A CN 112203096A
Authority
CN
China
Prior art keywords
frame
image group
encoding
key frame
coding
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
CN202011066044.6A
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 CN202011066044.6A priority Critical patent/CN112203096A/en
Publication of CN112203096A publication Critical patent/CN112203096A/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/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/177Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being a group of pictures [GOP]
    • 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/146Data rate or code amount at the encoder output

Landscapes

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

Abstract

The present application relates to a video encoding method, apparatus, computer device and storage medium. The method comprises the following steps: acquiring a video to be coded, and grouping the video to be coded to obtain a plurality of image groups, wherein each image group comprises a key frame; under the condition that the current image group is the last image group, acquiring the frame number of video frames contained in the current image group to obtain a first number; acquiring a coding strategy of a key frame of a current image group; under the condition that the first number is larger than the first preset number, the coding of the key frame of the current image group is executed by adopting the coding strategy of the key frame of the current image group; and under the condition that the first number is less than or equal to the first preset number, performing the coding of the key frames of the current image group by adopting a target coding strategy, wherein the target coding strategy is obtained by modifying the coding strategy of the key frames of the current image group. When the coding of the last image group is executed, if the number of frames is small, the coding strategy of the key frame is adjusted, and the coding efficiency is improved.

Description

Video encoding method, video encoding device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a video encoding method and apparatus, a computer device, and a storage medium.
Background
Video coding refers to the way of converting a file in an original video format into a file in another video format by compression techniques. The most important codec standards in video streaming are h.264, h.265, AVS, etc. Video coding typically encodes all frames in a segment of video in groups of GOPs (group of pictures), where there are usually three types of coded frames in each GOP, I-frame (key frame), P-frame and B-frame (normal frame). Each GOP must begin with an I-frame, and the GOP spacing usually refers to the distance between two I-frames. Generally, the smaller the GOP interval, the closer the I-frames are, the higher the encoding quality, but the lower the encoding compression efficiency. The I frame (intra-coded frame) is called a key frame, is used as a random access point in a video stream, is coded in an intra-frame prediction mode without referring to other frames, and is generally high in coding quality and low in compression efficiency; the P frame (predictive coding frame) is coded by referring to the forward I frame or other forward P frames in a mode of combining intra-frame prediction and inter-frame prediction, and the compression efficiency is high; b frames (bidirectional predictive coding frames) can be predictive coded by referring to the frames in the forward direction and the backward direction, and the compression efficiency is highest. The GOPs of a video encoding process are usually strictly divided according to frame number, and in the final stage of encoding, it may happen that the last GOP contains only a few frame numbers, while the first frame of the GOP is still encoded with I-frames. Because the number of the remaining frames is small and the last I frame is not much referred, the cost performance of coding the I frame with a higher code rate is low, and the code rate is wasted.
Disclosure of Invention
In order to solve the technical problem, the present application provides a video encoding method, an apparatus, a computer device and a storage medium.
The application provides a video coding method, which comprises the following steps:
acquiring a video to be coded, and grouping the video to be coded to obtain a plurality of image groups, wherein each image group comprises a key frame;
under the condition that the current image group is the last image group, acquiring the frame number of video frames contained in the current image group to obtain a first number;
acquiring a coding strategy of a key frame of the current image group;
under the condition that the first number is larger than a first preset number, adopting an encoding strategy of the key frame of the current image group to encode the key frame of the current image group;
and under the condition that the first number is less than or equal to the first preset number, adopting the target coding strategy to carry out coding on the key frame of the current image group, wherein the target coding strategy is obtained by modifying the coding strategy of the key frame of the current image group.
The present application provides a video encoding apparatus comprising:
the data acquisition module is used for acquiring a video to be coded, grouping the video to be coded to obtain a plurality of image groups, wherein each image group comprises a key frame;
the image processing device comprises a frame number acquisition module, a frame number acquisition module and a frame number acquisition module, wherein the frame number acquisition module is used for acquiring the frame number of a video frame contained in a current image group to obtain a first number under the condition that the current image group is the last image group;
the strategy acquisition module is used for acquiring the coding strategy of the key frame of the current image group;
the encoding execution module is used for executing the encoding of the key frame of the current image group by adopting the encoding strategy of the key frame of the current image group under the condition that the first number is larger than a first preset number;
the encoding execution module is further configured to, if the first number is less than or equal to the first preset number, execute encoding of the key frame of the current group of pictures by using the target encoding policy, where the target encoding policy is obtained by modifying the encoding policy of the key frame of the current group of pictures.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
acquiring a video to be coded, and grouping the video to be coded to obtain a plurality of image groups, wherein each image group comprises a key frame;
under the condition that the current image group is the last image group, acquiring the frame number of video frames contained in the current image group to obtain a first number;
acquiring a coding strategy of a key frame of the current image group;
under the condition that the first number is larger than a first preset number, adopting an encoding strategy of the key frame of the current image group to encode the key frame of the current image group;
and under the condition that the first number is less than or equal to the first preset number, adopting the target coding strategy to carry out coding on the key frame of the current image group, wherein the target coding strategy is obtained by modifying the coding strategy of the key frame of the current image group.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
acquiring a video to be coded, and grouping the video to be coded to obtain a plurality of image groups, wherein each image group comprises a key frame;
under the condition that the current image group is the last image group, acquiring the frame number of video frames contained in the current image group to obtain a first number;
acquiring a coding strategy of a key frame of the current image group;
under the condition that the first number is larger than a first preset number, adopting an encoding strategy of the key frame of the current image group to encode the key frame of the current image group;
and under the condition that the first number is less than or equal to the first preset number, adopting the target coding strategy to carry out coding on the key frame of the current image group, wherein the target coding strategy is obtained by modifying the coding strategy of the key frame of the current image group.
The video coding method, the video coding device, the computer equipment and the storage medium comprise the following steps: acquiring a video to be coded, and grouping the video to be coded to obtain a plurality of image groups, wherein each image group comprises a key frame; under the condition that the current image group is the last image group, acquiring the frame number of video frames contained in the current image group to obtain a first number; acquiring a coding strategy of a key frame of a current image group; under the condition that the first number is larger than the first preset number, the coding of the key frame of the current image group is executed by adopting the coding strategy of the key frame of the current image group; and under the condition that the first number is less than or equal to the first preset number, performing the coding of the key frames of the current image group by adopting a target coding strategy, wherein the target coding strategy is obtained by modifying the coding strategy of the key frames of the current image group. And when the encoding is executed to the last image group, judging the number of frames contained in the last image group, and if the number of frames is small, adjusting the encoding strategy of the key frame to improve the encoding efficiency.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
FIG. 1 is a diagram of an exemplary video encoding method;
FIG. 2 is a flow diagram illustrating a video encoding method according to one embodiment;
FIG. 3 is a block diagram of a video encoding apparatus in one embodiment;
FIG. 4 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, 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 some 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.
Fig. 1 is a diagram of an application environment of a video encoding method according to an embodiment. Referring to fig. 1, the video encoding method is applied to a video encoding system. The video coding system includes a terminal 110 and a server 120. The terminal 110 and the server 120 are connected through a network. The terminal 110 or the server 120 acquires a video to be encoded, groups the video to be encoded to obtain a plurality of image groups, wherein each image group comprises a key frame, and acquires the number of frames of video frames contained in the current image group to obtain a first number when the current image group is the last image group; acquiring an encoding strategy of a key frame of a current image group, executing encoding of the key frame of the current image group by adopting the encoding strategy of the key frame of the current image group under the condition that the first number is larger than the first preset number, and executing encoding of the key frame of the current image group by adopting a target encoding strategy under the condition that the first number is smaller than or equal to the first preset number
The terminal 110 may specifically be a desktop terminal or a mobile terminal, and the mobile terminal may specifically be at least one of a mobile phone, a tablet computer, a notebook computer, and the like. The server 120 may be implemented as a stand-alone server or a server cluster composed of a plurality of servers.
In one embodiment, as shown in fig. 2, a video encoding method is provided. The embodiment is mainly illustrated by applying the method to the terminal 110 (or the server 120) in fig. 1. Referring to fig. 2, the video encoding method specifically includes the following steps:
step S201, obtaining a video to be coded, and grouping the video to be coded to obtain a plurality of image groups.
In this particular embodiment, each group of images includes key frames.
Step S202, under the condition that the current image group is the last image group, acquiring the frame number of the video frame contained in the current image group to obtain a first number.
In step S203, the encoding strategy of the key frame of the current group of pictures is obtained.
And step S204, under the condition that the first number is larger than the first preset number, adopting the coding strategy of the key frame of the current image group to code the key frame of the current image group.
In step S205, in the case that the first number is less than or equal to the first preset number, the encoding of the key frame of the current group of pictures is performed using the target encoding strategy.
In this embodiment, the target encoding policy is obtained by modifying the encoding policy of the key frame of the current group of pictures.
Specifically, video to be encoded refers to video data that is ready to be encoded. When video coding is performed, all frames in a video to be coded are grouped and coded according to groups of Pictures (GOP), so that a plurality of groups of Pictures (GOP) are obtained. A GOP is a sequence of one or more frames of a continuously encoded frame that is used to aid random access in decoding. Each GOP must begin with an I-frame (key frame), and the GOP spacing usually refers to the distance between two I-frames. The smaller the GOP interval, the closer the I frame is, the higher the encoding quality is, and the lower the encoding compression efficiency is, whereas, the larger the interval is, the farther the I frame is, the higher the encoding quality is, and the lower the encoding compression efficiency is. The key frame is used as a random access point in the video stream, and is coded in an intra-frame prediction mode without referring to other frames, so that the coding quality is high and the compression efficiency is low. The image group also comprises a common frame which is a P frame (predictive coding frame) or a B frame (bidirectional predictive coding frame), wherein the P frame is coded by referring to a forward I frame or other forward P frames in a mode of combining intra-frame prediction and inter-frame prediction, and the compression efficiency is high. The B frame can refer to the forward and backward frames for predictive coding, and the compression efficiency is highest.
The last group of pictures refers to the group of pictures divided last. The number of frames contained in the last group of pictures is related to the length of the real video and the length of each GOP. Therefore, the number of frames contained in the last GOP is related to the actual situation, and after the video to be coded is grouped, the number of frames contained in the last GOP is counted to obtain the first number. If the number of frames included in the last GOP is large, it means that the number of images of the I frame referring to the GOP is large, that is, the requirement on the encoding quality of the I frame is high, otherwise, if the number of frames included in the last GOP is small, the number of images of the I frame considering the GOP is small, and when the I frame is encoded, the encoding quality of the video can be slightly reduced, thereby avoiding wasting the code rate. And when the frame number of the last GOP, namely the first number is less than or equal to a first preset number, adopting a new coding strategy to carry out the coding of the key frame of the GOP. For example, merge the GOP and the previous GOP into a new GOP, or keep the GOP, but modify the coding parameters of the I frame in the GOP, for example, increase the Quantization Parameter (QP) of the I frame, so as to obtain a new coding strategy (target coding strategy), and perform the coding of the last GOP by using the new strategy.
The first predetermined number is a predefined number, which may be determined according to the quality of the service to the video, and the defined number may be smaller for a high requirement of the coding order, and may be a larger number otherwise. The value is small, which means that when a small number of video frames exist, the original video coding strategy is also executed on the last image group, and the obtained coding quality is higher, otherwise, the more video frames contained in the last image group are, the new coding strategy is still adopted to execute coding, after the new video coding strategy is selected by the frame I, the coding quality is reduced, and the quality is also reduced when other video frames refer to the frame I.
In one embodiment, the first preset number is equal to the number of pre-analysis frames. The video frame to be coded is pre-analyzed in image content during coding so as to help decide scene switching or adaptive quantization during coding. The pre-analysis frame refers to the number of frames of the pre-analysis of the image content. The greater the number of pre-analysis frames, the higher the corresponding delay. The number of the analyzed frames during the pre-analysis can well represent the requirement of the service on the video coding quality, so that the first preset number is set as the number of the pre-analysis frames, and when the video coding of the last image group is executed, the content of each frame can be obtained through the pre-analysis, thereby better ensuring the video quality.
If the first number is larger than the first preset number, the number of frames in the GOP is large, and if a new coding strategy is adopted, the influence on the coding quality of the video is large, so that the old coding strategy is selected to code the last key frame, namely, the obtained coding strategy of the key frame of the current image group is adopted to execute the coding of the key frame of the current image group.
The video coding method comprises the following steps: acquiring a video to be coded, and grouping the video to be coded to obtain a plurality of image groups, wherein each image group comprises a key frame; under the condition that the current image group is the last image group, acquiring the frame number of video frames contained in the current image group to obtain a first number; acquiring a coding strategy of a key frame of a current image group; under the condition that the first number is larger than the first preset number, the coding of the key frame of the current image group is executed by adopting the coding strategy of the key frame of the current image group; and under the condition that the first number is less than or equal to the first preset number, performing the coding of the key frames of the current image group by adopting a target coding strategy, wherein the target coding strategy is obtained by modifying the coding strategy of the key frames of the current image group. And when the encoding is executed to the last image group, judging the number of frames contained in the last image group, and if the number of frames is small, adjusting the encoding strategy of the key frame to improve the encoding efficiency.
In one embodiment, under the condition that the current image group is the last image group, the frame number of the last image group of the current image group is obtained to obtain a second number; calculating the sum of the first number and the second number to obtain the total number; and in the case that the total number is less than the second preset number and the first number is less than or equal to the first preset number, performing a step of performing encoding of the key frames of the current group of pictures using the target encoding strategy.
Specifically, the number of frames included in the previous image group is the second number. And calculating the sum of the first number and the second number to obtain the total number. The second predetermined number is a self-defined value and the value is less than or equal to the maximum coding range of the encoder. The two ranges are set because the number of frames included in the last GOP of the first range is less than a first preset number, and the second range is such that the number of frames of the last two GOPs added together is less than a second preset number. The second preset number is set, firstly, the number of frames added for the surface is larger than the maximum coding range of the encoder, secondly, the second preset number is related to the quality requirement of video coding, because the longer the GOP is, the more the video frames of the reference I frame are, the coding quality will be deteriorated, so the second preset number with high coding quality requirement is set to be smaller, otherwise, the second preset number is larger, and the second preset number does not exceed the maximum coding range of the encoder. And when the total number is less than the second preset number and the first number is less than or equal to the first preset number, performing the coding of the key frame of the current image group by adopting a target coding strategy.
In one embodiment, the group of pictures further includes a normal frame, and the encoding type in the encoding strategy of the key frame of the current group of pictures is key frame encoding, further including: acquiring a common frame code corresponding to the common frame; and modifying the coding type in the coding strategy of the key frame of the current image group from key frame coding to common frame coding to obtain the target coding strategy.
Specifically, a normal frame refers to all video frames in the group of images except the processing key frame. The normal frames include P frames and B frames. The key frame is encoded by key frame encoding (intra-frame encoding), the spectral frame is encoded by prediction encoding, and the prediction encoding includes forward prediction encoding and bidirectional prediction encoding. The key frame and the common frame have different coding modes, the coding mode of the key frame consumes more code rate than that of the common frame, and the coding type of the key frame of the last GOP is modified into the coding mode of the common frame. The method adopts the common frame coding of the common frame to replace the key frame coding of the key frame, namely, the common frame coding is adopted to execute the coding of the key frame of the last GOP, so that the code rate can be saved.
In one embodiment, the encoding parameters in the encoding strategy of the key frame of the current group of pictures include quantization parameters corresponding to the key frame, and further include: and increasing the quantization parameter corresponding to the key frame in the coding strategy of the key frame of the current image group to obtain the target coding strategy.
Specifically, the encoding parameter in the encoding strategy of the key frame of the current group of pictures is modified, that is, the Quantization Parameter (QP) corresponding to the key frame in the encoding strategy of the key frame of the current group of pictures is increased, and then the encoding of the key frame of the current group of pictures is performed with the increased quantization parameter. The QP increases, the coding quality decreases, and the code rate increases, so that the QP of the I frame increases, the quality of the I frame decreases, and the code rate increases. When the QP of the I frame is increased, the QP value may be defined according to the requirement, for example, the QP increased to the P frame or the B frame, or another QP may be defined.
In one embodiment, the quantization parameter corresponding to a key frame in the encoding strategy for a key frame of the current group of pictures is increased such that the quantization parameter corresponding to a key frame of the current group of pictures is equal to the quantization parameter of a predictive coded frame of the group of pictures or equal to the quantization parameter of a bi-directional predictive coded frame of the group of pictures.
Specifically, when encoding, the QP of the I frame is smaller than the QP of the P frame, and the QP of the P frame is smaller than or equal to the QP of the B frame, and when increasing the QP, the QP of the key frame can be adjusted to the same QP as the P frame or the B frame, thereby saving the code rate of the I frame.
In a specific embodiment, the video encoding method includes:
after the coding is started, all the GOPs are normally coded according to the original coding flow, and the GOP intervals are consistent with the values set by the coding parameters, wherein the GOP intervals are marked as NGOP. Determining the remaining number of frames N when encoding to the last GOPlast(where there must be Nlast≤NGOPSince if N is presentlast>NGOPThe remaining frames are divided into two GOPs with N framesGOPAnd Nlast-NGOP). When the following two conditions are satisfied, the first frame of the last GOP is encoded with a normal frame without using an I frame, which is equivalent to merging the last two GOPs into one GOP. (at this time, the I frame becomes a normal frame, and specifically, a P frame or a B frame is used, which can be determined according to the conventional frame type decision).
Wherein the first condition is: the number of GOP interval plus last GOP is less than the maximum GOP interval NMAX_GOP(total number), i.e. NGOP+Nlast<NMAX_GOP. Because if the last two GOPs are merged, it is necessary to satisfy the requirement that the newly merged GOP length is smallDue to the limitation of the maximum GOP interval, otherwise, the problem of decoding error of a partial decoder due to too long GOP length may occur, and the common maximum GOP interval is 256.
The second condition is: the remaining number of frames of the last GOP is less than a threshold T (a first predetermined number), Nlast<And T. The removal of the I-frame of the last GOP is considered only when the last remaining number of frames is insufficient, otherwise the coding quality may be greatly affected. The threshold T may be set empirically, for example, let T be LookAheadDepth, i.e. the threshold is equal to the number of pre-analysis frames of LookAhead. The number of pre-analysis frames for a common LookAhead is 16.
If either of these two conditions is not met, the first frame of the last GOP is still encoded with I-frames (the last 2 GOPs are not merged).
In the final stage of encoding, if the number of remaining frames of the last GOP is small, the first frame of the GOP is encoded with normal frames instead of I-frames (equivalent to merging the last GOP with the second last GOP). Therefore, the code stream size of one I frame can be saved, and the situation that a plurality of subsequent frames need to be referred to the frame to cause great reduction of the coding quality can be avoided due to the fact that the number of the last remaining frames is small. The code rate can be saved, and the integral coding quality can hardly be influenced.
In one embodiment, the I-frame of the last GOP is retained and the quantization parameter QP for that I-frame is increased. Without changing the type of the I frame, i.e. without merging the last GOP, increasing the QP can save the bitrate of the I frame, but relatively also affects the quality of the I frame, and has less impact on the encoding quality of the entire video encoding.
In one embodiment, the specific value of the I-frame QP may be increased to be the same as the P-frame QP. The QP of the P frame is adopted to replace the QP of the I frame, so that the coding quality of the I frame can be better ensured.
FIG. 2 is a flow diagram illustrating a video encoding method according to one embodiment. It should be understood that, although the steps in the flowchart of fig. 2 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a portion of the steps in fig. 2 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 3, there is provided a video encoding apparatus 200, including:
the data obtaining module 201 is configured to obtain a video to be encoded, and group the video to be encoded to obtain a plurality of image groups, where each image group includes a key frame.
The frame number obtaining module 202 is configured to, when the current image group is the last image group, obtain a frame number of a video frame included in the current image group to obtain a first number.
And the strategy acquisition module 203 is used for acquiring the coding strategy of the key frame of the current image group.
And the encoding execution module 204 is configured to, if the first number is greater than the first preset number, execute encoding of the key frame of the current group of pictures by using an encoding policy of the key frame of the current group of pictures.
The encoding execution module 204 is further configured to, if the first number is less than or equal to the first preset number, execute encoding of the key frames of the current group of pictures by using a target encoding policy, where the target encoding policy is obtained by modifying an encoding policy of the key frames of the current group of pictures.
In an embodiment, the video encoding apparatus 200 further includes:
and the frame number calculating module is used for acquiring the frame number of the last image group of the current image group to obtain the second number and calculating the sum of the first number and the second number to obtain the total number under the condition that the current image group is the last image group.
The encoding execution module 204 is specifically configured to execute encoding of the key frame of the current group of pictures by using the target encoding policy when the total number is smaller than the second preset number and the first number is smaller than the first preset number.
In one embodiment, the group of pictures further includes a normal frame, the encoding type in the encoding strategy for the key frames of the current group of pictures is key frame encoding,
the encoding execution module 204 is specifically configured to obtain an ordinary frame encoding corresponding to an ordinary frame, and modify an encoding type in an encoding policy of a key frame of a current group of pictures from the key frame encoding to the ordinary frame encoding.
In one embodiment, the encoding parameters in the encoding strategy of the key frame of the current group of pictures are the quantization parameters corresponding to the key frame,
the encoding execution module 204 is specifically configured to increase a quantization parameter corresponding to a key frame in an encoding policy of the key frame of the current group of pictures to obtain a target encoding policy.
In one embodiment, the group of pictures also includes normal frames,
the encoding execution module 204 is further configured to obtain a quantization parameter corresponding to the common frame, and modify the quantization parameter corresponding to the key frame in the encoding policy of the key frame of the current image group into the quantization parameter corresponding to the common frame, so as to obtain the target encoding policy.
In one embodiment, the first number is equal to the number of frames of a pre-analysis frame, the pre-analysis frame being the number of frames used to pre-analyze the video to be encoded when encoding is performed.
FIG. 4 is a diagram illustrating an internal structure of a computer device according to an embodiment. The computer device may specifically be the terminal 110 (or the server 120) in fig. 1. As shown in fig. 4, the computer apparatus includes a processor, a memory, a network interface, an input device, and a display screen connected via a system bus. Wherein the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program that, when executed by the processor, causes the processor to implement the video encoding method. The internal memory may also have stored therein a computer program that, when executed by the processor, causes the processor to perform a video encoding method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 4 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, the video encoding apparatus provided herein may be implemented in the form of a computer program that is executable on a computer device such as that shown in fig. 4. The memory of the computer device may store therein various program modules constituting the video encoding apparatus, such as a data acquisition module 201, a frame number acquisition module 202, a policy acquisition module 203, and an encoding execution module 204 shown in fig. 3. The computer program constituted by the respective program modules causes the processor to execute the steps in the video encoding method of the respective embodiments of the present application described in the present specification.
For example, the computer device shown in fig. 4 may perform, by the data acquisition module 201 in the video encoding apparatus shown in fig. 3, acquiring a video to be encoded, and grouping the video to be encoded, resulting in a plurality of groups of pictures, each group of pictures including a key frame. The computer device may execute, by the frame number obtaining module 202, obtaining the number of frames of the video frame included in the current image group to obtain the first number in the case that the current image group is the last image group. The computer device may perform an encoding strategy to acquire key frames of the current group of pictures through the strategy acquisition module 203. The computer device may perform, by the encoding execution module 204, encoding of the key frame of the current group of pictures using the encoding policy of the key frame of the current group of pictures in case the first number is greater than the first preset number. The computer device may further perform, by the encoding execution module 204, encoding of the key frames of the current group of pictures using a target encoding policy in case the first number is less than or equal to a first preset number, the target encoding policy being obtained by modifying an encoding policy of the key frames of the current group of pictures.
In one embodiment, a computer device is provided, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of any of the embodiments of the video encoding method described above when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which computer program, when being executed by a processor, is adapted to carry out the steps of any of the embodiments of the video encoding method described above.
In one embodiment, a computer program product or computer program is provided that includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the steps of any of the embodiments of the video encoding method described above.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a non-volatile computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the program is executed. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (14)

1. A method of video encoding, the method comprising:
acquiring a video to be coded, and grouping the video to be coded to obtain a plurality of image groups, wherein each image group comprises a key frame;
under the condition that the current image group is the last image group, acquiring the frame number of video frames contained in the current image group to obtain a first number;
acquiring a coding strategy of a key frame of the current image group;
under the condition that the first number is larger than a first preset number, adopting an encoding strategy of the key frame of the current image group to encode the key frame of the current image group;
and under the condition that the first number is less than or equal to the first preset number, executing the coding of the key frame of the current image group by adopting a target coding strategy, wherein the target coding strategy is obtained by modifying the coding strategy of the key frame of the current image group.
2. The method according to claim 1, wherein in case that the current image group is the last image group, the method further comprises:
acquiring the frame number of the last image group of the current image group to obtain a second number;
calculating the sum of the first number and the second number to obtain the total number;
and if the total number is less than a second preset number and the first number is less than or equal to a first preset number, performing the step of performing encoding of the key frame of the current group of pictures by using the target encoding strategy.
3. The method according to claim 1, wherein the group of pictures further includes a normal frame, and the type of encoding in the encoding strategy for the key frame of the current group of pictures is key frame encoding, the method further comprising:
acquiring a common frame code corresponding to the common frame;
and modifying the coding type in the coding strategy of the key frame of the current image group from the key frame coding to the common frame coding to obtain the target coding strategy.
4. The method according to claim 1, wherein the encoding parameters in the encoding strategy for the key frames of the current group of pictures include quantization parameters corresponding to key frames, and the method further comprises:
and increasing the quantization parameter corresponding to the key frame in the coding strategy of the key frame of the current image group to obtain the target coding strategy.
5. The method of claim 4, wherein the group of pictures further includes normal frames,
the increasing quantization parameters corresponding to the key frames in the coding strategy of the key frames of the current image group to obtain the target coding strategy comprises:
obtaining a quantization parameter corresponding to the common frame;
and modifying the quantization parameter corresponding to the key frame in the coding strategy of the key frame of the current image group into the quantization parameter corresponding to the common frame to obtain the target coding strategy.
6. The method of claim 1, wherein the first number is equal to a number of pre-analysis frames used to pre-analyze the video to be encoded when encoding is performed.
7. A video encoding apparatus, characterized in that the apparatus comprises:
the data acquisition module is used for acquiring a video to be coded, grouping the video to be coded to obtain a plurality of image groups, wherein each image group comprises a key frame;
the image processing device comprises a frame number acquisition module, a frame number acquisition module and a frame number acquisition module, wherein the frame number acquisition module is used for acquiring the frame number of a video frame contained in a current image group to obtain a first number under the condition that the current image group is the last image group;
the strategy acquisition module is used for acquiring the coding strategy of the key frame of the current image group;
the encoding execution module is used for executing the encoding of the key frame of the current image group by adopting the encoding strategy of the key frame of the current image group under the condition that the first number is larger than a first preset number;
the encoding execution module is further configured to, if the first number is less than or equal to the first preset number, execute encoding of the key frame of the current group of pictures by using a target encoding policy, where the target encoding policy is obtained by modifying an encoding policy of the key frame of the current group of pictures.
8. The apparatus of claim 7, further comprising:
the frame number calculating module is used for acquiring the frame number of the last image group of the current image group to obtain a second number and calculating the sum of the first number and the second number to obtain the total number under the condition that the current image group is the last image group;
the encoding execution module is configured to execute the encoding of the key frame of the current group of pictures by using the target encoding policy if the total number is smaller than a second preset number and the first number is smaller than a first preset number.
9. The apparatus according to claim 7, wherein the group of pictures further comprises a normal frame, the encoding type in the encoding strategy for the key frames of the current group of pictures is key frame encoding,
and the coding execution module is used for acquiring a common frame code corresponding to the common frame and modifying the coding type in the coding strategy of the key frame of the current image group into the common frame code from the key frame code.
10. The apparatus according to claim 7, wherein the encoding parameters in the encoding strategy for the key frames of the current group of pictures include quantization parameters corresponding to key frames,
the coding execution module is used for increasing the quantization parameter corresponding to the key frame in the coding strategy of the key frame of the current image group to obtain the target coding strategy.
11. The apparatus of claim 10, wherein the group of pictures further comprises normal frames,
the coding execution module is used for acquiring the quantization parameter corresponding to the common frame, and modifying the quantization parameter corresponding to the key frame in the coding strategy of the key frame of the current image group into the quantization parameter corresponding to the common frame to obtain the target coding strategy.
12. The apparatus of claim 7, wherein the first number is equal to a number of pre-analysis frames used to pre-analyze the video to be encoded when encoding is performed.
13. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method of any of claims 1 to 6 are implemented when the computer program is executed by the processor.
14. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
CN202011066044.6A 2020-09-30 2020-09-30 Video encoding method, video encoding device, computer equipment and storage medium Pending CN112203096A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011066044.6A CN112203096A (en) 2020-09-30 2020-09-30 Video encoding method, video encoding device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011066044.6A CN112203096A (en) 2020-09-30 2020-09-30 Video encoding method, video encoding device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112203096A true CN112203096A (en) 2021-01-08

Family

ID=74013698

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011066044.6A Pending CN112203096A (en) 2020-09-30 2020-09-30 Video encoding method, video encoding device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112203096A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113453017A (en) * 2021-06-24 2021-09-28 咪咕文化科技有限公司 Video processing method, device, equipment and computer program product
CN113784123A (en) * 2021-11-11 2021-12-10 腾讯科技(深圳)有限公司 Video encoding method and apparatus, storage medium, and electronic device
CN115134629A (en) * 2022-05-23 2022-09-30 阿里巴巴(中国)有限公司 Video transmission method, system, device and storage medium
WO2022247031A1 (en) * 2021-05-27 2022-12-01 上海国茂数字技术有限公司 Knowledge image-based video encoding method and apparatus, and readable storage medium
CN115474077A (en) * 2022-09-06 2022-12-13 一汽解放汽车有限公司 Video transmission method and device, vehicle-end controller and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070025441A1 (en) * 2005-07-28 2007-02-01 Nokia Corporation Method, module, device and system for rate control provision for video encoders capable of variable bit rate encoding
CN103888765A (en) * 2014-03-27 2014-06-25 天格科技(杭州)有限公司 H.265 rate control method for improved R-lambda model
CN107027030A (en) * 2017-03-07 2017-08-08 腾讯科技(深圳)有限公司 A kind of code rate allocation method and its equipment
CN109819253A (en) * 2017-11-21 2019-05-28 腾讯科技(深圳)有限公司 Method for video coding, device, computer equipment and storage medium
CN110087078A (en) * 2019-05-10 2019-08-02 东华大学 A kind of measurement end observation efficiency regulation method towards image component masses compressed sensing
CN110800297A (en) * 2018-07-27 2020-02-14 深圳市大疆创新科技有限公司 Video encoding method and apparatus, and computer-readable storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070025441A1 (en) * 2005-07-28 2007-02-01 Nokia Corporation Method, module, device and system for rate control provision for video encoders capable of variable bit rate encoding
CN103888765A (en) * 2014-03-27 2014-06-25 天格科技(杭州)有限公司 H.265 rate control method for improved R-lambda model
CN107027030A (en) * 2017-03-07 2017-08-08 腾讯科技(深圳)有限公司 A kind of code rate allocation method and its equipment
CN109819253A (en) * 2017-11-21 2019-05-28 腾讯科技(深圳)有限公司 Method for video coding, device, computer equipment and storage medium
CN110800297A (en) * 2018-07-27 2020-02-14 深圳市大疆创新科技有限公司 Video encoding method and apparatus, and computer-readable storage medium
CN110087078A (en) * 2019-05-10 2019-08-02 东华大学 A kind of measurement end observation efficiency regulation method towards image component masses compressed sensing

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022247031A1 (en) * 2021-05-27 2022-12-01 上海国茂数字技术有限公司 Knowledge image-based video encoding method and apparatus, and readable storage medium
CN113453017A (en) * 2021-06-24 2021-09-28 咪咕文化科技有限公司 Video processing method, device, equipment and computer program product
CN113453017B (en) * 2021-06-24 2022-08-23 咪咕文化科技有限公司 Video processing method, device, equipment and computer program product
CN113784123A (en) * 2021-11-11 2021-12-10 腾讯科技(深圳)有限公司 Video encoding method and apparatus, storage medium, and electronic device
CN115134629A (en) * 2022-05-23 2022-09-30 阿里巴巴(中国)有限公司 Video transmission method, system, device and storage medium
CN115134629B (en) * 2022-05-23 2023-10-31 阿里巴巴(中国)有限公司 Video transmission method, system, equipment and storage medium
CN115474077A (en) * 2022-09-06 2022-12-13 一汽解放汽车有限公司 Video transmission method and device, vehicle-end controller and storage medium

Similar Documents

Publication Publication Date Title
CN112203096A (en) Video encoding method, video encoding device, computer equipment and storage medium
US10827182B2 (en) Video encoding processing method, computer device and storage medium
CN109862359B (en) Code rate control method and device based on layered B frame and electronic equipment
WO2018171447A1 (en) Video encoding method, video decoding method, computer device and storage medium
JP5063677B2 (en) VIDEO ENCODING METHOD AND DECODING METHOD, DEVICE THEREOF, THEIR PROGRAM, AND RECORDING MEDIUM CONTAINING THE PROGRAM
JP7012747B2 (en) Video frame coding method, terminal, and storage medium
US9420282B2 (en) Video coding redundancy reduction
CN110166771B (en) Video encoding method, video encoding device, computer equipment and storage medium
US9936217B2 (en) Method and encoder for video encoding of a sequence of frames
KR102263979B1 (en) Video encoding methods, computer devices and storage media
JP2016526336A (en) System and method for encoding multiple video streams using adaptive quantization for adaptive bitrate streaming
US8660191B2 (en) Software video decoder display buffer underflow prediction and recovery
US11070817B2 (en) Video encoding method, computer device, and storage medium for determining skip status
WO2018161868A1 (en) Method for allocating code rates for intra-frame coded frames, computer device and storage medium
CN111193924B (en) Method and device for determining video code rate, computer equipment and storage medium
CN101523915B (en) Two pass rate control techniques for video coding using a min-max approach
EP4262203A1 (en) Method and apparatus for video predictive coding
CN111726656B (en) Transcoding method, device, server and storage medium of live video
EP4333433A1 (en) Video coding method and apparatus, and electronic device
CN109218722B (en) Video coding method, device and equipment
CN102196253A (en) Video coding method and device for frame type adaptive selection
CN117676153A (en) Inter-frame prediction mode switching method and related device
JP2001251627A (en) Coder, coding method and recording medium recorded with program
CN109660806B (en) Encoding method and device and electronic equipment
JP4216769B2 (en) Moving picture coding method, moving picture coding apparatus, moving picture coding program, and computer-readable recording medium recording the program

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