Video coding method and device

By determining the proportion of videos and the proportion of dynamic areas, adjusting the encoding parameters with coding video fragments solves the problem of worsening of the dynamic area.

CN119363995APending Publication Date: 2025-01-24SHANGHAI HODE INFORMATION TECH CO LTD

Patent Information

Application Number
CN202411929998.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

During the video encoding process, although the overall picture quality of video clips with a small proportion of dynamic areas meets the requirements, the dynamic areas that the human eye pays attention to will deteriorate in the picture quality such as blur and block effect.

Method used

By dividing the video into multiple original video segments, the encoding parameters of the segments whose dynamic area ratio is lower than the preset threshold are determined, and the target video segments are encoded according to these parameters.

Benefits of technology

Improve the coding quality of dynamic areas, maintain the stability of the actual image quality, and avoid the deterioration of the picture quality of the dynamic area.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119363995A_ABST
    Figure CN119363995A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a video coding method, and relates to the technical field of video coding and decoding. The video coding method comprises the following steps: segmenting a video into a plurality of original video clips, wherein the plurality of original video clips comprise a target video clip; determining a dynamic region proportion of the target video clip, wherein the dynamic region proportion is a proportion of a dynamic region in the video picture; under the condition that the dynamic region proportion is lower than a preset proportion threshold value, determining a first coding parameter of the target video clip; and coding the target video clip according to the first coding parameter. According to the technical scheme, the coding quality of the dynamic region can be improved, and the stability of the actual image quality is kept.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of multimedia technology, and in particular to a video encoding method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] In the process of video production, in order to provide users with a stable viewing experience, the quality of the video after encoding will be controlled to meet a preset goal during video transcoding. For example, the VMAF (Video MultimethodAssessment Fusion) index after video encoding will be controlled. When VMAF evaluates the quality of the encoded video, it first calculates the local distortion in the image, then averages the local distortion to obtain the distortion of the entire image, and uses this to evaluate the video quality.

[0003] In actual use, for some videos with slight or still background movement but intense foreground movement, since the static or slow-moving images are relatively easy to encode, there is basically no obvious distortion. The dynamic area accounts for a small proportion, and the distortion in the dynamic area has a relatively small impact on the VMAF of the overall image. In this case, the video quality meets the requirements, but the dynamic area that the human eye pays attention to will show deterioration of image quality such as blurring and block effects.

[0004] It should be noted that the above content is not necessarily prior art, nor is it intended to limit the scope of patent protection of this application. Summary of the invention

[0005] The embodiments of the present application provide a video encoding method, apparatus, computer device, computer-readable storage medium, and computer program product to solve or alleviate one or more of the technical problems raised above.

[0006] An aspect of an embodiment of the present application provides a video encoding method, the method comprising: Splitting the video into a plurality of original video segments, wherein the plurality of original video segments include a target video segment; Determine the dynamic area ratio of the target video clip, where the dynamic area ratio is the ratio of the dynamic area in the video picture; When the dynamic area ratio is lower than a preset ratio threshold, determining a first encoding parameter of the target video segment; and The target video segment is encoded according to the first encoding parameter.

[0007] Optionally, the video is split into multiple original video segments, including: determining a plurality of scenes in the video; According to the multiple scenes, the video is divided into multiple original video segments; wherein one original video segment corresponds to one scene.

[0008] Optionally, determining the dynamic area ratio of the target video segment includes: Determine a plurality of video frames in the target video segment according to a preset interval; Determine the optical flow value of each pixel in each of the video frames; Determining a dynamic area of ​​the target video clip according to the optical flow value of each pixel; The dynamic area ratio of the target video segment is determined according to the dynamic area of ​​the target video segment and the video screen area.

[0009] Optionally, determining the dynamic area of ​​the target video segment according to the optical flow value of each pixel point includes: When the optical flow value of the pixel point is greater than the preset optical flow threshold, it is determined that the position of the pixel point is a dynamic area.

[0010] Optionally, the method comprises: The preset optical flow threshold is adjusted according to the optical flow value of each pixel in each of the video frames.

[0011] Optionally, the method further comprises: Encoding each of the original video clips according to preset encoding parameters to obtain multiple encoded video clips; When the image quality of the target coded video segment does not meet the preset condition, adjusting the preset coding parameter to obtain a second coding parameter; the target coded video segment is any one of the multiple coded video segments; A first original video segment corresponding to the target coded video segment is encoded according to the second encoding parameter.

