Video coding method and device, electronic equipment, chip and storage medium

By analyzing the interval and content complexity of the video frame and the previous keyframe, the target encoding parameters of the video frame are determined, which solves the problem of inaccurate encoding parameters during scene switching, and improves the encoding quality and efficiency.

CN120378613APending Publication Date: 2025-07-25BEIJING X RING TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510571068.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-30
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

In video encoding, the prior art cannot accurately determine the encoding parameters at the frame level during scene switching, resulting in a degradation of encoding quality.

Method used

By analyzing the interval between the current video frame and the previous keyframe, combining the frame type and content complexity, the target encoding parameters of the video frame are determined to adapt to scene changes.

Benefits of technology

It improves the accuracy of encoding parameters of frame-level data, improves encoding quality and encoding efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120378613A_ABST
    Figure CN120378613A_ABST
Patent Text Reader

Abstract

The invention provides a video coding method and device, electronic equipment, a chip and a storage medium, and the method comprises the steps: accurately determining the frame type of a first video frame according to the interval between the current first video frame and a previous key frame under the condition of scene switching, and further, determining the frame type of the first video frame according to the content complexity and the frame type of the first video frame. According to the invention, the target coding parameter of the first video frame is determined from multiple dimensions to adapt to the requirements of a new scene, the accuracy of the coding parameter of the frame-level data is improved, and the coding quality is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of video coding technology, and particularly to a video coding method, apparatus, electronic device, chip, and storage medium. Background Art

[0002] With the improvement of computer performance and the increase of network bandwidth, video coding algorithms have made significant progress in improving the compression ratio and coding efficiency. Among them, video coding technology improves the transmission efficiency by reducing the size of video data.

[0003] In the related art, when there is a scene switch in the video, the determined frame-level coding parameters cannot meet the requirements of scene changes, resulting in a reduction in coding quality. Summary of the Invention

[0004] This application aims to solve at least one of the technical problems in the related art to some extent.

[0005] To this end, this application proposes a video coding method, apparatus, electronic device, chip, and storage medium. The target coding parameters of the first video frame to be encoded are determined according to the content complexity and corresponding frame type of the first video frame to be encoded, so as to meet the coding requirements of scene switching and improve the coding quality.

[0006] An embodiment of one aspect of this application proposes a video coding method, including:

[0007] In response to the existence of a scene switch in the first video frame to be encoded, determine the frame type of the first video frame according to the interval between the first video frame and the previous key frame;

[0008] Determine the target coding parameters of the first video frame according to the content complexity and frame type of the first video frame.

[0009] An embodiment of another aspect of this application proposes a video coding apparatus, including:

[0010] A first determination module, configured to determine the frame type of the first video frame according to the interval between the first video frame and the previous key frame in response to the existence of a scene switch in the first video frame to be encoded;

[0011] A second determination module, configured to determine the target coding parameters of the first video frame according to the content complexity and frame type of the first video frame.

[0012] An embodiment of another aspect of this application proposes an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method described in the foregoing aspect is implemented.

[0013] In another aspect of the present application, an embodiment provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described in the foregoing aspect is implemented.

[0014] In another aspect of the present application, an embodiment provides a chip, which includes a processing circuit configured to execute the method described in the foregoing aspect.

[0015] In another aspect of the present application, an embodiment provides a computer program product, on which a computer program is stored. When the program is executed by a processor, the method described in the foregoing aspect is implemented.

[0016] The video encoding method, device, electronic device, chip, and storage medium provided by the present application can accurately determine the frame type of the first video frame according to the interval between the current first video frame and the previous key frame in the case of scene switching. Furthermore, according to the content complexity and frame type of the first video frame, the target encoding parameters of the first video frame are determined from multiple dimensions to meet the requirements of the new scene, improving the accuracy of the encoding parameters of frame-level data and thus enhancing the encoding quality.

[0017] Additional aspects and advantages of the present application will be given in part in the following description, become apparent in part from the following description, or be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The above and / or additional aspects and advantages of the present application will become apparent and be readily understood from the following description of the embodiments in conjunction with the drawings, where:

[0019] Figure 1 is a schematic flowchart of a video encoding method provided by an embodiment of the present application;

[0020] Figure 2 is a schematic flowchart of another video encoding method provided by an embodiment of the present application;

[0021] Figure 3 is a schematic flowchart of another video encoding method provided by an embodiment of the present application;

[0022] Figure 4 is a schematic diagram of the principle of a video encoding provided by an embodiment of the present application;

[0023] Figure 5 is a schematic structural diagram of a video encoding device provided by an embodiment of the present application

[0024] Figure 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present application;

[0025] Figure 7It is a schematic structural diagram of a chip proposed by an embodiment of the present application. Detailed implementation manners

