Video coding method and related product

By dividing video segments in video encoding and using slicing frame numbers and bit rate control parameters, the problem of low video encoding efficiency in the prior art is solved, the encoding speed and hardware resource utilization rate are improved, and the cost is reduced.

CN119110072AActive Publication Date: 2024-12-10XIAOHONGSHU TECH CO LTD

Patent Information

Application Number
CN202411173004.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2024-12-10
Estimated Expiration
2044-08-26

AI Technical Summary

Technical Problem

The existing video encoding technology is inefficient when handling different scenarios and bit rate control, resulting in large data processing volume, high hardware resource consumption, and slow encoding speed.

Method used

By dividing the video to be encoded into multiple video segments, and encoding it using the segmented frame number, reference code rate control parameters and the deviation to be encoded, the target code rate control parameters are determined and encoding are realized, and independent encoding of different video segments is reduced. deal with.

Benefits of technology

It improves video encoding speed, reduces hardware resource requirements, reduces data processing volume, reduces hardware costs, and avoids the possible audio and video asynchronicity and frame drop problems in traditional encoding methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119110072A_ABST
    Figure CN119110072A_ABST
Patent Text Reader

Abstract

The invention discloses a video coding method and a related product. The method comprises: inputting a to-be-coded video, n segmentation frame numbers, a reference code rate control parameter and (n + 1) to-be-coded deviations to a coder, the segmentation frame numbers being frame numbers of video frames in the to-be-coded video, the n segmentation frame numbers being used for determining (n + 1) to-be-coded video segments from the to-be-coded video, and the n being a positive integer; determining (n + 1) to-be-coded video segments determined by the n segmentation frame numbers from the to-be-coded video through an encoder; determining (n + 1) target code rate control parameters by the encoder based on the reference code rate control parameter and (n + 1) to-be-encoded deviations; and encoding the (n + 1) to-be-encoded video segments by the encoder based on the (n + 1) target code rate control parameters to obtain a video encoding result of the to-be-encoded video output by the encoder. Through the method, the video coding speed can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of video encoding technology, and in particular to a video encoding method and related products. Background Art

[0002] By encoding the video, the video can be compressed, thereby reducing the amount of video data, which is beneficial to the storage and transmission of the video. Therefore, how to encode the video is of great significance. Summary of the invention

[0003] The present application provides a video encoding method and related products to improve the video encoding speed, wherein the related products include a video encoding device, an electronic device, a computer-readable storage medium and a computer program product.

[0004] In a first aspect, a video encoding method is provided, the method comprising:

[0005] Inputting a video to be encoded, n segmentation frame numbers, a reference rate control parameter and (n+1) to-be-encoded deviations into an encoder, wherein the segmentation frame number is a frame number of a video frame in the video to be encoded, the n segmentation frame numbers are used to determine (n+1) to-be-encoded video segments from the video to be encoded, n is a positive integer, the to-be-encoded deviations correspond to the to-be-encoded video segments one-to-one, and the to-be-encoded deviations are deviations of the rate control parameters of the to-be-encoded video segments compared to the reference rate control parameters;

[0006] Determining, by the encoder, from the video to be encoded, (n+1) video segments to be encoded that are determined by the n segmentation frame numbers;

[0007] Determining, by the encoder, (n+1) target rate control parameters based on the reference rate control parameters and the (n+1) deviations to be encoded, wherein the video segments to be encoded correspond to the target rate control parameters in a one-to-one manner;

[0008] The encoder encodes the (n+1) video segments to be encoded based on the (n+1) target bit rate control parameters to obtain a video encoding result of the video to be encoded output by the encoder.

[0009] In combination with any implementation manner of the present application, the video to be encoded is a video in a first color space, the encoder is used to process a video in a second color space, and the first color space is different from the second color space;

[0010] Before inputting the video to be encoded, the n segmented frame numbers, the reference rate control parameter and the (n+1) deviations to be encoded into the encoder, the method further includes:

[0011] Converting the video to be encoded from the first color space to the second color space to obtain a converted video;

[0012] The step of inputting the to-be-encoded video, n segmented frame numbers, a reference bit rate control parameter, and (n+1) to-be-encoded deviations into the encoder comprises:

[0013] Inputting the converted video, the n segmented frame numbers, the reference rate control parameter and the (n+1) deviations to be encoded into the encoder;

[0014] The step of determining, by the encoder, from the video to be encoded, the (n+1) video segments to be encoded determined by the n segmentation frame numbers, comprises:

[0015] Determining, by the encoder based on the n segmented frame numbers, from the converted video, (n+1) segments of converted videos corresponding to the (n+1) segments of the video segments to be encoded;

[0016] The step of determining (n+1) target rate control parameters based on the reference rate control parameters and the (n+1) deviations to be encoded by the encoder includes:

[0017] Determining, by the encoder, (n+1) target rate control parameters of the (n+1) converted video segments based on the reference rate control parameters and the (n+1) deviations to be encoded, wherein the converted video segments correspond to the target rate control parameters in a one-to-one manner;

[0018] The step of encoding the (n+1) to-be-encoded video segments based on the (n+1) target bit rate control parameters by the encoder to obtain a video encoding result of the to-be-encoded video output by the encoder includes:

[0019] The encoder encodes the (n+1) to-be-encoded video segments based on the (n+1) target bit rate control parameters to obtain the video encoding result.

[0020] In combination with any embodiment of the present application, encoding the (n+1) converted video segments in the converted video based on the (n+1) key frames, the reference bit rate control parameters and the (n+1) deviations to be encoded by the encoder to obtain the video encoding result includes:

[0021] Determining, by the encoder, a sum of the reference rate control parameter and each of the (n+1) deviations to be encoded, and obtaining (n+1) target rate control parameters of the (n+1) converted video segments, wherein the target rate control parameters correspond to the converted video segments one by one;

[0022] The encoder encodes the (n+1) converted video segments based on the (n+1) key frames and the (n+1) target bit rate control parameters to obtain the video encoding result.

[0023] In combination with any implementation manner of the present application, the (n+1) to-be-encoded video segments include a target video segment, and the (n+1) to-be-encoded deviations include a target deviation corresponding to the target video segment;

[0024] Before inputting the converted video, the n segmented frame numbers, the reference rate control parameter and the (n+1) to-be-encoded deviations into the encoder, the method further includes:

[0025] Extracting features from the target video segment to obtain at least one feature of the target video segment;

[0026] Inputting the at least one feature into a first model to obtain a first relationship output by the first model;

[0027] The first model is used to predict the relationship between the rate control parameter of the video and the bit rate of the reference encoding result based on the characteristics of the video, the reference encoding result is obtained by encoding the video using the rate control parameter of the video, the first relationship is the relationship between the target rate control parameter of the target video segment and the bit rate of the target encoding result, the target encoding result is obtained by encoding the target video segment using the target rate control parameter;

[0028] Based on the first relationship, determining the target rate control parameter of the target video segment;

[0029] Alternatively, the at least one feature is input into a second model to obtain a second relationship output by the second model, wherein the first model is used to predict the relationship between the rate control parameter of the video and the video quality of the reference encoding result based on the feature of the video, and the second relationship is the relationship between the target rate control parameter of the target video segment and the video quality of the target encoding result;

[0030] Based on the second relationship, determining the target rate control parameter of the target video segment;

[0031] A difference between the target rate control parameter and the reference rate control parameter is determined to obtain the target deviation.

[0032] In combination with any implementation manner of the present application, before determining the target bit rate control parameter of the target video segment based on the first relationship, the method further includes:

[0033] Inputting the at least one feature into the second model to obtain the second relationship output by the second model;

[0034] The determining, based on the first relationship, the target rate control parameter of the target video segment includes:

[0035] Based on the first relationship and the second relationship, a rate control parameter that makes the target encoding result meet preset requirements is determined as the target rate control parameter, and the preset requirements include requirements for the rate of the target encoding result and requirements for the video quality of the target encoding result.

[0036] In combination with any implementation manner of the present application, in the video to be encoded, the video frames located on both sides of the segmentation frame number have different scenes, and the video frames located between two adjacent segmentation frame numbers have the same scene.

[0037] In combination with any implementation manner of the present application, the n segmentation frame numbers are determined by a scene detection process, and the scene detection process includes:

[0038] When the scene of consecutive i video frames in the to-be-encoded video is switched from a first scene to a second scene, determining a reference number of reference video frames having the second scene in the i video frames, where i is an integer greater than 1;

[0039] When the reference number is greater than or equal to the first threshold, the minimum frame number of the reference video frame is determined as the segmentation frame number.

[0040] In combination with any implementation manner of the present application, after the scene of the continuous i video frames is switched from the first scene to the second scene, the second scene is switched to the first scene, and the scene detection process further includes:

[0041] When the reference number is greater than or equal to the first threshold, determining the first threshold of the minimum frame number of the reference video frame to be before the segmentation frame number,

[0042] Determining an initial number of initial video frames having the first scene in the i video frames;

[0043] When the reference number is greater than or equal to a first threshold, determining a first threshold of a minimum frame number of the reference video frame as the segmentation frame number includes:

[0044] When the reference number is greater than or equal to a first threshold value and the initial number is less than or equal to the reference number, a minimum frame number of the reference video frame is determined as the segmentation frame number.

[0045] In combination with any embodiment of the present application, the scene detection process further includes: after determining the initial number of initial video frames having the first scene in the i-frame video frames,

[0046] In the case that the initial number is greater than the reference number, a frame number after a maximum frame number is determined as the segmentation frame number, and the maximum frame number is the maximum frame number of the initial video frame.

[0047] In combination with any embodiment of the present application, after the scene of the continuous i video frames is switched from the first scene to the second scene, the second scene is switched to the third scene;

[0048] The scene detection process further includes: when the reference number is greater than or equal to a first threshold, determining that the minimum frame number of the reference video frame is before the segmentation frame number,

[0049] Determining an initial number of initial video frames having the first scene in the i video frames;

[0050] When the reference number is greater than or equal to the first threshold, determining the frame number of the reference video frame whose frame number is smaller than the first threshold as the segmentation frame number includes:

[0051] When the reference number is greater than or equal to the first threshold and the initial number is less than or equal to the second threshold, the minimum frame number of the reference video frame is determined as the segmentation frame number.

[0052] In combination with any embodiment of the present application, the scene detection process further includes: after determining the initial number of initial video frames having the first scene in the i-frame video frames,

[0053] When the initial number is greater than the second threshold value and the reference number is less than a third threshold value, determining the number of to-be-confirmed video frames having the third scene in the i-frame video frames;

[0054] When the number to be confirmed is greater than or equal to the third threshold, the minimum frame number of the video frames to be confirmed is determined to be the segmentation frame number, and the third threshold is less than the second threshold.

[0055] In a second aspect, a video encoding device is provided, the device comprising:

[0056] An input unit, used to input a video to be encoded, n segmented frame numbers, a reference rate control parameter, and (n+1) to-be-encoded deviations into an encoder, wherein the segmented frame number is a frame number of a video frame in the video to be encoded, the n segmented frame numbers are used to determine (n+1) to-be-encoded video segments from the video to be encoded, n is a positive integer, the to-be-encoded deviations correspond to the to-be-encoded video segments in one-to-one correspondence, and the to-be-encoded deviations are deviations of the rate control parameters of the to-be-encoded video segments compared to the reference rate control parameters;

[0057] An encoding unit, configured to determine, by means of the encoder, from the video to be encoded, (n+1) segments of video to be encoded that are determined by the n segmentation frame numbers;

[0058] The encoding unit is configured to determine (n+1) target rate control parameters based on the reference rate control parameters and the (n+1) deviations to be encoded by the encoder, wherein the video segments to be encoded correspond to the target rate control parameters in a one-to-one manner;

[0059] The encoding unit is used to encode the (n+1) to-be-encoded video segments based on the (n+1) target bit rate control parameters through the encoder to obtain a video encoding result of the to-be-encoded video output by the encoder.

[0060] In combination with any implementation manner of the present application, the video to be encoded is a video in a first color space, the encoder is used to process a video in a second color space, and the first color space is different from the second color space;

[0061] The video encoding device further includes: a conversion unit, configured to convert the to-be-encoded video from the first color space to the second color space to obtain a converted video;

[0062] The encoding unit is specifically used for:

[0063] Inputting the converted video, the n segmented frame numbers, the reference rate control parameter and the (n+1) deviations to be encoded into the encoder;