[0012] Optionally, determining a first encoding parameter of the target video segment includes: When the target video segment is not the first original video segment, adjusting the first encoding parameter according to the second encoding parameter; In the case that the target video segment is the first original video segment, the first encoding parameter is obtained by adjusting the preset encoding parameter.

[0013] Optionally, encoding the target video segment according to the first encoding parameter includes: When the first encoding parameter is not less than a preset minimum encoding parameter, encoding the target video segment according to the first encoding parameter; When the first encoding parameter is less than a preset minimum encoding parameter, the target video segment is encoded according to the preset minimum encoding parameter.

[0014] Another aspect of an embodiment of the present application provides a video encoding device, the device comprising: A segmentation module, used for segmenting a video into a plurality of original video segments, wherein the plurality of original video segments include a target video segment; A first determination module is used to determine a dynamic area ratio of a target video segment, where the dynamic area ratio is a ratio of the dynamic area in the video picture; A second determining module is configured to determine a first encoding parameter of the target video segment when the dynamic area ratio is lower than a preset ratio threshold; and An encoding module is used to encode the target video segment according to the first encoding parameter.

[0015] Another aspect of an embodiment of the present application provides a computer device, including: at least one processor; and a memory communicatively coupled to the at least one processor; Wherein: the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method as described above.

[0016] Another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method described above is implemented.

[0017] Another aspect of an embodiment of the present application provides a computer program product, including a computer program, which implements the method described above when executed by a processor.

[0018] The embodiments of the present application adopting the above-mentioned technical solution may include the following advantages: by first dividing the video into video segments, and then adjusting the encoding parameters of the video segments containing dynamic areas with a smaller proportion in the picture, and using the adjusted encoding parameters for encoding, the encoding quality of the dynamic area can be improved and the stability of the actual image quality can be maintained. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings exemplarily illustrate the embodiments and constitute a part of the specification, and together with the text description of the specification, are used to explain the exemplary implementation of the embodiments. The embodiments shown are for illustrative purposes only and do not limit the scope of the claims. In all drawings, the same reference numerals refer to similar but not necessarily identical elements.

[0020] Figure 1 A diagram schematically shows an operating environment of a video encoding method according to Embodiment 1 of the present application; Figure 2 The flowchart of the video encoding method according to the first embodiment of the present application is schematically shown; Figure 3 Schematically shows Figure 2 Flow chart of sub-steps of step S200; Figure 4 Schematically shows Figure 2 Flow chart of sub-steps of step S202; Figure 5 The newly added flow chart of the video encoding method according to the first embodiment of the present application is schematically shown; Figure 6 Schematically shows Figure 2 Flow chart of sub-steps of step S204; Figure 7 Schematically shows Figure 2 Flow chart of sub-steps of step S206; Figure 8 is an example diagram of an application of a video encoding method according to an embodiment of the present application; Fig. 9 A block diagram schematically shows a video encoding device according to Embodiment 2 of the present application; and Fig.10 The hardware architecture diagram of the computer device according to the third embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0021] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0022] It should be noted that the descriptions involving "first", "second", etc. in the embodiments of the present application are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0023] In the description of the present application, it should be understood that the numerical labels before the steps do not indicate the order in which the steps are executed, but are only used to facilitate the description of the present application and to distinguish each step, and therefore should not be understood as a limitation on the present application.

[0024] First, the following terms are explained: Video encoding: is the process of converting raw video data into a compressed format for easy storage and transmission.

[0025] RF (Rate Factor) is a coding parameter of CRF coding mode, which can control the bit rate and quality of the encoded file. For the same video, the higher the RF, the lower the bit rate and the worse the image quality.

[0026] VMAF (Video Multimethod Assessment Fusion) is a full-reference evaluation method for measuring the quality of encoded videos.

[0027] Optical flow is a technology in the field of computer vision that is used to represent the speed and direction of movement of pixels in an image between adjacent frames.

[0028] Distortion: refers to the deformation of an image during compression, transmission or display, such as pixelation, blurring or color distortion.

[0029] Command line tool: refers to a tool that operates computer programs through a text command line interface (CLI).

[0030] API (Application Programming Interface) is a set of predefined functions, protocols, and tools for building software and applications.

[0031] PSNR (Peak Signal-to-Noise Ratio) is an indicator for evaluating image quality and is used in image compression and various image processing fields.

[0032] SSIM (Structural Similarity Index): is an indicator that measures the similarity between two images. It evaluates image quality by comparing the brightness, contrast, and structural information of the images.

