Video coding method and device, electronic equipment and storage medium

The video clips are encoded with a constant code rate through multiple precoders, and the optimal picture group structure is selected, which solves the problem of rate-distortion performance degradation caused by the fixed picture group structure in the existing technology and realizes the adaptability of video coding. and efficiency improvement.

CN118678068APending Publication Date: 2024-09-20TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310293622.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-15
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

When the video content to be encoded changes drastically, the existing video coding technology has a fixed frame group structure that leads to a decrease in rate-distortion performance, making it difficult to adapt to the video coding needs of different characteristics and scenarios.

Method used

Encode the target video clip with a constant bit rate through multiple precoders, obtain sample encoding data, determine the encoding performance parameters, select the optimal target picture group structure from the candidate picture group structure, and send it to the target encoding Configure the processor to improve rate-distortion performance.

Benefits of technology

It achieves improved rate-distortion performance during video encoding, can adapt to effectively encode video clips with different characteristics and scenes, and improves encoding efficiency and quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118678068A
    Figure CN118678068A
Patent Text Reader

Abstract

The embodiment of the invention discloses a video coding method and device, electronic equipment and a storage medium, and the method comprises the steps: carrying out the constant-code-rate coding processing of a target video segment based on a plurality of precoders, and determining the coding performance parameters of each precoder, a target picture group structure is determined from the multiple candidate picture group structures according to the coding performance parameters, and the obtained target picture group structure is the picture group structure with the best rate distortion performance in the multiple candidate picture group structures, so that the screening and matching effects of the picture group structures are achieved; therefore, the target picture group structure is sent to the target encoder for configuration, and then the target video clip is encoded, so that even if video encoding is carried out on the target video clips with different characteristics and different scenes, the appropriate target picture group structure can be adaptively selected; therefore, the rate distortion performance during video coding can be effectively improved, and the method can be widely applied to the technical fields of cloud technology, video processing and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of video processing technology, and in particular to a video encoding method, device, electronic device and storage medium. Background Art

[0002] With the development of digital media technology and computer technology, video is applied to various fields, such as mobile communication, network identification, network television, etc., which brings great convenience to people's entertainment and life. In the related technology, when encoding the video to be encoded, a fixed picture group structure is generally used. When the content of the video to be encoded changes drastically, the rate distortion performance of the video encoding will be reduced. Summary of the invention

[0003] The following is a summary of the subject matter described in detail in this application. This summary is not intended to limit the scope of the claims.

[0004] The embodiments of the present application provide a video encoding method, device, electronic device and storage medium, which can improve the rate-distortion performance during video encoding.

[0005] On the one hand, an embodiment of the present application provides a video encoding method, including:

[0006] Acquire a target video segment, and perform a constant bit rate encoding process on the target video segment based on multiple pre-encoders to obtain sample encoding data output by each of the pre-encoders, wherein the pre-encoders are configured with a preset candidate group of pictures structure, and the candidate group of pictures structures of any two of the pre-encoders are different;

[0007] Determining encoding performance parameters of each of the pre-encoders according to the sample encoding data, determining a target group of pictures structure from a plurality of the candidate group of pictures structures according to the encoding performance parameters, and sending the target group of pictures structure to a target encoder for configuration;

[0008] The target video segment is encoded based on the target encoder to obtain target encoding data of the target video segment.

[0009] On the other hand, the embodiment of the present application further provides a video encoding method, including:

[0010] Obtaining a target video clip and a target group of pictures structure, and sending the target group of pictures structure to a target encoder for configuration;

[0011] Performing encoding processing on the target video segment based on the target encoder to obtain target encoding data of the target video segment;

[0012] The target picture group structure is based on a plurality of pre-encoders performing a constant bit rate encoding process on the target video segment, obtaining sample encoding data output by each of the pre-encoders, determining encoding performance parameters of each of the pre-encoders according to the sample encoding data, and determining the target picture group structure from a plurality of candidate picture group structures according to the encoding performance parameters. The pre-encoders are configured with a preset candidate picture group structure, and the candidate picture group structures of any two pre-encoders are different.

[0013] On the other hand, an embodiment of the present application further provides a video encoding device, including:

[0014] A first encoding module is used to obtain a target video segment, and perform a constant bit rate encoding process on the target video segment based on multiple pre-encoders to obtain sample encoding data output by each of the pre-encoders, wherein the pre-encoders are configured with a preset candidate picture group structure, and the candidate picture group structures of any two of the pre-encoders are different;

[0015] A first GOP structure configuration module, configured to determine encoding performance parameters of each of the pre-encoders according to the sample encoding data, determine a target GOP structure from a plurality of candidate GOP structures according to the encoding performance parameters, and send the target GOP structure to a target encoder for configuration;

[0016] The second encoding module is used to perform encoding processing on the target video segment based on the target encoder to obtain target encoding data of the target video segment.

[0017] Further, the first encoding module is specifically used for:

[0018] Determine a first frame length of each of the candidate group of picture structures, calculate a target common multiple of a plurality of the first frame lengths, and obtain a second frame length;

[0019] An original video segment is acquired, and the target video segment is extracted from the original video segment according to the second frame length.

[0020] Further, the first encoding module is specifically used for:

[0021] Acquire a video to be encoded, and determine a plurality of first scene change frames in the video to be encoded;

[0022] The video to be encoded is divided into segments according to the first scene change frame to obtain a plurality of original video segments corresponding to different video scenes.

[0023] Further, the first encoding module is specifically used for:

[0024] Performing frame processing on the video to be encoded to obtain multiple candidate video frames;

[0025] Traversing the plurality of candidate video frames, determining a first image similarity between the current candidate video frame and a first adjacent video frame, and a second image similarity between the current candidate video frame and a second adjacent video frame, wherein the first adjacent video frame is a previous video frame adjacent to the current candidate video frame, and the second adjacent video frame is a subsequent video frame adjacent to the current candidate video frame;

[0026] When the difference between the second image similarity and the first image similarity is greater than or equal to a preset difference threshold, the current candidate video frame or the second adjacent video frame is determined as the first scene change frame of the video to be encoded.

[0027] Further, the first picture group structure configuration module is also used for:

[0028] When there are remaining video segments whose length is less than the second frame length after the target video segment is extracted from the original video segment according to the second frame length, determining the target picture group structure corresponding to the remaining video segment according to the target picture group structure corresponding to the target video segment;

[0029] The second encoding module is also used for:

[0030] The remaining video segments are encoded based on the target encoder configured with the target group of pictures structure corresponding to the remaining video segments.

[0031] Further, the first picture group structure configuration module is specifically used for:

[0032] Determine the segment similarity between the remaining video segments and each of the target video segments, and determine the target picture group structure corresponding to the remaining video segments from the target picture group structures corresponding to the multiple target video segments according to the segment similarity;

[0033] Alternatively, a third frame length of the remaining video segments is determined, and the target GOP structure corresponding to the target video segment and having the first frame length less than or equal to the third frame length is used as the target GOP structure corresponding to the remaining video segments.

[0034] Further, the first encoding module is specifically used for:

[0035] determining a plurality of second scene change frames in the target video segment;

[0036] determining scene change degree information of the target video segment according to the plurality of second scene change frames, wherein the scene change degree information is used to indicate a drastic degree of scene change of the target video segment;

[0037] Determine a plurality of candidate group of picture structures according to the scene change information, and send the plurality of candidate group of picture structures to each of the pre-encoders for configuration, wherein a first frame length of the candidate group of picture structures is shortened as the severity indicated by the scene change degree information increases.

[0038] Further, the first encoding module is specifically used for:

[0039] Determine an inter-frame distance between two adjacent second scene change frames, calculate an average of a plurality of the inter-frame distances to obtain an inter-frame average distance, and use the inter-frame average distance as scene change degree information of the target video segment;

[0040] Alternatively, the number of frames of the second scene change frames is determined, and the number of frames is used as the scene change degree information of the target video segment.

[0041] Further, the first picture group structure configuration module is specifically used for:

[0042] When all the precoders are configured with the same target bit rate, determining a peak signal-to-noise ratio of each of the precoders according to the sample coded data, taking the peak signal-to-noise ratio as the coding performance parameter, comparing the coding performance parameters corresponding to the precoders, and determining a target group of pictures structure from a plurality of candidate group of pictures structures according to a comparison result of the coding performance parameters;

[0043] Alternatively, when each of the precoders is configured with a different target bit rate, a peak signal-to-noise ratio of each of the precoders is determined according to the sample coding data, a number of codestream bits of each of the precoders is determined according to the sample coding data, a target weight of the codestream bit number is determined, a weighted number of bits is obtained according to the product of the target weight and the number of codestream bits, the coding performance parameter is obtained according to the sum of the peak signal-to-noise ratio and the weighted number of bits, the coding performance parameters corresponding to each of the precoders are compared, and a target picture group structure is determined from a plurality of the candidate picture group structures according to the comparison result of the coding performance parameters.

[0044] Further, the first picture group structure configuration module is specifically used for:

[0045] Decoding the sample coded data to obtain a reference video clip;

[0046] Determining a first pixel value of an image in the target video segment and a second pixel value of an image in the reference video segment;

[0047] Calculating a mean square error between the first pixel value and the corresponding second pixel value;

[0048] The number of pixel bits of the image in the target video segment is determined, and the peak signal-to-noise ratio of each of the pre-encoders is determined according to the mean square error value and the number of pixel bits.

[0049] Furthermore, the number of the target video segments is multiple, and the second encoding module is specifically used for:

[0050] Generate a segment identifier corresponding to each of the target video segments, and mark the corresponding target picture group structure according to the segment identifier;

[0051] Based on the target encoder, the target GOP structure corresponding to the current target video segment is determined according to the segment identifier, and the current target video segment is encoded according to the corresponding target GOP structure to obtain target encoding data of the target video segment.

[0052] Further, the first encoding module is specifically used for:

[0053] Downsampling the target video segment to obtain a downsampled video segment;

[0054] The down-sampled video segment is coded at a constant bit rate based on multiple pre-coders to obtain sample coded data output by each of the pre-coders.

[0055] On the other hand, an embodiment of the present application further provides a video encoding device, including:

[0056] A second GOP structure configuration module, configured to obtain a target video clip and a target GOP structure, and send the target GOP structure to a target encoder for configuration;

[0057] A third encoding module, configured to perform encoding processing on the target video segment based on the target encoder to obtain target encoding data of the target video segment;

[0058] The target picture group structure is based on a plurality of pre-encoders performing a constant bit rate encoding process on the target video segment, obtaining sample encoding data output by each of the pre-encoders, determining encoding performance parameters of each of the pre-encoders according to the sample encoding data, and determining the target picture group structure from a plurality of candidate picture group structures according to the encoding performance parameters. The pre-encoders are configured with a preset candidate picture group structure, and the candidate picture group structures of any two pre-encoders are different.