[0064] Determining, by the encoder based on the n segmented frame numbers, from the converted video, (n+1) segments of converted videos corresponding to the (n+1) segments of the video segments to be encoded;

[0065] Determining, by the encoder, (n+1) target rate control parameters of the (n+1) converted video segments based on the reference rate control parameters and the (n+1) deviations to be encoded, wherein the converted video segments correspond to the target rate control parameters in a one-to-one manner;

[0066] The encoder encodes the (n+1) to-be-encoded video segments based on the (n+1) target bit rate control parameters to obtain the video encoding result.

[0067] In combination with any implementation manner of the present application, the encoding unit is specifically used for:

[0068] Using the encoder to take the first frame of the conversion video and the video frames in the conversion video corresponding to the n segmentation frame numbers as (n+1) key frames of the (n+1) conversion video segments, wherein the key frames correspond to the conversion video segments one by one;

[0069] The encoder encodes the (n+1) converted video segments in the converted video based on the (n+1) key frames, the reference bit rate control parameters and the (n+1) deviations to be encoded to obtain the video encoding result.

[0070] In combination with any implementation manner of the present application, the encoding unit is specifically used for:

[0071] Determining, by the encoder, a sum of the reference rate control parameter and each of the (n+1) deviations to be encoded, and obtaining (n+1) target rate control parameters of the (n+1) converted video segments, wherein the target rate control parameters correspond to the converted video segments one by one;

[0072] The encoder encodes the (n+1) converted video segments based on the (n+1) key frames and the (n+1) target bit rate control parameters to obtain the video encoding result.

[0073] In combination with any implementation manner of the present application, the (n+1) to-be-encoded video segments include a target video segment, and the (n+1) to-be-encoded deviations include a target deviation corresponding to the target video segment;

[0074] The video encoding device further includes: a determining unit configured to:

[0075] Extracting features from the target video segment to obtain at least one feature of the target video segment;

[0076] Inputting the at least one feature into a first model to obtain a first relationship output by the first model;

[0077] The first model is used to predict the relationship between the rate control parameter of the video and the bit rate of the reference encoding result based on the characteristics of the video, the reference encoding result is obtained by encoding the video using the rate control parameter of the video, the first relationship is the relationship between the target rate control parameter of the target video segment and the bit rate of the target encoding result, the target encoding result is obtained by encoding the target video segment using the target rate control parameter;

[0078] Based on the first relationship, determining the target rate control parameter of the target video segment;

[0079] Alternatively, the at least one feature is input into a second model to obtain a second relationship output by the second model, wherein the first model is used to predict the relationship between the rate control parameter of the video and the video quality of the reference encoding result based on the feature of the video, and the second relationship is the relationship between the target rate control parameter of the target video segment and the video quality of the target encoding result;

[0080] Based on the second relationship, determining the target rate control parameter of the target video segment;

[0081] A difference between the target rate control parameter and the reference rate control parameter is determined to obtain the target deviation.

[0082] In combination with any implementation manner of the present application, the determining unit is further configured to:

[0083] Inputting the at least one feature into the second model to obtain the second relationship output by the second model;

[0084] Based on the first relationship and the second relationship, a rate control parameter that makes the target encoding result meet preset requirements is determined as the target rate control parameter, and the preset requirements include requirements for the rate of the target encoding result and requirements for the video quality of the target encoding result.

[0085] In combination with any implementation manner of the present application, in the video to be encoded, the video frames located on both sides of the segmentation frame number have different scenes, and the video frames located between two adjacent segmentation frame numbers have the same scene.

[0086] In combination with any implementation manner of the present application, the n segmentation frame numbers are determined by a scene detection process, and the scene detection process includes:

[0087] When the scene of consecutive i video frames in the to-be-encoded video is switched from a first scene to a second scene, determining a reference number of reference video frames having the second scene in the i video frames, where i is an integer greater than 1;

[0088] When the reference number is greater than or equal to the first threshold, the minimum frame number of the reference video frame is determined as the segmentation frame number.

[0089] In combination with any implementation manner of the present application, after the scene of the continuous i video frames is switched from the first scene to the second scene, the second scene is switched to the first scene, and the scene detection process further includes:

[0090] Determining an initial number of initial video frames having the first scene in the i video frames;

[0091] When the reference number is greater than or equal to a first threshold, determining a first threshold of a minimum frame number of the reference video frame as the segmentation frame number includes:

[0092] When the reference number is greater than or equal to a first threshold value and the initial number is less than or equal to the reference number, a minimum frame number of the reference video frame is determined as the segmentation frame number.

[0093] In combination with any embodiment of the present application, the scene detection process further includes: after determining the initial number of initial video frames having the first scene in the i-frame video frames,

[0094] In the case that the initial number is greater than the reference number, a frame number after a maximum frame number is determined as the segmentation frame number, and the maximum frame number is the maximum frame number of the initial video frame.

[0095] In combination with any embodiment of the present application, after the scene of the continuous i video frames is switched from the first scene to the second scene, the second scene is switched to the third scene;

[0096] The scene detection process further includes: when the reference number is greater than or equal to a first threshold, determining that the minimum frame number of the reference video frame is before the segmentation frame number,

[0097] Determining an initial number of initial video frames having the first scene in the i video frames;

[0098] When the reference number is greater than or equal to the first threshold, determining the frame number of the reference video frame whose frame number is smaller than the first threshold as the segmentation frame number includes:

[0099] When the reference number is greater than or equal to the first threshold and the initial number is less than or equal to the second threshold, the minimum frame number of the reference video frame is determined as the segmentation frame number.

[0100] In combination with any embodiment of the present application, the scene detection process further includes: after determining the initial number of initial video frames having the first scene in the i-frame video frames, when the initial number is greater than the second threshold and the reference number is less than a third threshold, determining the number of to-be-confirmed video frames having the third scene in the i-frame video frames;

[0101] When the number to be confirmed is greater than or equal to the third threshold, the minimum frame number of the video frames to be confirmed is determined to be the segmentation frame number, and the third threshold is less than the second threshold.

[0102] According to a third aspect, an electronic device is provided, comprising: a processor and a memory, wherein the memory is used to store computer program code, wherein the computer program code comprises computer instructions, and when the processor executes the computer instructions, the electronic device executes the first aspect and any one of its embodiments described above.

[0103] In a fourth aspect, another electronic device is provided, comprising: a processor, a sending device, an input device, an output device and a memory, wherein the memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device executes the first aspect and any one of its embodiments.

[0104] In a fifth aspect, a computer-readable storage medium is provided, in which a computer program is stored. The computer program includes program instructions. When the program instructions are executed by a processor, the processor is caused to execute the first aspect and any one of its embodiments.

[0105] In a sixth aspect, a computer program product is provided, wherein the computer program product comprises a computer program or instructions, and when the computer program or instructions are run on a computer, the computer is enabled to execute the above-mentioned first aspect and any embodiment thereof.

[0106] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application.

[0107] In the present application, there is a video to be encoded and n segmented frame numbers, wherein the segmented frame number is the frame number of the video frame in the video to be encoded, the n segmented frame numbers are used to determine (n+1) segments of the video to be encoded from the video to be encoded, and the deviation to be encoded is the deviation of the rate control parameter of the video segment to be encoded compared to the reference rate control parameter. After the video to be encoded, the n segmented frame numbers, the reference rate control parameter and the (n+1) deviations to be encoded are input into the encoder, the video encoding device can determine the (n+1) segments of the video to be encoded determined by the n segmented frame numbers from the video to be encoded through the encoder, and can determine the (n+1) target rate control parameters based on the reference rate control parameter and the (n+1) deviations to be encoded through the encoder. Finally, the encoder can encode the (n+1) segments of the video to be encoded based on the (n+1) target rate control parameters to obtain the video encoding result of the video to be encoded output by the encoder. Therefore, the encoder can encode the (n+1) video segments to be encoded by encoding the video to be encoded once, and realize encoding the (n+1) video segments to be encoded by using the bit rate control parameters of the (n+1) video segments to be encoded, thereby reducing the data processing amount for encoding different video segments to be encoded in the video to be encoded using different bit rate control parameters and improving the encoding speed. Furthermore, since the data processing amount can be reduced, it means that this encoding method requires fewer hardware resources, thereby reducing hardware costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0108] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background technology, the drawings required for use in the embodiments of the present application or the background technology will be described below.

[0109] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0110] Figure 1 A schematic diagram of a video encoding method provided in an embodiment of the present application;

[0111] Figure 2 A schematic diagram of the structure of a deep learning model provided in an embodiment of the present application;

[0112] Figure 3 A schematic diagram of the architecture of a video on demand system is provided for an embodiment of the present application;

[0113] Figure 4 A schematic diagram of the structure of a video encoding device provided in an embodiment of the present application;

[0114] Figure 5 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0115] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0116] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0117] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0118] The execution subject of the embodiment of the present application is a video encoding device, wherein the video encoding device can be any electronic device that can execute the technical solution disclosed in the embodiment of the method of the present application. Optionally, the video encoding device can be one of the following: a computer, a server.

[0119] It should be understood that the method embodiment of the present application can also be implemented by a processor executing a computer program code. The following describes the embodiment of the present application in conjunction with the drawings in the embodiment of the present application. Figure 1 , Figure 1 A flowchart of a video encoding method provided in an embodiment of the present application.

[0120] 101. Input a video to be encoded, n segmented frame numbers, a reference bit rate control parameter and (n+1) deviations to be encoded into an encoder.

[0121] In the embodiment of the present application, the video to be encoded may be any video. For example, the video to be encoded is a video on a video-on-demand platform, or for another example, the video to be encoded is a video captured by a mobile phone.

[0122] In an embodiment of the present application, the segmented frame number is the frame number of the video frame in the video to be encoded, and the frame number of the video frame in the video to be encoded represents the display order of the video frame in the video to be encoded. For example, the video frame to be encoded includes video frame a and video frame b, wherein the frame number of video frame a is 1, and the frame number of video frame b is 2. Then, when displaying the video frame to be encoded, video frame a is displayed first, and then video frame b is displayed.

[0123] The n segmentation frame numbers are used to determine (n+1) segments of the video to be encoded from the video to be encoded, where n is a positive integer. For example, n=1, and the n segmentation frame numbers are 101 frames. If the video to be encoded has a total of 180 video frames, then based on the n segmentation frame numbers, the following two segments of the video to be encoded can be determined from the video to be encoded: the 1st frame to the 100th frame in the video to be encoded is a segment of the video to be encoded, and the 101st frame to the 180th frame in the video to be encoded is a segment of the video to be encoded. For another example, n=2, and the n segmentation frame numbers include 88 frames and 150 frames. If the video to be encoded has a total of 180 video frames, then the following three video segments to be encoded can be determined from the video to be encoded based on n segmentation frame numbers: the 1st to 87th frames in the video to be encoded are a video segment to be encoded, the 88th to 149th frames in the video to be encoded are a video segment to be encoded, and the 150th to 180th frames in the video to be encoded are a video segment to be encoded. It should be understood that (n+1) video segments to be encoded can be determined from the video to be encoded based on n segmentation frame numbers, which means that (n+1) video segments to be encoded are defined from the entire video to be encoded, and the video to be encoded is not segmented into (n+1) video segments to be encoded.

[0124] Optionally, in the video to be encoded, the video frames located on both sides of the segmentation frame number have different scenes, and the video frames located between two adjacent segmentation frame numbers have the same scene. Since the video frames located on both sides of the segmentation frame number belong to different video segments to be encoded, and the video frames located between two adjacent segmentation frame numbers belong to the same video segment to be encoded, different video segments to be encoded have different scenes, and the video frames in the same video segment to be encoded have the same scene.

[0125] Optionally, an encoder is used to perform scene detection on the video to be encoded, and the scene in the video to be encoded can be determined, and then the segmentation frame number can be determined based on the scene in the video to be encoded, so that the video frames on both sides of the segmentation frame number have different scenes, and the video frames between two adjacent segmentation frame numbers have the same scene. Optionally, the encoder for performing scene detection on the video to be encoded can be different from the encoder in step 101.

