Video encoding method, device, equipment and storage medium
By decoding and GOP division of album videos and adjusting the encoding sequence, the problem of large amount of album videos is solved, and the amount of video data is reduced while ensuring the unchanged quality.
Patent Information
- Application Number
- CN202310094141.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-07
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2043-02-07
AI Technical Summary
In the prior art, when encoding photo album videos, it is difficult to reduce the amount of video data while ensuring that the video quality remains unchanged.
By decoding the target video, the similarity between multiple frame images is determined, divided into multiple GOPs, and the encoding order of images in each GOP is adjusted, and the frame type and reference frame are used for encoding.
Without reducing the video quality, the amount of video data is effectively reduced.
Smart Images

Figure CN117750030B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer application technology, and in particular to video encoding methods, devices, equipment, and storage media. Background Art
[0002] Currently, there is a type of video that is different from conventional videos. This type of video is produced or converted from multiple electronic images. The number of image frames contained in this type of video is relatively small, and this type of video has high requirements for image quality, such as album videos. Album videos refer to a type of electronic album that presents image content in the form of video. When users use multiple electronic images to create album videos, there is a certain order between the multiple electronic images, but this preset order is not the best for utilizing the content relevance / similarity between images and further compressing and encoding to save video data. Therefore, how to reduce the amount of video data, that is, to reduce the volume of the video while ensuring that the video quality remains unchanged, is a technical problem that needs to be solved at present. Summary of the Invention
[0003] The embodiments of the present application provide a video encoding method, apparatus, device, and storage medium, which can ensure that the data volume of the video is reduced without reducing the video quality.
[0004] In one aspect, an embodiment of the present application provides a video encoding method, the method comprising:
[0005] Decode the target video to obtain multiple frames of images;
[0006] Determining a value of a Group of Pictures (GOP) of the multi-frame images based on similarities between frames in the multi-frame images;
[0007] Based on the determined GOP values of the multiple frames of images, the multiple frames of images are divided into a plurality of GOPs, and an encoding order of images contained in each GOP is adjusted;
[0008] The images after the coding order is adjusted are encoded to obtain an encoded target video.
[0009] In one embodiment, adjusting the encoding order of images included in each GOP includes:
[0010] For any GOP, obtaining a frame type of each frame image in the any GOP and a reference frame of each frame image;
[0011] Based on the frame type of each frame of image and the reference frame of each frame of image, the encoding order of the images included in any GOP is adjusted.
[0012] In one embodiment, adjusting the encoding order of images included in any GOP based on the frame type of each frame and the reference frame of each frame includes:
[0013] Acquire a first image whose frame type is an I frame and a plurality of second images whose frame type is a B frame in any GOP;
[0014] Adjusting the encoding order of the first image; wherein the encoding order of the first image is prior to the encoding order of the plurality of second images;
[0015] traversing the plurality of second images, and determining, from the plurality of second images, a second image whose reference frame includes the first image;
[0016] Adjusting the determined coding order of the second images; wherein the determined coding order of the second images is prior to the coding order of other second images in the plurality of second images;
[0017] Determining the reference frame from the other second images includes a second image of any second image whose coding order has been most recently adjusted;
[0018] Adjusting the encoding order of the most recently determined second image, wherein the encoding order of the most recently determined second image is prior to the encoding order of other second images in the plurality of second images;
[0019] After the traversal is completed, the images in any GOP after the encoding order is adjusted are obtained.
[0020] In one embodiment, any GOP includes N frames of images, the frame type of the Nth frame of the image in any GOP is an I frame, the frame types of the other images in any GOP are B frames, the encoding order of the Nth frame of the image precedes the encoding order of the other images in any GOP, the encoding order of the N / 2th frame of the image in any GOP is later than the encoding order of the Nth frame of the image, the encoding order of the N / 4th frame of the image in any GOP is later than the encoding order of the N / 2th frame of the image, and the encoding order of the N / 8th frame of the image in any GOP is later than the encoding order of the N / 8th frame of the image. The coding order of the frame image is later than the coding order of the N / 4th frame image, the coding order of the 3N / 8th frame image in any GOP is later than the coding order of the N / 8th frame image, the coding order of the 3N / 4th frame image in any GOP is later than the coding order of the 3N / 8th frame image, the coding order of the 5N / 8th frame image in any GOP is later than the coding order of the 3N / 4th frame image, and the coding order of the 7N / 8th frame image in any GOP is later than the coding order of the 5N / 8th frame image.
[0021] In one embodiment, obtaining a reference frame for each frame of image includes:
[0022] Based on the frame type of each frame image and a reference frame determination strategy, a reference frame of each frame image is determined.
[0023] In one embodiment, when the value of the GOP of the multi-frame image is the determined value, the similarity between frames in the multi-frame image is greater than the similarity between frames in the multi-frame image when the value of the GOP of the multi-frame image is other values.
[0024] In one embodiment, encoding the images after adjusting the encoding order to obtain the encoded target video includes:
[0025] Determining a frame type of each frame image in each GOP and a reference frame of each frame image;
[0026] According to the adjusted encoding order of each frame image in each GOP, based on the frame type of each frame image and the reference frame of each frame image, the each frame image is encoded to obtain an encoded target video.
[0027] In one embodiment, the method further comprises:
[0028] Downsampling the resolution of each frame image to obtain multiple downsampled frames;
[0029] The determining of a value of a group of pictures (GOP) of the multiple-frame images based on similarities between frames in the multiple-frame images includes:
[0030] Based on the similarity between frames in the downsampled multi-frame image, a value of the GOP of the multi-frame image is determined.
[0031] In one embodiment, downsampling the resolution of each frame image to obtain multiple frames of downsampled images includes:
[0032] The resolution of the image parameter components of each frame image is downsampled to obtain multiple frames of downsampled images, wherein the image parameter components include one or more of the following: a luminance component and a chrominance component.
[0033] In one embodiment, the method further comprises:
[0034] Obtaining the frame rate of the target video;
[0035] If the frame rate is less than the frame rate threshold, the decoding process of the target video is triggered to obtain multiple frames of images.
[0036] On the other hand, an embodiment of the present application provides a video encoding device, the video encoding device comprising:
[0037] A decoding unit, used for decoding the target video to obtain multiple frames of images;
[0038] a determining unit, configured to determine a value of a GOP of the multiple image frames based on similarities between frames in the multiple image frames;
[0039] a dividing unit, configured to divide the multi-frame image into a plurality of GOPs based on the determined GOP values of the multi-frame image, and adjust the coding order of the images contained in each GOP;
[0040] The encoding unit is used to encode the images after the encoding order is adjusted to obtain an encoded target video.
[0041] On the other hand, an embodiment of the present application provides a computer device, including a processor, a storage device, and a communication interface, wherein the processor, the storage device, and the communication interface are interconnected, wherein the storage device is used to store a computer program that supports the computer device to perform the above method, the computer program including program instructions, and the processor is configured to call the program instructions and perform the following steps:
[0042] Decode the target video to obtain multiple frames of images;
[0043] Determining a GOP value of the multiple-frame images based on similarities between frames in the multiple-frame images;
[0044] Based on the determined GOP values of the multiple frames of images, the multiple frames of images are divided into a plurality of GOPs, and an encoding order of images contained in each GOP is adjusted;
[0045] The images after the coding order is adjusted are encoded to obtain an encoded target video.
[0046] On the other hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the above-mentioned video encoding method.
[0047] On the other hand, an embodiment of the present application provides a computer program product, which includes a computer program, and the computer program is suitable for being loaded by a processor and executing the above-mentioned video encoding method.
[0048] In an embodiment of the present application, after decoding the target video to obtain multiple frames of images, the GOP value of the multiple frames of images is determined based on the similarity between the frames in the multiple frames of images, and then based on the determined GOP value of the multiple frames of images, the multiple frames of images are divided into multiple GOPs. Then, the content correlation between the images contained in each GOP obtained by such division is the highest, so the encoding order of the images contained in each GOP is adjusted, and the images after the encoding order is adjusted are encoded to obtain the encoded target video. The amount of data of the encoded video obtained by this encoding method will be reduced without reducing the video quality. In other words, the embodiment of the present application can ensure that the amount of data of the video is reduced without reducing the video quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0050] Figure 1 This is a flow chart of a video encoding method provided by an embodiment of the present application;
[0051] Figure 2 is a schematic diagram of a GOP provided in an embodiment of the present application;
[0052] Figure 3 This is a flowchart of another video encoding method provided by an embodiment of the present application;
[0053] Figure 4 is a structural diagram of a video encoding device provided in an embodiment of the present application;
[0054] Figure 5 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0055] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0056] Users can upload videos to content publishing platforms to share and disseminate them. In order to reduce the size of the video, content publishing platforms usually encode the video and then publish the encoded video so that other users can watch the video or edit the video, such as forwarding, liking, or collecting it. Taking album videos as an example, album videos refer to a type of electronic album that presents image content in the form of video. The number of image frames in album videos is small, the frame rate of album videos is much lower than that of regular videos, and album videos have high requirements for image quality. In other words, when encoding album videos, content publishing platforms need to ensure that the video quality is as unaffected as possible. Therefore, how to reduce the amount of video data, that is, to reduce the size of the video, while ensuring that the video quality remains unchanged, is a technical problem that needs to be solved at present.
[0057] Based on this, the video encoding method provided by the embodiment of the present application, after decoding the target video to obtain multiple frames of images, determines the value of the GOP of the multiple frames of images based on the similarity between the frames in the multiple frames of images, and then divides the multiple frames of images into multiple GOPs based on the determined value of the GOP of the multiple frames of images. Then, the content correlation between the images contained in each GOP obtained by such division is the highest, so the encoding order of the images contained in each GOP is adjusted, and the images after the encoding order is adjusted are encoded to obtain the encoded target video. The amount of data of the encoded video obtained by this encoding method will be reduced without reducing the video quality. In other words, the embodiment of the present application can ensure that the amount of data of the video is reduced without reducing the video quality.
[0058] Among them, a GOP is a group of continuous pictures. GOP is a set of images in the target video. A GOP may include multiple images. GOP is used to assist random access. The value of GOP can be understood as the interval between two I frames.
[0059] The video encoding method provided in the embodiment of the present application can be applied to a video encoding device, the video encoding device can be installed or integrated in a content publishing platform, the content publishing platform can run in a computer device, the computer device can include a terminal device or a server, etc. The computer device includes but is not limited to a smartphone, a camera, a wearable device or a computer, etc.
[0060] See Figure 1 , Figure 1 is a flow chart of a video encoding method provided by an embodiment of the present application, which can be executed by a video encoding device, a content publishing platform or a computer device; Figure 1 The video encoding scheme shown includes but is not limited to steps S101 to S104, wherein:
[0061] S101: Decode the target video to obtain multiple frames of images.
[0062] The target video may be any video, for example, a video uploaded by a user to a content publishing platform, or a video to be encoded on the content publishing platform.
[0063] In one example, the target video can be decoded to obtain multiple frames of images in YUV format, i.e., the pixel format of each frame is YUV. YUV refers to a pixel format that represents luminance and chrominance parameters separately, where "Y" represents brightness (Luminance or Luma), or grayscale value, while "U" and "V" represent chrominance (Chrominance or Chroma), which describes the color and saturation of the image and is used to specify the color of the pixel.
[0064] In another example, the target video may be decoded to obtain multiple frames of images in RGB format, that is, the pixel format of each frame of the image is RGB, where RGB represents the colors of the three channels of red, green, and blue.
[0065] S102 : Determine a GOP value of the multi-frame image based on similarities between frames in the multi-frame image.
[0066] Among them, when the GOP value of the multi-frame image is a certain value, the similarity between frames in the multi-frame image is greater than the similarity between frames in the multi-frame image when the GOP value of the multi-frame image is other values.
[0067] In one implementation, the similarity between frames in a multi-frame image can be obtained when the GOP value is set to different values, and the GOP value of the multi-frame image is set to a target value. The target value refers to the value set when the similarity between frames is the highest.
[0068] In one implementation, multiple values can be traversed. When the value of GOP is set to the currently traversed value, multiple frames of images are divided into multiple candidate GOPs. For any candidate GOP among the multiple candidate GOPs, the inter-frame similarity index of the images contained in any candidate GOP is calculated. If the inter-frame similarity index of any candidate GOP is less than the index threshold corresponding to the GOP value, it is determined that when the value of GOP is set to the currently traversed value, the similarity between frames in the multiple frames of images is the highest.
[0069] In one implementation, if the inter-frame similarity index of any candidate GOP is greater than or equal to the index threshold corresponding to the value of the GOP, the next value is traversed.
[0070] For example, assuming multiple values include 4, 8, 16, and 32, and the target video is decoded to obtain 8 frames of images, when the value 4 is traversed, the GOP value is set to 4, that is, the 8 frames of images are divided into 2 GOPs, namely the first GOP and the second GOP, each GOP includes 4 frames of images, where the first GOP includes the first to fourth frames of images, and the second GOP includes the fifth to eighth frames of images. The inter-frame similarity index of the first frame image to the fourth frame image contained in the first GOP can be calculated. If the inter-frame similarity index of the first frame image to the fourth frame image is less than the index threshold corresponding to the GOP value set to 4, it is determined that when the GOP value is set to 4, the similarity between frames in the 12-frame image is the highest. Therefore, the GOP value of the 12-frame image can be set to 4, the 12-frame image can be divided into 3 GOPs, and the encoding order of the images contained in each GOP is adjusted, and the images after the adjusted encoding order are encoded to obtain an encoded video bit stream, and the encoded video bit stream and the audio bit stream of the target video are encapsulated to obtain the encoded target video.
[0071] If the inter-frame similarity index of the first to fourth frames is greater than or equal to the index threshold corresponding to when the GOP value is set to 4, it indicates that the similarity between the frames in the first to fourth frames is not the highest when the GOP value is set to 4. The inter-frame similarity index of the fifth to eighth frames included in the second GOP can be calculated. If the inter-frame similarity index of the fifth to eighth frames is less than the index threshold corresponding to when the GOP value is set to 4, it is determined that the similarity between the frames in the 12 frames is the highest when the GOP value is set to 4.
[0072] If the inter-frame similarity index of the fifth through eighth frames is greater than or equal to the index threshold corresponding to the GOP value set to 4, it indicates that the inter-frame similarity among the fifth through eighth frames is not the highest when the GOP value is set to 4. The GOP value can be set to 8, meaning that the eight frames are divided into one GOP, i.e., the GOP includes eight frames. The inter-frame similarity index of the first through eighth frames contained in the GOP can be calculated. If the inter-frame similarity index of the first through eighth frames is less than the index threshold corresponding to the GOP value set to 8, it is determined that the inter-frame similarity among the eight frames is the highest when the GOP value is set to 8. Therefore, the GOP value of the eight frames can be set to 8, the eight frames are divided into one GOP, and the coding order of the images contained in the GOP is adjusted. The images with the adjusted coding order are encoded to obtain a coded video bitstream, and the coded video bitstream is encapsulated with the audio bitstream of the target video to obtain the coded target video.
[0073] In another implementation, multiple values can be traversed, and when the value of GOP is set to the currently traversed value, the multi-frame image is divided into multiple candidate GOPs. For the first candidate GOP among the multiple candidate GOPs, the inter-frame similarity index of the images contained in the first candidate GOP is calculated. If the inter-frame similarity index of the first candidate GOP is less than the index threshold corresponding to the GOP value, it is determined that when the GOP value is set to the currently traversed value, the similarity between frames in the multi-frame image is the highest; if the inter-frame similarity index of the first candidate GOP is greater than or equal to the index threshold corresponding to the GOP value, the next value is traversed. The value of GOP of the multi-frame image is set to the target value, and the target value refers to the value set when the similarity between frames is the highest. Based on the value of GOP of the multi-frame image, the multi-frame image is divided into multiple GOPs, and the encoding order of the images contained in the first GOP is adjusted, and the images after the adjusted encoding order are encoded to obtain the encoded first video bit stream. For the other images in the multiple-frame images except the images included in the first GOP, the target value is determined in the same manner as above, the GOP values of the other images are set as the target value, and based on the GOP values of the other images, the other images are divided into multiple GOPs, and the encoding order of the images included in the first GOP is adjusted, and the images after the adjusted encoding order are encoded to obtain the encoded second video bit stream, until the encoding of the multiple-frame images is completed.
[0074] For example, assuming multiple values include 4, 8, 16, and 32, and the target video is decoded to obtain 12 frames of images. When traversing the value 4, the GOP value is set to 4, that is, the 8 frames of images are divided into 3 GOPs, namely the first GOP, the second GOP, and the third GOP. Each GOP includes 4 frames of images, where the first GOP includes the first to fourth frames of images, the second GOP includes the fifth to eighth frames of images, and the third GOP includes the ninth to twelfth frames of images. The inter-frame similarity index of the first frame image to the fourth frame image contained in the first GOP can be calculated. If the inter-frame similarity index of the first frame image to the fourth frame image is less than the index threshold corresponding to the GOP value set to 4, it is determined that when the GOP value is set to 4, the similarity between the frames in the 12 frame images is the highest. Therefore, the GOP value of the 12 frame images can be set to 4, the 12 frame images can be divided into 3 GOPs, and the encoding order of the first frame image to the fourth frame image can be adjusted, and the images after the adjusted encoding order are encoded to obtain the encoded first video bit stream.
[0075] Then, for the fifth to twelfth frames, when traversing the value 4, the GOP value is set to 4, that is, the fifth to twelfth frames are divided into two GOPs, namely the first GOP and the second GOP, each GOP including four frames, wherein the first GOP includes the fifth to eighth frames, and the second GOP includes the ninth to twelfth frames. The inter-frame similarity index of the fifth to eighth frames contained in the first GOP can be calculated. If the inter-frame similarity index of the fifth to eighth frames is greater than or equal to the index threshold corresponding to the GOP value set to 4, the value 8 is traversed, the fifth to twelfth frames are divided into one GOP, and the inter-frame similarity index of the fifth to twelfth frames is calculated. If the inter-frame similarity index of the fifth to twelfth frames is less than the index threshold corresponding to the GOP value set to 8, the encoding order of the fifth to twelfth frames is adjusted, and the images after the adjusted encoding order are encoded to obtain an encoded second video bitstream. The encoded first video bit stream, the encoded second video bit stream, and the audio bit stream of the target video are encapsulated to obtain the encoded target video.
[0076] In one implementation, inter-frame prediction is performed on each frame image included in any candidate GOP to obtain predicted pixel values for each frame image. Matching parameters for each frame image are obtained based on the predicted pixel values and target pixel values. The matching parameters include the sum of absolute differences (SATD) or mean absolute differences (MAD). Based on the matching parameters for each frame image, an inter-frame similarity index for the images included in any candidate GOP is obtained. The target pixel value for each frame image refers to the pixel value of each frame image obtained by decoding the target video.
[0077] In one example, the SATD of each frame can be obtained based on the predicted pixel values and target pixel values of each frame. The SATDs of each frame included in any candidate GOP are added together to obtain the inter-frame similarity index of the candidate GOP. The smaller the SATD of each frame, the smaller the inter-frame similarity index of the candidate GOP, indicating a higher similarity between the frames.
[0078] In another example, the MAD of each frame image can be obtained based on the predicted pixel values and target pixel values of each frame image, and the MADs of each frame image included in any candidate GOP can be added to obtain the inter-frame similarity index of the candidate GOP. The smaller the MAD of each frame image, the smaller the inter-frame similarity index of the candidate GOP, indicating a higher similarity between the frames.
[0079] In one implementation, each frame image can be divided into blocks to obtain multiple image blocks of each frame image, and inter-frame prediction can be performed on each image block to obtain predicted pixel values of each image block. Based on the predicted pixel values and target pixel values of each image block, matching parameters of each image block can be obtained. Based on the matching parameters of each image block in any frame image contained in any candidate GOP, matching parameters of any frame image can be obtained.
[0080] In one example, each frame image can be divided into blocks to obtain multiple image blocks of each frame image. Inter-frame prediction is performed on each image block to obtain predicted pixel values for each image block. The SATD of each image block is obtained based on the predicted pixel values and target pixel values of each image block. The SATD of each image block included in each frame image is added together to obtain the inter-frame similarity index of the candidate GOP.
[0081] For example, assuming that a candidate GOP includes the first to fourth frames, each of the first to fourth frames is divided into blocks to obtain 64 image blocks for each frame. Inter-frame prediction is performed on each image block to obtain predicted pixel values for each image block. Based on the predicted pixel values and target pixel values of each image block, the SATD of each image block is obtained. The SATD of the 64 image blocks of the first frame can be added together to obtain the SATD of the first frame. Similarly, the SATD of the second frame, the SATD of the third frame, and the SATD of the fourth frame can be obtained. Then, the SATD of the first frame, the SATD of the second frame, the SATD of the third frame, and the SATD of the fourth frame are added together to obtain the inter-frame similarity index of the candidate GOP.
[0082] In another example, the MAD of each frame image can be obtained based on the predicted pixel values and target pixel values of each frame image, and the MADs of each frame image included in any candidate GOP can be added to obtain the inter-frame similarity index of the candidate GOP. The smaller the MAD of each frame image, the smaller the inter-frame similarity index of the candidate GOP, indicating a higher similarity between the frames.
[0083] For example, assuming that a candidate GOP includes the first to fourth frames, each of the first to fourth frames is divided into blocks to obtain 64 image blocks for each frame. Inter-frame prediction is performed on each image block to obtain predicted pixel values for each image block. Based on the predicted pixel values and target pixel values of each image block, the MAD of each image block is obtained. The MADs of the 64 image blocks of the first frame can be added together to obtain the MAD of the first frame. Similarly, the MADs of the second, third, and fourth frames can be obtained. Then, the MADs of the first, second, third, and fourth frames are added together to obtain the inter-frame similarity index of the candidate GOP.
[0084] In one implementation, the resolution of each frame image can be downsampled to obtain multiple frames of downsampled images. Then, based on the similarity between frames in the multiple frames of downsampled images, the GOP value of the multiple frames of images is determined. The method of downsampling the resolution of each frame image can be referred to the description of step S203 in the following embodiment.
[0085] S103 : Based on the determined GOP values of the multi-frame images, the multi-frame images are divided into a plurality of GOPs, and the coding order of the images included in each GOP is adjusted.
[0086] For example, assuming that the GOP value of the multi-frame image is 4 and the number of multi-frame images is 12, the 12 frames of images can be divided into three GOPs, namely the first GOP, the second GOP, and the third GOP. Each GOP includes 4 frames of images, where the first GOP includes the first to fourth frames of images, the second GOP includes the fifth to eighth frames of images, and the third GOP includes the ninth to twelfth frames of images. Then, the encoding order of the images included in the first GOP, the second GOP, and the third GOP is adjusted respectively.
[0087] In one implementation, for any GOP, the frame type of each frame image in any GOP and the reference frame of each frame image can be obtained, and based on the frame type of each frame image and the reference frame of each frame image, the encoding order of the images contained in any GOP can be adjusted.
[0088] Image frame types include I-frames, P-frames, and B-frames. An I-frame, also known as an intrapicture, is a full-frame compressed frame that uses JPEG compression to encode and transmit the entire frame's image information. When an I-frame is decoded, the complete image can be reconstructed using only the I-frame data. A P-frame, also known as a predictive-frame, is a coded image that compresses the amount of transmitted data by fully utilizing temporal redundancy information that is lower than that of previously encoded frames in the image sequence. A P-frame uses the I-frame as a reference frame. The predicted value and motion vector for a certain point in the P-frame are found in the I-frame, and the predicted difference is transmitted along with the motion vector. At the decoder, the predicted value for a certain point in the P-frame is found in the I-frame based on the motion vector and added to the difference to obtain a sample value for that point in the P-frame, thus generating a complete P-frame. B-frames are bidirectionally predicted interpolated frames, also known as bi-directional prediction frames. They consider temporal redundancy between previous and subsequent frames in the source image sequence to reduce the amount of transmitted data. B-frames use the preceding I or P frame and the following P frame as reference frames. The prediction value and two motion vectors for a certain point in the B-frame are determined, and the difference between the predictions and the motion vectors is transmitted. The decoder then finds (or calculates) the prediction value in the two reference frames based on the motion vectors and sums it with the difference to obtain the sample value for the "certain point" in the B-frame, thus producing a complete B-frame.
[0089] In one implementation, the method of obtaining the reference frame of each frame of image may include: determining the reference frame of each frame of image based on the frame type of each frame of image and a reference frame determination strategy.
[0090] by Figure 2 Taking the schematic diagram of the GOP shown as an example, assuming that a GOP includes N frames, where the frame type of the last frame in the GOP is an I frame and the frame types of the other frames in the GOP are B frames, based on the reference frame determination strategy, it can be determined that the reference frame of the N / 2th frame in the GOP includes the Nth frame and the last frame in the previous GOP. The reference frame of the N / 4th frame in the GOP includes the N / 2th frame and the last frame in the previous GOP. Similarly, the reference frame of the 3N / 4th frame in the GOP includes the N / 2th frame and the Nth frame. The reference frame of the N / 8th frame image in the GOP includes the N / 4th frame image and the last frame image in the previous GOP. Similarly, the reference frame of the 3N / 8th frame image in the GOP includes the N / 4th frame image and the N / 2th frame image. The reference frame of the 5N / 8th frame image in the GOP includes the 3N / 4th frame image and the N / 2th frame image. The reference frame of the 7N / 8th frame image in the GOP includes the 3N / 4th frame image and the Nth frame image.
[0091] Optional, Figure 2 The reference frame determination strategy shown is merely an example, and other methods are also possible, that is, the frame type of each frame image may be in other forms, or the number of reference frames for each frame image may be 3 or 4, etc. For example, the frame type of the Nth frame image in a GOP is an I frame, and the frame types of the other frame images are P frames. The reference frame of the 7N / 8th frame image in the GOP includes the Nth frame image, the reference frame of the 6N / 8th frame image in the GOP includes the 7N / 8th frame image and the Nth frame image, the reference frame of the 5N / 8th frame image in the GOP includes the 6N / 8th frame image and the 7N / 8th frame image, the reference frame of the N / 2th frame image in the GOP includes the 5N / 8th frame image and the 6N / 8th frame image, and so on.
[0092] Optionally, adjusting the coding order of images within any GOP based on the frame type of each image and its reference frame may include: obtaining a first image with an I-frame type and multiple second images with B-frame types within any GOP. Then, adjusting the coding order of the first image, wherein the coding order of the first image precedes the coding order of the multiple second images. Then, traversing the multiple second images, determining, from the multiple second images, a second image whose reference frame includes the first image, and adjusting the coding order of the determined second image, wherein the coding order of the determined second image precedes the coding order of the other second images within the multiple second images. Furthermore, determining, from the other second images, a second image whose reference frame includes any second image whose coding order was most recently adjusted, and adjusting the coding order of the most recently determined second image, wherein the coding order of the most recently determined second image precedes the coding order of the other second images within the multiple second images. After the traversal is complete, obtaining the images within any GOP after the coding order adjustment.
[0093] by Figure 2For example, since the frame type of the last frame in a GOP is I-frame, and the frame types of the other frames in the GOP are B-frames, and the reference frames of the fourth frame in the GOP include the eighth frame and the last frame in the previous GOP, it can be determined that the coding order of the last frame in the GOP is first, and the coding order of the fourth frame in the GOP is second. Since the reference frames of the second frame in the GOP include the fourth frame and the last frame in the previous GOP, it can be determined that the coding order of the second frame in the GOP is third. Since the reference frames of the first frame in the GOP include the second frame and the last frame in the previous GOP, it can be determined that the coding order of the first frame in the GOP is fourth. Similarly, it can be determined that the coding order of the third frame in the GOP is fifth, the coding order of the sixth frame in the GOP is sixth, the coding order of the fifth frame in the GOP is seventh, and the coding order of the seventh frame in the GOP is eighth.
[0094] Optionally, assume that any GOP includes N frames of images, the frame type of the Nth frame image in any GOP is I frame, the frame type of other images in any GOP is B frame, the coding order of the Nth frame image precedes the coding order of other images in any GOP, the coding order of the N / 2th frame image in any GOP follows the coding order of the Nth frame image, the coding order of the N / 4th frame image in any GOP follows the coding order of the N / 2th frame image, the coding order of the N / 8th frame image in any GOP follows the coding order of the N / 4th frame image, the coding order of the 3N / 8th frame image in any GOP follows the coding order of the N / 8th frame image, the coding order of the 3N / 4th frame image in any GOP follows the coding order of the 3N / 8th frame image, the coding order of the 5N / 8th frame image in any GOP follows the coding order of the 3N / 4th frame image, and the coding order of the 7N / 8th frame image in any GOP follows the coding order of the 5N / 8th frame image.
[0095] S104: Encode the images after the encoding order is adjusted to obtain an encoded target video.
[0096] In one implementation, the frame type of each frame image in each GOP and the reference frame of each frame image can be determined, and each frame image can be encoded based on the frame type of each frame image and the reference frame of each frame image in accordance with the adjusted encoding order of each frame image in each GOP to obtain the encoded target video.
[0097] Optionally, the images after the coding order is adjusted may be encoded to obtain a coded video bit stream, and the coded video bit stream and the audio bit stream of the target video may be encapsulated to obtain a coded target video.
[0098] In an embodiment of the present application, after decoding the target video to obtain multiple frames of images, the GOP value of the multiple frames of images is determined based on the similarity between frames in the multiple frames of images, and then based on the determined GOP value of the multiple frames of images, the multiple frames of images are divided into multiple GOPs, the encoding order of the images contained in each GOP is adjusted, and the images after the adjusted encoding order are encoded to obtain the encoded target video, which can ensure that the data amount of the video is reduced without reducing the video quality.
[0099] Based on the above description, see Figure 3 , Figure 3 is a flow chart of another video encoding method provided in an embodiment of the present application, which can be executed by a video encoding device, a content publishing platform or a computer device; Figure 3 The video encoding scheme shown includes but is not limited to steps S301 to S309, wherein:
[0100] S301: Obtain the frame rate of the target video.
[0101] In this embodiment of the present application, since the frame rate of album videos is much lower than that of regular videos, after acquiring the target video, the frame rate of the target video can be obtained. If the frame rate is less than the frame rate threshold, it indicates that the target video is an album video, and then the target video is decoded to obtain multiple frames. If the frame rate is greater than or equal to the frame rate threshold, it indicates that the target video is a regular video, and the target video can be directly published.
[0102] S302: If the frame rate is less than the frame rate threshold, the target video is decoded to obtain multiple frames of images.
[0103] The embodiment of the present application decodes the target video to obtain multiple frames of images. The method can refer to the description of step S101 in the above embodiment, and will not be repeated in this embodiment.
[0104] S303 , downsampling the resolution of each frame image to obtain multiple frames of downsampled images.
[0105] In one implementation, the resolution of image parameter components of each frame image may be downsampled to obtain multiple frames of downsampled images, where the image parameter components include one or more of the following: a luminance component and a chrominance component.
[0106] For example, the resolution of the luminance component and the chrominance component of each frame image may be downsampled to obtain multiple frames of downsampled images, wherein the resolution of the multiple frames of downsampled images is relatively low.
[0107] S304 , obtaining similarities between frames in the downsampled multi-frame image when the GOP value is set to different values.
[0108] Among them, step S304 can refer to the specific description of step S102 in the above embodiment, and will not be repeated in this embodiment of the application.
[0109] S305 , setting the GOP value of the multiple frames of image as a target value, where the target value refers to a value set when the similarity between frames is the highest.
[0110] S306 , dividing the multiple image frames into multiple GOPs based on the GOP values of the multiple image frames, and determining the frame type of each image frame in each GOP and the reference frame of each image frame.
[0111] by Figure 2 Taking the schematic diagram of the GOP shown as an example, assume that a GOP includes N frames. Based on the encoding strategy, the frame type of the last frame in the GOP is determined to be an I frame, and the frame types of the other frames in the GOP are determined to be B frames. The reference frame for the N / 2th frame in the GOP includes the Nth frame and the last frame in the previous GOP. The reference frame for the N / 4th frame in the GOP includes the N / 2th frame and the last frame in the previous GOP. Similarly, the reference frame for the 3N / 4th frame in the GOP includes the N / 2th frame and the Nth frame. The reference frame of the N / 8th frame image in the GOP includes the N / 4th frame image and the last frame image in the previous GOP. Similarly, the reference frame of the 3N / 8th frame image in the GOP includes the N / 4th frame image and the N / 2th frame image. The reference frame of the 5N / 8th frame image in the GOP includes the 3N / 4th frame image and the N / 2th frame image. The reference frame of the 7N / 8th frame image in the GOP includes the 3N / 4th frame image and the Nth frame image.
[0112] Optional, Figure 2 The coding strategies shown are merely examples, and other approaches are also possible, i.e., the frame type of each frame image may be other forms, or the number of reference frames for each frame image may be 3 or 4, etc. For example, the frame type of the Nth frame image in a GOP is an I-frame, and the frame types of the other frame images are P-frames. The reference frame of the 7N / 8th frame image in the GOP includes the Nth frame image, the reference frame of the 6N / 8th frame image in the GOP includes the 7N / 8th frame image and the Nth frame image, the reference frame of the 5N / 8th frame image in the GOP includes the 6N / 8th frame image and the 7N / 8th frame image, the reference frame of the N / 2th frame image in the GOP includes the 5N / 8th frame image and the 6N / 8th frame image, and so on.
[0113] S307: Adjust the encoding order of the images included in each GOP.
[0114] by Figure 2 For example, since the frame type of the last frame image in the GOP is I frame, and the frame types of other frame images in the GOP are B frames, and the reference frames of the N / 2 frame image in the GOP include the N frame image and the last frame image in the previous GOP, it can be determined that the encoding order of the last frame image in the GOP is first, and the encoding order of the N / 2 frame image in the GOP is second. Since the reference frames of the N / 4 frame image in the GOP include the N / 2 frame image and the last frame image in the previous GOP, it can be determined that the encoding order of the N / 4 frame image in the GOP is third. Since the reference frames of the N / 8 frame image in the GOP include the N / 4 frame image and the last frame image in the previous GOP, it can be determined that the encoding order of the N / 8 frame image in the GOP is fourth. By analogy, it can be determined that the encoding order of the 3N / 8th frame image in GOP is fifth, the encoding order of the 3N / 4th frame image in GOP is sixth, the encoding order of the 5N / 8th frame image in GOP is seventh, and the encoding order of the 7N / 8th frame image in GOP is eighth.
[0115] S308 , encoding each frame image according to the adjusted encoding order of each frame image in each GOP based on the frame type of each frame image and the reference frame of each frame image to obtain an encoded video bit stream.
[0116] S309: Encapsulate the encoded video bit stream and the audio bit stream of the target video to obtain the encoded target video.
[0117] In an embodiment of the present application, if the frame rate of the target video is less than the frame rate threshold, the target video is decoded to obtain multiple frame images, the resolution of each frame image is downsampled to obtain the downsampled multiple frame images, and the similarity between frames in the downsampled multiple frame images when the GOP value is set to different values is obtained, and the GOP value of the multiple frame images is set to the target value. The target value refers to: the value set when the similarity between frames is the highest. Based on the GOP value of the multiple frame images, the multiple frame images are divided into multiple GOPs, and the frame type of each frame image in each GOP and the parameters of each frame image are determined. Consider the frames, adjust the coding order of the images contained in each GOP, encode each frame image according to the adjusted coding order of each frame image in each GOP based on the frame type of each frame image and the reference frame of each frame image to obtain an encoded video bit stream, encapsulate the encoded video bit stream and the audio bit stream of the target video to obtain the encoded target video, analyze the content correlation between the frame images, encode images with more similarities as continuous frames, until all the frame images of the target video are encoded, which can further reduce the size of the video while ensuring the video quality.
[0118] An embodiment of the present application further provides a computer storage medium, in which program instructions are stored. When the program instructions are executed, they are used to implement the corresponding methods described in the above embodiments.
[0119] See also Figure 4 , Figure 4 It is a structural diagram of a video encoding device provided in an embodiment of the present application.
[0120] In one implementation of the video encoding device of the embodiment of the present application, the video encoding device includes the following structure.
[0121] The decoding unit 401 is used to decode the target video to obtain multiple frames of images;
[0122] A determining unit 402 is configured to determine a GOP value of the multiple image frames based on similarities between frames in the multiple image frames;
[0123] A division unit 403 is configured to divide the multi-frame image into a plurality of GOPs based on the determined GOP values of the multi-frame image, and adjust the encoding order of the images included in each GOP;
[0124] The encoding unit 404 is configured to encode the images after the encoding order is adjusted to obtain an encoded target video.
[0125] In one embodiment, the division unit 403 adjusts the coding order of the images included in each GOP, including:
[0126] For any GOP, obtaining a frame type of each frame image in the any GOP and a reference frame of each frame image;
[0127] Based on the frame type of each frame of image and the reference frame of each frame of image, the encoding order of the images included in any GOP is adjusted.
[0128] In one embodiment, the dividing unit 403 adjusts the encoding order of the images included in any GOP based on the frame type of each frame and the reference frame of each frame, including:
[0129] Acquire a first image whose frame type is an I frame and a plurality of second images whose frame type is a B frame in any GOP;
[0130] Adjusting the encoding order of the first image; wherein the encoding order of the first image is prior to the encoding order of the plurality of second images;
[0131] traversing the plurality of second images, and determining, from the plurality of second images, a second image whose reference frame includes the first image;
[0132] Adjusting the determined coding order of the second images; wherein the determined coding order of the second images is prior to the coding order of other second images in the plurality of second images;
[0133] Determining the reference frame from the other second images includes a second image of any second image whose coding order has been most recently adjusted;
[0134] Adjusting the encoding order of the most recently determined second image, wherein the encoding order of the most recently determined second image is prior to the encoding order of other second images in the plurality of second images;
[0135] After the traversal is completed, the images in any GOP after the encoding order is adjusted are obtained.
[0136] In one embodiment, any GOP includes N frames of images, the frame type of the Nth frame of the image in any GOP is an I frame, the frame types of the other images in any GOP are B frames, the encoding order of the Nth frame of the image precedes the encoding order of the other images in any GOP, the encoding order of the N / 2th frame of the image in any GOP is later than the encoding order of the Nth frame of the image, the encoding order of the N / 4th frame of the image in any GOP is later than the encoding order of the N / 2th frame of the image, and the encoding order of the N / 8th frame of the image in any GOP is later than the encoding order of the N / 8th frame of the image. The coding order of the frame image is later than the coding order of the N / 4th frame image, the coding order of the 3N / 8th frame image in any GOP is later than the coding order of the N / 8th frame image, the coding order of the 3N / 4th frame image in any GOP is later than the coding order of the 3N / 8th frame image, the coding order of the 5N / 8th frame image in any GOP is later than the coding order of the 3N / 4th frame image, and the coding order of the 7N / 8th frame image in any GOP is later than the coding order of the 5N / 8th frame image.
[0137] In one embodiment, the division unit 403 obtains the reference frame of each frame of image, including:
[0138] Based on the frame type of each frame image and a reference frame determination strategy, a reference frame of each frame image is determined.
[0139] In one embodiment, when the value of the GOP of the multi-frame image is the determined value, the similarity between frames in the multi-frame image is greater than the similarity between frames in the multi-frame image when the value of the GOP of the multi-frame image is other values.
[0140] In one embodiment, the encoding unit 404 encodes the images after the encoding order is adjusted to obtain an encoded target video, including:
[0141] Determining a frame type of each frame image in each GOP and a reference frame of each frame image;
[0142] According to the adjusted encoding order of each frame image in each GOP, based on the frame type of each frame image and the reference frame of each frame image, the each frame image is encoded to obtain an encoded target video.
[0143] In one embodiment, the video encoding apparatus may further include a downsampling unit 405, wherein:
[0144] The downsampling unit 405 is configured to downsample the resolution of each frame image to obtain multiple frames of downsampled images;
[0145] The determining unit 402 determines a value of a group of pictures (GOP) of the multi-frame images based on similarities between frames in the multi-frame images, including:
[0146] Based on the similarity between frames in the downsampled multi-frame image, a value of the GOP of the multi-frame image is determined.
[0147] In one embodiment, the downsampling unit 405 downsamples the resolution of each frame image to obtain multiple frames of downsampled images, including:
[0148] The resolution of the image parameter components of each frame image is downsampled to obtain multiple frames of downsampled images, wherein the image parameter components include one or more of the following: a luminance component and a chrominance component.
[0149] In one embodiment, the video encoding apparatus may further include a frame rate acquisition unit 406, wherein:
[0150] A frame rate acquisition unit 406 is configured to acquire the frame rate of the target video;
[0151] If the frame rate is less than the frame rate threshold, the decoding unit 401 is triggered to decode the target video to obtain multiple frames of images.
[0152] In an embodiment of the present application, after the decoding unit 401 decodes the target video to obtain multiple frames of images, the determination unit 402 determines the GOP value of the multiple frames of images based on the similarity between frames in the multiple frames of images, and then the division unit 403 divides the multiple frames of images into multiple GOPs based on the determined GOP value of the multiple frames of images, adjusts the encoding order of the images contained in each GOP, and the encoding unit 404 encodes the images after the encoding order is adjusted to obtain the encoded target video, which can ensure that the data amount of the video is reduced without reducing the video quality.
[0153] See also Figure 5 , Figure 5 5 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. The computer device in this embodiment of the present application includes a power supply module and other structures, and includes a processor 501, a storage device 502, and a communication interface 503. The processor 501, the storage device 502, and the communication interface 503 can exchange data, and the processor 501 implements the corresponding video encoding method.
[0154] The storage device 502 may include a volatile memory, such as a random-access memory (RAM); the storage device 502 may also include a non-volatile memory, such as a flash memory, a solid-state drive (SSD), etc.; the storage device 502 may also include a combination of the above types of memory.
[0155] The processor 501 may be a central processing unit (CPU). The processor 501 may also be a combination of a CPU and a GPU. In a server, multiple CPUs and GPUs may be included as needed to perform corresponding video encoding. In one embodiment, the storage device 502 is used to store program instructions. The processor 501 may call the program instructions to implement the various methods involved in the embodiments of the present application.
[0156] In a first possible implementation, the processor 501 of the computer device calls the program instructions stored in the storage device 502 to decode the target video to obtain multiple frames of images; determines the GOP value of the multiple frames of images based on the similarity between frames in the multiple frames of images; divides the multiple frames of images into multiple GOPs based on the determined GOP value of the multiple frames of images, and adjusts the encoding order of the images contained in each GOP; encodes the images after the adjusted encoding order to obtain the encoded target video.
[0157] In one embodiment, the processor 501 may perform the following operations when adjusting the encoding order of images included in each GOP:
[0158] For any GOP, obtaining a frame type of each frame image in the any GOP and a reference frame of each frame image;
[0159] Based on the frame type of each frame of image and the reference frame of each frame of image, the encoding order of the images included in any GOP is adjusted.
[0160] In one embodiment, when adjusting the encoding order of the images included in any GOP based on the frame type of each frame and the reference frame of each frame, the processor 501 may perform the following operations:
[0161] Acquire a first image whose frame type is an I frame and a plurality of second images whose frame type is a B frame in any GOP;
[0162] Adjusting the encoding order of the first image; wherein the encoding order of the first image is prior to the encoding order of the plurality of second images;
[0163] traversing the plurality of second images, and determining, from the plurality of second images, a second image whose reference frame includes the first image;
[0164] Adjusting the determined coding order of the second images; wherein the determined coding order of the second images is prior to the coding order of other second images in the plurality of second images;
[0165] Determining the reference frame from the other second images includes a second image of any second image whose coding order has been most recently adjusted;
[0166] Adjusting the encoding order of the most recently determined second image, wherein the encoding order of the most recently determined second image is prior to the encoding order of other second images in the plurality of second images;
[0167] After the traversal is completed, the images in any GOP after the encoding order is adjusted are obtained.
[0168] In one embodiment, any GOP includes N frames of images, the frame type of the Nth frame of the image in any GOP is an I frame, the frame types of the other images in any GOP are B frames, the encoding order of the Nth frame of the image precedes the encoding order of the other images in any GOP, the encoding order of the N / 2th frame of the image in any GOP is later than the encoding order of the Nth frame of the image, the encoding order of the N / 4th frame of the image in any GOP is later than the encoding order of the N / 2th frame of the image, and the encoding order of the N / 8th frame of the image in any GOP is later than the encoding order of the N / 8th frame of the image. The coding order of the frame image is later than the coding order of the N / 4th frame image, the coding order of the 3N / 8th frame image in any GOP is later than the coding order of the N / 8th frame image, the coding order of the 3N / 4th frame image in any GOP is later than the coding order of the 3N / 8th frame image, the coding order of the 5N / 8th frame image in any GOP is later than the coding order of the 3N / 4th frame image, and the coding order of the 7N / 8th frame image in any GOP is later than the coding order of the 5N / 8th frame image.
[0169] In one embodiment, the processor 501 is configured to perform the following operations when acquiring the reference frame of each image frame:
[0170] Based on the frame type of each frame image and a reference frame determination strategy, a reference frame of each frame image is determined.
[0171] In one embodiment, when the value of the GOP of the multi-frame image is the determined value, the similarity between frames in the multi-frame image is greater than the similarity between frames in the multi-frame image when the value of the GOP of the multi-frame image is other values.
[0172] In one embodiment, when encoding the images after the encoding order is adjusted to obtain the encoded target video, the processor 501 is configured to perform the following operations:
[0173] Determining a frame type of each frame image in each GOP and a reference frame of each frame image;
[0174] According to the adjusted encoding order of each frame image in each GOP, based on the frame type of each frame image and the reference frame of each frame image, the each frame image is encoded to obtain an encoded target video.
[0175] In one embodiment, the processor 501 is further configured to perform the following operations: downsampling the resolution of each frame image to obtain multiple downsampled frames of image;
[0176] When determining the value of the group of pictures (GOP) of the multi-frame images based on the similarity between frames in the multi-frame images, the processor 501 is configured to perform the following operations:
[0177] Based on the similarity between frames in the downsampled multi-frame image, a value of the GOP of the multi-frame image is determined.
[0178] In one embodiment, when the processor 501 downsamples the resolution of each frame image to obtain multiple downsampled frames of image, it is configured to perform the following operations:
[0179] The resolution of the image parameter components of each frame image is downsampled to obtain multiple frames of downsampled images, wherein the image parameter components include one or more of the following: a luminance component and a chrominance component.
[0180] In one embodiment, the processor 501 is further configured to perform the following operations:
[0181] Obtaining the frame rate of the target video;
[0182] If the frame rate is less than the frame rate threshold, a decoding process is triggered to execute on the target video to obtain multiple frames of images.
[0183] In an embodiment of the present application, after the processor 501 decodes the target video to obtain multiple frames of images, it determines the GOP value of the multiple frames of images based on the similarity between frames in the multiple frames of images, and then divides the multiple frames of images into multiple GOPs based on the determined GOP value of the multiple frames of images, adjusts the encoding order of the images contained in each GOP, and encodes the images after the adjusted encoding order to obtain the encoded target video, which can ensure that the data volume of the video is reduced without reducing the video quality.
[0184] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When executed, the program can include the processes of the above-described method embodiments. The computer-readable storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM). The computer-readable storage medium can primarily include a program storage area and a data storage area. The program storage area can store an operating system, at least one application required for a function, and the like; the data storage area can store data created based on the use of the blockchain node.
[0185] The above disclosure is only part of the embodiments of the present application, and it is certainly not intended to limit the scope of the rights of the present application. Ordinary technicians in this field can understand that all or part of the processes of the above embodiments and equivalent changes made in accordance with the claims of this application are still within the scope of the present invention.
Claims
1. A video encoding method, characterized in that: include: Decode the target video to obtain multiple frames of images; Determining a value of a group of pictures (GOP) of the multi-frame images based on similarities between frames in the multi-frame images; when the value of the GOP of the multi-frame images is a certain value, the similarity between frames in the multi-frame images is greater than the similarity between frames in the multi-frame images when the value of the GOP of the multi-frame images is another value; Dividing the multiple frames of images into a plurality of GOPs based on the determined GOP values of the multiple frames of images; For any GOP, obtaining a frame type of each frame image in the any GOP and a reference frame of each frame image; Acquire a first image whose frame type is an I frame and a plurality of second images whose frame type is a B frame in any GOP; Adjusting the encoding order of the first image; wherein the encoding order of the first image is prior to the encoding order of the plurality of second images; traversing the plurality of second images, and determining, from the plurality of second images, a second image whose reference frame includes the first image; Adjusting the determined coding order of the second images; wherein the determined coding order of the second images is prior to the coding order of other second images in the plurality of second images; Determining the reference frame from the other second images includes a second image of any second image whose coding order has been most recently adjusted; Adjusting the encoding order of the most recently determined second image, wherein the encoding order of the most recently determined second image is prior to the encoding order of other second images in the plurality of second images; After the traversal is completed, obtaining the images after the coding order is adjusted in any GOP; The images after the coding order is adjusted are encoded to obtain an encoded target video.
2. The method according to claim 1, characterized in that Any GOP includes N frames of images, the frame type of the Nth frame of the image in any GOP is I frame, the frame types of other images in any GOP are B frames, the encoding order of the Nth frame of the image is prior to the encoding order of other images in any GOP, the encoding order of the N / 2th frame of the image in any GOP is after the encoding order of the Nth frame of the image, the encoding order of the N / 4th frame of the image in any GOP is after the encoding order of the N / 2th frame of the image, the encoding order of the N / 8th frame of the image in any GOP is after the encoding order of the N / 8th frame of the image The coding order is later than the coding order of the N / 4th frame image, the coding order of the 3N / 8th frame image in any GOP is later than the coding order of the N / 8th frame image, the coding order of the 3N / 4th frame image in any GOP is later than the coding order of the 3N / 8th frame image, the coding order of the 5N / 8th frame image in any GOP is later than the coding order of the 3N / 4th frame image, and the coding order of the 7N / 8th frame image in any GOP is later than the coding order of the 5N / 8 frame image.
3. The method according to claim 1 or 2, characterized in that The obtaining of the reference frame of each frame of image includes: Based on the frame type of each frame image and a reference frame determination strategy, a reference frame of each frame image is determined.
4. The method according to claim 1, wherein The step of encoding the images after adjusting the encoding order to obtain an encoded target video includes: Determining a frame type of each frame image in each GOP and a reference frame of each frame image; According to the adjusted encoding order of each frame image in each GOP, based on the frame type of each frame image and the reference frame of each frame image, the each frame image is encoded to obtain the encoded target video.
5. The method according to claim 1, characterized in that The method further comprises: Downsampling the resolution of each frame image to obtain multiple downsampled frames; The determining of a value of a group of pictures (GOP) of the multiple-frame images based on similarities between frames in the multiple-frame images includes: Based on the similarity between frames in the downsampled multi-frame image, a value of the GOP of the multi-frame image is determined.
6. The method according to claim 5, characterized in that The step of downsampling the resolution of each frame image to obtain multiple frames of downsampled images includes: The resolution of the image parameter components of each frame image is downsampled to obtain multiple frames of downsampled images, wherein the image parameter components include one or more of the following: a luminance component and a chrominance component.
7. The method according to claim 1, characterized in that The method further comprises: Obtaining the frame rate of the target video; If the frame rate is less than the frame rate threshold, the decoding process of the target video is triggered to obtain multiple frames of images.
8. A video encoding device, characterized in that: The device comprises: A decoding unit, used for decoding the target video to obtain multiple frames of images; a determining unit, configured to determine a value of a GOP of the multi-frame images based on the similarity between frames in the multi-frame images; when the value of the GOP of the multi-frame images is the determined value, the similarity between frames in the multi-frame images is greater than the similarity between frames in the multi-frame images when the value of the GOP of the multi-frame images is other values; A division unit is configured to divide the multiple frames of images into multiple GOPs based on the determined GOP values of the multiple frames of images; for any GOP, obtain the frame type of each frame of images in the any GOP and the reference frame of each frame of images; obtain a first image with a frame type of I frame and multiple second images with a frame type of B frame in the any GOP; adjust the coding order of the first image; wherein the coding order of the first image is prior to the coding order of the multiple second images; traverse the multiple second images and determine, from the multiple second images, a second image whose reference frame includes the first image; adjust the coding order of the determined second images; wherein the coding order of the determined second images is prior to the coding order of other second images in the multiple second images; determine, from the other second images, a second image whose reference frame includes any second image of the second images whose coding order was most recently adjusted; adjust the coding order of the most recently determined second images; wherein the coding order of the most recently determined second images is prior to the coding order of other second images in the multiple second images; after the traversal is completed, obtain the images in the any GOP whose coding order has been adjusted; The encoding unit is used to encode the images after the encoding order is adjusted to obtain an encoded target video.
9. A computer device, characterized in that: The computer device includes a processor, a storage device, and a communication interface, wherein the processor, the storage device, and the communication interface are interconnected, wherein: The storage device is used to store a computer program, wherein the computer program includes program instructions; The processor is configured to call the program instructions to execute the video encoding method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the program instructions are used to execute the video encoding method according to any one of claims 1 to 7.
11. A computer program product, characterized in that The computer program product comprises a computer program, and the computer program is adapted to be loaded by a processor and execute the video encoding method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Video data coding method and device
CN104811696A
Image coder
JP1996102951A