[0059] On the other hand, an embodiment of the present application further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned video encoding method when executing the computer program.

[0060] On the other hand, an embodiment of the present application further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is executed by a processor to implement the above-mentioned video encoding method.

[0061] On the other hand, the embodiment of the present application further provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned video encoding method.

[0062] The embodiments of the present application include at least the following beneficial effects: by acquiring a target video clip, encoding the target video clip with a constant bit rate based on multiple pre-encoders, obtaining sample encoding data output by each pre-encoder, and then determining the encoding performance parameters of each pre-encoder based on the sample encoding data, and determining the target picture group structure from multiple candidate picture group structures based on the encoding performance parameters. At this time, the target picture group structure obtained is the picture group structure with the best rate-distortion performance among the multiple candidate picture group structures, thereby achieving a screening and matching effect of the picture group structure, and then sending the target picture group structure to the target encoder for configuration, and then encoding the target video clip based on the target encoder to obtain the target encoding data of the target video clip. Since the target picture group structure can be flexibly screened and matched based on the pre-encoder, even when performing video encoding on target video clips with different characteristics and different scenes, a suitable target picture group structure can be adaptively selected, thereby effectively improving the rate-distortion performance during video encoding.

[0063] Other features and advantages of the present application will be set forth in the following description, and in part will become apparent from the description, or may be understood by practicing the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] The accompanying drawings are used to provide further understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.

[0065] Figure 1 A schematic diagram of an optional implementation environment provided for an embodiment of the present application;

[0066] Figure 2A schematic diagram of another optional implementation environment provided for an embodiment of the present application;

[0067] Figure 3 An optional flowchart of a video encoding method provided in an embodiment of the present application;

[0068] Figure 4 An optional schematic diagram of a candidate picture group structure provided in an embodiment of the present application;

[0069] Figure 5 Another optional schematic diagram of a candidate picture group structure provided in an embodiment of the present application;

[0070] Figure 6 A schematic diagram of segment division when encoding a video to be encoded provided by an embodiment of the present application;

[0071] Figure 7 An optional structural diagram of multiple candidate video frames provided in an embodiment of the present application;

[0072] Figure 8 Another optional flowchart of the video encoding method provided in the embodiment of the present application;

[0073] Fig. 9 An optional complete flow chart of the video encoding method provided in the embodiment of the present application;

[0074] Fig.10 Another optional complete flow chart of the video encoding method provided in the embodiment of the present application;

[0075] Fig.11 Another optional complete flow chart of the video encoding method provided in the embodiment of the present application;

[0076] Fig.12 Another optional complete flow chart of the video encoding method provided in the embodiment of the present application;

[0077] Fig.13 A schematic diagram of an optional structure of a first video encoding device provided in an embodiment of the present application;

[0078] Fig.14 A schematic diagram of an optional structure of a second video encoding device provided in an embodiment of the present application;

[0079] Fig.15 A partial structural block diagram of a terminal provided in an embodiment of the present application;

[0080] Fig.16 A partial structural block diagram of the server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0081] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0082] It should be noted that, in each specific embodiment of the present application, when it comes to the need to perform relevant processing based on data related to the characteristics of the target object such as target object attribute information or attribute information set, the permission or consent of the target object will be obtained first, and the collection, use and processing of these data will comply with the relevant laws, regulations and standards of the relevant countries and regions. Among them, the target object can be a user. In addition, when the embodiment of the present application needs to obtain the target object attribute information, the separate permission or separate consent of the target object will be obtained by means of a pop-up window or jumping to a confirmation page, and after the separate permission or separate consent of the target object is clearly obtained, the necessary target object-related data for enabling the normal operation of the embodiment of the present application will be obtained.

[0083] To facilitate understanding of the technical solutions provided in the embodiments of the present application, some key terms used in the embodiments of the present application are explained here:

[0084] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to achieve data computing, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool that can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of technical network systems require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, in the future, each item may have its own identification mark, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately. All kinds of industry data require strong system backing support, which can only be achieved through cloud computing.

[0085] Group of Pictures: Also known as GOP (Group Of Pictures), it is the basic unit of the encoder to encode the video sequence. A coded video sequence can be regarded as a combination of continuous GOP encodings. The GOP structure includes the number of frames (length) contained in the GOP and the reference relationship between frames.

[0086] P frame: Predictive Picture (predictive coding image frame), is a type of video frame that depends on the previous frame or the next frame for encoding and decoding.

[0087] B frame: Bidirectionally Predicted Picture (Bidirectionally Predicted Picture), is a type of video frame that requires both the previous frame and the next frame to be encoded and decoded. It generally has a higher compression rate than P frames.

[0088] CBR: Constant Bit Rate, a bit rate control mode. When using this mode, the output bit rate of the encoder remains basically constant within a certain time range.

[0089] In the current mainstream encoder implementation, video encoding is performed in units of GOP. The GOP structure specifies the frame type of the frames in the GOP and the reference relationship between the frames. There is considerable freedom in the design of GOP, and any GOP that conforms to the coding standard syntax can be used. Usually, once the GOP structure is determined, it will apply to all frames in a video to be encoded.

[0090] However, different GOP structures will bring different rate-distortion performance. For different videos to be encoded, or different video clips in the same video to be encoded, the GOP structure with the best rate-distortion performance may be different. Using different GOP structures to encode the same video to be encoded may result in a rate-distortion performance difference of more than 10%.

[0091] In the related art, when encoding a video to be encoded, a fixed picture group structure is generally used. For example, whether to reopen a picture group is usually determined based on the shot detection result, and the length of the picture group is not modified. When the content of the video to be encoded changes drastically, the rate-distortion performance of the video encoding will be reduced.

[0092] Based on this, the embodiments of the present application provide a video encoding method, device, electronic device and storage medium, which can improve the rate-distortion performance during video encoding.

[0093] Reference Figure 1 , Figure 1 A schematic diagram of an optional implementation environment provided for an embodiment of the present application, the implementation environment includes a terminal 101 or a server 102.

[0094] Exemplarily, the terminal 101 or the server 102 may be installed with a target encoder and multiple pre-encoders. After obtaining a target video segment, the target video segment is encoded with a constant bit rate based on the multiple pre-encoders to obtain sample encoding data output by each pre-encoder, wherein the pre-encoder is configured with a preset candidate picture group structure, and the candidate picture group structures of any two pre-encoders are different. The encoding performance parameters of each pre-encoder are determined according to the sample encoding data, and the target picture group structure is determined from the multiple candidate picture group structures according to the encoding performance parameters. The target picture group structure is sent to the target encoder for configuration, and the target video segment is encoded based on the target encoder to obtain target encoding data of the target video segment.

[0095] In addition, refer to Figure 2 , Figure 2 A schematic diagram of another optional implementation environment provided for an embodiment of the present application, the implementation environment includes a terminal 101 and a server 102, wherein the terminal 101 and the server 102 are connected via a communication network.

[0096] Exemplarily, the terminal 101 may be installed with a target encoder, and the server 102 may be installed with multiple pre-encoders. The server 102 may obtain a target video segment sent by the terminal, perform encoding processing on the target video segment with a constant bit rate based on multiple pre-encoders, and obtain sample encoding data output by each pre-encoder; determine the encoding performance parameters of each pre-encoder according to the sample encoding data, determine the target picture group structure from multiple candidate picture group structures according to the encoding performance parameters, send the target picture group structure to the terminal 101, and the terminal 101 receives the target picture group structure, configures the target picture group structure to the target encoder, and performs encoding processing on the target video segment based on the target encoder to obtain target encoding data of the target video segment.

[0097] based on Figure 1 or Figure 2In the implementation environment shown, a target video clip is obtained, and encoding processing is performed on the target video clip with a constant bit rate based on multiple pre-encoders to obtain sample encoding data output by each pre-encoder, and then the encoding performance parameters of each pre-encoder are determined according to the sample encoding data, and the target picture group structure is determined from multiple candidate picture group structures according to the encoding performance parameters. At this time, the target picture group structure obtained is the picture group structure with the best rate-distortion performance among the multiple candidate picture group structures, thereby achieving a screening and matching effect of the picture group structure, and then the target picture group structure is sent to the target encoder for configuration, and then the target video clip is encoded based on the target encoder to obtain the target encoding data of the target video clip. Since the target picture group structure can be flexibly screened and matched based on the pre-encoder, even when performing video encoding on target video clips with different characteristics and different scenes, a suitable target picture group structure can be adaptively selected, thereby effectively improving the rate-distortion performance during video encoding.

[0098] Server 102 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. In addition, server 102 can also be a node server in a blockchain network.

[0099] The terminal 101 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a vehicle-mounted terminal, etc., but is not limited thereto. The terminal 101 and the server 102 may be directly or indirectly connected via wired or wireless communication, which is not limited in the present embodiment.

[0100] The method provided in the embodiments of the present application can be applied to various technical fields, including but not limited to cloud technology, video processing and other technical fields.

[0101] Reference Figure 3 , Figure 3 An optional flowchart of a video encoding method provided in an embodiment of the present application, the video encoding method can be executed by a terminal, or can be executed by a server, or can be executed by a terminal and a server in cooperation, and the video encoding method includes but is not limited to the following steps 301 to 303.

[0102] Step 301: Obtain a target video segment, and perform a constant bit rate encoding process on the target video segment based on multiple pre-encoders to obtain sample encoding data output by each pre-encoder.

[0103] Among them, the target video segment is the video segment to be encoded. In a possible implementation, when the terminal performs video encoding, the target video segment can be a video segment stored locally by the terminal, or when the server performs video encoding, the target video segment can be a video segment collected by the terminal and sent to the server.

[0104] The precoder is a preconfigured encoder used to precode the target video segment, that is, the encoding result obtained by the precoder is not a formal encoding result. The number of precoders can be multiple, and the precoder is configured with a preset candidate picture group structure. The candidate picture group structures of any two precoders are different. The candidate picture group structure is a picture group structure preconfigured in the precoder. The number and specific structure of the candidate picture group structure can be set according to actual encoding requirements. The embodiment of the present application does not limit the number and specific structure of the candidate picture group structure.

