Video encoding method, device, electronic device and storage medium
By obtaining the inter-frame and intra-frame difference information of the video frame sequence, the GOP length is adaptively adjusted, which solves the problem of fixed GOP length in video encoding and improves the encoding efficiency.
Patent Information
- Application Number
- CN202211194192.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-28
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-09-28
AI Technical Summary
In the existing video encoding technology, the fixed GOP length leads to low encoding efficiency, and it is impossible to dynamically select the target image group length based on the video characteristics.
By obtaining the inter-frame difference information and intra-frame difference information of the sequence of frames to be encoded, the target image group length is adaptively adjusted, the keyframe position is determined and the encoding process is performed.
Improve video encoding efficiency, adapt to different video features and improve encoding performance by adaptively adjusting the length of the target image group.
Smart Images

Figure CN115514960B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of video processing technology, and in particular to a video encoding method, a video encoding device, an electronic device, and a computer-readable storage medium. Background Art
[0002] Video coding standards typically categorize frames into three types based on their functionality and compression efficiency: intra-frame (I-frame), inter-frame predicted (P-frame), and bidirectionally predicted (B-frame). With the exception of I-frames, which are self-reconstructed, all other frame types can be predictively coded using references to other frames, improving encoder efficiency.
[0003] In video coding, a Group of Pictures (GOP) typically refers to the interval between two key frames (I-frames / P-frames). A larger GOP typically contains more B-frames and fewer key frames. However, in some coding schemes, the GOP length is usually fixed to a constant value. Using a fixed GOP length for video coding can result in low video coding efficiency. Summary of the Invention
[0004] The present disclosure provides a video encoding method, video encoding apparatus, electronic device, computer-readable storage medium, and computer program product to at least address the problem in related art of being unable to dynamically select the target GOP length based on video features during the video encoding process, resulting in low video encoding efficiency. The technical solutions of the present disclosure are as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, a video encoding method is provided, including: obtaining a video to be processed, and determining a current frame sequence to be encoded based on the video to be processed; determining first inter-frame difference information and first intra-frame difference information of the current frame sequence to be encoded; updating a first target image group length corresponding to the current frame sequence to be encoded according to the first inter-frame difference information and the first intra-frame difference information; encoding the current frame sequence to be encoded according to the updated first target image group length to obtain an encoded video.
[0006] In an exemplary embodiment of the present disclosure, the current frame sequence to be encoded includes multiple video frames; determining the first inter-frame difference information and the first intra-frame difference information of the current frame sequence to be encoded includes: obtaining the frame interval corresponding to the current frame sequence to be encoded, and determining the reference frame associated with each of the video frames according to the frame interval; determining the first inter-frame difference information between each of the video frames and the reference frame associated with each of the video frames; and determining the first intra-frame difference information corresponding to each of the video frames.
[0007] In an exemplary embodiment of the present disclosure, updating the first target image group length corresponding to the current frame sequence to be encoded based on the first inter-frame difference information and the first intra-frame difference information includes: determining a change trend value corresponding to the current frame sequence to be encoded based on the first inter-frame difference information and the first intra-frame difference information; obtaining a pre-configured change trend threshold; if the change trend value is less than the change trend threshold, increasing the first target image group length corresponding to the current frame sequence to be encoded; if the change trend value is greater than or equal to the change trend threshold, reducing the first target image group length corresponding to the current frame sequence to be encoded.
[0008] In an exemplary embodiment of the present disclosure, encoding the current frame sequence to be encoded based on the updated first target image group length includes: determining the key frame position and video encoding parameters corresponding to the current frame sequence to be encoded based on the first target image group length; encoding the current frame sequence to be encoded based on the key frame position and the video encoding parameters.
[0009] In an exemplary embodiment of the present disclosure, encoding the current frame sequence to be encoded according to the key frame position and the video encoding parameters includes: determining the first key frame and the second key frame corresponding to the current frame sequence to be encoded according to the key frame position; taking the first key frame and the video frame between the first key frame and the second key frame as the image group to be encoded; encoding the image group to be encoded according to the video encoding parameters to obtain an encoded image group.
[0010] In an exemplary embodiment of the present disclosure, the above method also includes: obtaining the position of the second key frame and determining the length of the encoded image group; performing a frame reading operation according to the position of the second key frame and the length of the encoded image group to obtain an updated frame sequence to be encoded; determining the second target image group length corresponding to the updated frame sequence to be encoded; and encoding the updated frame sequence to be encoded according to the second target image group length.
[0011] In an exemplary embodiment of the present disclosure, determining the second target image group length corresponding to the updated frame sequence to be encoded includes: determining the second inter-frame difference information and the second intra-frame difference information of the updated frame sequence to be encoded; and determining the second target image group length based on the second inter-frame difference information and the second intra-frame difference information.
[0012] In an exemplary embodiment of the present disclosure, encoding the updated frame sequence to be encoded according to the second target image group length includes: determining the updated key frame corresponding to the updated frame sequence to be encoded according to the second target image group length; encoding the updated frame sequence to be encoded according to the updated key frame.
[0013] According to a second aspect of an embodiment of the present disclosure, a video encoding device is provided, including: a frame sequence acquisition module, used to acquire a video to be processed, and determine a current frame sequence to be encoded based on the video to be processed; a difference information determination module, used to determine first inter-frame difference information and first intra-frame difference information of the current frame sequence to be encoded; an image group determination module, used to update a first target image group length corresponding to the current frame sequence to be encoded according to the first inter-frame difference information and the first intra-frame difference information; a video encoding module, used to encode the current frame sequence to be encoded according to the updated first target image group length to obtain an encoded video.
[0014] In an exemplary embodiment of the present disclosure, the current frame sequence to be encoded includes multiple video frames; the difference information determination module includes a difference information determination unit, and the difference information determination unit is configured to perform: obtaining a frame interval corresponding to the current frame sequence to be encoded, and determining a reference frame associated with each of the video frames according to the frame interval; determining the first inter-frame difference information between each of the video frames and the reference frame associated with each of the video frames; and determining the first intra-frame difference information corresponding to each of the video frames.
[0015] In an exemplary embodiment of the present disclosure, the image group determination module includes an image group determination unit, which is configured to perform: determining a change trend value corresponding to the current frame sequence to be encoded based on the first inter-frame difference information and the first intra-frame difference information; obtaining a pre-configured change trend threshold; if the change trend value is less than the change trend threshold, increasing the first target image group length corresponding to the current frame sequence to be encoded; if the change trend value is greater than or equal to the change trend threshold, reducing the first target image group length corresponding to the current frame sequence to be encoded.
[0016] In an exemplary embodiment of the present disclosure, the video encoding module includes a first video encoding unit, which is configured to perform: determining the key frame position and video encoding parameters corresponding to the current frame sequence to be encoded based on the first target image group length; and encoding the current frame sequence to be encoded based on the key frame position and the video encoding parameters.
[0017] In an exemplary embodiment of the present disclosure, the first video encoding unit includes a first video encoding sub-unit, and the first video encoding sub-unit is configured to perform: determining the first key frame and the second key frame corresponding to the current frame sequence to be encoded according to the key frame position; taking the first key frame and the video frame between the first key frame and the second key frame as the image group to be encoded; encoding the image group to be encoded according to the video encoding parameters to obtain an encoded image group.
[0018] In an exemplary embodiment of the present disclosure, the video encoding module includes a second video encoding unit, which is configured to perform: obtaining the position of a second key frame and determining the length of the encoded image group; performing a frame reading operation according to the position of the second key frame and the length of the encoded image group to obtain an updated frame sequence to be encoded; determining the second target image group length corresponding to the updated frame sequence to be encoded; and encoding the updated frame sequence to be encoded according to the second target image group length.
[0019] In an exemplary embodiment of the present disclosure, the second video encoding unit includes a picture group determination subunit, and the picture group determination subunit is configured to perform: determining the second inter-frame difference information and the second intra-frame difference information of the updated frame sequence to be encoded; and determining the second target picture group length based on the second inter-frame difference information and the second intra-frame difference information.
[0020] In an exemplary embodiment of the present disclosure, the second video encoding unit includes a second video encoding sub-unit, and the second video encoding sub-unit is configured to perform: determining the updated key frame corresponding to the updated sequence of frames to be encoded based on the length of the second target image group; and encoding the updated sequence of frames to be encoded based on the updated key frame.
[0021] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement any one of the above-described video encoding methods.
[0022] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any one of the above-mentioned video encoding methods.
[0023] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising a computer program / instruction, wherein the computer program / instruction implements any one of the above-described video encoding methods when executed by a processor.
[0024] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: based on the inter-frame difference information and intra-frame difference information of the video frame sequence, the target image group length is adaptively adjusted. Since the encoding efficiency of different target image group lengths for different videos varies greatly, the video encoding efficiency can be effectively improved by adaptively adjusting the target image group length and performing video encoding.
[0025] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute an improper limitation of the present disclosure.
[0027] Figure 1 The figure is a flowchart of a video encoding method according to an exemplary embodiment.
[0028] Figure 2 FIG. 4 is an exemplary diagram showing how to determine inter-frame difference information between video frames according to an exemplary embodiment.
[0029] Figure 3 FIG. 1 is a diagram showing an example of a group of pictures (GOP) structure according to an exemplary embodiment.
[0030] Figure 4 This is an example diagram showing re-performing a frame acquisition operation to obtain an updated sequence of frames to be encoded according to an exemplary embodiment.
[0031] Figure 5 The diagram is a block diagram of a video encoding apparatus according to an exemplary embodiment.
[0032] Figure 6 A block diagram of an electronic device according to an exemplary embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0033] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0034] It should be noted that the terms "first," "second," and the like in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the numbers used in this manner are interchangeable where appropriate so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure as detailed in the appended claims.
[0035] During video encoding, increasing the GOP length can improve coding efficiency to a certain extent. However, in standard reference software such as the international video coding standard HEVC (High-Efficiency Video Coding) and the next-generation Versatile Video Coding (VVC), the GOP length is typically fixed to a constant value. The maximum GOP length cannot be dynamically adjusted based on the actual video content characteristics, which may result in a certain degree of coding performance loss.
[0036] In open source video encoders such as x264 and x265, the GOP length can be dynamically determined within a range within the video. There is a preset maximum GOP length. When deciding the frame type (determining the position of the P frame) during encoding preprocessing, a P frame will be forcibly inserted at the maximum GOP length. The optimal P frame position is calculated based on the inter-frame coding loss and intra-frame coding loss in the encoding preprocessing stage. Then, another P frame is forcibly inserted from the current optimal P frame position + maximum GOP length. The iterative calculation continues until the optimal frame type distribution for the entire video is obtained. Different maximum GOP length settings have significant performance differences for different videos. This processing solution also does not dynamically select the maximum GOP length based on the actual video content characteristics, resulting in a certain degree of encoding performance loss.
[0037] Based on this, the present disclosure proposes a video encoding method, a video encoding device, an electronic device, a computer-readable storage medium, and a computer program product.
[0038] Figure 1 is a flowchart of a video encoding method according to an exemplary embodiment. Figure 1As shown, the video encoding method can be used in a computer device, wherein the computer device described in this disclosure may include mobile terminal devices such as mobile phones, tablet computers, laptops, PDAs, and personal digital assistants (PDAs), as well as fixed terminal devices such as desktop computers. This exemplary embodiment uses the method applied to a computer device as an example. It is understood that the method can also be applied to a server, and can also be applied to a system including a computer device and a server, and implemented through the interaction between the computer device and the server. Specifically, the following steps are included.
[0039] In step S110 , a video to be processed is obtained, and a current frame sequence to be encoded is determined based on the video to be processed.
[0040] In an exemplary embodiment of the present disclosure, the video to be processed may be a video clip to be coded, and the current frame sequence to be coded may be a video frame sequence to be coded consisting of multiple video frames in the video to be processed.
[0041] In order to improve the rate and resource utilization of video transmission, the video to be transmitted can be encoded before the video is transmitted. The present disclosure can use the video clip that needs to be encoded as the video to be processed. The video to be processed is usually a video frame sequence composed of multiple video frames. Before the video to be processed is encoded, the video to be processed can be encoded preprocessed. In the encoding preprocessing stage, a corresponding encoding preprocessing length is usually configured. For example, the encoding preprocessing length can be configured to 60, and the encoder will obtain 60 video frames at a time for encoding. When the encoding preprocessing length is configured to 60, the 60 obtained video frames can be used as the current frame sequence to be encoded.
[0042] In step S120 , first inter-frame difference information and first intra-frame difference information of the current frame sequence to be encoded are determined.
[0043] In an exemplary embodiment of the present disclosure, the first inter-frame difference information may be the information amount difference between different frames in the current frame sequence to be encoded. The first intra-frame difference information may be the information amount difference between the same video frame in different encoding modes in the current frame sequence to be encoded.
[0044] After determining the current frame sequence to be encoded, the difference information between different video frames in the current frame sequence to be encoded can be determined. Figure 2 , Figure 2 FIG. 1 is an example diagram showing how to determine inter-frame difference information between video frames according to an exemplary embodiment. For example, Figure 2The current frame in the video is a video frame 210 . For the current frame 210 , a reference frame 220 corresponding to the current frame 210 can be determined. One or more intermediate frames 230 are spaced between the current frame 210 and the reference frame 220 .
[0045] After determining the reference frame 220 for the current frame 210, the information content difference between the two video frames can be calculated as the first inter-frame difference information. For example, the inter-frame coding loss calculated during the encoding preprocessing phase for the two video frames can be used as the first inter-frame difference information. Furthermore, since the same video frame may generate different amounts of information under different encoding modes, the difference in information content under different encoding modes can be calculated as the first intra-frame difference information.
[0046] Through the above processing, inter-frame difference information and intra-frame difference information corresponding to the video frame at each position in the current frame sequence to be encoded are determined as the first inter-frame difference information and first intra-frame difference information of the current frame sequence to be encoded.
[0047] In step S130 , a first target GOP length corresponding to the current frame sequence to be encoded is updated according to the first inter-frame difference information and the first intra-frame difference information.
[0048] In an exemplary embodiment of the present disclosure, the first target GOP length may be a target GOP length determined for the current frame sequence to be encoded according to frame difference information.
[0049] GOP in a video can be the interval between two key frames, refer to Figure 3 , Figure 3 FIG. 1 is a diagram showing an example of a group of pictures (GOP) structure according to an exemplary embodiment. Figure 3 The video frames 310 in the video are all key frames, such as I frames or P frames, and the video frames 320 can be B frames. B frames can be inserted between two key frames, and the two key frames and the inserted B frames together constitute a group of pictures (GOP); wherein the GOP length can be the maximum number of consecutive B frames + 1. For example, when the structure of a GOP is: the starting video frame is a key frame I frame, the ending video frame is a key frame P frame, and there are 15 B frames between the key frame I frame and the key frame P frame, then the length of the GOP is 15 + 1 = 16. During the video encoding process, the maximum GOP length can include 8, 16, 32, and 64, etc.
[0050] After determining the first inter-frame difference information and the first intra-frame difference information, the intensity of the motion of the current frame sequence to be encoded can be measured based on the first inter-frame difference information and the first intra-frame difference information, thereby updating the first target image group length corresponding to the current frame sequence to be encoded based on the determined intensity of the motion. If it is determined that the current frame sequence to be encoded is a video sequence with slow motion, the target image group length of the current frame sequence to be encoded can be increased, that is, the first target image group length can be increased. For example, if the initial maximum GOP length of the current frame sequence to be encoded is 16, and it is determined that the current frame sequence to be encoded is a video sequence with slow motion, the current maximum GOP length of the current frame sequence to be encoded can be updated to 32.
[0051] If it is determined that the current frame sequence to be encoded is a video sequence with intense motion, the target GOP length of the current frame sequence to be encoded can be reduced, that is, the first target GOP length can be reduced. For example, if the initial maximum GOP length of the current frame sequence to be encoded is 32, and it is determined that the current frame sequence to be encoded is a video sequence with slow motion, the current maximum GOP length of the current frame sequence to be encoded can be updated to 16. Through the above processing steps, the determined maximum GOP length can be adaptively adjusted to video features. This process can be called sequence-level frame decision making.
[0052] In step S140, the current frame sequence to be encoded is encoded according to the updated first target GOP length to obtain an encoded video.
[0053] In an exemplary embodiment of the present disclosure, the encoding process may be a method of converting a file in an original video format into a file in another video format by compression technology. The encoded video may be a video obtained by encoding using the above-mentioned video encoding method.
[0054] After determining the updated first target GOP length, encoding processing can be performed on the current frame sequence to be encoded based on the updated first target GOP length. For example, the insertion positions of key frames and B frames in the current frame sequence to be encoded can be determined based on the first target GOP length, thereby performing video encoding processing.
[0055] According to the video encoding method in this example embodiment, the target image group length is adaptively adjusted based on the inter-frame difference information and intra-frame difference information of the video frame sequence. Since different target image group lengths have large differences in encoding efficiency for different videos, the video encoding efficiency can be effectively improved by adaptively adjusting the target image group length and performing video encoding.
[0056] The video processing method in this exemplary embodiment will be further described below.
[0057] In an exemplary embodiment of the present disclosure, determining the frame difference information of the current frame sequence to be encoded can be performed by the following steps: obtaining the frame interval corresponding to the current frame sequence to be encoded, and determining the reference frame associated with each video frame based on the frame interval; determining the first inter-frame difference information between each video frame and the reference frame associated with each video frame; and determining the first intra-frame difference information corresponding to each video frame.
[0058] The frame interval may be the interval between two video frames in the current frame sequence to be encoded. The reference frame may be a video frame associated with a certain video frame, and the reference frame may be used to determine inter-frame difference information between the reference frame and the certain video frame.
[0059] Continue to refer Figure 2 When determining the frame difference information, the frame interval corresponding to the current frame sequence to be encoded can be determined first. For example, the frame interval can be determined to be 2, 4, 8, etc. Taking the frame interval as 4 as an example, the reference frame of the 5th video frame in the current frame sequence to be encoded can be the 1st frame. After determining the reference frame associated with a certain video frame, the inter-frame difference information between the video frame and the reference frame can be determined. For example, the inter-frame coding loss determined in the video encoding preprocessing stage can be used as the inter-frame difference information; wherein the inter-frame coding loss can be the loss generated by encoding the two video frames, the video frame and the reference frame. In addition, if a video frame is a B frame, since the B frame is a bidirectionally predicted frame, the two reference frames corresponding to the B frame can be determined according to the frame interval, and the inter-frame difference information between the B frame and the two reference frames can be calculated respectively.
[0060] After determining the inter-frame coding losses for different video frames, the intra-frame coding losses for each video frame calculated during the encoding preprocessing phase can be retrieved. For example, the same video frame may generate different amounts of information under different encoding modes. In this case, the intra-frame coding loss for the video frame can be determined based on the amount of information generated by the same video frame under the two different encoding modes. The inter-frame difference information and the intra-frame difference information can be used to measure the intensity of motion in a video, thereby adaptively adjusting the target group of pictures length (maximum GOP length).
[0061] It should be noted that, during the video encoding preprocessing stage, the amount of information contained in the video frames of the current frame sequence to be encoded can also be represented by other video features. Therefore, other types of video features can be used to calculate inter-frame difference information and intra-frame difference information. For example, other video features can include information such as the mean, variance, and gradient of frame-level pixel values. Inter-frame difference information can be calculated based on the mean, variance, and gradient of the pixel values between a certain video frame and a reference frame, and intra-frame difference information can be calculated based on the mean, variance, and gradient of the pixel values of the same video frame under different encoding modes.
[0062] In an exemplary embodiment of the present disclosure, updating the length of the first target image group corresponding to the current frame sequence to be encoded can be performed by the following steps based on the first inter-frame difference information and the first intra-frame difference information: determining the change trend value corresponding to the current frame sequence to be encoded based on the first inter-frame difference information and the first intra-frame difference information; obtaining a pre-configured change trend threshold; when the change trend value is less than the change trend threshold, increasing the length of the first target image group corresponding to the current frame sequence to be encoded; when the change trend value is greater than or equal to the change trend threshold, reducing the length of the first target image group corresponding to the current frame sequence to be encoded.
[0063] The change trend value may be a value describing the intensity of motion of the current frame sequence to be encoded, and the change trend threshold may be a value pre-configured for comparison with the change trend value.
[0064] After determining the first inter-frame difference information and the first intra-frame difference information corresponding to the current frame sequence to be encoded, the motion change trend of the entire video can be measured based on the first inter-frame difference information and the first intra-frame difference information. The motion change trend of the video can be quantified using a change trend value. For example, the change trend value = first inter-frame coding loss / first intra-frame coding loss. The change trend value is used to measure the intensity of the motion in the video.
[0065] After determining the change trend value corresponding to the current frame sequence to be encoded, a pre-configured change trend threshold can be obtained and the two can be compared. If the change trend value is less than the change trend threshold, it can be considered that the video is a slow-motion video. Therefore, the maximum GOP length of the current frame sequence to be encoded can be increased. For example, if the current maximum GOP length is 16, it can be increased from 16 to 32. If the change trend value is greater than or equal to the change trend threshold, it can be considered that the video is a relatively violent video. Therefore, the maximum GOP length of the current frame sequence to be encoded can be reduced, such as reducing the current maximum GOP length of 32 to 16. Through the above processing steps, the purpose of adaptively adjusting the maximum GOP length can be achieved.
[0066] In an exemplary embodiment of the present disclosure, the key frame position and video encoding parameters corresponding to the current frame sequence to be encoded are determined according to the first target image group length; and the current frame sequence to be encoded is encoded according to the key frame position and the video encoding parameters.
[0067] The key frame position may be a specific position of the key frame in the video frame sequence, and the video encoding parameter may be an encoding parameter used to encode the video.
[0068] After determining the first target image group length corresponding to the current frame sequence to be encoded, the video encoding parameters used for encoding the current frame sequence to be encoded can be determined based on the first target image group length; for example, the video encoding parameters may include the length of the encoding preprocessing, and the encoding preprocessing lengths corresponding to different target image group lengths may be different. For example, if the first target image group length is 16, the encoding preprocessing length that matches it may be 60. When the first target image group length is adjusted to 32, the encoding preprocessing length that matches the GOP length of 32 may be 90. The adjusted encoding preprocessing length will have better encoding performance during the video encoding process. Therefore, the video encoding parameters that best match the first target image group length can be determined for subsequent video encoding processing.
[0069] Furthermore, after determining the first target GOP length (the first maximum GOP length), the key frame positions in the current frame sequence to be encoded can be determined based on the first maximum GOP length. The first maximum GOP length provides a range of values for the key frame positions, and the key frame positions are determined within this range. After determining the video encoding parameters and key frame positions, the above parameters can be used to encode the current frame sequence to improve video encoding performance.
[0070] In an exemplary embodiment of the present disclosure, encoding processing is performed on the current frame sequence to be encoded according to the key frame position and video encoding parameters, which can be performed through the following steps: determining the first key frame and the second key frame corresponding to the current frame sequence to be encoded according to the key frame position; taking the first key frame and the video frame between the first key frame and the second key frame as the image group to be encoded; encoding processing is performed on the image group to be encoded according to the video encoding parameters to obtain an encoded image group.
[0071] The to-be-encoded group of pictures may be a group of pictures waiting to be video-encoded, and the coded group of pictures may be a group of pictures that have already been video-encoded.
[0072] After determining the first maximum GOP length, the key frame insertion position range can be determined. For example, when the first maximum GOP length is 16, the key frame can be inserted at any position numbered 0-15. For example, the first key frame can be located at position 0, and the second key frame can be located at position 9. Therefore, after determining the first and second key frames, a B frame can be inserted between the two key frames. The first key frame and the B frame between the two key frames together form a group of pictures, which is recorded as the group of pictures to be encoded.
[0073] After the to-be-encoded picture group is determined, the to-be-encoded picture group can be encoded according to the determined video encoding parameters to obtain an encoded picture group. Through the above processing steps, the video encoding process of the first 10 video frames in the current to-be-encoded frame sequence can be completed.
[0074] In an exemplary embodiment of the present disclosure, the position of the second key frame is obtained and the length of the encoded picture group is determined; a frame reading operation is performed based on the position of the second key frame and the length of the encoded picture group to obtain an updated frame sequence to be encoded; the length of the second target picture group corresponding to the updated frame sequence to be encoded is determined; and the updated frame sequence to be encoded is encoded based on the second target picture group length.
[0075] The position of the second key frame may be a position number of the second key frame in the video frame sequence. The length of the coded group of pictures may be the length of the group of pictures that has been processed by video encoding. The updated sequence of frames to be encoded may be a sequence of video frames to be encoded that is reconstructed after performing the frame read operation. The second target group of pictures length may be a target group of pictures length corresponding to the updated sequence of frames to be encoded.
[0076] refer to Figure 4 , Figure 4 This figure illustrates an example of re-performing a frame acquisition operation to obtain an updated sequence of frames to be encoded, according to an exemplary embodiment. A group of pictures to be encoded is encoded to obtain an encoded group of pictures; the encoded group of pictures includes a first key frame 401. The position of a second key frame 402 is determined based on the encoded group of pictures. Since the encoder typically maintains the number of video frames to be encoded at the encoding preprocessing length, after determining the position of the second key frame, the length of the encoded group of pictures can be determined. For example, the length of the encoded group of pictures is 10. The encoding process has completed the encoding of 10 video frames, generating 10 encoded video frames. 50 unencoded video frames remain, starting from the position of the second video frame. At this point, the frame read operation can be continued, based on the position of the second key frame, to read video frames for the encoding preprocessing length. This means that 10 new video frames are re-read. The remaining 50 unencoded video frames and the 10 new video frames together constitute the updated sequence of frames to be encoded.
[0077] After obtaining the updated sequence of frames to be encoded, the video features have changed due to the changes in the video frame sequence. Therefore, the target GOP length corresponding to the updated sequence of frames to be encoded, i.e., the second target GOP length, can be re-determined. The above processing steps enable more fine-grained adaptive selection of the maximum GOP length, ensuring that the determined second target GOP length is more consistent with the video features. Video encoding based on the second maximum GOP length can effectively improve video encoding performance.
[0078] In an exemplary embodiment of the present disclosure, the method for determining the second maximum GOP length is the same as the method for determining the first maximum GOP length, specifically including: determining the second inter-frame difference information and the second intra-frame difference information of the updated frame sequence to be encoded; and determining the second target image group length based on the second inter-frame difference information and the second intra-frame difference information.
[0079] The second inter-frame difference information may be the information amount difference between different frames in the updated frame sequence to be encoded, and the second intra-frame difference information may be the information amount difference generated by the same video frame in different encoding modes in the updated frame sequence to be encoded.
[0080] After obtaining an updated sequence of frames to be encoded, frame difference information for the sequence of frames to be encoded can be determined, including second inter-frame difference information and second intra-frame difference information. Specifically, a reference frame corresponding to a video frame is determined based on a predetermined frame interval. For example, the inter-frame coding loss between the video frame and the reference frame can be used as the second inter-frame difference information. Alternatively, the difference in information volume generated by the same video frame under different coding modes can be used as the second intra-frame difference information.
[0081] After determining the second inter-frame difference information and the second intra-frame difference information, a second target GOP length may be determined based on the second inter-frame difference information and the second intra-frame difference information. For example, a change trend value for updating the to-be-encoded frame sequence may be determined based on the second inter-frame difference information and the second intra-frame difference information. The determined change trend value may be compared with a change trend threshold. If the change trend value is less than the change trend threshold, it is determined that the to-be-encoded frame sequence is a slow-motion video, and the second maximum GOP length may be increased.
[0082] Conversely, if the change trend value is greater than or equal to the change trend threshold, the updated frame sequence to be encoded is considered to be a video with intense motion, and the second maximum GOP length can be reduced accordingly. Video encoding is then performed based on the determined second maximum GOP length. By adaptively adjusting the maximum GOP length using the change trend value, the second maximum GOP length determined in this manner will conform to the video characteristics of the updated frame sequence to be encoded, achieving a more fine-grained GOP length determination solution, known as GOP-level frame decision making.
[0083] It is easy for those skilled in the art to understand that when determining the second inter-frame difference information and the second intra-frame difference information, it can also be done based on information such as the mean, variance and gradient of the frame-level pixel values of the video frame, and the present disclosure does not make any special limitations on this.
[0084] In an exemplary embodiment of the present disclosure, encoding processing is performed on an updated sequence of frames to be encoded according to the length of the second target image group, including: determining an updated key frame corresponding to the updated sequence of frames to be encoded according to the length of the second target image group; and encoding processing is performed on the updated sequence of frames to be encoded according to the updated key frame.
[0085] The updating of the key frame may be updating of a video frame included in the to-be-encoded frame sequence, and the position of the updated key frame may be determined according to the second maximum GOP length.
[0086] After determining the second maximum GOP length, the key frame in the updated coded frame sequence can be determined according to the second maximum GOP length, that is, the updated key frame. For example, after the second maximum GOP length is adjusted from 16 to 32, the position of the second key frame can be at position numbered 10, and the position of the updated key frame can be at any position between 11 and 41.
[0087] Furthermore, after determining the second maximum GOP length, the video encoding parameters that match the second maximum GOP length can be determined, so that the updated frame sequence to be encoded is encoded according to the video encoding parameters and the updated key frames to obtain the encoded video corresponding to the video to be processed, so as to improve the encoding performance.
[0088] In summary, the video encoding method disclosed in the present invention obtains a video to be processed, determines the current frame sequence to be encoded based on the video to be processed; determines the first inter-frame difference information and the first intra-frame difference information of the current frame sequence to be encoded; updates the first target image group length corresponding to the current frame sequence to be encoded based on the first inter-frame difference information and the first intra-frame difference information; and encodes the current frame sequence to be encoded based on the updated first target image group length to obtain an encoded video. On the one hand, based on the inter-frame difference information and the intra-frame difference information of the video frame sequence, the target image group length is adaptively adjusted, and then the key frame position is determined according to the target image group length and video encoding is performed, which can effectively improve the video encoding efficiency. On the other hand, by effectively utilizing the video features and the information generated by the encoding preprocessing, the sequence level and the finer-grained (such as GOP level) levels are combined to adaptively determine the maximum GOP length, which can greatly improve the video encoding efficiency.
[0089] Figure 5 FIG. 1 is a block diagram of a video encoding device according to an exemplary embodiment. Figure 5 The video encoding device 500 includes a frame sequence acquisition module 510, a difference information determination module 520, a picture group determination module 530 and a video encoding module 540.
[0090] Specifically, the frame sequence acquisition module 510 is used to acquire the video to be processed and determine the current frame sequence to be encoded based on the video to be processed; the difference information determination module 520 is used to determine the first inter-frame difference information and the first intra-frame difference information of the current frame sequence to be encoded; the image group determination module 530 is used to update the first target image group length corresponding to the current frame sequence to be encoded according to the first inter-frame difference information and the first intra-frame difference information; the video encoding module 540 is used to encode the current frame sequence to be encoded according to the updated first target image group length to obtain the encoded video.
[0091] In an exemplary embodiment of the present disclosure, the current frame sequence to be encoded includes multiple video frames; the difference information determination module 520 includes a difference information determination unit, which is configured to perform: obtaining a frame interval corresponding to the current frame sequence to be encoded, and determining a reference frame associated with each video frame according to the frame interval; determining the first inter-frame difference information between each video frame and the reference frame associated with each video frame; and determining the first intra-frame difference information corresponding to each video frame.
[0092] In an exemplary embodiment of the present disclosure, the image group determination module 530 includes an image group determination unit, which is configured to perform: determining a change trend value corresponding to the current frame sequence to be encoded based on the first inter-frame difference information and the first intra-frame difference information; obtaining a pre-configured change trend threshold; when the change trend value is less than the change trend threshold, increasing the first target image group length corresponding to the current frame sequence to be encoded; when the change trend value is greater than or equal to the change trend threshold, reducing the first target image group length corresponding to the current frame sequence to be encoded.
[0093] In an exemplary embodiment of the present disclosure, the video encoding module 540 includes a first video encoding unit, which is configured to perform: determining the key frame position and video encoding parameters corresponding to the current frame sequence to be encoded based on the length of the first target image group; and encoding the current frame sequence to be encoded based on the key frame position and the video encoding parameters.
[0094] In an exemplary embodiment of the present disclosure, the first video encoding unit includes a first video encoding sub-unit, and the first video encoding sub-unit is configured to perform: determining the first key frame and the second key frame corresponding to the current frame sequence to be encoded according to the key frame position; taking the first key frame and the video frame between the first key frame and the second key frame as the image group to be encoded; encoding the image group to be encoded according to the video encoding parameters to obtain an encoded image group.
[0095] In an exemplary embodiment of the present disclosure, the video encoding module 540 includes a second video encoding unit, which is configured to perform: obtaining the position of the second key frame and determining the length of the encoded image group; performing a frame reading operation according to the position of the second key frame and the length of the encoded image group to obtain an updated frame sequence to be encoded; determining the second target image group length corresponding to the updated frame sequence to be encoded; and encoding the updated frame sequence to be encoded according to the second target image group length.
[0096] In an exemplary embodiment of the present disclosure, the second video encoding unit includes an image group determination subunit, which is configured to perform: determining and updating the second inter-frame difference information and the second intra-frame difference information of the frame sequence to be encoded; and determining the second target image group length based on the second inter-frame difference information and the second intra-frame difference information.
[0097] In an exemplary embodiment of the present disclosure, the second video encoding unit includes a second video encoding sub-unit, and the second video encoding sub-unit is configured to perform: determining an updated key frame corresponding to the updated frame sequence to be encoded based on the length of the second target image group; and encoding the updated frame sequence to be encoded based on the updated key frame.
[0098] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0099] Reference below Figure 6 6 to describe the electronic device 600 according to such an embodiment of the present disclosure. Figure 6 The electronic device 600 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0100] like Figure 6 As shown, electronic device 600 is implemented as a general-purpose computing device. Components of electronic device 600 may include, but are not limited to, the aforementioned at least one processing unit 610, the aforementioned at least one storage unit 620, a bus 630 connecting various system components (including storage unit 620 and processing unit 610), and a display unit 640.
[0101] The storage unit stores program codes, which can be executed by the processing unit 610, so that the processing unit 610 performs the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification.
[0102] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 621 and / or a cache memory unit 622 , and may further include a read-only memory unit (ROM) 623 .
[0103] The storage unit 620 may include a program / utility 624 having a set (at least one) of program modules 625, such program modules 625 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0104] Bus 630 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0105] The electronic device 600 may also communicate with one or more external devices 670 (e.g., a keyboard, a pointing device, a Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 600, and / or any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., a router, a modem, etc.). Such communication may occur via an input / output (I / O) interface 650. Furthermore, the electronic device 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 660. As shown, the network adapter 660 communicates with other modules of the electronic device 600 via a bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 600, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0106] In an exemplary embodiment, a computer program product is further provided, including a computer program / instruction, wherein the computer program / instruction implements any one of the above-mentioned video processing methods when executed by a processor.
[0107] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.
[0108] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A video encoding method, characterized in that: include: Acquire a video to be processed, and determine a current frame sequence to be encoded based on the video to be processed; Determining first inter-frame difference information and first intra-frame difference information of the current frame sequence to be encoded, where the first inter-frame difference information is a difference in information amount between different frames in the current frame sequence to be encoded, and the first intra-frame difference information is a difference in information amount between the same video frame in different encoding modes in the current frame sequence to be encoded; updating, based on the first inter-frame difference information and the first intra-frame difference information, a first target GOP length corresponding to the current sequence of frames to be encoded, wherein the first target GOP length is updated based on a change trend value corresponding to the current sequence of frames to be encoded, wherein the change trend value is determined based on the first inter-frame difference information and the first intra-frame difference information; The current frame sequence to be encoded is encoded according to the updated first target image group length to obtain an encoded video.
2. The method according to claim 1, characterized in that The current frame sequence to be encoded includes a plurality of video frames; and determining first inter-frame difference information and first intra-frame difference information of the current frame sequence to be encoded includes: Obtaining a frame interval corresponding to the current frame sequence to be encoded, and determining a reference frame associated with each of the video frames according to the frame interval; determining first inter-frame difference information between each of the video frames and a reference frame associated with each of the video frames; Determine first intra-frame difference information corresponding to each of the video frames.
3. The method according to claim 1, characterized in that The updating of the first target GOP length corresponding to the current to-be-encoded frame sequence according to the first inter-frame difference information and the first intra-frame difference information includes: determining a change trend value corresponding to the current to-be-encoded frame sequence according to the first inter-frame difference information and the first intra-frame difference information; Get pre-configured change trend thresholds; In a case where the change trend value is less than the change trend threshold, increasing the length of the first target image group corresponding to the current frame sequence to be encoded; When the change trend value is greater than or equal to the change trend threshold, the length of the first target image group corresponding to the current frame sequence to be encoded is reduced.
4. The method according to claim 1, wherein The encoding process of the current frame sequence to be encoded according to the updated first target picture group length includes: Determining, based on the first target GOP length, key frame positions and video encoding parameters corresponding to the current frame sequence to be encoded; The current frame sequence to be encoded is encoded according to the key frame position and the video encoding parameters.
5. The method according to claim 4, characterized in that The encoding process of the current frame sequence to be encoded according to the key frame position and the video encoding parameter includes: Determining a first key frame and a second key frame corresponding to the current frame sequence to be encoded according to the key frame positions; using the first key frame and the video frames between the first key frame and the second key frame as a group of pictures to be encoded; The to-be-encoded picture group is encoded according to the video encoding parameters to obtain an encoded picture group.
6. The method according to claim 1 or 5, characterized in that The method further comprises: Obtaining the position of the second key frame and determining the length of the encoded picture group; performing a frame reading operation according to the position of the second key frame and the length of the encoded group of pictures to obtain an updated sequence of frames to be encoded; Determining a second target group of pictures length corresponding to the updated sequence of frames to be encoded; The updated sequence of frames to be encoded is encoded according to the second target group of pictures length.
7. The method according to claim 6, characterized in that The determining of the second target GOP length corresponding to the updated sequence of frames to be encoded includes: Determining second inter-frame difference information and second intra-frame difference information of the updated frame sequence to be encoded; The second target image group length is determined according to the second inter-frame difference information and the second intra-frame difference information.
8. The method according to claim 6, characterized in that The encoding process of the updated sequence of frames to be encoded according to the second target group of pictures length includes: determining, according to the second target GOP length, an updated key frame corresponding to the updated sequence of frames to be encoded; The updated sequence of frames to be encoded is encoded according to the updated key frames.
9. A video encoding device, characterized in that: include: A frame sequence acquisition module is used to acquire a video to be processed and determine a current frame sequence to be encoded based on the video to be processed; a difference information determining module, configured to determine first inter-frame difference information and first intra-frame difference information of the current frame sequence to be encoded, wherein the first inter-frame difference information is the difference in information amount between different frames in the current frame sequence to be encoded, and the first intra-frame difference information is the difference in information amount between the same video frame in different encoding modes in the current frame sequence to be encoded; a picture group determination module, configured to update a first target picture group length corresponding to the current frame sequence to be encoded based on the first inter-frame difference information and the first intra-frame difference information, wherein the first target picture group length is updated based on a change trend value corresponding to the current frame sequence to be encoded, wherein the change trend value is determined based on the first inter-frame difference information and the first intra-frame difference information; The video encoding module is used to encode the current frame sequence to be encoded according to the updated first target image group length to obtain an encoded video.
10. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the video encoding method according to any one of claims 1 to 8. 11 . A computer-readable storage medium, wherein when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the video encoding method according to claim 1 .
Citation Information
Patent Citations
Method and encoder system for determining GOP length for encoding video
CN108574843A
Dynamically determining group of picture size during encoding of video sequence
US6307886B1