[0026] The embodiments of the present application will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to explain the present application, and should not be construed as a limitation to the present application.

[0027] The video encoding method, apparatus, electronic device, chip, and storage medium according to the embodiments of the present application will be described below with reference to the accompanying drawings.

[0028] In the related art, when there is a scene switch in a video, the current first video frame is directly used as a key frame. For a scene with too frequent scene switches, inserting key frames frequently will cause the code stream to become larger and reduce the encoding efficiency. At the same time, for the method of determining the encoding parameters of the first video frame, there is a problem of low accuracy, which reduces the encoding quality.

[0029] As an implementation manner, the embodiments of the present application provide a video encoding method, apparatus, electronic device, chip, and storage medium. In the case of a scene switch, according to the interval between the current first video frame and the previous key frame, the frame type of the first video frame is accurately determined. Furthermore, according to the content complexity and frame type of the first video frame, the target encoding parameters of the first video frame are determined from multiple dimensions to meet the requirements of the new scene, improve the accuracy of the encoding parameters of the frame-level data, and thus improve the encoding quality.

[0030] Figure 1 It is a flowchart of a video encoding method provided by an embodiment of the present application.

[0031] As an implementation manner, the video encoding method of the embodiments of the present application can be configured in a video encoding apparatus, and the video encoding apparatus can be applied to any electronic device so that the electronic device can perform the function of determining video encoding parameters.

[0032] Among them, the electronic device can be any device with computing power. For example, it can be a mobile terminal, and the mobile terminal can be a hardware device such as a mobile phone, a tablet computer, a personal digital assistant, a wearable device, etc. with various operating systems, touch screens, and / or display screens.

[0033] As another implementation, the video encoding method according to the embodiments of the present application may also be executed by a chip with processing capabilities. The chip includes an Image Signal Processor (ISP), a Central Processing Unit (CPU), an Application-Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Field-Programmable Gate Array (FPGA), a System On A Chip (SOC), a Reduced Instruction Set Computer (RISC), etc., which will not be listed one by one here.

[0034] As Figure 1 shown, the method may include the following steps:

[0035] Step 101, in response to a scene change existing in the first video frame to be encoded, determine the frame type of the first video frame according to the interval between the first video frame and the previous key frame.

[0036] In the embodiments of the present application, the first video frame is a frame of image data in the video. The existence of a scene change in the first video frame means that the scene of the first video frame has changed relative to the scenes of at least one previous video frame. The scene change is determined based on the difference in video content, and the difference in video content is determined according to at least one of visual content, theme, and environment, etc. In the case of a scene change, it is necessary to determine the frame type of the first video frame because different frame types correspond to different target encoding parameters. Among them, the frame type includes key frames, or the frame type includes non-key frames. Key frames include Intra-coded pictures (I-frames). An I-frame contains the complete information of a frame of image and can be independently decoded without referring to the data of other frames in the picture group, which can enable the video encoding to obtain better compression efficiency in different scenes and reduce the decoding delay. If the frame type includes non-key frames, that is, the first video frame is not an I-frame.

[0037] When encoding video data, it is usually necessary to determine key frames, such as I-frames. However, if there are too many key frames, the bitstream of video encoding will increase, reducing the encoding efficiency. Therefore, in the embodiments of the present application, according to the interval between the current first video frame to be encoded and the previous key frame, it is determined whether the first video frame can be used as a key frame, that is, it is determined whether the frame type of the first video frame is a key frame or a non-key frame, so as to improve the accuracy of key frame determination and avoid the reduction of encoding efficiency caused by too many key frames in the case of frequent scene switching. Among them, the interval includes at least one of a time interval and a frame number interval.

[0038] Step 102: Determine the target encoding parameters of the first video frame according to the content complexity and frame type of the first video frame.

[0039] In the embodiments of the present application, the content complexity of the first video frame is related to the encoding parameters that the first video frame needs to adopt. Different content complexities correspond to different encoding parameters, and different frame types also correspond to different encoding parameters. Therefore, according to the content complexity and frame type of the first video frame, the target encoding parameters of the first video frame are determined from multiple dimensions, improving the accuracy of target encoding parameter determination and thus improving the encoding quality.

[0040] Among them, the content complexity of a video frame is an index used to describe the richness of visual information and the structural complexity in the video frame. For example, if there is more visual information in the video frame and the degree of dispersion of the information is greater, that is, it looks more chaotic, then the content complexity of the video frame is stronger. For example, a busy street has a higher content complexity because there are vehicles, pedestrians, buildings, etc., with rich textures and colors and many moving objects. If there is less visual information in the video frame and the degree of dispersion of the information is smaller, that is, it looks more regular and structured, then the content complexity of the video frame is weaker. For example, the content complexity of a picture corresponding to a sparsely populated street is lower than that of a picture corresponding to a busy street.