[0126] Optionally, the encoder can extract image information of each video frame in the video to be encoded by encoding the video to be encoded, and then determine whether different video frames have the same scene based on the image information of each video frame, so as to determine the segmentation frame number based on the judgment result, wherein the image information includes color. In a possible implementation, the encoder generates a histogram for each video frame in the video to be encoded by encoding the video to be encoded, wherein the histogram can represent the distribution of the color of the pixels in the video frame. For two adjacent video frames in the video to be encoded, the difference between the histograms of the two is determined. When the difference is greater than or equal to the difference threshold, it means that the difference in the content of the two adjacent video frames is large, and then it is determined that the two adjacent video frames have different scenes. When the difference is less than the difference threshold, it means that the difference in the content of the two adjacent video frames is small, and then it is determined that the two adjacent video frames have the same scene. When it is determined that the two adjacent video frames have different scenes, the maximum frame number of the two adjacent video frames is used as the segmentation frame number.

[0127] In one possible implementation, the similarity of video frames in the same video segment to be encoded is greater than a similarity threshold, and the similarity of video frames in different video segments to be encoded is less than or equal to the similarity threshold, that is, the similarity of video frames with the same scene is greater than the similarity threshold, and the similarity of video frames with different scenes is less than or equal to the similarity threshold. In another possible implementation, the scene is a background. Video frames in the same video segment to be encoded contain the same background, and video frames in different video segments to be encoded contain different backgrounds. In yet another possible implementation, the scene includes an area that includes an eye-focused area and an area that does not include an eye-focused area. Video frames that include an eye-focused area and video frames that do not include an eye-focused area belong to different video segments to be encoded, wherein the eye-focused area is an area in the video frame that is focused on by the eye, and optionally, the eye-focused area is a region of interest (ROI). In another possible implementation, the scene includes high picture complexity and low picture complexity, and the video frames with picture complexity higher than the complexity threshold and the video frames with picture complexity lower than the complexity threshold belong to different video segments to be encoded, wherein the higher the picture complexity of the video frame, the higher the bit rate required for encoding the video frame. Optionally, the picture complexity of the video frame can be determined based on the magnitude of the gradient of the video frame, and specifically, the amplitude is positively correlated with the picture complexity.

[0128] In the embodiment of the present application, the rate control parameter is a parameter used to control the rate of the encoding result of the video. Optionally, the rate control parameter is one of the following: constant rate factor (CRF), constant bit rate (CBR), variable bit rate (VBR), constant QP (CQP).

[0129] In an embodiment of the present application, the reference rate control parameter is a preset rate control parameter. Optionally, the reference rate control parameter is determined based on historical experience. For example, the rate control parameter is CRF. Based on historical experience, when CRF is 32, the rate of the encoding result obtained by encoding the video using CRF meets expectations, so the reference rate control parameter can be determined to be 32. For another example, the rate control parameter is CRF. Based on historical experience, when CRF is 33, the quality of the video obtained by encoding the video using CRF and then decoding the encoding result meets expectations, so the reference rate control parameter can be determined to be 33.

[0130] In the embodiment of the present application, the deviation to be encoded corresponds to the video segment to be encoded one by one, that is, each video segment to be encoded has a deviation to be encoded. The deviation to be encoded is the deviation of the rate control parameter of the video segment to be encoded compared with the reference rate control parameter. Based on the deviation to be encoded and the reference rate control parameter of the video segment to be encoded, the rate control parameter of the video segment to be encoded can be determined. The deviation to be encoded can be a positive number or a negative number. For example, the rate control parameter is CRF. The reference rate control parameter is 32, and the deviation to be encoded of the video segment to be encoded is 3, then the rate control parameter of the video segment to be encoded is 32+3=35. For another example, the rate control parameter is CRF. The reference rate control parameter is 32, and the deviation to be encoded of the video segment to be encoded is -1, then the rate control parameter of the video segment to be encoded is 32-1=31.

[0131] Optionally, when different video segments to be encoded have different scenes, the bit rates required for encoding different video segments to be encoded are different, so the bit rate control parameters of different video segments to be encoded are different, and accordingly, different deviations to be encoded are different. In one possible implementation, video frames containing areas of human eye attention and video frames not containing areas of human eye attention belong to different video segments to be encoded. For the convenience of expression, the video segments to be encoded to which the video frames containing areas of human eye attention belong are referred to as video segments to which the human eye attention belongs, and the video segments to which the video frames not containing areas of human eye attention belong are referred to as video segments to which the human eye does not pay attention. Then, the bit rate required for encoding the video segments to which the human eye pays attention is higher than the bit rate required for encoding the video segments to which the human eye does not pay attention, which results in the deviations to be encoded of the video segments to which the human eye pays attention being different from the deviations to be encoded of the video segments to which the human eye does not pay attention being different. In another possible implementation, video frames whose picture complexity is higher than a complexity threshold and video frames whose picture complexity is lower than a complexity threshold belong to different video segments to be encoded. For the sake of convenience, the video segments to be encoded to which video frames with picture complexity higher than the complexity threshold belong are referred to as complex video segments, and the video segments to be encoded to which video frames with picture complexity higher than the complexity threshold belong are referred to as simple video segments. Then, the bit rate required to encode the complex video segments is higher than the bit rate required to encode the simple video segments, which results in the deviation to be encoded of the complex video segments being different from the deviation to be encoded of the simple video segments.

[0132] In a possible implementation, after determining the rate control parameter of the video segment to be encoded, the video encoding device determines the difference between the rate control parameter of the video segment to be encoded and a reference rate control parameter to obtain a deviation to be encoded.

[0133] In the embodiment of the present application, the encoder can be any encoder, and optionally, the encoder is one of the following: an encoder built based on the H.265 standard, an encoder built based on the H.264 standard, an encoder built based on the H.266 standard, and an encoder built based on the Open Multimedia Alliance (AOMedia Video 1, AV1) standard. By inputting the bit rate control parameters and the video to the encoder, the encoder can encode the video using the bit rate control parameters.

[0134] By inputting a rate control parameter to the encoder, the encoder can complete one encoding based on the rate control parameter. Since the rate control parameters of different video segments to be encoded are different, in order to express the rate control parameters of different video segments to be encoded by one rate control parameter, the video encoding parameter inputs a reference rate control parameter and (n+1) deviations to be encoded to the encoder, so that the encoder can determine the rate control parameters of (n+1) video segments to be encoded based on the reference rate control parameter and (n+1) deviations to be encoded during one encoding process.

[0135] Since encoding by the encoder is to encode a segment of video, and the video to be encoded includes (n+1) segments of video to be encoded, in order to enable the encoder to distinguish different segments of video to be encoded in the video to be encoded, the video encoding device inputs the video to be encoded and n segmentation frame numbers to the encoder. In this way, the encoder can determine (n+1) segments of video to be encoded from the video to be encoded based on the n segmentation frame numbers. Optionally, after obtaining the n segmentation frame numbers, the video encoder stores the n segmentation frame numbers as a file in a comma-separated values ​​(CSV) format, and inputs the CSV format file to the encoder. Optionally, in the CSV file, the arrangement order of the n segmentation frame numbers is determined based on the presentation time stamp (PTS) of the video frame corresponding to the segmentation frame number.

[0136] Therefore, after the video encoding device inputs the video to be encoded, n segmented frame numbers, the reference rate control parameters and (n+1) deviations to be encoded into the encoder, the encoder can determine (n+1) video segments to be encoded from the video to be encoded based on the n segmented frame numbers, and can determine the rate control parameters of the (n+1) video segments to be encoded based on the reference rate control parameters and the (n+1) deviations to be encoded. Then, the rate control parameters of the (n+1) video segments to be encoded can be used to encode the (n+1) video segments to be encoded, and the encoding of the video to be encoded is completed to obtain a video encoding result, wherein the video encoding result is the encoding result of the video to be encoded.

[0137] 102. Determine, by means of the encoder, from the video to be encoded, an (n+1)th video segment to be encoded which is determined by the n segmentation frame numbers.

[0138] The encoder uses the first frame of the video to be encoded and the video frame corresponding to the segmentation frame number as the starting video frame of a video segment to be encoded, and can determine (n+1) video segments to be encoded determined by n segmentation frame numbers from the video to be encoded.

[0139] 103. Determine (n+1) target rate control parameters through the encoder based on the reference rate control parameters and the (n+1) deviations to be encoded.

[0140] In the embodiment of the present application, the video segment to be encoded corresponds to the target rate control parameter one-to-one. Since the deviation to be encoded represents the deviation of the rate control parameter of the video segment to be encoded compared with the reference rate control parameter, the video encoding device can determine (n+1) target rate control parameters based on the reference rate control parameter and (n+1) deviations to be encoded. In a possible implementation method, the encoder determines the sum of the reference rate control parameter and each of the (n+1) deviations to be encoded to obtain the (n+1) target rate control parameters of the (n+1) converted video segment.

[0141] 104. Encode the (n+1) to-be-encoded video segments based on the (n+1) target bit rate control parameters through the encoder to obtain a video encoding result of the to-be-encoded video output by the encoder.

[0142] The video encoding device encodes any one of the (n+1) video segments to be encoded using the corresponding target bit rate control parameters. After the encoding of the (n+1) video segments to be encoded is completed, the encoding of the video to be encoded can be completed to obtain a video encoding result. In this process, the encoder uses different target bit rate control parameters to encode different parts of the video to be encoded, and does not divide the video to be encoded into (n+1) video segments to be encoded and then encode the (n+1) video segments to be encoded separately.

[0143] In one possible implementation, the encoder uses the first frame in the video to be encoded and the video frames corresponding to the n segmented frame numbers in the video to be encoded as the (n+1) key frames (intra-coded frames) of the (n+1) segment of the video to be encoded. The encoder determines the rate control parameters of the (n+1) segment of the video to be encoded based on the reference rate control parameters and the (n+1) deviations to be encoded. The encoder encodes the (n+1) segment of the video to be encoded based on the rate control parameters of the (n+1) segment of the video to be encoded and the (n+1) key frames of the (n+1) segment of the video to be encoded to obtain a video encoding result.

[0144] In the embodiment of the present application, there is a video to be encoded and n segmented frame numbers, wherein the segmented frame number is the frame number of the video frame in the video to be encoded, the n segmented frame numbers are used to determine (n+1) segments of the video to be encoded from the video to be encoded, and the deviation to be encoded is the deviation of the rate control parameter of the video segment to be encoded compared to the reference rate control parameter. After the video encoding device inputs the video to be encoded, the n segmented frame numbers, the reference rate control parameter and the (n+1) deviations to be encoded into the encoder, the encoder can determine the (n+1) segments of the video to be encoded determined by the n segmented frame numbers from the video to be encoded, and the encoder can determine the (n+1) target rate control parameters based on the reference rate control parameters and the (n+1) deviations to be encoded. Finally, the encoder can encode the (n+1) segments of the video to be encoded based on the (n+1) target rate control parameters to obtain the video encoding result of the video to be encoded output by the encoder. Therefore, the encoder can encode the (n+1) video segments to be encoded by encoding the video to be encoded once, and realize encoding the (n+1) video segments to be encoded by using the bit rate control parameters of the (n+1) video segments to be encoded, thereby reducing the data processing amount for encoding different video segments to be encoded in the video to be encoded using different bit rate control parameters and improving the encoding speed. Furthermore, since the data processing amount can be reduced, it means that this encoding method requires fewer hardware resources, thereby reducing hardware costs.

[0145] Specifically, the conventional video encoding method usually first determines n segmentation frame numbers from the video to be encoded, and then segments the video to be encoded into (n+1) video segments to be encoded based on the n segmentation frame numbers. For each of the (n+1) video segments to be encoded, the video segment to be encoded and the rate control parameter of the video segment to be encoded are input into the encoder, so that the encoder encodes the video segment to be encoded based on the rate control parameter of the video segment to be encoded to obtain a sub-encoding result of the video segment to be encoded. By encoding the (n+1) video segments to be encoded, (n+1) sub-encoding results can be obtained. Finally, the encoding result of the video to be encoded is obtained by splicing the (n+1) sub-encoding results.

[0146] However, if the segmentation frame number is usually not a key frame, then there is no key frame in the video segment to be encoded, and the encoder cannot encode the video segment to be encoded. Therefore, when the segmentation frame number is not a key frame, the traditional video encoding method needs to encode the video to be encoded, set the video frame corresponding to the segmentation frame number as a key frame, and then divide the video to be encoded into (n+1) segments to be encoded based on n segmentation frame numbers, and use the encoder to encode the (n+1) segments to be encoded.