[0105] For example, the number of candidate picture group structures may be two, referring to Figure 4 , Figure 4 An optional schematic diagram of a candidate picture group structure provided in an embodiment of the present application, Figure 4 The frame length of the candidate GOP structure shown is 8, and its structure is divided into three layers. The ag frame is a B frame, the h frame is a P frame, and the theta frame is a video frame of the previous GOP structure. Frames in the same GOP structure as the h frame cannot be referenced by the h frame. The h frame can only reference the theta frame belonging to the previous GOP structure. When encoding, the encoder encodes from the bottom layer of the GOP structure upwards. In addition, refer to Figure 5 , Figure 5 Another optional schematic diagram of a candidate picture group structure provided in an embodiment of the present application is Figure 4 The structure principle of the candidate picture group shown is similar, except that Figure 5 The frame length of the candidate GOP structure shown is 16, and the structure is divided into four layers, ao frame is a B frame, p frame is a P frame, and θ frame is a video frame of the previous GOP structure.

[0106] In a possible implementation, the pre-encoder encodes the target video segment using a constant bit rate, for example, the target video segment can be encoded using a CBR mode. By encoding the target video segment using a constant bit rate, the number of bits consumed in encoding the entire target video segment can be made substantially consistent, providing a feasible basis for subsequently determining the target GOP structure from a plurality of candidate GOP structures according to the encoding performance parameters, thereby making the target GOP structure more accurate and reliable.

[0107] In a possible implementation, when a target video segment is encoded at a constant bit rate based on multiple precoders to obtain sample encoded data output by each precoder, the target video segment may be downsampled to obtain a downsampled video segment. The downsampled video segment is encoded at a constant bit rate based on multiple precoders to obtain sample encoded data output by each precoder.

[0108] The target video segment is downsampled, that is, the image size of the target video segment is reduced to reduce the resolution of the target video segment. For example, the length and width can be downsampled by half, and of course, other ratios can be used for downsampling, which is not limited in the embodiment of the present application.

[0109] By downsampling the target video segment and then encoding it using a precoder, the encoding speed of the precoding can be effectively improved. Moreover, since the precoder is used to precode the target video segment, even if the target video segment is downsampled, it will not affect the final encoding result of the target video segment.

[0110] Step 302: Determine encoding performance parameters of each pre-encoder according to sample encoding data, determine a target GOP structure from a plurality of candidate GOP structures according to the encoding performance parameters, and send the target GOP structure to a target encoder for configuration.

[0111] The coding performance parameter is used to indicate the adaptability between the precoder and the target video segment, that is, to indicate the rate-distortion performance after the target video segment is coded by the precoder. The sample coded data is the coded data of each frame of the target video segment output by the precoder. The coding performance parameters of each precoder are determined based on the sample coded data. The sample coded data can be compared with the original target video segment to determine the error between the sample coded data and the original target video segment after coding by the precoder. This error can be used as the coding performance parameter of the precoder.

[0112] Among them, the target encoder is an encoder that formally encodes the target video segment, that is, the encoding structure output by the target encoder is the final encoding data of the target video segment. In some application scenarios, the target encoder can be deployed on the same device (or the same application) as the precoder, for example, the target encoder and the precoder can be deployed on the terminal, or both deployed on the server. Alternatively, in other application scenarios, the target encoder and the precoder can also be deployed on different devices, for example, the target encoder can be deployed on the terminal, and the precoder can be deployed on the server.

[0113] By acquiring a target video segment, encoding the target video segment with a constant bit rate based on multiple pre-encoders, sample encoding data output by each pre-encoder is obtained, encoding performance parameters of each pre-encoder are determined according to the sample encoding data, and a target picture group structure is determined from multiple candidate picture group structures according to the encoding performance parameters. At this time, the target picture group structure obtained is the picture group structure with the best rate-distortion performance among the multiple candidate picture group structures, thereby achieving a screening and matching effect of the picture group structure.

[0114] In a possible implementation, when the encoding performance parameters of each precoder are determined according to the sample encoding data, and the target picture group structure is determined from multiple candidate picture group structures according to the encoding performance parameters, the encoding performance parameters of each precoder may be determined according to the sample encoding data, and a candidate picture group structure with the best encoding performance parameters is selected from the multiple candidate picture group structures as the target picture group structure.

[0115] When each precoder is configured with the same target bit rate, the Peak Signal to Noise Ratio (PSNR) of each precoder can be determined based on sample coding data, and the peak signal to noise ratio is used as a coding performance parameter. The coding performance parameters corresponding to each precoder are compared, and the target picture group structure is determined from multiple candidate picture group structures based on the comparison results of the coding performance parameters.

[0116] Among them, different pre-coders can be configured with the same target bit rate, and because the pre-coder uses a constant bit rate to encode the target video segment, in this case, the number of bits of the code streams output by different pre-coders can be the same. Therefore, the peak signal-to-noise ratio can be directly used as a coding performance parameter for comparison, and the candidate picture group structure of the pre-coder with the highest peak signal-to-noise ratio is used as the target picture group structure. By configuring the same target bit rate in different pre-coders, the parameters that need to be compared can be reduced when determining the target picture group structure, which is conducive to improving the efficiency of determining the target picture group structure.

[0117] In addition, when each precoder is configured with a different target bit rate, the peak signal-to-noise ratio of each precoder is determined according to the sample coding data, the number of codestream bits of each precoder is determined according to the sample coding data, the target weight of the number of codestream bits is determined, the weighted number of bits is obtained according to the product of the target weight and the number of codestream bits, the coding performance parameter is obtained according to the sum of the peak signal-to-noise ratio and the weighted number of bits, the coding performance parameters corresponding to the precoders are compared, and the target picture group structure is determined from multiple candidate picture group structures according to the comparison result of the coding performance parameters.

[0118] Among them, different pre-coders can also be configured with different target bit rates. In this case, the number of code stream bits output by different pre-coders will be different. Therefore, the coding performance parameters can be obtained by the sum of the peak signal-to-noise ratio and the number of code stream bits. Specifically, the target weight is used to eliminate the dimensional difference between the peak signal-to-noise ratio and the number of code stream bits. The function can be fitted through multiple groups of sample values ​​of the peak signal-to-noise ratio and the number of code stream bits to determine the target weight. The coding performance parameters are then obtained based on the sum of the peak signal-to-noise ratio and the weighted number of bits for comparison, which can improve the comprehensiveness of the coding performance parameters and reduce the parameter restrictions on the pre-coder.

[0119] In a possible implementation, when determining the peak signal-to-noise ratio of each precoder based on the sample coded data, the sample coded data can be specifically decoded to obtain a reference video clip; a first pixel value of an image in a target video clip and a second pixel value of an image in a reference video clip are determined; a mean square error value between the first pixel value and the corresponding second pixel value is calculated; the number of pixel bit bits of the image in the target video clip is determined, and the peak signal-to-noise ratio of each precoder is determined based on the mean square error value and the number of pixel bit bits.

[0120] Specifically, the peak signal-to-noise ratio can be expressed as:

[0121]

[0122] Among them, PSNR represents peak signal-to-noise ratio, MSE represents the mean square error between the first pixel value and the corresponding second pixel value, and n is the number of pixel bits.

[0123] Among them, the first pixel value is the image pixel value of each video frame of the target video clip, and the second pixel value is the image pixel value of each video frame of the reference video clip. Since the sample coding data is the encoded data of each frame of the target video clip output by the precoder, the reference video clip obtained by decoding the sample coding data is actually the restored target video clip, and then further compared with the pixel value of the image of the corresponding frame in the original target video clip, the peak signal-to-noise ratio can be obtained. By calculating the mean square error value between the first pixel value and the corresponding second pixel value, and then combining the pixel bit number to determine the peak signal-to-noise ratio of each precoder, the sample coding data can be finely compared with the original target video clip, which is conducive to improving the accuracy of determining the coding performance parameters, and then improving the accuracy of the subsequent determination of the target picture group structure.

[0124] Each video frame in the target video segment corresponds to a peak signal-to-noise ratio, so the peak signal-to-noise ratio of each pre-encoder may be an average value of the peak signal-to-noise ratios corresponding to each video frame.

[0125] Step 303: Encode the target video segment based on the target encoder to obtain target encoded data of the target video segment.

[0126] After the target picture group structure is sent to the target encoder for configuration, the target video clip can be input into the target encoder for encoding processing. The encoding mode of the target encoder can be set according to the actual encoding requirements of the target video clip. By configuring the target picture group structure to the target encoder, and then encoding the target video clip based on the target encoder, the target encoding data of the target video clip is obtained. Since the target picture group structure can be flexibly screened and matched based on the pre-encoder, even when encoding target video clips with different characteristics and scenes, the appropriate target picture group structure can be adaptively selected, thereby effectively improving the rate-distortion performance during video encoding.

[0127] In a possible implementation, it may be necessary to encode a relatively long original video segment, and in this case, the target video segment may be a portion of the original video segment. Therefore, when encoding the original video segment, the original video segment may be divided to obtain a plurality of target video segments, and then the target video segments are encoded.

[0128] Based on this, when obtaining the target video segment, the first frame length of each candidate picture group structure can be specifically determined, and the target common multiple of multiple first frame lengths can be calculated to obtain the second frame length; the original video segment is obtained, and the target video segment is extracted from the original video segment according to the second frame length.

[0129] Among them, the first frame length is the number of video frames included in the candidate group of pictures structure, and the target common multiple can be the least common multiple. Since the target video segments are input to the pre-encoder for encoding respectively, if the frame length of the target video segment is too short, some pre-encoders will not be able to encode several complete group of pictures structures. By calculating the target common multiples of the first frame lengths to obtain the second frame length, and then extracting the target video segment from the original video segment according to the second frame length, the rationality of the frame length of the target video segment can be improved, so that the pre-encoder can encode several complete group of pictures structures.

[0130] For example, Figure 4 The first frame length of the candidate GOP structure shown is 8. Figure 5The first frame length of the candidate GOP structure shown is 16, and the second frame length is 16. In this case, a number of target video segments with a frame length of 16 are extracted from the original video segments for encoding. For another example, the first frame lengths of the two candidate GOP structures are 8 and 20, respectively, and the second frame length is 20. In this case, a number of target video segments with a frame length of 40 are extracted from the original video segments for encoding.

[0131] In a possible implementation, the original video segment may be one of the segments of a complete video to be encoded. Based on this, when obtaining the original video segment, the video to be encoded can be obtained specifically to determine a plurality of first scene change frames in the video to be encoded; the video to be encoded is segmented according to the first scene change frames to obtain a plurality of original video segments corresponding to different video scenes.

[0132] Specifically, the first scene change frame is used to distinguish original video clips of different scenes. Assuming that the scenes of two adjacent original video clips are different, the last video frame of the first original video clip can be used as the first scene change frame, or the first video frame of the second original video clip can be used as the first scene change frame. By segmenting the video to be encoded according to the first scene change frame, a plurality of original video clips corresponding to different video scenes are obtained, which can facilitate the subsequent allocation of different candidate picture group structures to the original video clips of different scenes, thereby improving the degree of adaptation between the pre-encoder and the original video clip, and effectively improving the rate-distortion performance of video encoding.