[0041] In the video encoding method of the embodiments of the present application, in the case of scene switching, according to the interval between the current first video frame and the previous key frame, the frame type of the first video frame is accurately determined. Furthermore, according to the content complexity and frame type of the first video frame, the target encoding parameters of the first video frame are determined from multiple dimensions to meet the requirements of the new scene, improving the accuracy of the encoding parameters of frame-level data and thus improving the encoding quality.

[0042] Based on the above embodiments, Figure 2 is a schematic flowchart of another video encoding method provided by the embodiments of the present application. As Figure 2 shown, the method includes the following steps:

[0043] Step 201: Determine the image difference information based on the histograms of the first video frame and the second video frame.

[0044] Among them, scene switching is usually accompanied by changes in image content. Therefore, it is possible to determine whether there is a scene switching by analyzing the difference in histograms between video frames. As an implementation, based on the histograms of the first video frame and the second video frame, determine the distance information between the histograms of the first video frame and the second video frame, and determine the image difference information according to the distance information. Among them, the distance information includes cosine distance, Euclidean distance, etc., which will not be listed one by one here.

[0045] In the embodiments of the present application, the case where the distance information includes cosine distance is taken as an example for illustration:

[0046]

[0047] Among them, bin represents the number of intervals obtained by dividing the histogram, i represents the identifier of the interval, and hist j [i] represents the number of pixels corresponding to the i-th interval of the j-th video frame. Among them, j - 1 represents the identifier of the second video frame, and j represents the identifier of the first video frame.

[0048] Among them, the cosine distance indicates the similarity between the first video frame and the second video frame, and the similarity can be used to indicate the image difference information between the first video frame and the second video frame. The higher the similarity, the smaller the image difference between the video frames. Therefore, according to the similarity, the image difference information between the first video frame and the second video frame can be determined. As an implementation, the image difference information D = 1 - cosθ.

[0049] Step 202: In response to the image difference information being greater than the set threshold, determine that there is a scene switching in the first video frame.

[0050] In the embodiments of the present application, if the similarity between the first video frame and the previous second video frame is high, it means that the images of the first video frame and the second video frame are similar in content, that is, the image difference information is less than or equal to the set threshold, then there is no scene switching in the first video frame; if the similarity between the first video frame and the previous second video frame is not high, that is, the image difference information is greater than the set threshold, then there is a scene switching in the first video frame.

[0051] As an implementation manner, the image difference is determined according to at least one of the mean value, variance, and distance information between video frames. To improve the accuracy of scene change determination, in the embodiments of the present application, the case where the image difference includes the differences corresponding to the mean value, variance, and distance information between video frames is taken as an example for description, so as to determine the image difference between video frames from multiple dimensions and improve the accuracy of difference determination. The principles of the image differences determined by other various combinations are similar and will not be elaborated in the embodiments of the present application.

[0052] Among them, the mean value μ of the pixels in the histogram of the first video frame j is determined by the following formula:

[0053]

[0054] Among them, N j is the total number of pixels in the first video frame. Similarly, the mean value μ of the pixels in the histogram of the second video frame can be determined j-1 . The formula principle is the same and will not be elaborated here.

[0055] Among them, the variance σ of the pixels in the histogram of the first video frame j 2 is determined by the following formula:

[0056]

[0057] Similarly, the variance σ of the pixels in the histogram of the second video frame can be determined j-1 2 . The formula principle is the same and will not be elaborated here.

[0058] Furthermore, the absolute value of the difference between the means of the first video frame and the second video frame is determined, which is used to indicate at least one of the differences in brightness and color between the first video frame and the second video frame, and the absolute value of the difference between the variances of the first video frame and the second video frame is used to indicate at least one of the differences in the degree of dispersion of the pixel brightness and color intensity distributions between these two video frames, as follows:

[0059]

[0060] Further, the set weight coefficients are obtained, and the total difference information is calculated as the image difference, which improves the accuracy of image difference determination. The formula is as follows:

[0061] D = ω1×Δμ + ω2×Δσ 2 + ω3×(1 - cosθ);

[0062] Among them, w1 is the weight of the mean value, w2 is the weight of the variance, and w3 is the weight of the cosine distance.

[0063] Step 203: In response to a scene change in the first video frame to be encoded, determine the frame type of the first video frame according to the interval between the first video frame and the previous key frame.

[0064] As an implementation, the video encoding method may be implemented based on a Group of Pictures (GOP), and the I frame is the first frame in the GOP. Among them, the first video frame is not the first frame of the video. Therefore, the video frame is not necessarily a key frame, and it is necessary to determine whether it is a key frame.