[0147] The implementation of the present application can encode the (n+1) segments of the video to be encoded by encoding the video to be encoded once, and realize the encoding of the (n+1) segments of the video to be encoded by using the bit rate control parameters of the (n+1) segments of the video to be encoded. Therefore, compared with the traditional video encoding method, the overhead of setting the video frame corresponding to the segmentation frame number as a key frame by encoding the video to be encoded can be omitted, thereby reducing the amount of data processing and improving the encoding speed. Since the amount of data processing can be reduced, the hardware cost can be reduced. For example, if the set of the videos to be encoded is encoded according to the traditional video encoding method, 100,000 central processing unit (CPU) cores are required. If the method provided by the embodiment of the present application is used to encode the set of videos to be encoded, the data processing amount can be reduced by 20% compared with the traditional video encoding method. Then, the number of CPU cores required for encoding the set of videos to be encoded using the method provided by the embodiment of the present application is 80,000. At this time, encoding the same set of videos to be encoded, the embodiment of the present application can save 20,000 CPU cores, and thus save the cost of 20,000 CPU cores.

[0148] In addition, the conventional encoding method splices (n+1) sub-encoding results based on the timestamp of the video to be encoded to obtain the encoding result of the video to be encoded. Therefore, if there is an error in the timestamp of the video to be encoded, the display order of the video frames in the spliced ​​encoding result is different from the display of the video frames in the video to be encoded. For example, in the video to be encoded, the timestamp of the 10th frame is t1, and the timestamp of the 11th frame is t2. If t2 is less than t1, then in the spliced ​​encoding result, the display order of the 11th frame is before the display order of the 10th frame. However, in the video to be encoded, the display order of the 10th frame is before the display order of the 11th frame. If the display order of the video frames in the spliced ​​encoding result is different from the display of the video frames in the video to be encoded, then after the encoding result of the video to be encoded is decoded to obtain a decoded video, the problem of mismatch between the audio frame and the video frame will occur when playing the decoded video and the audio corresponding to the decoded video, that is, the problem of audio and video being out of sync. Furthermore, if the timestamp of the video to be encoded is wrong, the encoding result obtained by splicing may also have frame loss problems compared to the video to be encoded. However, since the video segments to be encoded are not segmented in the embodiment of the present application, the video encoding result of the video to be encoded can be directly obtained through the encoding of the encoder, and there is no need to perform the step of splicing the sub-encoding results, thereby avoiding the problems of audio and video asynchrony and frame loss caused by splicing the sub-encoding results.

[0149] Furthermore, since the embodiment of the present application completes the process of determining (n+1) video segments to be encoded from the video to be encoded by using the bit rate control parameters of the (n+1) video segments to be encoded and encoding the (n+1) video segments to be encoded, relevant personnel can integrate the process of determining (n+1) video segments to be encoded from the video to be encoded and encoding the (n+1) video segments to be encoded into the same program code when developing the program code for implementing the technical solution of the embodiment of the present application. This can save the manpower cost of development and facilitate the subsequent maintenance of the program code, compared with the process of different personnel developing the program code for determining (n+1) video segments to be encoded from the video to be encoded and encoding the (n+1) video segments to be encoded.

[0150] In a possible scenario, the video encoding device is a server running a video on demand platform. After receiving the video to be encoded uploaded by the user of the video on demand platform, the video encoding device can encode the (n+1) video segments to be encoded in the video to be encoded by the video encoding method provided in the embodiment of the present application to obtain a video encoding result, and then different bit rate control parameters can be used to encode different video segments to be encoded, so that different bit rate control parameters can be selected for encoding according to different video contents, thereby improving the video quality of the video encoding result and reducing the bit rate of the video encoding result. After obtaining the video encoding result, the video encoding result can be published to the video on demand platform.

[0151] As an optional implementation, the video to be encoded is a video in a first color space, and the encoder is used to process the video in a second color space, wherein the first color space is different from the second color space. Optionally, the first color space is an RGB color space and the second color space is a YUV color space. In this case, the video to be encoded is a video in RGB format, and the encoder is used to process the video in YUV format, wherein R represents red, G represents green, B represents blue, Y represents luminance, U represents red chroma, and V represents blue chroma.

[0152] In this implementation manner, the video encoding device further performs the following steps before performing step 101:

[0153] 201. Convert the video to be encoded from the first color space to the second color space to obtain a converted video.

[0154] Since the encoder is used to process the video in the second color space, the video encoding device can convert the video to be encoded into a converted video that can be processed by the encoder by executing step 201. In a possible implementation, the first color space is an RGB color space, and the second color space is a YUV color space. The video encoding device obtains the converted video by converting the video to be encoded from the RGB color space to the YUV color space.

[0155] After obtaining the converted video, the video encoding device performs the following steps during the process of executing step 101:

[0156] 202. Input the converted video, the n segmented frame numbers, the reference rate control parameter and the (n+1) deviations to be encoded into the encoder.

[0157] After obtaining the converted video, the video encoding device performs the following steps in the process of executing step 102:

[0158] 203. Determine, by the encoder based on the n segmented frame numbers, from the converted videos (n+1) segments of converted videos corresponding to the (n+1) segments of the to-be-encoded video segments.

[0159] In the embodiment of the present application, the (n+1) converted video segments in the converted video are determined based on n segmentation frame numbers. The implementation method of determining the (n+1) converted video segments from the converted video based on the n segmentation frame numbers can be referred to the implementation method of determining the (n+1) video segments to be encoded from the video to be encoded based on the n segmentation frame numbers in step 101, which will not be repeated here.

[0160] Since the converted video is a video that can be processed by the encoder, after the video encoding device inputs the converted video, n segmented frame numbers, the reference bit rate control parameters and (n+1) deviations to be encoded into the encoder, the encoder can determine (n+1) converted video segments from the converted video based on the n segmented frame numbers.

[0161] After obtaining the converted video, the video encoding device performs the following steps in the process of executing step 103:

[0162] 204. Determine, by the encoder, (n+1) target rate control parameters of the (n+1) converted video segments based on the reference rate control parameters and the (n+1) deviations to be encoded.

[0163] Since the video segments to be encoded correspond to the target rate control parameters one-to-one, the video segments to be encoded correspond to the converted video segments one-to-one, and the converted video segments correspond to the target rate control parameters one-to-one, the encoder can determine the (n+1) target rate control parameters of the (n+1) converted video segments based on the reference rate control parameters and the (n+1) deviations to be encoded.

[0164] After obtaining the converted video, the video encoding device performs the following steps in the process of executing step 104:

[0165] 205. Encode the (n+1) to-be-encoded video segments through the encoder based on the (n+1) target bit rate control parameters to obtain the video encoding results.

[0166] The video encoding device encodes any one of the (n+1) converted video segments using the corresponding target bit rate control parameters. After the encoding of the (n+1) converted video segments is completed, the encoding of the converted video can be completed. Since the converted video is obtained by converting the video to be encoded, the result obtained by encoding the converted video is the result obtained by encoding the video to be encoded. Therefore, the encoder encodes the (n+1) video segments to be encoded based on the (n+1) target bit rate control parameters to obtain a video encoding result.

[0167] In this implementation, since the encoder is used to process the video in the second color space, and the video to be encoded is not a video in the second color space, before using the encoder to encode the video to be encoded, it is necessary to convert the video to be encoded into the second color space to obtain a converted video. Then, the converted video, n segmentation frame numbers, the reference bit rate control parameter and (n+1) deviations to be encoded are input into the encoder, and the video encoding result can be obtained through the encoding of the encoder.

[0168] Because in this implementation, the encoder only needs to perform encoding once, so the video encoding device only needs to perform a color space conversion on the video to be encoded, wherein the color space conversion refers to converting the video to be encoded from the first color space to the second color space. If it is a traditional video encoding method, it is necessary to first encode the video to be encoded, set the video frame corresponding to the segmentation frame number as a key frame, and then encode the (n+1) segments of the video to be encoded, that is, the traditional video encoding method needs to perform encoding twice, and then needs to perform two color space conversions. Therefore, compared with the traditional video encoding method, this implementation method can save the cost of one color space conversion, thereby reducing the amount of data processing, increasing the encoding speed, and reducing the hardware cost.

[0169] As an optional implementation manner, the video encoding device performs the following steps during the process of executing step 205:

[0170] 301. Using the encoder, the first frame of the conversion video and the video frames in the conversion video corresponding to the n segmentation frame numbers are used as (n+1) key frames of the (n+1) conversion video segments.

[0171] In the embodiment of the present application, the first frame of the converted video and the video frames corresponding to the n segmented frame numbers are all key frames. The key frames correspond to the converted video segments one by one, that is, one converted video segment has one key frame. Optionally, the key frame is an instantaneous decoding refresh (IDR) frame.

[0172] 302. Encode the (n+1) converted video segments in the converted video based on the (n+1) key frames, the reference bit rate control parameters and the (n+1) deviations to be encoded by the encoder to obtain the video encoding result.

[0173] The encoder can determine the rate control parameters of the (n+1) conversion video segments based on the reference rate control parameters and the (n+1) deviations to be encoded, and then can encode the (n+1) conversion video segments based on the rate control parameters of the (n+1) conversion video segments and the (n+1) key frames to obtain video encoding results.

[0174] In a possible implementation, an encoder determines a sum of a reference rate control parameter and each of the (n+1) deviations to be encoded, and obtains (n+1) target rate control parameters of the (n+1) converted video segments, wherein the target rate control corresponds to the converted video segment one by one. The encoder encodes the (n+1) converted video segments based on the (n+1) key frames and the (n+1) target rate control parameters to obtain a video encoding result.

[0175] As an optional implementation, the (n+1) video segments to be encoded include a target video segment, and the (n+1) deviations to be encoded include a target deviation corresponding to the target video segment, wherein the target video segment can be any one of the (n+1) video segments to be encoded.

[0176] In this implementation manner, the video encoding device obtains the target deviation by performing the following steps:

[0177] 401. Perform feature extraction on the target video segment to obtain at least one feature of the target video segment.

[0178] In the embodiment of the present application, when the number of features of the target video segment is greater than 1, different features include information of different dimensions. In a possible implementation, the features of the target video segment include: video content features, encoding result features, and pre-encoding features.

[0179] The video content features include one or more of the following: texture information, noise information, blind video quality assessment (BVQA) information, block effect information, blur degree information, and spatiotemporal information. Among them, texture information is the information of texture in the target video segment. Noise information can be used to evaluate the intensity and distribution of noise in the video, and noise will affect the clarity and perception of the video. The non-parametric quality assessment information refers to the quality score predicted from the target video segment based on the statistical analysis of the video signal of the target video segment or the machine learning model, and the prediction does not depend on the reference video. Block effect information can represent the image blocking effect caused by compression or other processing, which is usually manifested as a clear boundary in the image (i.e., the video frame of the target video segment), affecting the visual continuity. Blur degree information can measure the blur degree of the video, which can usually be determined by analyzing the sharpness or edge information of the video frame. Spatiotemporal information includes the time domain information of the target video segment and the spatial domain information of the target video segment. For example, the time domain information can be the correlation between different video frames in the target video segment, and the spatial domain information can be the complexity of the scene in the video frame in the target video segment.

[0180] Optionally, the texture information is a video spatial texture feature. The video encoding device can extract the video spatial texture features of the target video segment based on the gray-level co-occurrence matrix (GLCM). Among them, the gray-level co-occurrence matrix is ​​a commonly used image processing technology, which is used to analyze the texture features of an image. The co-occurrence matrix reflects the co-occurrence probability of different gray levels in space, thereby capturing the texture information of the image, such as roughness, regularity, etc. When applied to video, each color video frame in the video can be first converted into a grayscale image, and then the co-occurrence matrix of the pixel grayscale values ​​in each frame can be calculated. By analyzing these matrices, indicators reflecting the texture characteristics of the video frame can be extracted, such as contrast, correlation, entropy, etc.

[0181] Optionally, the spatiotemporal information includes spatiotemporal correlation features of the video, and the spatiotemporal correlation features of the target video segment are extracted based on a preset spatiotemporal domain algorithm. The spatiotemporal domain algorithm may include motion estimation, optical flow calculation, or a technology based on time series analysis to capture information such as dynamic behavior, motion trajectory, and scene transition of objects in the video. Through these analyses, features in both time and space dimensions such as the law of video content change, action coherence, or scene complexity can be extracted.