[0033] QP (Quantizer Parameter) is a parameter in video encoding that determines the degree of image compression. The smaller the QP value, the smaller the quantization step size and the higher the image quality, but the corresponding bit rate will also increase. On the contrary, the larger the QP value, the larger the quantization step size, the lower the image quality and the lower the bit rate.

[0034] Secondly, in order to facilitate those skilled in the art to understand the technical solutions provided in the embodiments of the present application, the relevant technologies are described below: In the process of video production, in order to provide users with a stable viewing experience, the quality of the video after encoding will be controlled to meet a preset goal during video transcoding. For example, the VMAF index after video encoding will be controlled. When VMAF evaluates the quality of the encoded video, it will first calculate the local distortion in the image, then average the local distortion to get the distortion of the entire image, and use this to evaluate the video quality.

[0035] However, the inventors have found that for some videos with slight or still background motion but intense foreground motion, since the static or slow-moving images are relatively easy to encode, there is basically no obvious distortion. The dynamic areas that are more difficult to encode account for a small proportion, and the distortion of the dynamic areas has a relatively small impact on the VMAF of the overall image. In this case, although the overall image quality of the encoded video meets the VMAF requirements, the dynamic areas that the human eye pays attention to will show deterioration in image quality such as blurring and block effects.

[0036] To this end, the embodiment of the present application provides a video encoding technical solution. In this technical solution, by first dividing the video into video segments, and then adjusting the encoding parameters of the video segments containing a relatively small proportion of dynamic areas in the picture, and encoding using the adjusted encoding parameters, the encoding quality of the dynamic area can be improved and the stability of the actual image quality can be maintained. See below for details.

[0037] Finally, for ease of understanding, an exemplary operating environment is provided below.

[0038] For example, it can be used for Figure 1 The computer devices 2 and 6 shown in the figure. The computer device 6 can be configured to access the content (e.g., video) and services of the server. The computer device 6 can include an electronic device carrying or externally connected to a display panel, such as a mobile device, a tablet device, a laptop computer, a workstation, a virtual reality device, a gaming device, a digital streaming device, a vehicle user terminal, a smart TV, a set-top box, etc., and can also include a virtualized computing instance. Among them, the virtualized computing instance can include a virtual machine, such as a simulation of a computer system, an operating system, a server, etc.

[0039] The computer device 6 may be associated with one or more users. A single user may also use one or more of the computer devices 6 to access the server. The computer device 6 may travel to various locations and use different networks to access the server. The computer device 6 may include multiple client programs, such as a video codec, for providing encoding and decoding services. The video codec may encode and compress a video or image to facilitate transmission or storage of the video or image.

[0040] In the following, multiple embodiments are provided in the above exemplary application environment to illustrate the video coding scheme. It should be noted that these embodiments can be implemented in many different forms and should not be construed as being limited to the embodiments described herein.

[0041] Embodiment 1 Figure 2 The flowchart of the video encoding method according to the first embodiment of the present application is schematically shown.

[0042] like Figure 2 As shown, the video encoding method may include steps S200 to S206, wherein: Step S200: dividing a video into a plurality of original video segments, wherein the plurality of original video segments include a target video segment.

[0043] Step S202, determining the dynamic area ratio of the target video segment, where the dynamic area ratio is the ratio of the dynamic area in the video picture.

[0044] Step S204: when the dynamic area ratio is lower than a preset ratio threshold, determine a first encoding parameter of the target video segment.

[0045] Step S206: encode the target video segment according to the first encoding parameter.

[0046] The video encoding method provided in this embodiment adjusts the encoding parameters of the dynamic video segments before encoding. That is, in the embodiment of the present application, by first dividing the video into video segments, and then adjusting the encoding parameters of the video segments containing a relatively small proportion of dynamic areas in the picture, and encoding using the adjusted encoding parameters, the encoding quality of the dynamic areas can be improved and the stability of the actual image quality can be maintained. In this way, while maintaining high video quality, the image quality of the dynamic areas that the human eye pays attention to is also good, and there will be no deterioration of image quality such as blurring and block effects.

[0047] The following combination Figure 2 , each step in steps S200~S206 and other optional steps are described in detail.

[0048] Step S200, dividing the video into multiple original video segments, where the multiple original video segments include the target video segment.

[0049] In specific implementation, video segmentation can be performed through editing tools, command line tools, video processing APIs, etc. According to actual needs, video segmentation can be performed according to video scenes, action changes, audio features, face or object recognition, etc.

[0050] In this embodiment, the video is first segmented, so that the encoder can focus on specific parts of the video (such as target video segments with a relatively small proportion of dynamic areas) during the subsequent encoding process, thereby reducing the waste of computing resources and improving encoding efficiency.