[0065] In the embodiments of the present application, in response to the interval being greater than or equal to the set interval, determine that the frame type of the first video frame is a key frame. In response to the interval being less than the set interval, determine that the frame type of the first video frame is a non-key frame. Among them, the interval includes at least one of a time interval and a frame number interval.

[0066] In the embodiments of the present application, by determining whether the interval meets the requirements of the set interval, the number of key frames in the case of scene switching is reduced, the number of inserted key frames is reduced, the bitstream is reduced, and the encoding efficiency is improved.

[0067] Step 204: Obtain the histogram of the first video frame and the histogram of the second video frame before the first video frame.

[0068] As an implementation, the histogram in the embodiments of the present application includes a YUV histogram, such as a luminance histogram.

[0069] Step 205: Determine the content complexity of the first video frame according to the histogram of the first video frame, and determine the content complexity of the second video frame according to the histogram of the second video frame.

[0070] As an implementation, the content complexity can be determined by entropy information. The entropy information can be used to judge the content complexity of the video frame. The higher the value corresponding to the entropy information, the more dispersed and un-concentrated the information in the video frame, and it may look more chaotic; while the lower the value corresponding to the entropy information, the higher the structure and regularity of the video frame. As an implementation, the complexity of the video frame can be indicated according to the entropy value interval to which the entropy information corresponds.

[0071] As an implementation, determine the content complexity cur_hist_entropy of the first video frame according to the histogram of the first video frame, which is determined by the following formula:

[0072]

[0073] Among them, width represents the width of the image corresponding to the video frame, and height represents the height of the image corresponding to the video frame.

[0074] Among them, for the principle of determining the content complexity pre_hist_entropy of the second video frame according to the histogram of the second video frame, it is the same as that of the first video frame, which will not be elaborated here.

[0075] It should be noted that the image width and image height of the first video frame are the same as those of the second video frame. In an actual scenario, the image width and image height of the first video frame and those of the second video frame may also be different, which is not limited in this embodiment.

[0076] Step 206: Determine the target encoding parameters of the first video frame of the frame type according to the content complexity of the first video frame and the content complexity of the second video frame.

[0077] In the embodiment of the present application, according to the content complexity of the first video frame and the content complexity of the second video frame, correction information matching the frame type of the first video frame can be determined, and the encoding parameters are adjusted based on the correction information to obtain the target encoding parameters of the first video frame, so as to meet the encoding requirements of the frame type corresponding to the first video frame after scene switching and improve the encoding quality. Among them, the correction information will be elaborated in subsequent embodiments and will not be elaborated here.

[0078] In the video encoding method of the embodiment of the present application, the image difference information is determined based on the distance information. The determination method is simple and the calculation amount is small. Based on the image difference information, it is determined whether there is a scene switch for the first video frame corresponding to the previous video frame, which improves the determination efficiency. By determining whether the interval meets the requirements of the set interval, the number of key frames is reduced in the case of scene switching, the number of inserted key frames is reduced, and the bitstream is reduced to improve the encoding efficiency. Further, according to the content complexity of the first video frame and the content complexity of the second video frame, correction information matching the frame type of the first video frame can be determined, and the encoding parameters are adjusted based on the correction information to obtain the target encoding parameters of the first video frame, so as to meet the encoding requirements of the frame type corresponding to the first video frame after scene switching and improve the encoding quality.

[0079] Based on the above embodiment, Figure 3 is a schematic flowchart of another video encoding method provided by the embodiment of the present application, as Figure 3 shown. This method includes the following steps:

[0080] Step 301: In response to a scene switch in the first video frame to be encoded, determine the frame type of the first video frame according to the interval between the first video frame and the previous key frame.

[0081] As an example, Figure 4A schematic diagram of the principle of video encoding provided by an embodiment of the present application is as follows Figure 4 As shown, the histogram information of each video frame is output by a pre - installed Image Signal Processor (ISP) and sent to a Video Processing Unit (VPU) for scene change detection. In the case of a scene change, it is determined whether the first video frame is a target frame, and corresponding target encoding parameters are determined according to the judgment result. For specific details, reference can be made to the relevant explanations in the foregoing embodiments and this embodiment.

[0082] Step 302: Obtain the histogram of the first video frame and the histogram of the second video frame before the first video frame.

[0083] Step 303: Determine the content complexity of the first video frame according to the histogram of the first video frame, and determine the content complexity of the second video frame according to the histogram of the second video frame.

[0084] Among them, steps 301 to 303 can refer to the relevant explanations in the foregoing embodiments. The principles are the same and will not be elaborated here.