[0182] The encoding result characteristics are the characteristics of the encoding result obtained by encoding the target video segment using the preset bit rate control parameters, wherein the preset bit rate control parameters are determined based on historical experience. For example, the bit rate control parameter is CRF. Based on historical experience, when the CRF is 32, the bit rate of the encoding result obtained by encoding the video using CRF meets expectations, so it can be determined that the preset bit rate control parameter is 32. For another example, the bit rate control parameter is CRF. Based on historical experience, when the CRF is 33, the quality of the video obtained by encoding the video using CRF and then decoding the encoding result meets expectations, so it can be determined that the preset bit rate control parameter is 33.

[0183] The encoding result feature includes one or more of the following: a preset rate control parameter and a multi-method fusion evaluation index (VideoMuitimethod Assessment Fusion, VMAF) of the encoding result obtained by encoding the target video segment using the preset rate control parameter, a preset rate control parameter and a bit rate of the encoding result obtained by encoding the target video segment using the preset rate control parameter.

[0184] The precoding features include one or more of the following: intra-frame prediction coding information, inter-frame prediction coding information, motion vector information, quantization step information, peak signal-to-noise ratio, prediction mode (or coding mode) information, block division information, video bit rate of the precoding result, VMAF value of the precoding result, video width and height of the target video segment, and video frame rate of the target video segment.

[0185] Among them, intra prediction refers to predicting the content of the current block within the same frame using the encoded information around the pixel block. It is suitable for I frames (key frames) and helps with random access and error recovery of videos. Inter prediction uses the similarity between the previous and next frames to predict the content of the current frame. It is usually used for P frames (forward prediction frames) and B frames (bidirectional prediction frames), which can greatly improve compression efficiency. Among them, the motion vector refers to the displacement of the current block relative to the corresponding block in the reference frame in inter prediction. It is used to compensate for motion and is the key to reducing spatial redundancy in video compression. Among them, the size of the quantization step during the encoding process affects the degree of compression and the quality of the video. Among them, block division information and prediction mode information refer to the macroblock (or sub-macroblock) division of the video frame during the encoding process and the selection of the best prediction mode. The encoding process allows block division in different sizes and shapes (such as 16x16, 8x8, 4x4, etc.), as well as multiple prediction modes (such as DC, plane, directional prediction of various angles, etc.) to achieve the best compression effect.

[0186] 402. Input the at least one feature into a first model to obtain a first relationship output by the first model.

[0187] In an embodiment of the present application, the first model can predict the relationship between the rate control parameters of the video and the bit rate of the reference encoding result based on the characteristics of the video, wherein the reference encoding result is obtained by encoding the video using the rate control parameters of the video. In this relationship, the rate control parameters correspond to the bit rate of the reference encoding result one-to-one. Based on this relationship, it can be determined that for a certain specific rate control parameter, the bit rate of the encoding result obtained by encoding the video using the specific rate control parameter is what. Based on this relationship, it can also be determined that for a certain specific bit rate, how large the rate control parameter is used to encode the video can make the bit rate of the encoding result the specific bit rate.

[0188] Optionally, the first model is trained through the following training process: the training features of the training video are input into the first model to obtain a first training relationship predicted by the first model, wherein the first training relationship is a rate control parameter of the training video and the rate of the encoding result obtained by encoding the training video using the rate control parameter. Based on the first difference between the first training relationship and the first true value (ground truth, GT), the first loss of the first model is obtained, wherein the first difference is positively correlated with the first loss. The parameters of the first model are updated based on the first loss until the first loss converges, thereby completing the training of the first model.

[0189] In the case where the first model is used to predict the relationship between the rate control parameter of the video and the bit rate of the reference encoding result based on the characteristics of the video, after the video encoding device inputs at least one characteristic into the first model, the first model can predict the relationship between the target rate control parameter of the target video segment and the bit rate of the target encoding result based on at least one characteristic of the target video segment, wherein the target encoding result is obtained by encoding the target video segment using the target rate control parameter. Therefore, the first relationship is the relationship between the target rate control parameter of the target video segment and the bit rate of the target encoding result. Optionally, the first relationship is a curve representing the relationship between the target rate control parameter of the target video segment and the bit rate of the target encoding result.

[0190] 403. Determine the target rate control parameter of the target video segment based on the first relationship.

[0191] Because it can be determined based on the first relationship that for a certain specific bit rate, the bit rate control parameter used to encode the video can make the bit rate of the encoding result the specific bit rate, so the video encoding device can determine the target bit rate control parameter based on the first relationship, so that the bit rate of the target encoding result meets the requirement. For example, if the bit rate of the target encoding result is required not to exceed the bit rate threshold, then the bit rate control parameter that makes the bit rate of the target encoding result not exceed the bit rate threshold can be determined based on the first relationship as the target bit rate control parameter.

[0192] 404. Determine a difference between the target rate control parameter and the reference rate control parameter to obtain the target deviation.

[0193] The video encoding apparatus determines a result of subtracting a reference rate control parameter from a target rate control parameter as a target deviation.

[0194] In this embodiment, after the video encoding device extracts features from the target video segment and obtains at least one feature of the target video segment, the at least one feature is input into the first model to obtain a first relationship output by the first model, wherein the first relationship is a relationship between a target rate control parameter of the target video segment and the bit rate of the target encoding result. The video encoding device determines the target rate control parameter of the target video segment based on the first relationship, so that the bit rate of the target encoding result obtained by encoding the target video segment using the target rate control parameter meets the requirements. After obtaining the target rate control parameter, the difference between the target rate control parameter and the reference rate control parameter is determined to obtain a target deviation.

[0195] In this implementation manner, the video encoding device may also obtain the target deviation by executing the following steps:

[0196] 501. Perform feature extraction on the target video segment to obtain at least one feature of the target video segment.

[0197] The implementation of this step can refer to step 401 and will not be described in detail here.

[0198] 502. Input the at least one feature into a second model to obtain a second relationship output by the second model.

[0199] In an embodiment of the present application, the second model can predict the relationship between the rate control parameters of the video and the video quality of the reference encoding result based on the characteristics of the video. It should be understood that the video quality of the encoding result is the quality of the video obtained by decoding the encoding result, and optionally, the quality is represented by VMAF. In this relationship, the rate control parameters correspond one-to-one to the video quality of the reference encoding result. Based on this relationship, it can be determined that for a certain specific rate control parameter, the video quality of the encoding result obtained by encoding the video using the specific rate control parameter is what. Based on this relationship, it can also be determined that for a certain specific video quality, what rate control parameter is used to encode the video so that the video quality of the encoding result is the specific video quality.

[0200] Optionally, the second model is trained through the following training process: the training features of the training video are input into the second model to obtain a second training relationship predicted by the second model, wherein the second training relationship is the rate control parameter of the training video and the video quality of the encoding result obtained by encoding the training video using the rate control parameter. Based on the second difference between the first training relationship and the second GT, the second loss of the second model is obtained, wherein the second difference is positively correlated with the second loss. The parameters of the second model are updated based on the second loss until the second loss converges, thereby completing the training of the second model.

[0201] In the case where the second model is used to predict the relationship between the rate control parameter of the video and the video quality of the reference coding result based on the characteristics of the video, after the video coding device inputs at least one characteristic into the second model, the second model can predict the relationship between the target rate control parameter of the target video segment and the video quality of the target coding result based on the at least one characteristic of the target video segment. Therefore, the second relationship is the relationship between the target rate control parameter of the target video segment and the video quality of the target coding result. Optionally, the second relationship is a curve representing the relationship between the target rate control parameter of the target video segment and the video quality of the target coding result.

[0202] 503. Based on the second relationship, determine the target rate control parameter of the target video segment.

[0203] Because it can be determined based on the second relationship that for a certain specific video quality, the rate control parameter used to encode the video can make the video quality of the encoding result the specific video quality, so the video encoding device can determine the target rate control parameter based on the second relationship, so that the video quality of the target encoding result meets the requirements. For example, the requirement for the bit rate of the target encoding result is not less than the video quality threshold, then the rate control parameter that makes the bit rate of the target encoding result not less than the video quality threshold can be determined based on the second relationship as the target rate control parameter.

[0204] 504. Determine a difference between the target rate control parameter and the reference rate control parameter to obtain the target deviation.

[0205] The video encoding apparatus determines a result of subtracting a reference rate control parameter from a target rate control parameter as a target deviation.

[0206] In this embodiment, after the video encoding device extracts features from the target video segment and obtains at least one feature of the target video segment, the at least one feature is input into the second model to obtain a second relationship output by the second model, wherein the second relationship is the relationship between the target rate control parameter of the target video segment and the video quality of the target encoding result. The video encoding device determines the target rate control parameter of the target video segment based on the second relationship, so that the video quality of the target encoding result obtained by encoding the target video segment using the target rate control parameter meets the requirements. After obtaining the target rate control parameter, the difference between the target rate control parameter and the reference rate control parameter is determined to obtain the target deviation.

[0207] As an optional implementation, before executing step 403, the video encoding device further performs the following steps: inputting at least one feature into the second model to obtain a second relationship output by the second model. The implementation of this step can be found in step 502 and will not be repeated here.

[0208] After obtaining the second relationship, the video encoding apparatus performs the following steps in the process of executing step 403: based on the first relationship and the second relationship, determining a rate control parameter that makes the target encoding result meet the preset requirements as the target rate control parameter.

[0209] In the embodiment of the present application, the preset requirements include requirements for the bit rate of the target encoding result and the video quality of the target encoding result. Since the first relationship is the relationship between the target bit rate control parameter of the target video segment and the bit rate of the target encoding result, and the second relationship is the relationship between the target bit rate control parameter of the target video segment and the video quality of the target encoding result, the video encoding device determines the target bit rate control parameter of the target video segment based on the first relationship and the second relationship, so that the bit rate and video quality of the target encoding result can meet the requirements.

[0210] It should be understood that the target video segment and the target deviation in the implementation manner of the present application are the description objects selected for the purpose of briefly describing the technical solution, and should not be understood as the video encoding device determining one of the (n+1) deviations to be encoded by only obtaining the target deviation. In practical applications, the video encoding device can determine any one of the (n+1) deviations to be encoded by obtaining the target deviation.

[0211] Optionally, both the first model and the second model can be deep learning models. Figure 2 , Figure 2 A schematic diagram of the structure of a deep learning model provided in an embodiment of the present application. Figure 2 As shown, the deep learning model can be connected to the feature extraction module used to implement the method flow in the above step 401.

[0212] like Figure 2 As shown, the feature extraction module may include video content feature extraction, online complete encoding feature extraction, and fast pre-encoding feature extraction, wherein the video content feature extraction is used to extract video content features, the online complete encoding feature extraction is used to extract encoding result features, and the fast pre-encoding feature extraction is used to extract pre-encoding features. Figure 2 As shown, the video content features include texture information, non-parameter video quality assessment, spatiotemporal information, etc. The encoding result features include anchor_crf, anchor_vmaf, and anchor_bitrate, wherein the feature extraction module performs a complete encoding of the video segment to be encoded based on anchor_crf when extracting features of the video segment to be encoded, and obtains the corresponding anchor_vmaf and anchor_bitrate, wherein anchor_crf is a preset bit rate control parameter, anchor_vmaf indicates the video quality of the target encoding result when the target encoding result is obtained by encoding the video segment to be encoded using anchor_crf, and anchor_bitrate indicates the bit rate of the target encoding result when the target encoding result is obtained by encoding the video segment to be encoded using anchor_crf. For example, the bit rate control parameter is CRF. Based on historical experience, when CRF is 32, the bit rate of the encoding result obtained by encoding the video using CRF meets expectations, so it can be determined that anchor_crf is 32. The pre-coding features include prediction mode, coding frame type features, and video width / height / frame rate features, wherein the coding frame type features include coding information of intra-frame prediction or coding information of inter-frame prediction. The feature extraction module extracts features from the video to be encoded, and at least one feature of any video segment to be encoded in the video to be encoded can be obtained.

[0213] like Figure 2 As shown, the deep learning model may include a first base network (base-net), a suspension operator, and a second base network connected in sequence.

[0214] In a possible implementation, at least one feature of the video segment to be encoded output by the feature extraction module can be input into the first basic network, and the first basic network predicts the first relationship or the second relationship based on the at least one feature, that is, Figure 2The pred 1pass vmaf / bitrate curve shown in FIG. 1 , wherein pred 1pass bitrate represents the first relationship and pred 1pass vmaf represents the second relationship.