[0051] In an optional embodiment, if Figure 3 As shown, step S200 may include: S300: Determine multiple scenes in the video.

[0052] S302: divide the video into a plurality of original video segments according to the plurality of scenes; wherein one original video segment corresponds to one scene.

[0053] Videos are generally composed of different scene clips, and the features of different scenes are not the same. In the same scene, the action types of people or objects in different frames are relatively similar, and the dynamic area of ​​the picture changes relatively little. Therefore, the complete video can be firstly subjected to video scene switching detection to obtain the location of scene switching, and then the video can be segmented according to the scene switching. In specific implementation, scene switching algorithms, video summarization technology, user manual marking of scene change points, video frame clustering analysis and other methods can be used for scene recognition and video segmentation.

[0054] In this embodiment, by segmenting the video according to the scene, it can be ensured that most of the frames in the same segment have similar dynamic area proportions, thereby improving the applicability of the adjusted encoding parameters to each frame in the same segment and improving the quality and efficiency of video encoding.

[0055] Step S202 , determine the dynamic area ratio of the target video clip, where the dynamic area ratio is the ratio of the dynamic area in the video picture.

[0056] In actual video transcoding, indicators such as VMAF can be used to measure the quality of the encoded video. When using the VMAF indicator, you can first calculate the local distortion in the image, then average the local distortion to get the distortion of the entire image, and use this to evaluate the video quality. In the process of image quality evaluation, the video screen can be divided into dynamic areas where people or objects move violently, and static areas where people or objects are still or moving slowly. At this time, the proportion of the dynamic area in the video screen determines its impact on the VMAF indicator. The higher the proportion, the greater the impact.

[0057] In this embodiment, by calculating the proportion of the dynamic area in the video picture, it is possible to determine the degree of influence of the picture quality of the dynamic area on the video quality evaluation index after the encoding is completed, so that the subsequent encoding strategy can be adjusted according to the proportion of the dynamic area, thereby improving the quality of video encoding and reducing the image quality damage in the dynamic area.

[0058] In an optional embodiment, if Figure 4 As shown, step S202 may include: S400: Determine a plurality of video frames in the target video segment according to a preset interval.

[0059] S402: Determine the optical flow value of each pixel in each of the video frames.

[0060] S404: Determine a dynamic area of ​​the target video segment according to the optical flow value of each pixel.

[0061] S406: Determine a dynamic area ratio of the target video segment according to the dynamic area of ​​the target video segment and the video screen area.

[0062] In specific implementation, when the video frame rate is 30fps, the preset interval can be set to extract 2 video frames per second. According to actual needs or in the case of other frame rates, other intervals can also be used to extract video frames.

[0063] After the video frame extraction is completed, the dense optical flow of all extracted video frames is calculated first, and then the optical flow between two adjacent video frames is calculated respectively, and all the optical flow results of the video clip can be obtained. According to the obtained optical flow results, the dynamic area in the video screen can be determined, and then the proportion of the dynamic area in the video clip can be obtained.

[0064] In this embodiment, by quantitatively analyzing the optical flow values ​​of pixels in a video frame, the dynamic area in the video can be more accurately identified, which helps to determine whether further parameter adjustment is required for the target video segment in subsequent encoding work, which can not only improve the video quality, but also achieve more efficient and intelligent video processing.

[0065] In an optional embodiment, step S404 may include: When the optical flow value of the pixel point is greater than the preset optical flow threshold, it is determined that the position of the pixel point is a dynamic area.

[0066] In this embodiment, by determining the dynamic area in the picture according to the optical flow value of the pixel points in the video, the proportion of the dynamic area in the video picture can be judged more accurately, which improves the pertinence and efficiency of video encoding and helps to improve the quality of the video.

[0067] In an optional embodiment, the method may include: The preset optical flow threshold is adjusted according to the optical flow value of each pixel in each of the video frames.

[0068] In specific implementation, the preset optical flow threshold may be adjusted to the average value of the optical flow map. According to actual needs, other methods (such as the median of the optical flow map, weighted average value, etc.) may also be used to adjust the preset optical flow threshold.

[0069] In practice, the optical flow value of a pixel point may be affected by factors such as camera motion and lighting changes, and the preset optical flow threshold may not be applicable to all video images.