[0085] Among them, the encoding parameters include quantization parameter QP, frame rate, bit rate, etc. Among them, the quantization parameter (Quantization Parameter, QP) is a key control parameter, which directly affects the efficiency of video compression and the quality of the reconstructed image. The QP value determines the fineness of quantization of the transform coefficients during video encoding, thus affecting the balance between the compression ratio and the image quality. Therefore, the adjustment of the target encoding parameters at least includes the adjustment of the QP parameter. In the embodiment of the present application, the adjustment method of the QP parameter is taken as an example for illustration. For the adjustment methods of other parameters, reference can be made to the adjustment method of the QP parameter. The principles are the same and will not be elaborated.

[0086] Step 304: Determine the first correction information of the encoding parameters of the first video frame according to the content complexity of the first video frame and the content complexity of the second video frame.

[0087] Among them, in one scenario, the content complexity of the first video frame is not equal to that of the second video frame, including that the content complexity of the first video frame is greater than that of the second video frame, and that the content complexity of the first video frame is less than that of the second video frame. Then, according to the content complexity of the first video frame, the corresponding intermediate correction information is determined. Among them, there is a set corresponding relationship between the content complexity of the first video frame and the intermediate correction information, and this corresponding relationship can be stored in a corresponding relationship table, and the intermediate correction information corresponding to the content complexity of the first video frame is determined by looking up the table. As an implementation method, the interval to which the content complexity of the first video frame belongs can be determined, and there is a corresponding relationship between each interval and the intermediate correction information, and the intermediate correction information corresponding to the interval to which it belongs is determined by looking up the table. As an example, it can be determined as follows. Among them, the interval to which the content complexity belongs is represented by an entropy value, and specifically as follows:

[0088] The interval corresponding to the entropy value is [0-2]: The corresponding content complexity is that the video frame is very simple, with almost no detail or texture information.

[0089] The interval corresponding to the entropy value is (2-4]: The corresponding content complexity is that the video frame is relatively simple, with some detail or texture information, but not much.

[0090] The interval corresponding to the entropy value is (4-6]: The corresponding content complexity is that the video frame is moderately complex, with some obvious detail or texture information.

[0091] The interval corresponding to the entropy value is (6-8]: The corresponding content complexity is that the video frame is relatively complex, with a lot of detail or texture information.

[0092] The interval corresponding to the entropy value is (8-10]: The corresponding content complexity is that the video frame is very complex, with a very large amount of detail or texture information.

[0093] Therefore, the larger the value of the interval, the more complex the video frame is.

[0094] Specifically, see Table 1:

[0095]

[0096]

[0097] Furthermore, according to the magnitude relationship between the content complexity of the first video frame and the content complexity of the second video frame, the sign of the intermediate correction information is adjusted to obtain the first correction information. In one scenario, if the content complexity of the first video frame is higher than that of the second video frame, the sign of the intermediate correction information is a positive sign, that is, the intermediate correction information is a positive value, which means that the value of the encoding parameter of the first video frame needs to be increased; if the content complexity of the first video frame is lower than that of the second video frame, the sign of the intermediate correction information is a negative sign, that is, the intermediate correction information is a negative value, which means that the value of the encoding parameter of the first video frame needs to be decreased. Additionally, if the content complexity of the first video frame is equal to that of the second video frame, the first correction information is determined according to the set correction information, that is, the set correction information is used as the first correction information. For example, if the set correction information is 0, no correction of the encoding parameter is performed.

[0098]

[0099] Among them, qp_offset1 is the first correction information, and qp_delta is the intermediate correction information.

[0100] Step 305: In response to the frame type being a key frame, obtain the average encoding parameter corresponding to the group of pictures to which the previous key frame belongs.

[0101] In the embodiments of the present application, in a video encoding scenario, video encoding is usually performed based on a group of pictures (GOP). A GOP usually starts with an I frame and includes predictive-coded pictures (P) frames, bi-predictive-coded pictures (B) frames, etc.

[0102] Step 306: Adjust the average encoding parameter according to the first correction information to obtain the target encoding parameter of the first video frame.

[0103] In the embodiments of the present application, if the frame type of the first video frame is a key frame, it means that the first video frame will be used as an I frame to determine a new group of pictures. Then, the average encoding parameter corresponding to the group of pictures to which the previous key frame belongs is obtained, and the average encoding parameter of the previous GOP is adjusted, which can quickly determine the target encoding parameter of the first video frame and improve the efficiency. At the same time, adjusting based on the average encoding parameter of the previous GOP can avoid drastic fluctuations in the encoding parameters, make the encoding process more stable, and optimize the balance between the compression ratio and quality globally.

[0104] Step 307: In response to the frame type being a non-key frame, determine the second correction information of the encoding parameter of the first video frame according to the difference between the content complexity of the first video frame and the content complexity of the second video frame.