[0215] In one possible implementation, the number of features of the video segment to be encoded output by the feature extraction module is greater than 1, and the server may first perform feature concatenation on at least one feature output by the feature extraction module to obtain a corresponding target feature, and then input the target feature into the first basic network, and the first basic network predicts the first relationship or the second relationship based on the target feature. It should be understood that by feature concatenation, features from different sources or different types can be integrated together to obtain a more comprehensive feature, and the network can learn the interaction and combination effects between features to improve the prediction performance of the model.

[0216] like Figure 2 As shown, the first basic network may include a batch normalization layer, a self-attention layer, a residual feature layer, and a fully connected layer. Figure 2 The internal structure of the first basic network shown describes the process of the first basic network predicting the first relationship or the second relationship.

[0217] First, the target feature obtained by concatenating at least one feature is input to a batch normalization layer, which performs batch normalization on at least one feature contained in the target feature and outputs at least one normalized feature. It should be understood that features of different scales can be converted to the same scale through normalization, for example, the value of at least one feature is adjusted to the range of [0, 1], which is conducive to the comparison and combination of different features.

[0218] Then, the at least one normalized feature is input into the self-attention mechanism layer, and the self-attention mechanism layer extracts the association information between the at least one feature, and integrates the at least one feature into a deep feature based on the association information. In an illustrated embodiment, the association information between the at least one feature may include a correlation coefficient between the at least one feature.

[0219] Then, the deep features output by the self-attention mechanism layer are input to the residual feature layer, and the residual feature layer performs residual correction on the deep features to obtain residual features. Figure 2As shown, the residual feature layer may include two residual blocks (res-block). It should be understood that setting the residual block can help the network learn the residual more easily, that is, the difference between the output and the input, promote deeper feature learning, and effectively solve the common gradient vanishing problem in deep networks, etc. This application does not make specific limitations on this.

[0220] Finally, the residual features output by the residual feature layer are input to the fully connected layer, and the fully connected layer predicts the first relationship or the second relationship based on the residual features and outputs it.

[0221] In this way, the present application can maximize network performance and improve the prediction accuracy of the first relationship or the second relationship by using at least one feature combination as the input of the first basic network and using reasonable normalization methods and self-attention mechanisms and other network designs in the first basic network.

[0222] Optionally, when extracting features from the video segment to be encoded, the feature extraction module performs a complete encoding on the video segment to be encoded based on anchor_crf to obtain corresponding anchor_vmaf and anchor_bitrate. The real first relationship corresponding to the video segment to be encoded should pass through the first anchor point (anchor_crf, anchor_bitrate) composed of anchor_crf and anchor_bitrate, and the real second relationship corresponding to the video segment to be encoded should pass through the second anchor point (anchor_crf, anchor_vmaf) composed of anchor_crf and anchor_vmaf.

[0223] Based on this, Figure 2 As shown, the present application further sets a suspension operator connected to the above-mentioned first basic network in the deep learning model, through which the first relationship or the second relationship predicted by the first basic network can be further suspended based on the anchor_crf, anchor_vmaf and anchor_bitrate in the above-mentioned video features to obtain the first relationship or the second relationship after suspension processing, that is, Figure 2 The pred vmaf / bitrate suspension curve is shown, where pred bitrate represents the first relationship after the suspension process and pred vmaf represents the second relationship after the suspension process.

[0224] Among them, the first relationship after the suspension processing passes through the first anchor point (anchor_crf, anchor_bitrate), and the second relationship after the suspension processing passes through the second anchor point (anchor_crf, anchor_vmaf), thereby improving the prediction accuracy of the deep learning model and making the predicted relationship closer to the real relationship, that is, Figure 2 The label vmaf / bitrate curve shown.

[0225] In an illustrated embodiment, the suspension processing may specifically include: adding a first bias to all the bit rates of the predicted first relation, wherein the first bias may be equal to anchor_bitrate minus the bit rate corresponding to anchor_crf in the first relation. Adding a second bias to all the video qualities of the predicted second relation, wherein the second bias may be equal to anchor_vmaf minus the video quality corresponding to anchor_crf in the crf-vmaf curve.

[0226] Thus, after the suspension process, the first relationship passes through the first anchor point (anchor_crf, anchor_bitrate), and the second relationship passes through the second anchor point (anchor_crf, anchor_vmaf).

[0227] In an illustrated embodiment, in order to further improve the prediction accuracy of the deep learning model, Figure 2 As shown, the present application further provides a second basic network connected to the above-mentioned suspension operator in the deep learning model, and the second basic network can perform residual correction on the first relationship or the second relationship after the suspension processing to obtain the first relationship or the second relationship after the residual correction, that is, Figure 2 The pred 2pass vmaf / bitrate curve shown in FIG. 1 , wherein pred 2pass bitrate represents the first relationship after residual correction, and pred 2pass vmaf represents the second relationship after residual correction.

[0228] It should be noted that the present application does not specifically limit the specific structure of the second basic network. In one illustrated embodiment, the second basic network can perform residual learning based on skip connection to enable the model to have better prediction performance, etc., and the present application does not specifically limit this.

[0229] Optionally, the training of deep learning models can be achieved through supervised training. Specifically, Figure 2As shown, the supervised training process may include: using the L1 loss function to supervise the difference between each point and the label point pair in the first relation or the second relation output by the first basic network in the deep learning model and the first relation or the second relation output by the second basic network, where label is a label. At the same time, the L1 loss function is used to supervise the gradient difference (i.e. Figure 2 The gradient can be defined as the vmaf_diff value of the adjacent crf point divided by the bitrate_diff value. The vmaf_diff value is the difference between the two video qualities corresponding to the adjacent crf points, and the bitrate_diff value is the difference between the two bitrates corresponding to the adjacent crf points.

[0230] As an optional implementation, the n segmented frame numbers are determined by a scene detection process, wherein the execution subject of the scene detection process may be the above-mentioned video encoding device, or may be an electronic device other than the video encoding device. The scene detection process includes:

[0231] 601. When the scene of consecutive i video frames in a to-be-encoded video is switched from a first scene to a second scene, determine a reference number of reference video frames having the second scene in the i video frames.

[0232] In the embodiment of the present application, i is an integer greater than 1. The first scene and the second scene may be any scene, and the first scene is different from the second scene. In step 601, when determining that a scene switch occurs in consecutive i frames, the video encoding device determines the number of reference video frames having the switched scene to obtain a reference number.

[0233] 602. When the reference quantity is greater than or equal to a first threshold, determine a minimum frame number of the reference video frame as a segmentation frame number.

[0234] The reference number is greater than or equal to the first threshold, indicating that the number of video frames with the second scene is large, and further indicating that the appearance of the second scene in the continuous i-frame video frames is not caused by misrecognition of the scene. Therefore, the video encoding device determines the minimum frame number of the reference video frame as the segmentation frame number, and then the segmentation of the first scene and the second scene can be completed by the segmentation frame number. For example, A represents the video frame with the first scene, and B represents the reference video frame. The continuous i-frame video frame is AAAB, and the first threshold is 1. Since the number of B is greater than or equal to 1, the segmentation frame number is the frame number of B.

[0235] As an optional implementation, after the scene of the consecutive i-frame video frames is switched from the first scene to the second scene, it is switched from the second scene to the first scene. In this implementation, the scene detection process further includes: before executing step 602, determining the initial number of initial video frames having the first scene in the i-frame video frames.

[0236] After obtaining the initial number, step 602 in the scene detection process specifically includes the following steps: when the reference number is greater than or equal to the first threshold and the initial number is less than or equal to the reference number, determining the minimum frame number of the reference video frame as the segmentation frame number.

[0237] The initial number is less than or equal to the reference number, indicating that the number of video frames with the first scene does not exceed the number of video frames with the second scene, which means that the second scene does not appear between the first scenes due to misidentification of the scene. Therefore, the video encoding device determines the minimum frame number of the reference video frame as the segmentation frame number, and the segmentation of the first scene and the second scene can be completed by the segmentation frame number. For example, A represents the initial video frame and B represents the reference video frame. The continuous i-frame video frame is AAABBBBA, and the first threshold is 1. Since the number of A is equal to the number of B, and the number of B is greater than or equal to 1, the segmentation frame number is the frame number of the first B.

[0238] Optionally, the scene detection process also includes: after determining the initial number of initial video frames having the first scene in the i-frame video frame, when the initial number is greater than the reference number, determining a frame number after the maximum frame number as the segmentation frame number, wherein the maximum frame number is the maximum frame number of the initial video frame. The initial number is greater than the reference number, indicating that the number of video frames having the first scene is greater than the number of video frames having the second scene, which also means that the second scene appears between the first scenes due to misidentification of the scene. Therefore, the video encoding device determines the maximum frame number as the segmentation frame number, which can avoid the error of the segmentation frame number caused by misidentification of the scene. For example, A represents the initial video frame, and B represents the reference video frame. The continuous i-frame video frame is AAAABBAAAA. Since the number of A is equal to the number of B, the segmentation frame number is the frame number of the video frame after the last A. For example, if the frame number of the last A is 100, the segmentation frame number is 101.

[0239] It should be understood that when the scene of continuous i-frame video frames switches from the first scene to the second scene and then switches from the second scene to the first scene, if the initial number is greater than the reference number and the reference number is greater than the first threshold, the video encoding device determines that the maximum frame number is the split frame number.

[0240] As an optional implementation, after the scene of the continuous i-frame video frames is switched from the first scene to the second scene, it is switched from the second scene to the third scene. The first scene, the second scene, and the third scene can all be any scenes, and any two of the first scene, the second scene, and the third scene are different. The scene detection process also includes: before step 602, determining the initial number of initial video frames having the first scene in the i-frame video frames.

[0241] After obtaining the initial number, step 602 in the scene detection process specifically includes the following steps: when the reference number is greater than or equal to the first threshold and the initial number is less than or equal to the second threshold, determining the minimum frame number of the reference video frame as the segmentation frame number.

[0242] The initial number is less than or equal to the second threshold, indicating that the number of video frames having the first scene is small, and further indicating that the scene switching of consecutive i-frame video frames from the first scene to the second scene is not caused by misrecognition of the scene. Therefore, the video encoding device determines the minimum frame number of the reference video frame as the split frame number, and then the splitting of the first scene and the second scene can be completed by the split frame number.

[0243] As an optional implementation, after determining the initial number, the scene detection step further includes the following steps: when the initial number is greater than the second threshold and the reference number is less than the third threshold, determining the number of to-be-confirmed video frames with the third scene in the i-frame video frame. When the number to be confirmed is greater than or equal to the third threshold, determining the minimum frame number of the first video frame as the segmentation frame number.

[0244] The initial number is greater than the second threshold, indicating that the number of video frames with the first scene is large, and further indicating that the scene of the continuous i-frame video frame switches from the first scene to the second scene may be caused by the misrecognition of the scene. Therefore, the video encoding device determines whether the second scene is caused by the misrecognition of the scene based on the reference number. A large reference number indicates that it is not caused by misrecognition, and conversely, a small reference number indicates that it is caused by misrecognition. In this embodiment, the video encoding device determines whether the reference number is large or small based on the third threshold, wherein the third threshold is smaller than the second threshold. Specifically, the reference number is less than the third threshold, indicating that the reference number is small, and the reference number is greater than or equal to the third threshold, indicating that the reference number is large. Therefore, when the initial number is greater than the second threshold and the reference number is less than the third threshold, the video encoding device determines that it is not necessary to split the first scene and the second scene, and then continues to determine the number of video frames to be confirmed with the third scene to be confirmed, so as to further determine whether the third scene needs to be separated from other scenes (the first scene and the second scene). If the number to be confirmed is greater than or equal to the third threshold, it means that the number to be confirmed is large, and then it is determined that the appearance of the third scene is not caused by misidentification. Therefore, the video encoding device determines the minimum frame number of the video frame to be confirmed as the segmentation frame number, and then the segmentation of the second scene and the third scene can be completed by the segmentation frame number, thereby separating the third scene from the other scenes (the first scene and the second scene). For example, A represents the initial video frame, B represents the reference video frame, and C represents the video frame to be confirmed. The continuous i-frame video frame is AAABBCCCC, the second threshold is 2, and the third threshold is 3. Since the number of A is greater than 2 and the number of B is less than 3, A and B are not segmented. However, since the number of C is greater than 3, the video encoding device segments B and C, and the segmentation frame number is the frame number of the first C.

[0245] It should be understood that the first scene, the second scene, and the third scene in this embodiment are the description objects selected by the concise description technical solution. In actual applications, the number of scenes that appear in the continuous i-frame video frames can be greater than 3, and when it is greater than 3, if the first scene that appears meets the conditions required to be met by the first scene, the last scene that appears meets the conditions required to be met by the third scene, and the scenes that appear in the middle all meet the conditions satisfied by the second scene, then the video encoding device uses the minimum frame number in the last scene as the segmentation frame number. For example, A, B, C, D, E, and F are used to represent video frames with different scenes respectively. The continuous i-frame video frames are AAABBCCDDEEFFFF, the second threshold is 2, and the third threshold is 3. Since the number of A is greater than 2, and the numbers of B, C, D, and E are all less than 3, A and B are not segmented, nor are B and C segmented, nor are C and D segmented, nor are D and E segmented. However, since the number of F is greater than 3, the video encoding device segments E and F, and the segmentation frame number is the frame number of the first F.

[0246] Based on the technical solution provided in the embodiment of the present application, the embodiment of the present application also provides a possible application scenario. Figure 3 , Figure 3 The present invention provides a schematic diagram of the architecture of a video on demand system. Figure 3 As shown, the video-on-demand system 1 includes a client 11, a client 12, and a video encoding device 13, wherein both the client 11 and the client 12 have a communication connection with the video encoding device 13, and both the client 11 and the client 12 can upload videos to the video encoding device 13 through the communication connection, and the client 11 and the client 12 can also obtain videos from the video-on-demand platform run by the video encoding device 13 through the communication connection. Optionally, the client 11 and the client 12 can be one of the following: a mobile phone, a computer, a tablet computer, a wearable smart device, for example, the client 11 is a mobile phone, the client 12 is a computer, and for another example, the client 11 and the client 12 are both tablet computers. Optionally, the video encoding device 13 is a server.

[0247] In this video on demand scenario, the video encoding device 13 is a server running a video on demand platform. After receiving the video to be encoded uploaded by the user of the video on demand platform, the video encoding device 13 can determine n segmentation frame numbers from the video to be encoded by the method of obtaining the segmentation frame number provided in the embodiment of the present application, and then store the n segmentation frame numbers as a CSV file. The video encoding device 13 can determine the rate control parameters of (n+1) video segments to be encoded according to the method of determining the target deviation provided in the embodiment of the present application, and then can determine (n+1) deviations to be encoded based on the rate control parameters of the (n+1) video segments to be encoded and the reference rate control parameters. The video encoding device 13 then inputs the video to be encoded, the CSV file, the reference rate control parameters and the (n+1) deviations to be encoded into the encoder, so that the encoder encodes the (n+1) segments of the video to be encoded in the video to be encoded based on the reference rate control parameters and the (n+1) deviations to be encoded, and obtains the video encoding result of the video to be encoded output by the encoder. Finally, the video encoding result is published to the video on demand platform.

[0248] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0249] The method of the embodiment of the present application is described in detail above, and the device of the embodiment of the present application is provided below.