[0070] In this embodiment, the preset optical flow threshold is adjusted according to the actual optical flow of the pixel points in each video frame. That is, the preset optical flow threshold can be optimized according to the characteristics of the video content, and the optimized preset optical flow threshold can more accurately identify the dynamic area in the video, thereby improving the flexibility of encoding and the quality of the encoded video.

[0071] In an optional embodiment, if Figure 5 As shown, the method may also include: S500: Encode each of the original video segments according to preset encoding parameters to obtain a plurality of encoded video segments.

[0072] S502, when the image quality of the target coded video segment does not meet the preset condition, adjust the preset coding parameter to obtain a second coding parameter; the target coded video segment is any one of the multiple coded video segments.

[0073] S504: Encode a first original video segment corresponding to the target encoding video segment according to the second encoding parameter.

[0074] In specific implementation, the VMAF index can be used to measure the image quality of the encoded video. According to actual needs, PSNR, SSIM, etc. can also be used to evaluate the video quality. In this embodiment, RF parameters are used as encoding parameters. In other embodiments, other parameters such as QP value can also be used as encoding parameters.

[0075] It should be noted that step S502 may be executed repeatedly until the image quality of the target encoded video segment finally obtained meets the preset condition. In the loop process, the second encoding parameter used in each loop is different.

[0076] In this embodiment, the encoding parameters can be continuously adjusted (such as increasing or decreasing the parameter values) so that the encoded video can meet the expected image quality requirements, thereby optimizing storage space and bandwidth usage while ensuring video quality, and achieving efficient video transmission and distribution.

[0077] Step S204 , when the proportion of the dynamic area is lower than a preset proportion threshold, determining a first encoding parameter of the target video segment.

[0078] When encoding videos where static or slow-moving images account for a large proportion, and where the dynamic area of ​​intense movement accounts for a small proportion, the static area is easy to encode and basically does not produce obvious distortion, while the dynamic area that is more difficult to encode is prone to distortion. However, since the dynamic area accounts for a small proportion of the image, its impact on the VAMF index is also small. Therefore, although the VAMF index is qualified, the dynamic area that the human eye pays attention to will be damaged, such as blur and block effects.

[0079] In specific implementation, the preset percentage threshold may be set to 30%. According to actual needs, the preset percentage threshold may also be set to other values.

[0080] In this embodiment, by adjusting the encoding parameters of the video clips whose dynamic area ratio is lower than the preset ratio threshold, the overall image quality of the encoded video can meet the expected image quality requirements while ensuring the encoding effect of the dynamic area in the video, thereby improving the quality and efficiency of video encoding, and preventing damage to the dynamic area, such as blurring, blocking effects, etc.

[0081] In an optional embodiment, if Figure 6 As shown, step S204 may include: S600: When the target video segment is not the first original video segment, obtain the first encoding parameter by adjusting the second encoding parameter.

[0082] S602: When the target video segment is a first original video segment, obtain the first encoding parameter according to the preset encoding parameter adjustment.

[0083] In some embodiments, each video clip may be configured to perform a preliminary encoding operation before determining whether it contains a small dynamic region, so that the overall video quality can meet the expected quality requirements. In other embodiments, the preliminary encoding step may be configured to be performed before the determination step or simultaneously with the determination step according to actual needs.

[0084] In this embodiment, for video clips that have not undergone preliminary encoding operations, or have undergone preliminary encoding operations but have not adjusted the preset encoding parameters and have already met the expected image quality requirements, the first encoding parameters can be obtained by adjusting the preset encoding parameters (increasing or decreasing the parameter values ​​on the basis of the preset encoding parameters). For video clips that have undergone preliminary encoding operations and adjusted the preset encoding parameters before determining the dynamic area ratio, corrections can be made on the basis of the second encoding parameters obtained after adjustment (increasing or decreasing the parameter values) to determine the first encoding parameters that meet the requirements, thereby improving the efficiency of video encoding and achieving a more efficient video processing workflow.

[0085] Step S206 , encoding the target video segment according to the first encoding parameter.

[0086] In this embodiment, the first encoding parameter is used to encode the target video segment with a relatively small proportion of dynamic areas, thereby improving the image quality of the dynamic area in a targeted manner, thereby ensuring the encoding effect of the target video segment, reducing the instability of the image quality, and having a certain anti-shake and translation effect.

[0087] In an optional embodiment, if Figure 7 As shown, step S206 may include: S700: When the first encoding parameter is not less than a preset minimum encoding parameter, encode the target video segment according to the first encoding parameter.

[0088] S702: When the first encoding parameter is less than a preset minimum encoding parameter, encode the target video segment according to the preset minimum encoding parameter.