[0133] In a possible implementation, after dividing and obtaining a plurality of original video clips corresponding to different video scenes, any video frame can be obtained from the original video clip and input into a pre-trained neural network model, which first extracts the image feature vector of the video frame, and then maps the image feature vector through a fully connected layer to obtain a mapping feature vector, and then classifies the mapping feature vector to obtain a classification vector, wherein the vector elements of the classification vector correspond to the selection probabilities of different candidate picture group structures, and finally, the TopN candidate picture group structures are selected according to the number of pre-encoders. In addition, the neural network model can be obtained through supervised training of sample image frames and sample picture group structures.

[0134] Based on this, refer to Figure 6 , Figure 6A schematic diagram of segment division when encoding a video to be encoded is provided in an embodiment of the present application. After obtaining the video to be encoded, the video to be encoded can be segmented according to the first scene change frame to obtain a plurality of original video segments corresponding to different video scenes. Then, each original video segment is further divided, and a second frame length is obtained according to the least common multiple of the frame lengths of each candidate picture group structure. A target video segment is extracted from the original video segment according to the second frame length, and the target video segment is the smallest unit encoded by the precoder.

[0135] In a possible implementation, when determining multiple first scene change frames in a video to be encoded, the video to be encoded can be specifically frame-processed to obtain multiple candidate video frames; the multiple candidate video frames are traversed to determine a first image similarity between a current candidate video frame and a first adjacent video frame, and a second image similarity between the current candidate video frame and a second adjacent video frame; when the difference between the second image similarity and the first image similarity is greater than or equal to a preset difference threshold, the current candidate video frame or the second adjacent video frame is determined as the first scene change frame of the video to be encoded.

[0136] The first adjacent video frame is a previous video frame adjacent to the current candidate video frame, and the second adjacent video frame is a subsequent video frame adjacent to the current candidate video frame.

[0137] In a possible implementation, the first image similarity between the current candidate video frame and the first adjacent video frame is determined, specifically, the current candidate video frame and the first adjacent video frame are input into a pre-trained image feature extraction model, the image feature vectors of the current candidate video frame and the first adjacent video frame are extracted respectively, and the first image similarity is calculated according to the image feature vector, or, the current candidate video frame and the first adjacent video frame are grayed, the average value of the pixel value of each pixel after the graying process is calculated, and the size relationship between the pixel value of each pixel and the average value of the pixel value is compared. If the pixel value of the pixel is greater than the average value of the pixel value, it is set to 1, otherwise it is set to 0, so as to obtain the image feature information of the current candidate video frame and the first adjacent video frame, and then the first image similarity is calculated according to the image feature information. It can be understood that the calculation principle of the second image similarity is similar to that of the first image similarity, which will not be repeated here.

[0138] When the difference between the second image similarity and the first image similarity is greater than or equal to the preset difference threshold, it indicates that the image difference between the current candidate video frame and the second adjacent video frame is large, and it can be determined that the second adjacent video frame has undergone a scene switch compared to the current candidate video frame, and then the current candidate video frame can be determined as the first scene change frame of the video to be encoded. It can be understood that the second adjacent video frame can also be determined as the first scene change frame of the video to be encoded. The difference threshold can be set according to actual conditions, and the embodiment of the present application does not limit it. Determining the first scene change frame by determining the difference between the second image similarity and the first image similarity can have a comparison effect. Compared with directly determining the first scene change frame based on the second image similarity, the determination error of the first scene change frame caused by the difference in setting the difference threshold can be effectively reduced, and the accuracy of determining the first scene change frame can be improved.

[0139] For example, assuming that multiple candidate video frames are video frame f1, video frame f2, video frame f3, video frame f4 and video frame f5, traverse multiple candidate video frames, first, the current candidate video frame is video frame f1, which has no first adjacent video frame and is not compared; then, the current candidate video frame is video frame f2, whose first adjacent video frame is video frame f1, and whose second adjacent video frame is video frame f3, at this time, the first image similarity between video frame f2 and video frame f1, and the second image similarity between video frame f2 and video frame f3 are calculated, and the difference between the second image similarity and the first image similarity is further determined. If the difference is greater than or equal to the preset difference threshold, video frame f2 is the first scene change frame; then, the current candidate video frame is video frame f3 and the current candidate video frame is video frame f4, and the same principle is used for judgment; finally, the current candidate video frame is video frame f5, which has no second adjacent video frame and is not compared. At this point, the process of determining the first scene change frame from multiple candidate video frames is completed.

[0140] In a possible implementation, the number of target video segments extracted from the original video segments may be multiple, and different target video segments may correspond to different target picture group structures. When the target video segments are encoded based on the target encoder to obtain target encoding data of the target video segments, a segment identifier corresponding to each target video segment can be generated, and the corresponding target picture group structure can be marked according to the segment identifier; based on the target encoder, the target picture group structure corresponding to the current target video segment is determined according to the segment identifier, and the current target video segment is encoded according to the corresponding target picture group structure to obtain the target encoding data of the target video segment.

[0141] In this scenario, multiple target group of pictures structures can be configured in the target encoder, and the target encoder can support switching between different target group of pictures structures to encode different target group of pictures structures. Specifically, after determining the target group of pictures structures corresponding to each target video segment according to the encoding performance parameter, a data pair consisting of a segment identifier and a target group of pictures structure can be generated. When encoding the target group of pictures structure, a corresponding target group of pictures structure can be matched according to the current target group of pictures structure to be encoded and the data pair, and then the corresponding target group of pictures structure is switched to encode the current target group of pictures structure.

[0142] By introducing the segment identifier, when multiple target video segments are input at one time, the encoding process of the multiple target video segments can be realized more coherently and accurately.

[0143] For example, the terminal may generate segment identifiers of multiple target video segments, and the server may receive the multiple target video segments and the corresponding segment identifiers sent by the terminal. After determining the target picture group of each target video segment according to the encoding performance parameters, the server may generate data pairs consisting of each segment identifier and the target picture group structure, and then return the data pairs to the terminal. Multiple target picture group structures may be configured on the target encoder of the terminal, and the target picture group structure corresponding to each target video segment may be switched according to the local segment identifier to complete the encoding processing of the multiple target video segments.

[0144] In one possible implementation, when there are remaining video segments that are less than the second frame length after the target video segments are extracted from the original video segments according to the second frame length, the target picture group structure corresponding to the remaining video segments can be determined from the target picture group structures corresponding to multiple target video segments, and the remaining video segments can be encoded based on the target encoder configured with the target picture group structure corresponding to the remaining video segments.

[0145] Since the frame length of the original video segment is not necessarily an integer multiple of the second frame length, there may be a residual video segment that is shorter than the second frame length.

[0146] For example, assuming that there are two pre-encoders, and the first frame lengths of the two candidate picture group structures are 8 and 16 respectively, the second frame length is 16, and the corresponding frame length of the target video segment is 16. If the frame length of the original video segment is 170, 10 target video segments can be extracted from the original video segment, and the total frame length of these 10 target video segments is 160. Subsequently, these target video segments are encoded using two pre-encoders respectively, and then the target picture group structure corresponding to each target video segment is determined.

[0147] At this time, there are remaining video segments with a third frame length of 10, and the target picture group structure corresponding to the remaining video segments can be determined according to the target picture group structure of the confirmed target video segment.

[0148] In one case, when it has been confirmed that the target picture group structures of the target video segments are all the same, this target picture group structure can be used as the target picture group structure corresponding to the remaining video segments.

[0149] For example, continuing with the above example, if the first frame lengths of the target GOP structures of the 10 target video clips are all 8, then the target GOP structures corresponding to the remaining video clips are also 8.

[0150] Another situation is that when it has been confirmed that there are at least two target picture group structures in the target video segment, the segment similarity between the remaining video segments and each target video segment can be determined, and the target picture group structure corresponding to the remaining video segment can be determined from the target picture group structures corresponding to multiple target video segments based on the segment similarity.

[0151] Specifically, when determining the segment similarity between the remaining video segment and each target video segment, at least one image frame that can express the central theme can be sampled from the target video segment and the remaining video segment respectively, and the segment similarity between the remaining video segment and each target video segment can be obtained according to the image similarity of the image frame. Alternatively, a pre-trained neural network model can be used to input the remaining video segment and the target video segment into the neural network model, and the segment similarity between the remaining video segment and each target video segment can be output. After determining the segment similarity between the remaining video segment and each target video segment, the target picture group structure corresponding to the target video segment with the highest similarity to the remaining video segment can be used as the target picture group structure corresponding to the remaining video segment.

[0152] For example, continuing with the previous example, if the first frame lengths of the target picture group structures of the 10 target video clips are 8 and 16 respectively, and assuming that among the 10 target video clips, the first frame length of the target picture group structure of the target video clip with the highest similarity to the remaining video clips is 8, then the first frame length of the target picture group structure corresponding to the remaining video clips is also 8.

[0153] Since the third frame length of the remaining video fragments is less than the second frame length, there may be a candidate picture group structure whose first frame length is greater than the third frame length. If the remaining video fragments are encoded using various pre-encoders at this time, it may be impossible to encode a complete picture group structure, affecting the accuracy and reliability of comparing the encoding performance parameters of different pre-encoders. By directly determining the target picture group structure of the remaining video fragments through the fragment similarity between the remaining video fragments and each target video fragment, the target picture group structure of the remaining video fragments can be determined more reasonably. At the same time, there is no need to encode the remaining video fragments using a pre-encoder, which can also improve the efficiency of video encoding to a certain extent.

[0154] Another situation is that when it has been confirmed that there are at least two target picture group structures in the target video segment, the third frame length of the remaining video segments can also be determined, and the target picture group structure corresponding to the target video segment with a first frame length less than or equal to the third frame length can be used as the target picture group structure corresponding to the remaining video segment.

[0155] For example, continuing with the above example, if the first frame lengths of the target GOP structures of 10 target video clips are 8 and 16 respectively, and the third frame length is 10, then the first frame length of the target GOP structures corresponding to the remaining video clips may be 8.

[0156] Since the target picture group structure is obtained through screening, the target picture group structure corresponding to the target video segment and with a first frame length less than or equal to the third frame length is used as the target picture group structure corresponding to the remaining video segment, so that when the target encoder based on the target picture group structure corresponding to the remaining video segment is used to encode the remaining video segment, it can not only inherit the screening result of the target picture group structure, but also ensure that at least one complete picture group structure can be encoded, thereby improving the reliability of encoding the remaining video segment.