[0250] See also Figure 4 , Figure 4The schematic diagram of the structure of a video encoding device provided in an embodiment of the present application is as follows. The video encoding device 2 includes: an input unit 21, an encoding unit 22. Optionally, the video encoding device 2 also includes: a conversion unit 23, a determination unit 24. Specifically:

[0251] An input unit 21 is used to input a video to be encoded, n segmented frame numbers, a reference rate control parameter, and (n+1) deviations to be encoded into an encoder, wherein the segmented frame number is a frame number of a video frame in the video to be encoded, the n segmented frame numbers are used to determine (n+1) video segments to be encoded from the video to be encoded, n is a positive integer, the deviations to be encoded correspond to the video segments to be encoded one by one, and the deviations to be encoded are deviations of the rate control parameters of the video segments to be encoded compared to the reference rate control parameters;

[0252] The encoding unit 22 is used to determine, from the video to be encoded, the (n+1)th video segment to be encoded determined by the n segmentation frame numbers through the encoder;

[0253] The encoding unit 22 is configured to determine (n+1) target rate control parameters based on the reference rate control parameters and the (n+1) deviations to be encoded by the encoder, wherein the video segments to be encoded correspond to the target rate control parameters in a one-to-one manner;

[0254] The encoding unit 22 is used to encode the (n+1) to-be-encoded video segments based on the (n+1) target bit rate control parameters through the encoder to obtain a video encoding result of the to-be-encoded video output by the encoder.

[0255] In combination with any implementation manner of the present application, the video to be encoded is a video in a first color space, the encoder is used to process a video in a second color space, and the first color space is different from the second color space;

[0256] The video encoding device 2 further includes: a conversion unit 23, configured to convert the video to be encoded from the first color space to the second color space to obtain a converted video;

[0257] The encoding unit 22 is specifically used for:

[0258] Inputting the converted video, the n segmented frame numbers, the reference rate control parameter and the (n+1) deviations to be encoded into the encoder;

[0259] Determining, by the encoder based on the n segmented frame numbers, from the converted video, (n+1) segments of converted videos corresponding to the (n+1) segments of the video segments to be encoded;

[0260] Determining, by the encoder, (n+1) target rate control parameters of the (n+1) converted video segments based on the reference rate control parameters and the (n+1) deviations to be encoded, wherein the converted video segments correspond to the target rate control parameters in a one-to-one manner;

[0261] The encoder encodes the (n+1) to-be-encoded video segments based on the (n+1) target bit rate control parameters to obtain the video encoding result.

[0262] In combination with any implementation manner of the present application, the encoding unit 22 is specifically used for:

[0263] Using the encoder to take the first frame of the conversion video and the video frames in the conversion video corresponding to the n segmentation frame numbers as (n+1) key frames of the (n+1) conversion video segments, wherein the key frames correspond to the conversion video segments one by one;

[0264] The encoder encodes the (n+1) converted video segments in the converted video based on the (n+1) key frames, the reference bit rate control parameters and the (n+1) deviations to be encoded to obtain the video encoding result.

[0265] In combination with any implementation manner of the present application, the encoding unit 22 is specifically used for:

[0266] Determining, by the encoder, a sum of the reference rate control parameter and each of the (n+1) deviations to be encoded, and obtaining (n+1) target rate control parameters of the (n+1) converted video segments, wherein the target rate control parameters correspond to the converted video segments one by one;

[0267] The encoder encodes the (n+1) converted video segments based on the (n+1) key frames and the (n+1) target bit rate control parameters to obtain the video encoding result.

[0268] In combination with any implementation manner of the present application, the (n+1) to-be-encoded video segments include a target video segment, and the (n+1) to-be-encoded deviations include a target deviation corresponding to the target video segment;

[0269] The video encoding device 2 further includes a determining unit 24 configured to:

[0270] Extracting features from the target video segment to obtain at least one feature of the target video segment;

[0271] Inputting the at least one feature into a first model to obtain a first relationship output by the first model;

[0272] The first model is used to predict the relationship between the rate control parameter of the video and the bit rate of the reference encoding result based on the characteristics of the video, the reference encoding result is obtained by encoding the video using the rate control parameter of the video, the first relationship is the relationship between the target rate control parameter of the target video segment and the bit rate of the target encoding result, the target encoding result is obtained by encoding the target video segment using the target rate control parameter;

[0273] Based on the first relationship, determining the target rate control parameter of the target video segment;

[0274] Alternatively, the at least one feature is input into a second model to obtain a second relationship output by the second model, wherein the first model is used to predict the relationship between the rate control parameter of the video and the video quality of the reference encoding result based on the feature of the video, and the second relationship is the relationship between the target rate control parameter of the target video segment and the video quality of the target encoding result;

[0275] Based on the second relationship, determining the target rate control parameter of the target video segment;

[0276] A difference between the target rate control parameter and the reference rate control parameter is determined to obtain the target deviation.

[0277] In combination with any implementation manner of the present application, the determining unit 24 is further configured to:

[0278] Inputting the at least one feature into the second model to obtain the second relationship output by the second model;

[0279] Based on the first relationship and the second relationship, a rate control parameter that makes the target encoding result meet preset requirements is determined as the target rate control parameter, and the preset requirements include requirements for the rate of the target encoding result and requirements for the video quality of the target encoding result.

[0280] In combination with any implementation manner of the present application, in the video to be encoded, the video frames located on both sides of the segmentation frame number have different scenes, and the video frames located between two adjacent segmentation frame numbers have the same scene.

[0281] In combination with any implementation manner of the present application, the n segmentation frame numbers are determined by a scene detection process, and the scene detection process includes:

[0282] When the scene of consecutive i video frames in the to-be-encoded video is switched from a first scene to a second scene, determining a reference number of reference video frames having the second scene in the i video frames, where i is an integer greater than 1;

[0283] When the reference number is greater than or equal to the first threshold, the minimum frame number of the reference video frame is determined as the segmentation frame number.

[0284] In combination with any implementation manner of the present application, after the scene of the continuous i video frames is switched from the first scene to the second scene, the second scene is switched to the first scene, and the scene detection process further includes:

[0285] Determining an initial number of initial video frames having the first scene in the i video frames;

[0286] When the reference number is greater than or equal to a first threshold, determining a first threshold of a minimum frame number of the reference video frame as the segmentation frame number includes:

[0287] When the reference number is greater than or equal to a first threshold value and the initial number is less than or equal to the reference number, a minimum frame number of the reference video frame is determined as the segmentation frame number.

[0288] In combination with any embodiment of the present application, the scene detection process further includes: after determining the initial number of initial video frames having the first scene in the i-frame video frames,

[0289] In the case that the initial number is greater than the reference number, a frame number after a maximum frame number is determined as the segmentation frame number, and the maximum frame number is the maximum frame number of the initial video frame.

[0290] In combination with any embodiment of the present application, after the scene of the continuous i video frames is switched from the first scene to the second scene, the second scene is switched to the third scene;

[0291] The scene detection process further includes: when the reference number is greater than or equal to a first threshold, determining that the minimum frame number of the reference video frame is before the segmentation frame number,

[0292] Determining an initial number of initial video frames having the first scene in the i video frames;

[0293] When the reference number is greater than or equal to the first threshold, determining the frame number of the reference video frame whose frame number is smaller than the first threshold as the segmentation frame number includes:

[0294] When the reference number is greater than or equal to the first threshold and the initial number is less than or equal to the second threshold, the minimum frame number of the reference video frame is determined as the segmentation frame number.

[0295] In combination with any embodiment of the present application, the scene detection process further includes: after determining the initial number of initial video frames having the first scene in the i-frame video frames,

[0296] When the initial number is greater than the second threshold value and the reference number is less than a third threshold value, determining the number of to-be-confirmed video frames having the third scene in the i-frame video frames;

[0297] When the number to be confirmed is greater than or equal to the third threshold, the minimum frame number of the video frames to be confirmed is determined to be the segmentation frame number, and the third threshold is less than the second threshold.

[0298] In the embodiment of the present application, there is a video to be encoded and n segmented frame numbers, wherein the segmented frame number is the frame number of the video frame in the video to be encoded, the n segmented frame numbers are used to determine (n+1) segments of the video to be encoded from the video to be encoded, and the deviation to be encoded is the deviation of the rate control parameter of the video segment to be encoded compared to the reference rate control parameter. After the video encoding device inputs the video to be encoded, the n segmented frame numbers, the reference rate control parameter and the (n+1) deviations to be encoded into the encoder, the encoder can determine the (n+1) segments of the video to be encoded determined by the n segmented frame numbers from the video to be encoded, and the encoder can determine the (n+1) target rate control parameters based on the reference rate control parameters and the (n+1) deviations to be encoded. Finally, the encoder can encode the (n+1) segments of the video to be encoded based on the (n+1) target rate control parameters to obtain the video encoding result of the video to be encoded output by the encoder. Therefore, the encoder can encode the (n+1) video segments to be encoded by encoding the video to be encoded once, and realize encoding the (n+1) video segments to be encoded by using the bit rate control parameters of the (n+1) video segments to be encoded, thereby reducing the data processing amount for encoding different video segments to be encoded in the video to be encoded using different bit rate control parameters and improving the encoding speed. Furthermore, since the data processing amount can be reduced, it means that this encoding method requires fewer hardware resources, thereby reducing hardware costs.

[0299] In some embodiments, the functions or modules included in the device provided in the embodiments of the present application can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments. For the sake of brevity, it will not be repeated here.