[0089] In the actual video encoding process, if the encoding parameters (such as RF parameters) are too low, it may cause excessive video compression, or even loss of details and picture damage, affecting the video quality.

[0090] In this embodiment, the parameters finally used for encoding are controlled to be not less than the preset minimum encoding parameters, thereby ensuring that the output quality during the video encoding process meets certain standards and avoiding the video quality being affected by setting the parameters too low.

[0091] In order to make this application easier to understand, the following Figure 8 An exemplary application is provided. S11, input a video, the video frame rate is 30fps, the preset ratio threshold is S=0.3, the preset encoding parameter is RF=23, the preset image quality condition is VMAF=95, and the preset minimum encoding parameter is RFmin=18.

[0092] S12, performing scene switching detection on the video to obtain three segments A, B, and C.

[0093] S13, encoding segment A using preset encoding parameters to obtain segment A1, where VMAF of segment A1 is 94.

[0094] S14, determining that the image quality of segment A1 does not meet a preset condition, and adjusting the second encoding parameter to RF=21.

[0095] S15, using the second encoding parameter to encode segment A to obtain segment A2, where VMAF of segment A2 is 96.

[0096] S16, determining whether the image quality of segment A2 meets a preset condition.

[0097] S17, extract 2 frames of images per second for segment A, calculate their dense optical flows respectively, and obtain f1, f2, f3 ... fn.

[0098] S18, respectively calculating the optical flows between f1 and f2, between f2 and f3, ... between fn-1 and fn, and obtaining the optical flow result of segment A.

[0099] S19, according to the optical flow result of segment A, the average optical flow value of all pixels is calculated to be 5 pixels / frame, and the preset optical flow threshold is set to 5 pixels / frame accordingly.

[0100] S20, among all the pixels in the fragment A picture, 50% of the pixels have an optical flow value greater than 5 pixels / frame in at least one frame of the image, and the dynamic area ratio of fragment A is S1=0.5.

[0101] S21, determine that S1>S, and there is no need to adjust segment A.

[0102] S22, encode segment B using preset encoding parameters to obtain segment B1, where VMAF of segment B1 is 97.

[0103] S23, determining whether the image quality of segment B1 meets a preset condition.

[0104] S24, referring to steps S17 to S20, the dynamic area ratio S2 of segment B1 is obtained to be 0.2.

[0105] S25. Determine if S2 < S. If so, fragment B needs to be adjusted.

[0106] S26. Adjust according to the preset encoding parameters to obtain the first encoding parameter of fragment B as RF1 = 21, and max(RF1, RFmin) = RF1.

[0107] S27. Encode fragment B using the first encoding parameter to obtain fragment B2.

[0108] S28. Determine if there are no phenomena such as picture damage in the dynamic area of fragment B2.

[0109] S29. Refer to the steps of S13 - S15 to encode fragment C to obtain fragment C2, and the VMAF of fragment C2 is 98.

[0110] S30. Determine if the picture quality of fragment C2 meets the preset conditions.

[0111] S31. Refer to the steps of S17 - S20 to obtain the proportion S3 of the dynamic area of fragment C1 as 0.1.

[0112] S32. Determine if S3 < S. If so, fragment C needs to be adjusted.

[0113] S33. Adjust according to the preset encoding parameters to obtain the first encoding parameter of fragment C as RF1 = 17, and max(RF1, RFmin) = RFmin.

[0114] S34. Encode fragment C using the preset minimum encoding parameter to obtain fragment C3.

[0115] S35. Determine if there are no phenomena such as picture damage in the dynamic area of fragment C3.

[0116] Embodiment II Fig. 9 Schematically shows a block diagram of a video encoding device according to Embodiment II of the present application. The device can be divided into one or more program modules. One or more program modules are stored in a storage medium and executed by one or more processors to complete the embodiments of the present application. The program modules referred to in the embodiments of the present application refer to a series of computer program instruction segments that can complete specific functions. The following description will specifically introduce the functions of each program module in this embodiment. As Fig. 9 shown, the device 1000 may include: a splitting module 1100, a first determination module 1200, a second determination module 1300, and an encoding module 1400, where: The splitting module 1100 is used to split a video into multiple original video fragments, and the multiple original video fragments include a target video fragment; A first determination module 1200 is used to determine a dynamic area ratio of a target video segment, where the dynamic area ratio is a ratio of the dynamic area in the video image; The second determining module 1300 is configured to determine a first encoding parameter of the target video segment when the dynamic area ratio is lower than a preset ratio threshold; and The encoding module 1400 is configured to encode the target video segment according to the first encoding parameter.