[0105] In one implementation of the embodiment of the present application, according to the absolute value of the difference between the content complexity of the first video frame and the content complexity of the second video frame, the second correction information qp_offset2 of the encoding parameter of the first video frame is determined.

[0106] As an implementation, it can be determined by the following formula:

[0107] qp_offset2 = (-|cur_hist_entropy - pre_hist_entropy|).

[0108] Step 308, according to the first correction information and the second correction information, adjust the encoding parameter of the second video frame to obtain the target encoding parameter of the first video frame.

[0109] As an implementation, the QP included in the target encoding parameter of the first video frame is determined by the following formula:

[0110] QP = initi_qp + qp_offset1 + qp_offset2;

[0111] where initi_qp is the encoding parameter of the second video frame.

[0112] It should be understood that there is a scene switch in the current first video frame, but the first video frame is not a key frame. Therefore, when determining the target encoding parameter of the first video frame, the encoding parameter of the second video frame in the previous frame can be used as a reference, and the first correction information and the second correction information are used for correction to improve the image quality of the first video frame after the scene switch. Among them, the first correction information is to adjust the sign of the intermediate correction information based on the magnitude relationship between the content complexity of the first video frame and the content complexity of the second video frame to obtain the first correction information. For specific reference, see the relevant explanations in the foregoing embodiments. The principle is the same and will not be elaborated here.

[0113] In the video encoding method of the embodiment of the present application, for the case where the scene changes violently, it is judged whether there is a scene switch in the current first video frame through histogram information, and the target encoding parameter of the first video frame is determined to meet the requirements of the new scene, which can improve the overall encoding quality at the same bit rate and ensure the smoothness and picture clarity of video playback.

[0114] To implement the above embodiment, the embodiment of the present application also proposes a video encoding device.

[0115] Figure 5 It is a schematic structural diagram of a video encoding device provided by the embodiment of the present application.

[0116] Such asFigure 5 As shown, the device may include:

[0117] A first determination module 51, configured to determine the frame type of the first video frame according to the interval between the first video frame to be encoded and the previous key frame in response to the presence of a scene change in the first video frame;

[0118] A second determination module 52, configured to determine the target encoding parameters of the first video frame according to the content complexity and frame type of the first video frame.

[0119] Furthermore, in an implementation manner of the embodiment of the present application, the second determination module 52 is further configured to:

[0120] Obtain the histogram of the first video frame and the histogram of a second video frame before the first video frame;

[0121] Determine the content complexity of the first video frame according to the histogram of the first video frame, and determine the content complexity of the second video frame according to the histogram of the second video frame;

[0122] Determine the target encoding parameters of the first video frame of the frame type according to the content complexity of the first video frame and the content complexity of the second video frame.

[0123] In an implementation manner of the embodiment of the present application, the second determination module 52 is further configured to:

[0124] Determine first correction information for the encoding parameters of the first video frame according to the content complexity of the first video frame and the content complexity of the second video frame;

[0125] In response to the frame type being a key frame, obtain the average encoding parameters corresponding to the picture group to which the previous key frame belongs;

[0126] Adjust the average encoding parameters according to the first correction information to obtain the target encoding parameters of the first video frame.

[0127] In an implementation manner of the embodiment of the present application, the second determination module 52 is further configured to:

[0128] In response to the content complexity of the first video frame not being equal to the content complexity of the second video frame, determine corresponding intermediate correction information according to the content complexity of the first video frame;

[0129] Adjust the sign of the intermediate correction information according to the magnitude relationship between the content complexity of the first video frame and the content complexity of the second video frame to obtain the first correction information.

[0130] In an implementation manner of the embodiment of the present application, the second determination module 52 is further configured to:

[0131] In response to the content complexity of the first video frame being equal to the content complexity of the second video frame, determine the first correction information according to the set correction information.

[0132] In an implementation manner of the embodiment of the present application, the second determination module 52 is further configured to:

[0133] In response to the frame type being a non-key frame, determine the second correction information of the encoding parameters of the first video frame according to the difference between the content complexity of the first video frame and the content complexity of the second video frame;

[0134] Adjust the encoding parameters of the second video frame according to the first correction information and the second correction information to obtain the target encoding parameters of the first video frame.

[0135] In an implementation manner of the embodiment of the present application, the first determination module 51 is further configured to:

[0136] In response to the interval being greater than or equal to the set interval, determine that the frame type of the first video frame is a key frame;

[0137] Alternatively, in response to the interval being less than the set interval, determine that the frame type of the first video frame is a non-key frame.

[0138] In an implementation manner of the embodiment of the present application, the device further includes a third determination module, configured to:

[0139] Determine the image difference information according to the histogram of the first video frame and the histogram of the second video frame;

[0140] In response to the image difference information being greater than the set threshold, determine that there is a scene switch in the first video frame.

[0141] In an implementation manner of the embodiment of the present application, the third determination module is further configured to:

[0142] Determine the distance information between the histogram of the first video frame and the histogram of the second video frame according to the histogram of the first video frame and the histogram of the second video frame;

[0143] Determine the image difference information according to the distance information.

[0144] It should be noted that the foregoing explanation of the method embodiment is also applicable to the device of this embodiment, and will not be repeated here.

[0145] The video encoding device according to the embodiment of the present application, in the case of scene switching, determines the frame type of the first video frame accurately according to the interval between the current first video frame and the previous key frame. Furthermore, according to the content complexity and frame type of the first video frame, the target encoding parameters of the first video frame are determined from multiple dimensions to meet the requirements of the new scene, improving the accuracy of the encoding parameters of frame-level data and thus improving the encoding quality.

[0146] To implement the above embodiment, the present application also proposes a non-transitory computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the method described in the foregoing method embodiment is implemented.

[0147] To implement the above embodiment, the present application also proposes a computer program product, on which a computer program is stored. When the computer program is executed by a processor, the method described in the foregoing method embodiment is implemented.

[0148] To implement the above embodiment, the present application also proposes an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method described in the foregoing method embodiment is implemented.

[0149] Figure 6 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0150] Refer to Figure 6 , the electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.

[0151] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communication, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.

[0152] The memory 804 is configured to store various types of data to support the operation of the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, and the like. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk.

[0153] The power component 806 provides power to the various components of the electronic device 800. The power component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 800.

[0154] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can not only sense the boundaries of the touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.

[0155] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC) that is configured to receive external audio signals when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, the audio component 810 further includes a speaker for outputting audio signals.

[0156] The I / O interface 812 provides an interface between the processing component 802 and a peripheral interface module, which can be a keyboard, a click wheel, buttons, etc. These buttons can include, but are not limited to: a home button, a volume button, a power-on button, and a lock button.

[0157] The sensor assembly 814 includes one or more sensors for providing an assessment of the status of various aspects of the electronic device 800. For example, the sensor assembly 814 can detect the on / off state of the electronic device 800, the relative positioning of components, such as the display and keypad of the electronic device 800. The sensor assembly 814 can also detect a change in the position of the electronic device 800 or a component of the electronic device 800, the presence or absence of user contact with the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and a change in the temperature of the electronic device 800. The sensor assembly 814 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 can also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0158] The communication component 816 is configured to facilitate communication between the electronic device 800 and other devices in a wired or wireless manner. The electronic device 800 can access a wireless network based on communication standards, such as WiFi, 4G, or 5G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0159] In an exemplary embodiment, the electronic device 800 can be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above-described methods.

[0160] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, which can be executed by a processor 820 of the electronic device 800 to complete the above-described methods. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0161] To implement the above embodiments, the present application further provides a chip, including: The chip includes a processing circuit configured to execute the method provided in the foregoing embodiments.

[0162] Figure 7 It is a schematic structural diagram of a chip proposed in an embodiment of the present application. It can be referred to Figure 7 the schematic structural diagram of the chip 1100 shown, but not limited thereto.

[0163] The chip 1100 includes a processing circuit 1101 configured to execute any of the above methods.

[0164] In some embodiments, the chip 1100 further includes one or more interface circuits 1102. Optionally, the interface circuit 1102 is connected to the memory 1103. The interface circuit 1102 can be used to receive signals from the memory 1103 or other devices, and the interface circuit 1102 can be used to send signals to the memory 1103 or other devices. For example, the interface circuit 1102 can read the instructions stored in the memory 1103 and send the instructions to the processing circuit 1101.

[0165] In some embodiments, the interface circuit 1102 executes at least one of the communication steps such as sending and / or receiving in the above method, and the processing circuit 1101 executes other steps.

[0166] In some embodiments, terms such as interface circuit, interface, transceiver pin, transceiver, etc. can be used interchangeably.

[0167] In some embodiments, the chip 1100 further includes one or more memories 1103 for storing instructions. Optionally, all or part of the memories 1103 can be outside the chip 1100.

[0168] In the description of this specification, the description with reference to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0169] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include at least one such feature. In the description of this application, "a plurality of" means at least two, such as two, three, etc., unless otherwise specifically defined.

[0170] Any process or method description represented in a flowchart or otherwise described herein can be understood to represent a module, segment, or portion of code including one or more executable instructions for implementing a customized logical function or process. The scope of the preferred embodiments of this application includes additional implementations, where functions may be executed in a substantially simultaneous manner or in a reverse order according to the functions involved, rather than in the order shown or discussed, which should be understood by those skilled in the technical field to which the embodiments of this application pertain.