[0157] When there is no target GOP structure whose first frame length is less than or equal to the third frame length, a target GOP structure of a target video segment may be arbitrarily selected as the target GOP structure corresponding to the remaining video segments.

[0158] For different situations, by determining the target picture group structure corresponding to the remaining video segments according to the target picture group structure corresponding to the target video segment, the target picture group structure can be determined without omission and in a more refined manner, thereby effectively improving the accuracy and reliability of video encoding as a whole, and improving the rate-distortion performance during video encoding.

[0159] In a possible implementation, the target video segment may not be obtained by dividing the original video segment based on the first scene change frame, but it may be possible when configuring the candidate GOP structure for the pre-encoder.

[0160] Among them, similar to the concept of the first scene change frame, the second scene change frame is used to distinguish between segments of different scenes in the target video segment, and the scene change degree information is used to indicate the drastic degree of scene change in the target video segment. For example, the scene change degree information can be the average distance between frames of multiple second scene change frames, or the number of frames of second scene change frames, etc.

[0161] In one possible implementation, when determining the scene change degree information of the target video segment based on multiple second scene change frames, it can be specifically determined the inter-frame distance between two adjacent second scene change frames, calculate the average of the multiple inter-frame distances, obtain the inter-frame average distance, and use the inter-frame average distance as the scene change degree information between multiple candidate video frames.

[0162] The inter-frame distance is used to indicate the interval between two second scene change frames, for example, it can be the number of candidate video frames between two second scene change frames, or the time interval between two second scene change frames. Figure 7 , Figure 7 An optional structural schematic diagram of multiple candidate video frames provided in an embodiment of the present application, the multiple second scene change frames are video frame f1, video frame f2, video frame f3 and video frame f4, there are 4 candidate video frames between video frame f1 and video frame f2, there are 3 candidate video frames between video frame f2 and video frame f3, there are 5 candidate video frames between video frame f3 and video frame f4, then the inter-frame distances are 3, 4, and 5 respectively, and the average inter-frame distance is (3+4+5) / 3=4, that is, the scene change degree information is 4.

[0163] In a possible implementation, when determining the scene change degree information of the target video segment according to multiple second scene change frames, the frame number of the multiple second scene change frames may be determined, and the frame number is used as the scene change degree information between the multiple candidate video frames.

[0164] For example, refer again to Figure 7 In the example shown, the frame number of the second scene change frame is 4, that is, the scene change degree information is 4.

[0165] Furthermore, the first frame length of the candidate picture group structure shortens as the severity of the scene change indicated by the scene change degree information increases, that is, when the scene change degree information indicates that the scene change of the target video segment is more drastic, the first frame length is shorter. Combined with the aforementioned example of the scene change degree information, when the scene change degree information is the average distance between frames of multiple second scene change frames, the shorter the average distance between frames, the more drastic the scene change is, and the shorter the first frame length is; when the scene change degree information is the number of frames of multiple second scene change frames, the more the number of frames, the more drastic the scene change is, and the shorter the first frame length is.

[0166] Accordingly, the correspondence between the candidate GOP structures and the scene change degree information may be preset, and after the scene change degree information between multiple candidate video frames is determined, the corresponding candidate GOP structures are matched from the preset correspondence and configured to the precoder.

[0167] For example, the corresponding relationship can be preset using the frame length of the candidate picture group structure, and the corresponding relationship can be an array of the structure of [scene change degree information, frame length one of the candidate picture group structure, frame length two of the candidate picture group structure, ..., frame length N of the candidate picture group structure]. Taking the scene change degree information as the average distance between frames as an example, if the number of precoders is two, the preset corresponding relationship can be [3,8,16], [6,12,16], etc. When the average distance between frames is 3, the frame lengths of the candidate picture group structure are 8 and 16, that is, the two precoders respectively configure the candidate picture group structure with a frame length of 8 and the candidate picture group structure with a frame length of 16. When the average distance between frames is 6, the frame lengths of the candidate picture group structure are 12 and 16, that is, the two precoders respectively configure the candidate picture group structure with a frame length of 12 and the candidate picture group structure with a frame length of 16. It can be understood that the above corresponding relationship is only used for exemplary description, and can be specifically set according to actual conditions, and the embodiments of the present application are not limited thereto.

[0168] In addition, the scene change degree information in the corresponding relationship can also be a range value. When the scene change degree information between multiple candidate video frames is within the range value in the preset corresponding relationship, the corresponding candidate picture group structure can be matched to the pre-encoder, thereby improving the success rate and stability of the candidate picture group structure matching.

[0169] In addition, the same scene change degree information may correspond to different combinations of candidate picture group structures, that is, the scene change degree information in multiple different corresponding relationships may be the same. After determining the scene change degree information, multiple groups of different candidate picture group structures may be obtained. At this time, the frame length of the target video segment may be determined. From the multiple groups of different candidate picture group structures, a group of candidate picture group structures whose frame lengths are all divisors of the frame length of the target video segment are selected and respectively configured in each pre-encoder, so that the pre-encoder can encode several complete picture group structures when encoding the target video segment.

[0170] For example, taking the scene change degree information as the average distance between frames as an example, the preset corresponding relationships may include [3,8,12], [3,8,16], [6,12,16] and [6,16,20]. When the average distance between frames is 3, the matched corresponding relationships are [3,8,12] and [3,8,16]. If the frame length of the target video segment is 16, since the frame lengths 8 and 16 of the candidate picture group structures are both divisors of the frame length 16 of the target video segment, the frame lengths of the candidate picture group structures are finally determined to be 8 and 16.

[0171] By determining multiple candidate picture group structures according to scene change information, and sending the multiple candidate picture group structures to each pre-encoder for configuration, the pre-encoder can be flexibly configured so that the candidate picture group structure of the pre-encoder is more compatible with the target video segment, that is, the target picture group structure subsequently determined from the candidate picture group structure is more compatible with the target video segment, thereby effectively improving the rate-distortion performance of video encoding.

[0172] In addition, refer to Figure 8 , Figure 8 Another optional flowchart of the video encoding method provided in an embodiment of the present application, the video encoding method can be executed by a terminal, or can be executed by a server, and the video encoding method includes but is not limited to the following steps 801 to 802.

[0173] Step 801: Obtain a target video clip and a target GOP structure, and send the target GOP structure to a target encoder for configuration;

[0174] Step 802: Encode the target video segment based on the target encoder to obtain target encoded data of the target video segment.

[0175] Among them, the target picture group structure is based on multiple pre-encoders performing constant bit rate encoding processing on the target video segment, obtaining sample encoding data output by each pre-encoder, determining the encoding performance parameters of each pre-encoder according to the sample encoding data, and determining it from multiple candidate picture group structures according to the encoding performance parameters. The pre-encoder is configured with a preset candidate picture group structure, and the candidate picture group structures of any two pre-encoders are different.

[0176] Specifically, Figure 8 In the process shown, the step of determining the target group of pictures structure is not performed locally. For example, the determination of the target group of pictures structure is performed by the server, and the terminal is only responsible for the configuration of the target encoder and the encoding process based on the target encoder, which can effectively reduce the resource occupation of the terminal when performing video encoding. Among them, the terminal can send the target video segment to the server, and the server performs a constant bit rate encoding process on the target video segment based on multiple pre-encoders, obtains sample encoding data output by each pre-encoder, determines the encoding performance parameters of each pre-encoder according to the sample encoding data, determines the target group of pictures structure from multiple candidate group of pictures structures according to the encoding performance parameters, and sends the target group of pictures structure to the terminal. The terminal configures the target group of pictures structure to the target encoder and then performs encoding process on the target video segment.

[0177] In a possible implementation, after receiving the target video segment sent by the terminal, the server can perform downsampling processing on the target video segment, thereby improving the encoding efficiency of the precoder, and further improving the efficiency of determining the target picture group structure. In addition, the terminal can also perform downsampling processing on the target video segment, and send the downsampled video segment obtained after the downsampling processing to the server, and the server then encodes the downsampled video segment sent by the terminal based on the precoder. At this time, since the resolution of the downsampled video segment is reduced compared to the target video segment, its data volume is also reduced, thereby reducing the resource occupation when transmitting data between the terminal and the server.

[0178] In a possible implementation, the terminal may also send a video to be encoded to a server, and the server determines multiple first scene change frames in the video to be encoded, and segments the video to be encoded according to the first scene change frames to obtain multiple original video segments corresponding to different video scenes, and allocates different candidate picture group structures to the original video segments of different scenes, thereby improving the degree of adaptation between the candidate picture group structure and the original video segments, and then extracts the target video segments from the original video segments for encoding, thereby improving the degree of adaptation between the candidate picture group structure and the target video segments, and effectively improving the rate-distortion performance of video encoding.

[0179] In one possible implementation, the terminal may also send multiple target video clips to the server, and the server may determine multiple second scene change frames in the target video clip, determine the scene change degree information of the target video clip based on the multiple second scene change frames, and then determine multiple candidate picture group structures based on the scene change information, and send the multiple candidate picture group structures to each pre-encoder for configuration, so that the server can flexibly configure the pre-encoder, so that the candidate picture group structure of the pre-encoder is more compatible with the target video clip, that is, the target picture group structure subsequently determined from the candidate picture group structure is more compatible with the target video clip, thereby effectively improving the rate-distortion performance of video encoding.

[0180] Understandably, Figure 8 The video encoding method shown is similar to Figure 3 The video encoding method shown is based on the same inventive concept, and the specific details can be found in the previous explanation, which will not be repeated here. By obtaining the target video segment and the target GOP structure, since the target GOP structure is based on multiple pre-encoders to perform coding processing on the target video segment with a constant bit rate, sample coding data output by each pre-encoder is obtained, and the coding performance parameters of each pre-encoder are determined according to the sample coding data, and the target GOP structure obtained at this time is the GOP structure with the best rate-distortion performance among the multiple candidate GOP structures, thereby achieving the screening and matching effect of the GOP structure, and then sending the target GOP structure to the target encoder for configuration, and then encoding the target video segment based on the target encoder to obtain the target coding data of the target video segment. Since the target GOP structure can be flexibly screened and matched based on the pre-encoder, even when performing video coding on target video segments with different characteristics and different scenes, a suitable target GOP structure can be adaptively selected, thereby effectively improving the rate-distortion performance during video coding.

[0181] The principle of the video encoding method provided in the embodiment of the present application is described in detail below based on actual examples.