[0117] As an optional embodiment, the segmentation module 1100 may also be used for: determining a plurality of scenes in the video; According to the multiple scenes, the video is divided into multiple original video segments; wherein one video segment corresponds to one scene.

[0118] As an optional embodiment, the first determining module 1200 may also be used to: Determine a plurality of video frames in the target video segment according to a preset interval; Determine the optical flow value of each pixel in each of the video frames; Determining a dynamic area of ​​the target video clip according to the optical flow value of each pixel; The dynamic area ratio of the target video segment is determined according to the dynamic area of ​​the target video segment and the video screen area.

[0119] As an optional embodiment, the device 1000 may also be used for: When the optical flow value of the pixel point is greater than the preset optical flow threshold, it is determined that the position of the pixel point is a dynamic area.

[0120] As an optional embodiment, the device 1000 may also be used for: The preset optical flow threshold is adjusted according to the optical flow value of each pixel in each of the video frames.

[0121] As an optional embodiment, the device 1000 may also be used for: Encoding each of the original video clips according to preset encoding parameters to obtain multiple encoded video clips; When the image quality of the target coded video segment does not meet the preset condition, adjusting the preset coding parameter to obtain a second coding parameter; the target coded video segment is any one of the multiple coded video segments; A first original video segment corresponding to the target coded video segment is encoded according to the second encoding parameter.

[0122] As an optional embodiment, the second determining module 1300 may also be used to: When the target video segment is a first original video segment, adjusting the first encoding parameter according to the second encoding parameter; In a case where the target video segment is not the first original video segment, the first encoding parameter is obtained by adjusting the preset encoding parameter.

[0123] As an optional embodiment, the encoding module 1400 is further configured to: When the first encoding parameter is not less than a preset minimum encoding parameter, encoding the target video segment using the first encoding parameter; When the first encoding parameter is less than a preset minimum encoding parameter, the target video segment is encoded using the preset minimum encoding parameter.

[0124] Embodiment 3 Fig.10 The schematic diagram of the hardware architecture of a computer device 10000 suitable for implementing a video encoding method according to the third embodiment of the present application is shown schematically. In some embodiments, the computer device 10000 may be a terminal device such as a smart phone, a wearable device, a tablet computer, a personal computer, a vehicle-mounted terminal, a game console, a virtual device, a workbench, a digital assistant, a set-top box, a robot, etc. In other embodiments, the computer device 10000 may be a rack server, a blade server, a tower server, or a cabinet server (including an independent server, or a server cluster composed of multiple servers), etc. Fig.10 As shown, the computer device 10000 includes but is not limited to: a memory 10010, a processor 10020, and a network interface 10030 that can communicate with each other through a system bus. Among them: The memory 10010 includes at least one type of computer-readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 10010 can be an internal storage module of the computer device 10000, such as a hard disk or memory of the computer device 10000. In other embodiments, the memory 10010 can also be an external storage device of the computer device 10000, such as a plug-in hard disk equipped on the computer device 10000, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 10010 can also include both the internal storage module of the computer device 10000 and its external storage device. In this embodiment, the memory 10010 is generally used to store an operating system and various application software installed in the computer device 10000, such as program codes of a video encoding method, etc. In addition, the memory 10010 can also be used to temporarily store various data that have been output or are to be output.

[0125] In some embodiments, the processor 10020 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other chips. The processor 10020 is generally used to control the overall operation of the computer device 10000, such as performing control and processing related to data interaction or communication with the computer device 10000. In this embodiment, the processor 10020 is used to run the program code stored in the memory 10010 or process data.

[0126] The network interface 10030 may include a wireless network interface or a wired network interface, and the network interface 10030 is generally used to establish a communication link between the computer device 10000 and other computer devices. For example, the network interface 10030 is used to connect the computer device 10000 to an external terminal through a network, and to establish a data transmission channel and a communication link between the computer device 10000 and the external terminal. The network may be a wireless or wired network such as an intranet, the Internet, the Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, etc.

[0127] It should be pointed out that Fig.10 Only a computer device having components 10010 - 10030 is shown, but it should be understood that implementation of all of the components shown is not a requirement, and more or fewer components may alternatively be implemented.

[0128] In this embodiment, the video encoding method stored in the memory 10010 can also be divided into one or more program modules and executed by one or more processors (such as processor 10020) to complete the embodiment of the present application.

[0129] Embodiment 4 An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the video encoding method in the embodiment are implemented.