[0300] Figure 5A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. The electronic device 3 includes a processor 31 and a memory 32. Optionally, the electronic device 3 also includes an input device 33 and an output device 34. The processor 31, the memory 32, the input device 33 and the output device 34 are coupled via a connector, and the connector includes various interfaces, transmission lines or buses, etc., which are not limited in the embodiments of the present application. It should be understood that in each embodiment of the present application, coupling refers to mutual connection in a specific manner, including direct connection or indirect connection through other devices, for example, it can be connected through various interfaces, transmission lines, buses, etc.

[0301] The processor 31 may include one or more processors, for example, one or more CPUs. When the processor is a CPU, the CPU may be a single-core CPU or a multi-core CPU. Optionally, the processor 31 may be a processor group composed of multiple CPUs, and the multiple processors are coupled to each other through one or more buses. Optionally, the processor may also be other types of processors, etc., which are not limited in the embodiments of the present application.

[0302] The memory 32 can be used to store computer program instructions and various computer program codes including the program code for executing the program code of the present application. Optionally, the memory includes but is not limited to random access memory (RAM), read-only memory (ROM), erasable programmable read only memory (EPROM), or portable read only memory (CD-ROM), which is used for related instructions and data.

[0303] The input device 33 is used to input data and / or signals, and the output device 34 is used to output data and / or signals. The input device 33 and the output device 34 can be independent devices or an integrated device.

[0304] It can be understood that in the embodiment of the present application, the memory 32 can be used not only to store relevant instructions, but also to store relevant data. The embodiment of the present application does not limit the specific data stored in the memory.

[0305] Understandably, Figure 5 Only a simplified design of an electronic device is shown. In practical applications, the electronic device may also include other necessary components, including but not limited to any number of input / output devices, processors, memories, etc., and all electronic devices that can implement the embodiments of the present application are within the protection scope of the present application.

[0306] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0307] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. Those skilled in the art can also clearly understand that the descriptions of the various embodiments of the present application have different focuses. For the convenience and brevity of description, the same or similar parts may not be repeated in different embodiments. Therefore, for parts not described or not described in detail in a certain embodiment, refer to the records of other embodiments.

[0308] 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 the units is only a logical function division. There may be other division methods in actual implementation, such as 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 through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0309] 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.

[0310] 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.

[0311] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).

[0312] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by a computer program to instruct the relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above-mentioned method embodiments. The aforementioned storage medium includes: a read-only memory (ROM) or a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

Claims

1. A video encoding method, characterized in that: The method comprises: Inputting a video to be encoded, n segmentation frame numbers, a reference rate control parameter and (n+1) to-be-encoded deviations into an encoder, wherein the segmentation frame number is a frame number of a video frame in the video to be encoded, the n segmentation frame numbers are used to determine (n+1) to-be-encoded video segments from the video to be encoded, n is a positive integer, the to-be-encoded deviations correspond to the to-be-encoded video segments one-to-one, and the to-be-encoded deviations are deviations of the rate control parameters of the to-be-encoded video segments compared to the reference rate control parameters; Determining, by the encoder, from the video to be encoded, (n+1) video segments to be encoded that are determined by the n segmentation frame numbers; Determining, by the encoder, (n+1) target rate control parameters based on the reference rate control parameters and the (n+1) deviations to be encoded, wherein the video segments to be encoded correspond to the target rate control parameters in a one-to-one manner; The encoder encodes the (n+1) video segments to be encoded based on the (n+1) target bit rate control parameters to obtain a video encoding result of the video to be encoded output by the encoder.

2. The method according to claim 1, characterized in that The video to be encoded is a video in a first color space, and the encoder is used to process the video in a second color space, and the first color space is different from the second color space; Before inputting the video to be encoded, the n segmented frame numbers, the reference rate control parameter and the (n+1) deviations to be encoded into the encoder, the method further includes: Converting the video to be encoded from the first color space to the second color space to obtain a converted video; The step of inputting the to-be-encoded video, n segmented frame numbers, a reference bit rate control parameter, and (n+1) to-be-encoded deviations into the encoder comprises: Inputting the converted video, the n segmented frame numbers, the reference rate control parameter and the (n+1) deviations to be encoded into the encoder; The step of determining, by the encoder, from the video to be encoded, the (n+1) video segments to be encoded determined by the n segmentation frame numbers, comprises: Determining, by the encoder based on the n segmented frame numbers, from the converted video, (n+1) segments of converted videos corresponding to the (n+1) segments of the video segments to be encoded; The step of determining (n+1) target rate control parameters based on the reference rate control parameters and the (n+1) deviations to be encoded by the encoder includes: Determining, by the encoder, (n+1) target rate control parameters of the (n+1) converted video segments based on the reference rate control parameters and the (n+1) deviations to be encoded, wherein the converted video segments correspond to the target rate control parameters in a one-to-one manner; The step of encoding the (n+1) to-be-encoded video segments based on the (n+1) target bit rate control parameters by the encoder to obtain a video encoding result of the to-be-encoded video output by the encoder includes: The encoder encodes the (n+1) to-be-encoded video segments based on the (n+1) target bit rate control parameters to obtain the video encoding result.

3. The method according to claim 2, characterized in that The step of encoding the (n+1) to-be-encoded video segments based on the (n+1) target bit rate control parameters by the encoder to obtain the video encoding result includes: Using the encoder to take the first frame of the conversion video and the video frames in the conversion video corresponding to the n segmentation frame numbers as (n+1) key frames of the (n+1) conversion video segments, wherein the key frames correspond to the conversion video segments one by one; The encoder encodes the (n+1) converted video segments in the converted video based on the (n+1) key frames, the reference bit rate control parameters and the (n+1) deviations to be encoded to obtain the video encoding result.

4. The method according to claim 3, characterized in that The step of encoding the (n+1) converted video segments in the converted video based on the (n+1) key frames, the reference rate control parameters and the (n+1) deviations to be encoded by the encoder to obtain the video encoding result includes: Determining, by the encoder, a sum of the reference rate control parameter and each of the (n+1) deviations to be encoded, and obtaining (n+1) target rate control parameters of the (n+1) converted video segments, wherein the target rate control parameters correspond to the converted video segments one by one; The encoder encodes the (n+1) converted video segments based on the (n+1) key frames and the (n+1) target bit rate control parameters to obtain the video encoding result.

5. The method according to any one of claims 1 to 4, characterized in that: The (n+1) to-be-encoded video segments include a target video segment, and the (n+1) to-be-encoded deviations include a target deviation corresponding to the target video segment; Before inputting the converted video, the n segmented frame numbers, the reference rate control parameter and the (n+1) to-be-encoded deviations into the encoder, the method further includes: Extracting features from the target video segment to obtain at least one feature of the target video segment; Inputting the at least one feature into a first model to obtain a first relationship output by the first model; The first model is used to predict the relationship between the rate control parameter of the video and the bit rate of the reference encoding result based on the characteristics of the video, the reference encoding result is obtained by encoding the video using the rate control parameter of the video, the first relationship is the relationship between the target rate control parameter of the target video segment and the bit rate of the target encoding result, the target encoding result is obtained by encoding the target video segment using the target rate control parameter; Based on the first relationship, determining the target rate control parameter of the target video segment; Alternatively, the at least one feature is input into a second model to obtain a second relationship output by the second model, wherein the first model is used to predict the relationship between the rate control parameter of the video and the video quality of the reference encoding result based on the feature of the video, and the second relationship is the relationship between the target rate control parameter of the target video segment and the video quality of the target encoding result; Based on the second relationship, determining the target rate control parameter of the target video segment; A difference between the target rate control parameter and the reference rate control parameter is determined to obtain the target deviation.

6. The method according to claim 5, characterized in that Before determining the target rate control parameter of the target video segment based on the first relationship, the method further includes: Inputting the at least one feature into the second model to obtain the second relationship output by the second model; The determining, based on the first relationship, the target rate control parameter of the target video segment includes: Based on the first relationship and the second relationship, a rate control parameter that makes the target encoding result meet preset requirements is determined as the target rate control parameter, and the preset requirements include requirements for the rate of the target encoding result and requirements for the video quality of the target encoding result.

7. The method according to any one of claims 1 to 4, characterized in that In the video to be encoded, the video frames located on both sides of the segmentation frame number have different scenes, and the video frames located between two adjacent segmentation frame numbers have the same scene.

8. The method according to claim 7, characterized in that The n segmentation frame numbers are determined by a scene detection process, and the scene detection process includes: When the scene of consecutive i video frames in the to-be-encoded video is switched from a first scene to a second scene, determining a reference number of reference video frames having the second scene in the i video frames, where i is an integer greater than 1; When the reference number is greater than or equal to the first threshold, the minimum frame number of the reference video frame is determined as the segmentation frame number.

9. The method according to claim 8, characterized in that After the scene of the continuous i-frame video frames is switched from the first scene to the second scene, the second scene is switched to the first scene, and the scene detection process further includes: when the reference number is greater than or equal to the first threshold, determining that the minimum frame number of the reference video frame is before the first threshold is the segmentation frame number, determining the initial number of initial video frames having the first scene in the i-frame video frames; When the reference number is greater than or equal to a first threshold, determining a first threshold of a minimum frame number of the reference video frame as the segmentation frame number includes: When the reference number is greater than or equal to a first threshold value and the initial number is less than or equal to the reference number, a minimum frame number of the reference video frame is determined as the segmentation frame number.

10. The method according to claim 9, characterized in that The scene detection process also includes: after determining the initial number of initial video frames having the first scene in the i-frame video frames, when the initial number is greater than the reference number, determining a frame number after a maximum frame number as the split frame number, and the maximum frame number is the maximum frame number of the initial video frame.

11. The method according to claim 8, characterized in that After the scene of the continuous i-frame video frames is switched from the first scene to the second scene, the second scene is switched to the third scene, and the scene detection process further includes: when the reference number is greater than or equal to the first threshold, before determining that the minimum frame number of the reference video frame is the segmentation frame number, determining the initial number of initial video frames having the first scene in the i-frame video frames; When the reference number is greater than or equal to the first threshold, determining the frame number of the reference video frame whose frame number is smaller than the first threshold as the segmentation frame number includes: When the reference number is greater than or equal to the first threshold and the initial number is less than or equal to the second threshold, the minimum frame number of the reference video frame is determined as the segmentation frame number.

12. The method according to claim 11, characterized in that The scene detection process further includes: after determining the initial number of initial video frames having the first scene in the i-frame video frames, if the initial number is greater than the second threshold and the reference number is less than a third threshold, determining the number of to-be-confirmed video frames having the third scene in the i-frame video frames; When the number to be confirmed is greater than or equal to the third threshold, the minimum frame number of the video frames to be confirmed is determined to be the segmentation frame number, and the third threshold is less than the second threshold.

13. A video encoding device, characterized in that: The device comprises: an acquisition unit, configured to acquire a video to be encoded and n segmentation frame numbers, wherein the segmentation frame numbers are frame numbers of video frames in the video to be encoded, and the n segmentation frame numbers are used to divide the video to be encoded into (n+1) video segments to be encoded, where n is a positive integer; The acquisition unit is used to acquire a reference rate control parameter and (n+1) to-be-encoded deviations of the (n+1) to-be-encoded video segment, wherein the to-be-encoded deviations correspond to the to-be-encoded video segment in a one-to-one manner, and the to-be-encoded deviations are deviations of the rate control parameters of the to-be-encoded video segment compared to the reference rate control parameters; The encoding unit is used to input the video to be encoded, the n segmented frame numbers, the reference rate control parameters and the (n+1) deviations to be encoded into an encoder, so that the encoder encodes the (n+1) video segments to be encoded in the video to be encoded based on the reference rate control parameters and the (n+1) deviations to be encoded, and obtains a video encoding result of the video to be encoded output by the encoder.

14. An electronic device, characterized in that: include: A processor and a memory, wherein the memory is used to store computer program code, wherein the computer program code includes computer instructions, and when the processor executes the computer instructions, the electronic device executes the method according to any one of claims 1 to 12.

15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor is caused to execute the method according to any one of claims 1 to 12.

16. A computer program product, characterized in that The computer program product comprises a computer program or instructions; when the computer program or instructions are run on a computer, the computer is caused to execute the method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Information collection method and device, storage medium and electronic equipment

    CN113747161A

  • Video coding method and device, computer equipment and medium

    CN118055240A

  • Video processing method and device, and storage medium

    WO2021254139A1

Cited By

  • Video coding method and device, method for generating bit stream, electronic equipment, storage medium and program product

    CN119815115A

  • Video encoding methods and apparatus, methods for transmitting bit streams, electronic devices, storage media and software products

    CN119815115B