[0182] Reference Fig. 9 , Fig. 9An optional complete flow diagram of a video encoding method provided in an embodiment of the present application, wherein a video encoding system is deployed on a terminal or server, the video encoding system comprising at least a downsampling module, a precoder A, a precoder B and a target encoder, precoder A is configured with a candidate picture group structure a, precoder B is configured with a candidate picture group structure b, and precoder A and precoder B are configured with the same target bit rate, the frame length of the target video segment is the least common multiple of the frame lengths of the candidate picture group structure a and the candidate picture group structure b, the target video segment is input into the video encoding system, and will first be downsampled into a low-resolution downsampled video segment by the downsampling module, and the downsampled video segment obtained by downsampling will be used as the input of precoder A and precoder B respectively , precoder A uses candidate group of pictures structure a and uses CBR mode to encode the downsampled video clip, precoder B uses candidate group of pictures structure b and uses CBR mode to encode the downsampled video clip, and determines the peak signal-to-noise ratio of precoder A after decoding the sample encoded data output by precoder A, and determines the peak signal-to-noise ratio of precoder B after decoding the sample encoded data output by precoder B, compares the peak signal-to-noise ratio of precoder A with the peak signal-to-noise ratio of precoder B to make a group of pictures structure decision, configures the candidate group of pictures structure corresponding to the precoder with a higher peak signal-to-noise ratio as the target group of pictures structure to the target encoder, inputs the target video clip into the configured target encoder for encoding, and obtains the target encoded data of the target video clip.

[0183] In addition, refer to Fig.10 , Fig.10Another optional complete flow diagram of the video encoding method provided in an embodiment of the present application, wherein a video encoding system is deployed on a terminal or server, the video encoding system comprising at least a downsampling module, a precoder A, a precoder B and a target encoder, precoder A and precoder B are configured with the same target bit rate, the number of target video clips input into the video encoding system is multiple, for each target video clip input into the video encoding system, multiple scene change frames in the target video clip are determined, and then the scene change degree information of the target video clip is determined based on the multiple scene change frames, and the candidate picture group structure a and the candidate picture group structure b corresponding to each of the target video clips are determined based on the scene change degree information, when encoding one of the target video clips, the corresponding candidate picture group structure a is configured to the precoder A, and the corresponding candidate picture group structure b is configured to the precoder B, the target video clip is first The downsampled video clips are downsampled into low-resolution downsampled video clips by the downsampling module. The downsampled video clips obtained by downsampling are respectively used as inputs of precoder A and precoder B. Precoder A uses candidate picture group structure a and uses CBR mode to encode the downsampled video clips. Precoder B uses candidate picture group structure b and uses CBR mode to encode the downsampled video clips. After decoding the sample encoded data output by precoder A, the peak signal-to-noise ratio of precoder A is determined. After decoding the sample encoded data output by precoder B, the peak signal-to-noise ratio of precoder B is determined. The peak signal-to-noise ratio of precoder A is compared with the peak signal-to-noise ratio of precoder B to make a picture group structure decision. The candidate picture group structure corresponding to the precoder with a higher peak signal-to-noise ratio is configured as the target picture group structure to the target encoder. The target video clip is input into the configured target encoder for encoding to obtain the target encoded data of the target video clip.

[0184] In addition, refer to Fig.11 , Fig.11Another optional complete flow diagram of the video encoding method provided in an embodiment of the present application, wherein the video encoding system includes at least a downsampling module, a precoder A, a precoder B and a target encoder, the target encoder is deployed on a terminal, the downsampling module, the precoder A, and the precoder B are deployed on a server, the precoder A is configured with a candidate picture group structure a, the precoder B is configured with a candidate picture group structure b, and the precoder A and the precoder B are configured with the same target bit rate, the terminal sends the target video segment to the server, the frame length of the target video segment is the least common multiple of the frame lengths of the candidate picture group structure a and the candidate picture group structure b, the server uses the downsampling module to downsample the target video segment into a low-resolution downsampled video segment, and the downsampled video segment obtained by downsampling will be used as the precoder A and the precoder B respectively. The precoder A encodes the downsampled video clip using the candidate group of pictures structure a and the CBR mode, and the precoder B encodes the downsampled video clip using the candidate group of pictures structure b and the CBR mode, and determines the peak signal-to-noise ratio of the precoder A after decoding the sample coded data output by the precoder A, and determines the peak signal-to-noise ratio of the precoder B after decoding the sample coded data output by the precoder B, and compares the peak signal-to-noise ratio of the precoder A with the peak signal-to-noise ratio of the precoder B to make a group of pictures structure decision, and sends the candidate group of pictures structure corresponding to the precoder with a higher peak signal-to-noise ratio to the terminal, and the terminal configures the received candidate group of pictures structure as the target group of pictures structure to the target encoder, and inputs the target video clip into the configured target encoder for encoding to obtain the target coded data of the target video clip.

[0185] In addition, refer to Fig.12 , Fig.12Another optional complete flow diagram of the video encoding method provided in an embodiment of the present application, wherein a video encoding system is deployed on a terminal or server, the video encoding system at least including a segment preprocessing module, a downsampling module, a precoder A, a precoder B and a target encoder, precoder A is configured with a candidate picture group structure a, precoder B is configured with a candidate picture group structure b, and precoder A and precoder B are configured with the same target bit rate. In this example, the input to the video encoding system is a video to be encoded, the segment preprocessing module first determines a plurality of scene change frames of the video to be encoded, divides the video to be encoded into a plurality of original video segments according to the plurality of scene change frames of the video to be encoded, and then divides the original video segments into a plurality of target video segments according to the least common multiple of the frame lengths of the candidate picture group structure a and the candidate picture group structure b, and the target video segments are downsampled into low-resolution segments by the downsampling module. The downsampled video clips are downsampled to a resolution of 100,000 pixels. The downsampled video clips obtained by downsampling are respectively used as inputs of precoder A and precoder B. Precoder A uses candidate picture group structure a and uses CBR mode to encode the downsampled video clip. Precoder B uses candidate picture group structure b and uses CBR mode to encode the downsampled video clip. After decoding the sample encoded data output by precoder A, the peak signal-to-noise ratio of precoder A is determined. After decoding the sample encoded data output by precoder B, the peak signal-to-noise ratio of precoder B is determined. The peak signal-to-noise ratio of precoder A is compared with the peak signal-to-noise ratio of precoder B to make a picture group structure decision. The candidate picture group structure corresponding to the precoder with a higher peak signal-to-noise ratio is configured as the target picture group structure to the target encoder. The target video clip is input to the configured target encoder for encoding to obtain target encoded data of the target video clip.

[0186] The following describes an exemplary application scenario of the video encoding method provided in an embodiment of the present application.

[0187] The video encoding method provided in the embodiment of the present application can be applied to a local video encoding scenario, wherein a video encoding software encapsulating a downsampling module, a target encoder, and multiple pre-encoders can be installed on a terminal. After the video encoding software is run on the terminal, the target video segment to be encoded can be read from the terminal local storage or other mobile storage devices. After encoding the target video segment based on the pre-encoder, the pre-encoder with the highest peak signal-to-noise ratio is determined, and the candidate picture group structure of the pre-encoder is configured to the target encoder. The target video segment is then encoded using the target encoder. After obtaining the target encoded data, it is stored in the terminal local storage or other mobile storage devices.

[0188] The video encoding method provided in the embodiment of the present application can also be applied to cloud gaming scenarios, wherein a terminal runs cloud gaming software, and the terminal sends collected game operation instructions to a server corresponding to the cloud gaming software. A video encoding system is deployed in the server corresponding to the cloud gaming software, and the video encoding system includes a downsampling module, a target encoder, and multiple pre-encoders. After receiving the game operation instructions sent by the terminal, the server performs picture calculations and obtains a target video clip based on the game operation instructions. After encoding the target video clip based on the pre-encoder, the pre-encoder with the highest peak signal-to-noise ratio is determined, and the candidate picture group structure of the pre-encoder is configured to the target encoder. The target video clip is then encoded using the target encoder to obtain target encoded data, and the target encoded data is sent to the terminal. The cloud gaming software of the terminal decodes the target encoded data to display the corresponding game screen.

[0189] The video encoding method provided in the embodiment of the present application can also be applied to a live broadcast scenario, wherein a live broadcast terminal runs live broadcast software, and the live broadcast terminal sends the collected target video clip to a server corresponding to the live broadcast software. A video encoding system is deployed in the server corresponding to the live broadcast software, and the video encoding system includes a downsampling module, a target encoder, and multiple pre-encoders. After receiving the target video clip sent by the live broadcast terminal, the server encodes the target video clip based on the pre-encoder, determines the pre-encoder with the highest peak signal-to-noise ratio, configures the candidate picture group structure of the pre-encoder to the target encoder, and then uses the target encoder to encode the target video clip to obtain target encoded data, and sends the target encoded data to a viewing terminal, which also runs live broadcast software. The live broadcast software of the viewing terminal decodes the target encoded data, thereby displaying the live content collected by the live broadcast terminal.

[0190] It is to be understood that, although the steps in the above-mentioned various flow charts are shown in sequence according to the indication of the arrows, these steps are not necessarily performed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in the present embodiment, the execution of these steps does not have a strict order restriction, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the above-mentioned flow charts can include a plurality of steps or a plurality of stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of the steps or stages in other steps or other steps.

[0191] Reference Fig.13 , Fig.13 This is an optional structural diagram of a first video encoding device provided in an embodiment of the present application. The first video encoding device 1300 includes:

[0192] The first encoding module 1301 is used to obtain a target video segment, and perform a constant bit rate encoding process on the target video segment based on multiple pre-encoders to obtain sample encoding data output by each pre-encoder, wherein the pre-encoder is configured with a preset candidate picture group structure, and the candidate picture group structures of any two pre-encoders are different;

[0193] A first GOP structure configuration module 1302 is configured to determine encoding performance parameters of each pre-encoder according to sample encoding data, determine a target GOP structure from a plurality of candidate GOP structures according to the encoding performance parameters, and send the target GOP structure to a target encoder for configuration;

[0194] The second encoding module 1303 is used to perform encoding processing on the target video segment based on the target encoder to obtain target encoding data of the target video segment.

[0195] Further, the first encoding module 1301 is specifically used for:

[0196] Determine the first frame length of each candidate group of picture structures, calculate the target common multiple of the first frame lengths, and obtain the second frame length;

[0197] An original video segment is obtained, and a target video segment is extracted from the original video segment according to the second frame length.

[0198] Further, the first encoding module 1301 is specifically used for:

[0199] Acquire a video to be encoded, and determine a plurality of first scene change frames in the video to be encoded;

[0200] The video to be encoded is segmented according to the first scene change frame to obtain a plurality of original video segments corresponding to different video scenes.

[0201] Further, the first encoding module 1301 is specifically used for:

[0202] Performing frame processing on the video to be encoded to obtain multiple candidate video frames;