[0171] The logic and / or steps represented in a flowchart or otherwise described herein, for example, can be considered a sequenced list of executable instructions for implementing a logical function and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or in conjunction with such instruction execution systems, apparatuses, or devices. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or other appropriate processing as necessary, and then stored in a computer memory.

[0172] It should be understood that various parts of the present application can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, any one of the following techniques known in the art or a combination thereof can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application specific integrated circuits having appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.

[0173] Those of ordinary skill in the art can understand that all or part of the steps carried by the method of the above embodiments can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.

[0174] In addition, in each embodiment of the present application, each functional unit can be integrated in a processing module, or each unit can exist physically alone, or two or more units can be integrated in a module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. When the above integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0175] The above-mentioned storage medium can be a read-only memory, a magnetic disk, an optical disc, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present application. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present application.

Claims

1. A video encoding method, characterized in that, Including: In response to a scene change existing in a first video frame to be encoded, determining a frame type of the first video frame according to an interval between the first video frame and a previous key frame; Determining target encoding parameters of the first video frame according to a content complexity and the frame type of the first video frame.

2. The method according to claim 1, wherein, The determining the target encoding parameters of the first video frame according to the content complexity and the frame type of the first video frame includes: Obtaining a histogram of the first video frame and a histogram of a second video frame before the first video frame; Determining the content complexity of the first video frame according to the histogram of the first video frame, and determining the content complexity of the second video frame according to the histogram of the second video frame; Determining the target encoding parameters of the first video frame of the frame type according to the content complexity of the first video frame and the content complexity of the second video frame.

3. The method according to claim 2, wherein The determining the target encoding parameters of the first video frame of the frame type according to the content complexity of the first video frame and the content complexity of the second video frame includes: Determining first correction information of encoding parameters of the first video frame according to the content complexity of the first video frame and the content complexity of the second video frame; In response to the frame type being a key frame, obtaining an average encoding parameter corresponding to a picture group to which the previous key frame belongs; Adjusting the average encoding parameter according to the first correction information to obtain the target encoding parameters of the first video frame.

4. The method according to claim 3, wherein The determining the first correction information of the encoding parameters of the first video frame according to the content complexity of the first video frame and the content complexity of the second video frame includes: In response to the content complexity of the first video frame not being equal to the content complexity of the second video frame, determining corresponding intermediate correction information according to the content complexity of the first video frame; Adjusting a sign of the intermediate correction information according to a magnitude relationship between the content complexity of the first video frame and the content complexity of the second video frame to obtain the first correction information.

5. The method according to claim 3, wherein The determining the first correction information of the encoding parameters of the first video frame according to the content complexity of the first video frame and the content complexity of the second video frame includes: In response to the content complexity of the first video frame being equal to the content complexity of the second video frame, determining the first correction information according to set correction information.

6. The method according to claim 3, characterized in that The method further includes: In response to the frame type being a non-key frame, determining second correction information of the encoding parameters of the first video frame according to a difference between the content complexity of the first video frame and the content complexity of the second video frame; Adjusting the encoding parameters of the second video frame according to the first correction information and the second correction information to obtain the target encoding parameters of the first video frame.

7. The method according to claim 1, characterized in that, The determining the frame type of the first video frame according to the interval between the first video frame and the previous key frame includes: In response to the interval being greater than or equal to a set interval, determining the frame type of the first video frame as a key frame; Alternatively, in response to the interval being less than the set interval, determine that the frame type of the first video frame is a non-key frame.

8. The method according to any one of claims 1-7, characterized in that, The method further includes: Determine image difference information according to the histogram of the first video frame and the histogram of the second video frame; In response to the image difference information being greater than a set threshold, determine that there is a scene change in the first video frame.

9. The method according to claim 8, characterized in that, The determining the image difference information according to the histogram of the first video frame and the histogram of the second video frame further includes: Determine distance information between the histogram of the first video frame and the histogram of the second video frame according to the histogram of the first video frame and the histogram of the second video frame; Determine the image difference information according to the distance information.

10. A video encoding device, characterized in that, Includes: A first determination module, configured to, in response to a scene change existing in a first video frame to be encoded, determine the frame type of the first video frame according to the interval between the first video frame and the previous key frame; A second determination module, configured to determine target encoding parameters of the first video frame according to the content complexity and frame type of the first video frame.

11. An electronic device, characterized in that, Includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method according to any one of claims 1-9 is implemented.

12. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the method according to any one of claims 1-9 is implemented.

13. A chip, characterized in that, The chip includes a processing circuit configured to execute the method according to any one of claims 1-9.