[0130] In this embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the computer-readable storage medium may be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium may also be an external storage device of a computer device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device. Of course, the computer-readable storage medium may also include both the internal storage unit of the computer device and its external storage device. In this embodiment, the computer-readable storage medium is generally used to store an operating system and various application software installed on the computer device, such as the program code of the video encoding method in the embodiment, etc. In addition, the computer-readable storage medium may also be used to temporarily store various types of data that have been output or are to be output.

[0131] Embodiment 5 An embodiment of the present application also provides a computer program product, including a computer program, which implements the method in the above embodiment when executed by a processor.

[0132] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present application can be implemented by general-purpose computer devices, they can be concentrated on a single computer device, or distributed on a network composed of multiple computer devices, optionally, they can be implemented by executable program codes of computer devices, so that they can be stored in a storage device and executed by the computer device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.

[0133] It should be noted that the above are only preferred embodiments of the present application, and the patent protection scope of the present application is not limited thereto. Any equivalent structure or equivalent process transformation made using the contents of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A video encoding method, characterized in that: The method comprises: Splitting the video into a plurality of original video segments, wherein the plurality of original video segments include a target video segment; Determine the dynamic area ratio of the target video clip, where the dynamic area ratio is the ratio of the dynamic area in the video picture; When the dynamic area ratio is lower than a preset ratio threshold, determining a first encoding parameter of the target video segment; and The target video segment is encoded according to the first encoding parameter.

2. The method according to claim 1, characterized in that Split the video into multiple original video segments, including: determining a plurality of scenes in the video; According to the multiple scenes, the video is divided into multiple original video segments; wherein one original video segment corresponds to one scene.

3. The method according to claim 1, characterized in that Determine the dynamic area ratio of the target video clip, including: Determine a plurality of video frames in the target video segment according to a preset interval; Determine the optical flow value of each pixel in each of the video frames; Determining a dynamic area of ​​the target video clip according to the optical flow value of each pixel; The dynamic area ratio of the target video segment is determined according to the dynamic area of ​​the target video segment and the video screen area.

4. The method according to claim 3, characterized in that: Determining the dynamic area of ​​the target video segment according to the optical flow value of each pixel point includes: When the optical flow value of the pixel point is greater than the preset optical flow threshold, it is determined that the position of the pixel point is a dynamic area.

5. The method according to claim 4, characterized in that The method comprises: The preset optical flow threshold is adjusted according to the optical flow value of each pixel in each of the video frames.

6. The method according to claim 1, characterized in that Also includes: Encoding each of the original video clips according to preset encoding parameters to obtain multiple encoded video clips; When the image quality of the target coded video segment does not meet the preset condition, adjusting the preset coding parameter to obtain a second coding parameter; the target coded video segment is any one of the multiple coded video segments; A first original video segment corresponding to the target coded video segment is encoded according to the second encoding parameter.

7. The method according to claim 6, characterized in that Determining a first encoding parameter of the target video segment includes: When the target video segment is a first original video segment, adjusting the first encoding parameter according to the second encoding parameter; In a case where the target video segment is not the first original video segment, the first encoding parameter is obtained by adjusting the preset encoding parameter.

8. The method according to any one of claims 1 to 7, characterized in that: Encoding the target video segment according to the first encoding parameter includes: When the first encoding parameter is not less than a preset minimum encoding parameter, encoding the target video segment according to the first encoding parameter; When the first encoding parameter is less than a preset minimum encoding parameter, the target video segment is encoded according to the preset minimum encoding parameter.

9. A video encoding device, characterized in that: The device comprises: A segmentation module, used for segmenting a video into a plurality of original video segments, wherein the plurality of original video segments include a target video segment; A first determination module is used to determine a dynamic area ratio of a target video segment, where the dynamic area ratio is a ratio of the dynamic area in the video picture; A second determining module is configured to determine a first encoding parameter of the target video segment when the dynamic area ratio is lower than a preset ratio threshold; and An encoding module is used to encode the target video segment according to the first encoding parameter.

10. A computer device, characterized in that: include: at least one processor; and a memory communicatively coupled to the at least one processor; wherein: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.

12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Video coding method and device

    CN106162177A

  • Monitoring video abnormal behavior detection method based on motion information clustering

    CN111325073A

  • Abnormal behavior identification method and device, equipment and storage medium

    CN113762027A

  • Video coding method and device, computer equipment and storage medium

    CN116896629A

  • Video processing with static and dynamic regions and method for use therewith

    US20150281698A1

Cited By

  • Video encoding method and apparatus

    WO2026138025A1