[0203] Traversing multiple candidate video frames, determining a first image similarity between a current candidate video frame and a first adjacent video frame, and a second image similarity between the current candidate video frame and a second adjacent video frame, wherein the first adjacent video frame is a previous video frame adjacent to the current candidate video frame, and the second adjacent video frame is a subsequent video frame adjacent to the current candidate video frame;

[0204] When the difference between the second image similarity and the first image similarity is greater than or equal to a preset difference threshold, the current candidate video frame or the second adjacent video frame is determined as the first scene change frame of the video to be encoded.

[0205] Furthermore, the first picture group structure configuration module 1302 is further used for:

[0206] After the target video segment is extracted from the original video segment according to the second frame length, if there is a remaining video segment shorter than the second frame length, determining the target picture group structure corresponding to the remaining video segment according to the target picture group structure corresponding to the target video segment;

[0207] The second encoding module 1303 is also used for:

[0208] The remaining video segments are encoded based on a target encoder configured with a target group of pictures structure corresponding to the remaining video segments.

[0209] Further, the first picture group structure configuration module 1302 is specifically used for:

[0210] Determine the segment similarity between the remaining video segments and each target video segment, and determine the target picture group structure corresponding to the remaining video segments from the target picture group structures corresponding to the multiple target video segments according to the segment similarity;

[0211] Alternatively, the third frame length of the remaining video segments is determined, and the target GOP structure corresponding to the target video segment whose first frame length is less than or equal to the third frame length is used as the target GOP structure corresponding to the remaining video segments.

[0212] Further, the first encoding module 1301 is specifically used for:

[0213] determining a plurality of second scene change frames in the target video segment;

[0214] Determining scene change degree information of the target video segment according to the plurality of second scene change frames, wherein the scene change degree information is used to indicate a drastic degree of scene change of the target video segment;

[0215] A plurality of candidate GOP structures are determined according to the scene change information, and the plurality of candidate GOP structures are respectively sent to respective pre-encoders for configuration, wherein the first frame length of the candidate GOP structure is shortened as the severity indicated by the scene change degree information increases.

[0216] Further, the first encoding module 1301 is specifically used for:

[0217] Determine the inter-frame distance between two adjacent second scene change frames, calculate the average of multiple inter-frame distances, obtain the inter-frame average distance, and use the inter-frame average distance as the scene change degree information of the target video segment;

[0218] Alternatively, the number of frames of the plurality of second scene change frames is determined, and the number of frames is used as the scene change degree information of the target video segment.

[0219] Further, the first picture group structure configuration module 1302 is specifically used for:

[0220] When all precoders are configured with the same target bit rate, a peak signal-to-noise ratio of each precoder is determined according to sample coded data, the peak signal-to-noise ratio is used as a coding performance parameter, the coding performance parameters corresponding to each precoder are compared, and a target group of picture structures is determined from a plurality of candidate group of picture structures according to a comparison result of the coding performance parameters;

[0221] Alternatively, when each precoder is configured with a different target bit rate, a peak signal-to-noise ratio of each precoder is determined according to sample coding data, a number of codestream bits of each precoder is determined according to the sample coding data, a target weight of the number of codestream bits is determined, a weighted number of bits is obtained according to the product of the target weight and the number of codestream bits, a coding performance parameter is obtained according to the sum of the peak signal-to-noise ratio and the weighted number of bits, the coding performance parameters corresponding to each precoder are compared, and a target picture group structure is determined from a plurality of candidate picture group structures according to the comparison result of the coding performance parameters.

[0222] Further, the first picture group structure configuration module 1302 is specifically used for:

[0223] Decoding the sample coded data to obtain a reference video clip;

[0224] Determining a first pixel value of an image in a target video segment and a second pixel value of an image in a reference video segment;

[0225] Calculating a mean square error between a first pixel value and a corresponding second pixel value;

[0226] The number of pixel bits of an image in a target video segment is determined, and the peak signal-to-noise ratio of each precoder is determined according to the mean square error value and the number of pixel bits.

[0227] Furthermore, the number of target video segments is multiple, and the second encoding module 1303 is specifically used for:

[0228] Generate segment identifiers corresponding to each target video segment, and mark the corresponding target picture group structure according to the segment identifiers;

[0229] Based on the target encoder, the target GOP structure corresponding to the current target video segment is determined according to the segment identifier, and the current target video segment is encoded according to the corresponding target GOP structure to obtain target encoding data of the target video segment.

[0230] Further, the first encoding module 1301 is specifically used for:

[0231] Downsampling the target video segment to obtain a downsampled video segment;

[0232] The down-sampled video segments are coded at a constant bit rate based on multiple pre-coders to obtain sample coded data output by each pre-coder.

[0233] The first video encoding device 1300 and Figure 3 The video encoding method shown is based on the same inventive concept, by acquiring a target video clip, performing encoding processing on the target video clip with a constant bit rate based on multiple pre-encoders, obtaining sample encoding data output by each pre-encoder, and then determining the encoding performance parameters of each pre-encoder based on the sample encoding data, and determining the target picture group structure from multiple candidate picture group structures based on the encoding performance parameters. At this time, the target picture group structure obtained is the picture group structure with the best rate-distortion performance among the multiple candidate picture group structures, thereby achieving a screening and matching effect of the picture group structure, and then sending the target picture group structure to the target encoder for configuration, and then encoding processing is performed on the target video clip based on the target encoder to obtain target encoding data of the target video clip. Since the target picture group structure can be flexibly screened and matched based on the pre-encoder, even when performing video encoding on target video clips with different characteristics and different scenes, a suitable target picture group structure can be adaptively selected, thereby effectively improving the rate-distortion performance during video encoding.

[0234] Reference Fig.14 , Fig.14 This is an optional structural diagram of a second video encoding device provided in an embodiment of the present application. The second video encoding device 1400 includes:

[0235] The second GOP structure configuration module 1401 is used to obtain a target video segment and a target GOP structure, and send the target GOP structure to a target encoder for configuration;

[0236] The third encoding module 1402 is used to encode the target video segment based on the target encoder to obtain target encoding data of the target video segment;

[0237] Among them, the target picture group structure is based on multiple pre-encoders performing constant bit rate encoding processing on the target video segment, obtaining sample encoding data output by each pre-encoder, determining the encoding performance parameters of each pre-encoder according to the sample encoding data, and determining it from multiple candidate picture group structures according to the encoding performance parameters. The pre-encoder is configured with a preset candidate picture group structure, and the candidate picture group structures of any two pre-encoders are different.

[0238] The second video encoding device 1400 and Figure 8The video encoding method shown is based on the same inventive concept, by obtaining a target video clip and a target GOP structure, since the target GOP structure is based on multiple pre-encoders to perform coding processing on the target video clip with a constant bit rate, sample coding data output by each pre-encoder is obtained, and coding performance parameters of each pre-encoder are determined according to the sample coding data, and are determined from multiple candidate GOP structures according to the coding performance parameters. At this time, the target GOP structure obtained is the GOP structure with the best rate-distortion performance among the multiple candidate GOP structures, thereby achieving a screening and matching effect of the GOP structure, and then the target GOP structure is sent to the target encoder for configuration, and then the target video clip is encoded based on the target encoder to obtain the target coding data of the target video clip. Since the target GOP structure can be flexibly screened and matched based on the pre-encoder, even when performing video coding on target video clips with different characteristics and different scenes, a suitable target GOP structure can be adaptively selected, thereby effectively improving the rate-distortion performance during video coding.

[0239] The electronic device for executing the above-mentioned video encoding method provided in the embodiment of the present application may be a terminal. Fig.15 , Fig.15 This is a partial structural block diagram of a terminal provided in an embodiment of the present application. The terminal includes: a camera assembly 1510, a memory 1520, an input unit 1530, a display unit 1540, a sensor 1550, an audio circuit 1560, a wireless fidelity (WiFi) module 1570, a processor 1580, and a power supply 1590. Those skilled in the art can understand that Fig.15 The terminal structure shown in the figure does not constitute a limitation on the terminal, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0240] The camera assembly 1510 can be used to capture images or videos. Optionally, the camera assembly 1510 includes a front camera and a rear camera. Typically, the front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and the VR (Virtual Reality) shooting function or other fusion shooting functions.

[0241] The memory 1520 may be used to store software programs and modules. The processor 1580 executes various functional applications and data processing of the terminal by running the software programs and modules stored in the memory 1520 .

[0242] The input unit 1530 may be used to receive input digital or character information and generate key signal input related to the terminal's settings and function control. Specifically, the input unit 1530 may include a touch panel 1531 and other input devices 1532 .

[0243] The display unit 1540 may be used to display input information or provided information and various menus of the terminal. The display unit 1540 may include a display panel 1541 .

[0244] The audio circuit 1560 , the speaker 1561 , and the microphone 1562 may provide an audio interface.

[0245] The power source 1590 may be alternating current, direct current, a disposable battery, or a rechargeable battery.

[0246] The number of sensors 1550 may be one or more, and the one or more sensors 1550 include but are not limited to: acceleration sensors, gyroscope sensors, pressure sensors, optical sensors, etc. Among them:

[0247] The acceleration sensor can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal. For example, the acceleration sensor can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 1580 can control the display unit 1540 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor. The acceleration sensor can also be used for collecting game or user motion data.

[0248] The gyroscope sensor can detect the body direction and rotation angle of the terminal, and the gyroscope sensor can cooperate with the acceleration sensor to collect the user's 3D actions on the terminal. The processor 1580 can implement the following functions based on the data collected by the gyroscope sensor: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.

[0249] The pressure sensor can be set in the side frame of the terminal and / or the lower layer of the display unit 1540. When the pressure sensor is set in the side frame of the terminal, the user's holding signal of the terminal can be detected, and the processor 1580 performs left and right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor. When the pressure sensor is set in the lower layer of the display unit 1540, the processor 1580 controls the operability controls on the UI interface according to the user's pressure operation on the display unit 1540. The operability control includes at least one of a button control, a scroll bar control, an icon control, and a menu control.

[0250] The optical sensor is used to collect the ambient light intensity. In one embodiment, the processor 1580 can control the display brightness of the display unit 1540 according to the ambient light intensity collected by the optical sensor. Specifically, when the ambient light intensity is high, the display brightness of the display unit 1540 is increased; when the ambient light intensity is low, the display brightness of the display unit 1540 is decreased. In another embodiment, the processor 1580 can also dynamically adjust the shooting parameters of the camera assembly 1510 according to the ambient light intensity collected by the optical sensor.

[0251] In this embodiment, the processor 1580 included in the terminal can execute the video encoding method of the previous embodiment.

[0252] The electronic device for executing the above-mentioned video encoding method provided in the embodiment of the present application may also be a server, referring to Fig.16 , Fig.16 Partial structural block diagram of a server provided in an embodiment of the present application. The server 1600 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPUs) 1622 (e.g., one or more processors) and a memory 1632, and one or more storage media 1630 (e.g., one or more mass storage devices) storing application programs 1642 or data 1644. Among them, the memory 1632 and the storage medium 1630 may be short-term storage or permanent storage. The program stored in the storage medium 1630 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server 1600. Furthermore, the central processing unit 1622 may be configured to communicate with the storage medium 1630 to execute a series of instruction operations in the storage medium 1630 on the server 1600.

[0253] The server 1600 may also include one or more power supplies 1626, one or more wired or wireless network interfaces 1650, one or more input and output interfaces 1658, and / or one or more operating systems 1641, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0254] The processor in the server 1600 may be configured to execute the video encoding method.

[0255] The embodiment of the present application also provides a computer-readable storage medium, which is used to store program code, and the program code is used to execute the video encoding method of each of the above embodiments.

[0256] The embodiment of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned video encoding method.

[0257] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0258] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0259] It should be understood that in the description of the embodiments of the present application, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood to not include the number, and above, below, within, etc. are understood to include the number.

[0260] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0261] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0262] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0263] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.

[0264] It should also be understood that the various implementations provided in the embodiments of the present application can be combined arbitrarily to achieve different technical effects.

[0265] The above is a specific description of the preferred implementation of the present application, but the present application is not limited to the above implementation mode. Technical personnel familiar with the field can also make various equivalent modifications or substitutions under the shared conditions without violating the spirit of the present application. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present application.

Claims

1. A video encoding method, characterized in that: include: Acquire a target video segment, and perform a constant bit rate encoding process on the target video segment based on multiple pre-encoders to obtain sample encoding data output by each of the pre-encoders, wherein the pre-encoders are configured with a preset candidate group of pictures structure, and the candidate group of pictures structures of any two of the pre-encoders are different; Determining encoding performance parameters of each of the pre-encoders according to the sample encoding data, determining a target group of pictures structure from a plurality of the candidate group of pictures structures according to the encoding performance parameters, and sending the target group of pictures structure to a target encoder for configuration; The target video segment is encoded based on the target encoder to obtain target encoding data of the target video segment.

2. The video encoding method according to claim 1, characterized in that The step of obtaining the target video clip includes: Determine a first frame length of each of the candidate group of picture structures, calculate a target common multiple of a plurality of the first frame lengths, and obtain a second frame length; An original video segment is acquired, and the target video segment is extracted from the original video segment according to the second frame length.

3. The video encoding method according to claim 2, characterized in that: The obtaining of the original video clip comprises: Acquire a video to be encoded, and determine a plurality of first scene change frames in the video to be encoded; The video to be encoded is divided into segments according to the first scene change frame to obtain a plurality of original video segments corresponding to different video scenes.

4. The video encoding method according to claim 3, characterized in that: The determining a plurality of first scene change frames in the video to be encoded comprises: Performing frame processing on the video to be encoded to obtain multiple candidate video frames; Traversing the plurality of candidate video frames, determining a first image similarity between the current candidate video frame and a first adjacent video frame, and a second image similarity between the current candidate video frame and a second adjacent video frame, wherein the first adjacent video frame is a previous video frame adjacent to the current candidate video frame, and the second adjacent video frame is a subsequent video frame adjacent to the current candidate video frame; When the difference between the second image similarity and the first image similarity is greater than or equal to a preset difference threshold, the current candidate video frame or the second adjacent video frame is determined as the first scene change frame of the video to be encoded.

5. The video encoding method according to any one of claims 2 to 4, characterized in that: The video encoding method further comprises: When there are remaining video segments whose length is less than the second frame length after the target video segment is extracted from the original video segment according to the second frame length, determining the target picture group structure corresponding to the remaining video segment according to the target picture group structure corresponding to the target video segment; The remaining video segments are encoded based on the target encoder configured with the target group of pictures structure corresponding to the remaining video segments.

6. The video encoding method according to claim 5, characterized in that: The determining, according to the target picture group structure corresponding to the target video segment, the target picture group structure corresponding to the remaining video segments comprises: Determine the segment similarity between the remaining video segments and each of the target video segments, and determine the target picture group structure corresponding to the remaining video segments from the target picture group structures corresponding to the multiple target video segments according to the segment similarity; Alternatively, a third frame length of the remaining video segments is determined, and the target GOP structure corresponding to the target video segment and having the first frame length less than or equal to the third frame length is used as the target GOP structure corresponding to the remaining video segments.

7. The video encoding method according to claim 1, characterized in that: The precoder presets the candidate picture group structure by the following steps: determining a plurality of second scene change frames in the target video segment; determining scene change degree information of the target video segment according to the plurality of second scene change frames, wherein the scene change degree information is used to indicate a drastic degree of scene change of the target video segment; Determine a plurality of candidate group of picture structures according to the scene change information, and send the plurality of candidate group of picture structures to each of the pre-encoders for configuration, wherein a first frame length of the candidate group of picture structures is shortened as the severity indicated by the scene change degree information increases.

8. The video encoding method according to claim 7, characterized in that: The determining the scene change degree information of the target video segment according to the plurality of second scene change frames includes: Determine an inter-frame distance between two adjacent second scene change frames, calculate an average of a plurality of the inter-frame distances to obtain an inter-frame average distance, and use the inter-frame average distance as scene change degree information of the target video segment; Alternatively, the number of frames of the second scene change frames is determined, and the number of frames is used as the scene change degree information of the target video segment.

9. The video encoding method according to claim 1, characterized in that: The step of determining encoding performance parameters of each of the pre-encoders according to the sample encoding data, and determining a target group of pictures structure from a plurality of candidate group of pictures structures according to the encoding performance parameters, comprises: When all the precoders are configured with the same target bit rate, determining a peak signal-to-noise ratio of each of the precoders according to the sample coded data, taking the peak signal-to-noise ratio as the coding performance parameter, comparing the coding performance parameters corresponding to the precoders, and determining a target group of pictures structure from a plurality of candidate group of pictures structures according to a comparison result of the coding performance parameters; Alternatively, when each of the precoders is configured with a different target bit rate, a peak signal-to-noise ratio of each of the precoders is determined according to the sample coding data, a number of codestream bits of each of the precoders is determined according to the sample coding data, a target weight of the codestream bit number is determined, a weighted number of bits is obtained according to the product of the target weight and the number of codestream bits, the coding performance parameter is obtained according to the sum of the peak signal-to-noise ratio and the weighted number of bits, the coding performance parameters corresponding to each of the precoders are compared, and a target picture group structure is determined from a plurality of the candidate picture group structures according to the comparison result of the coding performance parameters.

10. The video encoding method according to claim 9, characterized in that: The determining the peak signal-to-noise ratio of each of the precoders according to the sample coded data comprises: Decoding the sample coded data to obtain a reference video clip; Determining a first pixel value of an image in the target video segment and a second pixel value of an image in the reference video segment; Calculating a mean square error between the first pixel value and the corresponding second pixel value; The number of pixel bits of the image in the target video segment is determined, and the peak signal-to-noise ratio of each of the pre-encoders is determined according to the mean square error value and the number of pixel bits.

11. The video encoding method according to claim 1, characterized in that: The number of the target video segments is multiple, and the encoding process is performed on the target video segments based on the target encoder to obtain target encoding data of the target video segments, including: Generate a segment identifier corresponding to each of the target video segments, and mark the corresponding target picture group structure according to the segment identifier; Based on the target encoder, the target GOP structure corresponding to the current target video segment is determined according to the segment identifier, and the current target video segment is encoded according to the corresponding target GOP structure to obtain target encoding data of the target video segment.

12. The video encoding method according to claim 1, characterized in that: The step of performing a coding process on the target video segment with a constant bit rate based on multiple pre-coders to obtain sample coded data output by each of the pre-coders includes: Downsampling the target video segment to obtain a downsampled video segment; The down-sampled video segment is coded at a constant bit rate based on multiple pre-coders to obtain sample coded data output by each of the pre-coders.

13. A video encoding method, characterized in that: include: Obtaining a target video clip and a target group of pictures structure, and sending the target group of pictures structure to a target encoder for configuration; Performing encoding processing on the target video segment based on the target encoder to obtain target encoding data of the target video segment; The target picture group structure is based on a plurality of pre-encoders performing a constant bit rate encoding process on the target video segment, obtaining sample encoding data output by each of the pre-encoders, determining encoding performance parameters of each of the pre-encoders according to the sample encoding data, and determining the target picture group structure from a plurality of candidate picture group structures according to the encoding performance parameters. The pre-encoders are configured with a preset candidate picture group structure, and the candidate picture group structures of any two pre-encoders are different.

14. A video encoding device, characterized in that: include: A first encoding module is used to obtain a target video segment, and perform a constant bit rate encoding process on the target video segment based on multiple pre-encoders to obtain sample encoding data output by each of the pre-encoders, wherein the pre-encoders are configured with a preset candidate picture group structure, and the candidate picture group structures of any two of the pre-encoders are different; A first GOP structure configuration module, configured to determine encoding performance parameters of each of the pre-encoders according to the sample encoding data, determine a target GOP structure from a plurality of candidate GOP structures according to the encoding performance parameters, and send the target GOP structure to a target encoder for configuration; The second encoding module is used to perform encoding processing on the target video segment based on the target encoder to obtain target encoding data of the target video segment.

15. A video encoding device, characterized in that: include: A second GOP structure configuration module, configured to obtain a target video clip and a target GOP structure, and send the target GOP structure to a target encoder for configuration; A third encoding module, configured to perform encoding processing on the target video segment based on the target encoder to obtain target encoding data of the target video segment; The target picture group structure is based on a plurality of pre-encoders performing a constant bit rate encoding process on the target video segment, obtaining sample encoding data output by each of the pre-encoders, determining encoding performance parameters of each of the pre-encoders according to the sample encoding data, and determining the target picture group structure from a plurality of candidate picture group structures according to the encoding performance parameters. The pre-encoders are configured with a preset candidate picture group structure, and the candidate picture group structures of any two pre-encoders are different.

16. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the video encoding method according to any one of claims 1 to 13 is implemented.

17. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the video encoding method according to any one of claims 1 to 13 is implemented.

18. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the video encoding method according to any one of claims 1 to 13 is implemented.

Citation Information

Cited By

  • Image transmission method, electronic device, storage medium and computer program product

    CN121531135A

  • Image transmission methods, electronic devices, storage media, and computer program products

    CN121531135B