Video encoding method, device, equipment and storage medium

By calculating the intra and inter-frame complexity in the video file and matching the encoding strategy, the problem of high complexity in video scene segmentation calculation in the prior art is solved, and the transcoding efficiency and resource utilization are improved.

CN112449182BActive Publication Date: 2025-01-07GUANGZHOU HUYA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910803054.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-08-28
Publication Date
2025-01-07
Estimated Expiration
2039-08-28

AI Technical Summary

Technical Problem

In the prior art, the calculation complexity of video scene segmentation is high, and it is impossible to perform frame-by-frame synchronous calculation, resulting in a large resource consumption and low transcoding efficiency.

Method used

By obtaining the frame type parameters corresponding to each image group (GOP) in the video file, calculate the intra-frame complexity and inter-frame complexity, calculate the scene complexity based on these complexity, and use a coding strategy that matches the scene complexity for videos. coding.

Benefits of technology

It realizes the accurate synchronous computing scenario complexity while reducing development costs and resource consumption, and improves the transcoding efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112449182B_ABST
    Figure CN112449182B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a video encoding method, device, equipment and storage medium. The method comprises: obtaining frame type parameters corresponding to video frames in each group of images GOP of the video file to be encoded; calculating the intra-frame complexity and inter-frame complexity of each GOP according to the frame type parameters; calculating the scene complexity corresponding to each GOP according to the intra-frame complexity and the inter-frame complexity; and performing video encoding on each GOP in the video file using an encoding strategy matching the scene complexity. The technical solution of the embodiment of the present invention accurately and synchronously calculates the scene complexity while improving the transcoding efficiency under the premise of reducing development costs and resource consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of digital signal processing technology, and in particular to a video encoding method, apparatus, device and storage medium. Background Art

[0002] With the rapid development of Internet technology, users' demand for high-definition video is increasing day by day, and the amount of video data of video multimedia is also increasing. If these videos are not compressed, they are difficult to apply to actual storage and transmission.

[0003] In the prior art, X264 is a video compression encoder based on the H.264 / MPEG-4AVC video compression standard, which provides many configurable parameters to control its encoding efficiency. Among them, narrowband HD technology can reduce the video bit rate as much as possible without affecting the subjective viewing quality of the video, and one of the key steps to achieve narrowband HD is scene segmentation.

[0004] Currently, there are a variety of technologies that can be used for scene segmentation, but most of the existing scene detection methods are based on calculating the temporal and spatial complexity of video frames, and then obtaining the scene complexity of the video after weighted normalization. Although this algorithm can calculate the scene complexity well, its computational complexity is high and it cannot be calculated frame by frame. It requires another thread for asynchronous calculation. At the same time, in the background transcoding service, the resources of the transcoding machine are limited, and high-complexity scene calculations will also reduce transcoding efficiency. Summary of the invention

[0005] Embodiments of the present invention provide a video encoding method, apparatus, device and storage medium to achieve accurate and synchronous calculation of scene complexity while reducing development costs and resource consumption, and improve transcoding efficiency.

[0006] In a first aspect, an embodiment of the present invention provides a video encoding method, including:

[0007] Obtain frame type parameters corresponding to video frames in each group of pictures (GOP) of the video file to be encoded;

[0008] According to the frame type parameters, the intra-frame complexity and inter-frame complexity of each GOP are calculated;

[0009] Calculate the scene complexity corresponding to each GOP based on the intra-frame complexity and the inter-frame complexity;

[0010] A coding strategy that matches the scene complexity is used to encode each GOP in the video file.

[0011] Optionally, obtaining frame type parameters corresponding to video frames in each GOP of the video file processed by the X264 plug-in includes:

[0012] By calling at least one application program interface provided by the X264 plug-in, frame type parameters corresponding to video frames in each GOP of the video file processed by the X264 plug-in are obtained.

[0013] Optionally, the intra-frame complexity and inter-frame complexity of each GOP are calculated according to the frame type parameter, including:

[0014] Calculating the intra-frame complexity of each GOP according to the frame type parameters of the intra-frame coded image frames in each GOP;

[0015] The inter-frame complexity of each GOP is calculated according to the frame type parameters of the predictive coded image frames and / or the bidirectional predictive coded image frames in each GOP.

[0016] Optionally, the inter-frame complexity of each GOP is calculated according to the frame type parameters of the predictive coded image frames in each GOP, including:

[0017] In the GOP currently being processed, a frame sequence of predictive coded image frames is sequentially extracted;

[0018] According to the video frame cost value of each predictive coding image frame in the frame sequence and the set attenuation factor, each video frame cost value is weighted to obtain the inter-frame complexity of the GOP;

[0019] In the GOP, the closer the predicted coded image frame is to the intra-coded image frame, the greater the attenuation of the video frame cost value of the predicted coded image frame.

[0020] Optionally, according to the video frame cost value of each predictive coding image frame in the frame sequence and the set attenuation factor, each video frame cost value is weighted to obtain the inter-frame complexity of the GOP, including:

[0021] According to the formula: Cost = Cost N-1 +dacay*Cost N-2 +…+dacay N-1 * Cost0 calculates the frame sequence (P0, P1, ..., P N-1 ) Weighted cost Cost;

[0022] Among them, with (P0, P1, ..., P N-1 ) The corresponding video frame cost value sequence is (Cost0, Cost1, ..., Cost N-1 );N is the total number of predictive coded image frames included in the GOP, dacay is the attenuation factor, dacay∈(0,1);

[0023] According to the formula: num = 1 + dacay + ... + dacayN-1 Calculate the normalization coefficient num corresponding to Cost;

[0024] According to the formula: Cost p = Cost / num, calculate the inter-frame complexity Cost of GOP p .

[0025] Optionally, after calculating the intra-frame complexity and the inter-frame complexity of each GOP according to the frame type parameter, the method further includes:

[0026] The intra-frame complexity and inter-frame complexity of each GOP are calculated and normalized according to the set macroblock size.

[0027] In a second aspect, an embodiment of the present invention further provides a video encoding device, including:

[0028] A parameter acquisition module, used for acquiring frame type parameters corresponding to video frames in each group of pictures GOP of the video file to be encoded;

[0029] A first complexity calculation module, used for calculating the intra-frame complexity and inter-frame complexity of each GOP according to the frame type parameter;

[0030] A second complexity calculation module, used to calculate the scene complexity corresponding to each GOP according to the intra-frame complexity and the inter-frame complexity;

[0031] The video encoding module is used to adopt an encoding strategy that matches the scene complexity to perform video encoding on each GOP in the video file.

[0032] In a third aspect, an embodiment of the present invention further provides a device, the device comprising:

[0033] one or more processors;

[0034] a storage device for storing one or more programs,

[0035] When one or more programs are executed by one or more processors, the one or more processors implement the video encoding method provided by any embodiment of the present invention.

[0036] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the video encoding method provided by any embodiment of the present invention.

[0037] The technical solution of the embodiment of the present invention obtains frame type parameters corresponding to video frames in each GOP of the video file to be encoded, calculates the intra-frame complexity and inter-frame complexity of each GOP according to the frame type parameters, calculates the scene complexity corresponding to each GOP according to the intra-frame complexity and the inter-frame complexity, and adopts a coding strategy matching the scene complexity to perform video encoding on each GOP in the video file. This solves the problems in the prior art of high computational complexity of scene segmentation of the video, inability to perform synchronous calculation frame by frame, large number of resources used, and low transcoding efficiency, and achieves accurate synchronous calculation of scene complexity while improving transcoding efficiency while reducing development costs and resource consumption. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 is a flowchart of a video encoding method in Embodiment 1 of the present invention;

[0039] Figure 2 is a flowchart of a video encoding method in Embodiment 2 of the present invention;

[0040] Figure 3 is a structural diagram of a video encoding device in Embodiment 3 of the present invention;

[0041] Figure 4 It is a structural diagram of a device in Embodiment 4 of the present invention. DETAILED DESCRIPTION

[0042] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0043] Embodiment 1

[0044] Figure 1 1 is a flowchart of a video encoding method in Embodiment 1 of the present invention. This embodiment is applicable to the case where the scene complexity of each GOP in a video file is calculated to perform video encoding on the GOP. The method can be executed by a video encoding device, which can be implemented by hardware and / or software and can generally be integrated in a device that provides video encoding services. Figure 1 As shown, the method includes:

[0045] Step 110: Obtain frame type parameters corresponding to video frames in each GOP of the video file to be encoded.

[0046] In this embodiment, the video file includes multiple GOPs, and a GOP is a group of continuous video images, each of which is slightly different from the previous image. Each GOP may include three types of video frames: I frame, P frame, and B frame, and each GOP starts with an I frame and ends with the next I frame.

[0047] In this embodiment, the I frame is called an intra-frame coded image frame. It is a reference frame that records all the information of the original image. It can be decoded independently without referring to other images. It can be simply understood as a static image. The first frame of a GOP is always an intra-frame coded image frame, and there is only one intra-frame coded image frame in a GOP. The intra-frame coded image frame is the starting point of encoding and decoding, and is also a reference frame for P frames and B frames. Its quality can directly affect the quality of subsequent video frames in the same GOP.

[0048] In this embodiment, the P frame is called a predictive coding image frame, which needs to refer to the previous intra-frame coded image frame to be encoded, and represents the difference between the current frame image and the previous frame image, wherein the previous frame may be an intra-frame coded image frame or a predictive coding image frame. When decoding the current predictive coding image frame, it is necessary to superimpose the previously cached image with the difference defined by the current frame to generate the final image.

[0049] In this embodiment, the B frame is called a bidirectional predictive interpolation coded frame, which records the difference between the current frame and the previous and next frames. That is to say, when decoding the bidirectional predictive interpolation coded frame, it is necessary not only to obtain the cached image before the current frame, but also to obtain the image after the current frame. The final image is generated by superimposing the images of the previous and next frames with the data of the current frame.

[0050] Optionally, obtaining frame type parameters corresponding to video frames in each GOP of the video file to be encoded includes: calling an X264 plug-in to process the video file, and obtaining frame type parameters corresponding to video frames in each GOP of the video file processed by the X264 plug-in; the frame type parameters include: video frame type, video frame cost value. Among them, the video frame types include: intra-frame coded image frames, predictive coded image frames, and bidirectional predictive interpolation coded frames. The video frame cost value specifically refers to the frame loss, that is, the loss value of intra-frame coding or inter-frame coding of a video frame.

[0051] The X264 plug-in includes an analysis module, which has three main functions: 1) making frame type decisions; 2) macroblock tree adaptive quantization calculations; 3) bit rate control related calculations, which can pre-calculate some optimization parameters and provide better bit rate allocation, so that better video quality can be encoded at the same bit rate.

[0052] In this embodiment, calling the X264 plug-in to process the video file mainly refers to making a frame type decision on the video file to obtain frame type parameters corresponding to the video frames in each GOP of the video file. Specifically, the X264 plug-in supports three frame type decision algorithms: 1) X264_B_ADAPT_TRELLIS, which applies the idea of ​​dynamic programming to dynamically calculate the cost of each video frame in the video file when it is of different frame types, and finally selects the line with the smallest cost to obtain the frame type of the video file. The algorithm has high computational complexity, but can obtain the optimal frame type decision; 2) X264_B_ADAPT_FAST, which only calculates the cost of the current video frame and the next video frame, and on the premise that the next video frame is a predictive coded image frame, calculates the cost of the current frame as a bidirectional predictive interpolation coded frame and a predictive coded image frame, and selects the frame type corresponding to the smallest cost value as the current frame type. The algorithm has low computational complexity and can obtain a better frame type decision; 3) X264_B_ADAPT_NONE, which does not introduce any calculations and only needs to provide a frame type sequence that meets the GOP restriction.

[0053] Optionally, under the premise of considering complexity and accuracy, the X264_B_ADAPT_ FAST algorithm is usually used to make frame type decision processing for video files. Of course, other algorithms can also be used. This embodiment does not specifically limit which frame type decision algorithm is used. After the frame type decision is completed, the frame type parameters corresponding to the video frames in each GOP are stored so that the parameters can be called at any time.

[0054] Optionally, obtaining frame type parameters corresponding to video frames in each GOP of the video file processed by the X264 plug-in includes: obtaining frame type parameters corresponding to video frames in each GOP of the video file processed by the X264 plug-in by calling at least one application program interface provided by the X264 plug-in.

[0055] In this embodiment, considering the efficiency and open source nature of the X264 plug-in, the frame type parameters of each frame calculated by the X264 plug-in can be directly called to calculate the scene complexity of the entire GOP, and then the encoding strategy for each GOP can be determined in units of GOP, which ensures both the real-time calculation and the accuracy of the entire algorithm.

[0056] Of course, it is understandable that other methods may be used to obtain the frame type parameters corresponding to the video frames in each GOP of the video file, for example, by calling other types of encoder plug-ins, such as H264, etc., and this embodiment does not limit this.

[0057] Step 120: Calculate the intra-frame complexity and inter-frame complexity of each GOP according to the frame type parameter.

[0058] Optionally, the intra-frame complexity of each GOP may be calculated according to frame type parameters of intra-frame coded images in each GOP; the inter-frame complexity of each GOP may be calculated according to frame type parameters of predictive coded images and / or bidirectional predictive coded images in each GOP.

[0059] In this embodiment, since the intra-frame coded image frame records all the information of the original image, each macroblock therein can only be coded by referring to the macroblocks that have been coded before the current frame. Therefore, the complexity of the intra-frame coded image frame can be used as the intra-frame complexity of the GOP in which it is located, that is, it is only necessary to extract the complexity of the intra-frame coded image frame calculated by the analysis module of the X264 plug-in. The intra-frame complexity can represent the image texture and detail area.

[0060] In this embodiment, since the predictive coding image frame and the bidirectional predictive coding image frame are both inter-frame prediction frames and can reflect the size of the inter-frame complexity, the predictive coding image frame and / or the bidirectional predictive coding image frame can be used as a measure of the inter-frame complexity. In order to simplify the calculation, the inter-frame complexity of each GOP can be calculated only based on the frame type parameters of the predictive coding image frame in each GOP, or the inter-frame complexity of each GOP can be calculated only based on the frame type parameters of the bidirectional predictive coding image frame in each GOP.

[0061] Step 130: Calculate the scene complexity corresponding to each GOP according to the intra-frame complexity and the inter-frame complexity.

[0062] After the intra-frame complexity and inter-frame complexity of each GOP are obtained, the scene complexity corresponding to each GOP is calculated according to a predefined scene complexity calculation formula, for example, a weighted formula of the intra-frame complexity and the inter-frame complexity.

[0063] Step 140: Use a coding strategy that matches the scene complexity to perform video coding on each GOP in the video file.

[0064] Optionally, according to the correspondence between scene complexity and video scene, the video scene corresponding to each GOP is found, and then the encoding strategy matching each GOP is determined, and the encoding strategy is adopted to perform video encoding on the corresponding GOP.

[0065] Typically, a mapping relationship between scene complexity intervals and encoding strategies can be set, and different scene complexity intervals correspond to different encoding strategies, and different encoding strategies correspond to different encoding parameters, such as encoding type, frame rate or resolution, etc. Accordingly, those skilled in the art can set different encoding strategies for different scene complexity ranges according to actual conditions to achieve narrowband high definition.

[0066] In an embodiment of the present invention, frame type parameters corresponding to video frames in each image group GOP of a video file to be encoded are obtained, the intra-frame complexity and inter-frame complexity of each GOP are calculated according to the frame type parameters, the scene complexity corresponding to each GOP is calculated according to the intra-frame complexity and the inter-frame complexity, and a coding strategy matching the scene complexity is adopted to perform video encoding on each GOP in the video file. This solves the problems in the prior art of high computational complexity of scene segmentation of videos, inability to perform synchronous calculation frame by frame, large number of resources used, and low transcoding efficiency. This achieves accurate and synchronous calculation of scene complexity while improving transcoding efficiency while reducing development costs and resource consumption.

[0067] Embodiment 2

[0068] Figure 2 is a flow chart of a video encoding method in Embodiment 2 of the present invention. This embodiment can be combined with each optional solution in the above embodiments. Figure 2 , the method may include the following steps:

[0069] Step 210: Pre-establish a corresponding relationship between scene complexity and video scene.

[0070] Since the movement speeds of people or objects in video files are different, the encoding requirements for video files are also different, and the corresponding encoding schemes are also different. Therefore, in order to find the corresponding video scene according to the scene complexity, it is necessary to pre-establish the correspondence between the scene complexity and the video scene to specify the scene complexity interval corresponding to each video scene. For example, the scene complexity interval corresponding to the high-speed motion scene is A, the scene complexity interval corresponding to the medium-speed motion scene is B, the scene complexity interval corresponding to the slow-speed motion scene is C, and the scene complexity interval corresponding to the static scene is D, among which the intervals A, B, C, and D are in an opposing relationship.

[0071] Step 220: Call the X264 plug-in to process the video file to be encoded, and obtain frame type parameters corresponding to the video frames in each GOP of the video file to be encoded.

[0072] Optionally, after obtaining the frame type parameters corresponding to the video frames in each GOP of the video file processed by the X264 plug-in, a buffer area is provided locally to store the frame types and video frame cost values ​​of all the video frames in each GOP.

[0073] Step 230: Calculate the intra-frame complexity and inter-frame complexity of each GOP according to the frame type parameter.

[0074] Optionally, the intra-frame complexity of each GOP is calculated based on frame type parameters of intra-frame coded image frames in each GOP; the inter-frame complexity of each GOP is calculated based on frame type parameters of predictive coded image frames and / or bidirectional predictive coded image frames in each GOP.

[0075] For the convenience of calculation, only the frame type parameters of the predictive coded image frames in each GOP may be obtained from the buffer area for calculating the inter-frame complexity of each GOP.

[0076] Optionally, the inter-frame complexity of each GOP is calculated based on the frame type parameters of the predicted coded image frames in each GOP, which can include: in the currently processed GOP, sequentially extracting the frame sequence of predicted coded image frames; according to the video frame cost value of each predicted coded image frame in the frame sequence and a set attenuation factor, weighting each video frame cost value to obtain the inter-frame complexity of the GOP; wherein, in the GOP, the closer the predicted coded image frame is to the intra-frame coded image frame, the greater the attenuation of the video frame cost value of the predicted coded image frame.

[0077] Among them, when there are moving objects or people in the image of GOP, the farther the predicted coded image frame is from the intra-coded image frame of GOP, the greater the difference between it and the intra-coded image frame, the greater its reference value, and therefore, the smaller the corresponding attenuation factor.

[0078] Optionally, according to the video frame cost value of each predictive coding image frame in the frame sequence and the set attenuation factor, weighted processing is performed on each video frame cost value to obtain the inter-frame complexity of the GOP, which may include: according to the formula: Cost = Cost N-1 +dacay*Cost N-2 +…+dacay N-1 * Cost0 calculates the frame sequence (P0, P1, ..., P N-1 ) weighted cost Cost; where (P0, P1, ..., P N-1 ) The corresponding video frame cost value sequence is (Cost0, Cost1, ..., Cost N-1); N is the total number of predictive coded image frames included in the GOP, dacay is the attenuation factor, dacay∈(0,1); according to the formula: num=1+dacay+…+dacay N-1 Calculate the normalization coefficient num corresponding to Cost; according to the formula: Cost p = Cost / num, calculate the inter-frame complexity Cost of GOP p .

[0079] Step 240: Calculate the scene complexity corresponding to each GOP according to the intra-frame complexity and the inter-frame complexity.

[0080] Optionally, after calculating the intra-frame complexity and inter-frame complexity of each GOP according to the frame type parameter, the method further includes: normalizing the intra-frame complexity and inter-frame complexity of each GOP according to a set macroblock size.

[0081] In this embodiment, in order to shield the difference between different resolutions, the obtained intra-frame complexity and inter-frame complexity are normalized to obtain the normalized cost value of each macroblock size. Specifically, let the width and height of the source Y, U, and V data be width and height respectively, then the final cost values ​​of the intra-frame complexity and inter-frame complexity are:

[0082] Cost I _norm = Cost I <<8 / (width*height) (1)

[0083] Cost P _norm = Cost P <<8 / (width*height) (2)

[0084] Among them, << is a left shift operation, the source Y data represents the brightness of the pixel, that is, the grayscale value of the pixel; the source U data and the source V data represent the chromaticity of the pixel, which is used to describe the color and saturation of the image, and can specify the color of the pixel.

[0085] Formulas (1) and (2) divide the cost value of the complexity by the width and height of the source Y, U, and V data to obtain the cost value of each pixel in the image. By shifting left by 8 bits, the cost value of a 16*16 macroblock is obtained. Then, according to the pre-defined scene complexity calculation formula, the scene complexity corresponding to each GOP is calculated.

[0086] Step 250: Match the scene complexity of each GOP and the corresponding relationship between the scene complexity and the video scene to determine the scene corresponding to each GOP.

[0087] In the correspondence between scene complexity and video scene, a scene complexity range matching the scene complexity of the current GOP is found, and the video scene corresponding to the scene complexity range is used as the scene corresponding to the current GOP.

[0088] Step 260: Perform video encoding on each GOP in the video file by using an encoding strategy that matches the scene corresponding to each GOP.

[0089] In an embodiment of the present invention, frame type parameters corresponding to video frames in each image group GOP of a video file to be encoded are obtained, the intra-frame complexity and inter-frame complexity of each GOP are calculated according to the frame type parameters, the scene complexity corresponding to each GOP is calculated according to the intra-frame complexity and the inter-frame complexity, and a coding strategy matching the scene complexity is adopted to perform video encoding on each GOP in the video file. This solves the problems in the prior art of high computational complexity of scene segmentation of videos, inability to perform synchronous calculation frame by frame, large number of resources used, and low transcoding efficiency. This achieves accurate and synchronous calculation of scene complexity while improving transcoding efficiency while reducing development costs and resource consumption.

[0090] Embodiment 3

[0091] Figure 3 is a schematic diagram of the structure of a video encoding device in Embodiment 3 of the present invention. This embodiment is applicable to the case where the scene complexity of each GOP in a video file is calculated to perform video encoding on the GOP. Figure 3 As shown, the video encoding device includes: a parameter acquisition module 310, a first complexity calculation module 320, a second complexity calculation module 330 and a video encoding module 340;

[0092] The parameter acquisition module 310 is used to acquire frame type parameters corresponding to the video frames in each GOP of the video file to be encoded;

[0093] A first complexity calculation module 320, configured to calculate the intra-frame complexity and inter-frame complexity of each GOP according to the frame type parameter;

[0094] A second complexity calculation module 330, configured to calculate the scene complexity corresponding to each GOP according to the intra-frame complexity and the inter-frame complexity;

[0095] The video encoding module 340 is used to perform video encoding on each GOP in the video file by adopting an encoding strategy that matches the scene complexity.

[0096] In an embodiment of the present invention, frame type parameters corresponding to video frames in each GOP of a video file to be encoded are obtained, the intra-frame complexity and inter-frame complexity of each GOP are calculated according to the frame type parameters, the scene complexity corresponding to each GOP is calculated according to the intra-frame complexity and the inter-frame complexity, and a coding strategy matching the scene complexity is adopted to perform video encoding on each GOP in the video file. This solves the problems in the prior art of high computational complexity of scene segmentation of videos, inability to perform synchronous calculation frame by frame, large number of resources used, and low transcoding efficiency. This achieves accurate synchronous calculation of scene complexity while improving transcoding efficiency while reducing development costs and resource consumption.

[0097] Optionally, the parameter acquisition module 310 is specifically used to: call the X264 plug-in to process the video file, and obtain the frame type parameters corresponding to the video frames in each GOP of the video file processed by the X264 plug-in; the frame type parameters include: video frame type, video frame cost value.

[0098] Optionally, the first complexity calculation module 320 is specifically used to: calculate the intra-frame complexity of each GOP based on the frame type parameters of the intra-frame coded image frames in each GOP; calculate the inter-frame complexity of each GOP based on the frame type parameters of the predictive coded image frames and / or the bidirectional predictive coded image frames in each GOP.

[0099] Optionally, the first complexity calculation module 320 is specifically used to: sequentially extract a frame sequence of predicted coded image frames in the currently processed GOP; perform weighted processing on each video frame cost value according to the video frame cost value of each predicted coded image frame in the frame sequence and a set attenuation factor to obtain the inter-frame complexity of the GOP; wherein, in the GOP, the closer the predicted coded image frame is to the intra-frame coded image frame, the greater the attenuation of the video frame cost value of the predicted coded image frame.

[0100] Optionally, the first complexity calculation module 320 is specifically used to: According to the formula: Cost = Cost N-1 + dacay*Cost N-2 +…+dacay N-1 * Cost0 calculates the frame sequence (P0, P1, ..., P N-1 ) weighted cost Cost; where (P0, P1, ..., P N-1 ) The corresponding video frame cost value sequence is (Cost0, Cost1, ..., Cost N-1 ); N is the total number of predictive coding image frames included in the GOP, dacay is the attenuation factor, dacay∈(0,1); according to the formula: num=1+dacay+…+dacay N-1Calculate the normalization coefficient num corresponding to Cost; according to the formula: Cost p = Cost / num, calculate the inter-frame complexity Cost of GOP p .

[0101] Optionally, the first complexity calculation module 320 is further used to: after calculating the intra-frame complexity and inter-frame complexity of each GOP according to the frame type parameters, normalize the intra-frame complexity and inter-frame complexity of each GOP according to the set macroblock size.

[0102] The video encoding device provided in the embodiment of the present invention can execute the video encoding method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0103] Embodiment 4

[0104] Figure 4 It is a structural schematic diagram of a device disclosed in Embodiment 4 of the present invention. Figure 4 A block diagram of an exemplary device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 4 The device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0105] like Figure 4 As shown, device 12 is in the form of a general purpose computing device. Components of device 12 may include, but are not limited to, one or more processors or processing units 16, system memory 28, and bus 18 that connects various system components (including system memory 28 and processing unit 16).

[0106] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.

[0107] Device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by device 12, including volatile and non-volatile media, removable and non-removable media.

[0108] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 4 not shown, usually called a "hard drive"). Although Figure 4 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the embodiments of the present invention.

[0109] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in the memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described herein.

[0110] The device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the device 12, and / or may communicate with any device that enables the device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the device 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0111] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the video encoding method provided in the embodiment of the present invention.

[0112] That is, a video encoding method is implemented, including:

[0113] Obtaining frame type parameters corresponding to video frames in each GOP of the video file to be encoded;

[0114] Calculating the intra-frame complexity and inter-frame complexity of each of the GOPs according to the frame type parameters;

[0115] Calculating the scene complexity corresponding to each of the GOPs according to the intra-frame complexity and the inter-frame complexity;

[0116] A coding strategy matching the scene complexity is adopted to perform video coding on each of the GOPs in the video file.

[0117] Embodiment 5

[0118] Embodiment 5 of the present invention further discloses a computer storage medium, on which a computer program is stored. When the program is executed by a processor, a video encoding method is implemented, including:

[0119] Obtaining frame type parameters corresponding to video frames in each GOP of the video file to be encoded;

[0120] Calculating the intra-frame complexity and inter-frame complexity of each of the GOPs according to the frame type parameters;

[0121] Calculating the scene complexity corresponding to each of the GOPs according to the intra-frame complexity and the inter-frame complexity;

[0122] A coding strategy matching the scene complexity is adopted to perform video coding on each of the GOPs in the video file.

[0123] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0124] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0125] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0126] Computer program code for performing the operations of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0127] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A video encoding method, characterized in that: include: Obtaining frame type parameters corresponding to video frames in each group of pictures GOP of the video file to be encoded; Calculating the intra-frame complexity and inter-frame complexity of each of the GOPs according to the frame type parameters; Calculating the scene complexity corresponding to each of the GOPs according to the intra-frame complexity and the inter-frame complexity; The calculating the scene complexity corresponding to each of the GOPs according to the intra-frame complexity and the inter-frame complexity comprises: calculating the scene complexity corresponding to each of the GOPs by a weighted formula of the intra-frame complexity and the inter-frame complexity; A coding strategy matching the scene complexity is adopted to perform video coding on each of the GOPs in the video file.

2. The method according to claim 1, characterized in that Obtaining frame type parameters corresponding to video frames in each GOP of the video file to be encoded, including: Calling an X264 plug-in to process the video file, and obtaining frame type parameters corresponding to video frames in each GOP of the video file obtained by the X264 plug-in; The frame type parameters include: video frame type and video frame cost value.

3. The method according to claim 2, characterized in that Obtaining frame type parameters corresponding to video frames in each GOP of the video file obtained by the X264 plug-in, including: By calling at least one application program interface provided by the X264 plug-in, frame type parameters corresponding to video frames in each GOP of the video file processed by the X264 plug-in are obtained.

4. The method according to claim 1, characterized in that Calculating the intra-frame complexity and inter-frame complexity of each of the GOPs according to the frame type parameters, including: Calculating the intra-frame complexity of each of the GOPs according to the frame type parameters of the intra-frame coded image frames in each of the GOPs; The inter-frame complexity of each of the GOPs is calculated according to the frame type parameters of the predictive coded image frames and / or the bidirectional predictive coded image frames in each of the GOPs.

5. The method according to claim 4, characterized in that Calculating the inter-frame complexity of each of the GOPs according to the frame type parameters of the predictive coded image frames in each of the GOPs, including: In the GOP currently being processed, sequentially extracting a frame sequence of the predictive coded image frames; According to the video frame cost value of each of the predictive coded image frames in the frame sequence and the set attenuation factor, weighted processing is performed on each of the video frame cost values ​​to obtain the inter-frame complexity of the GOP; Wherein, in the GOP, the closer the predicted coded image frame is to the intra-frame coded image frame, the greater the attenuation of the video frame cost value of the predicted coded image frame.

6. The method according to claim 5, characterized in that According to the video frame cost value of each of the predictive coded image frames in the frame sequence and the set attenuation factor, weighted processing is performed on each of the video frame cost values ​​to obtain the inter-frame complexity of the GOP, including: According to the formula: Cost = Cost N-1 +dacay*Cost N-2 +…+dacay N-1 * Cost0 calculates the frame sequence (P0, P1, ..., P N-1 ) Weighted cost Cost; Among them, with the (P0, P1, ..., P N-1 ) The corresponding video frame cost value sequence is (Cost0, Cost1, ..., Cost N-1 ); N is the total number of predictive coding image frames included in the GOP, dacay is the attenuation factor, dacay∈(0,1); According to the formula: num = 1 + dacay + ... + dacay N-1 Calculate the normalization coefficient num corresponding to the Cost; According to the formula: Cost p = Cost / num, calculate the inter-frame complexity Cost of the GOP p .

7. The method according to claim 4, characterized in that After calculating the intra-frame complexity and the inter-frame complexity of each GOP according to the frame type parameter, the method further includes: The intra-frame complexity and inter-frame complexity of each GOP are normalized according to the set macroblock size.

8. A video encoding device, characterized in that: include: A parameter acquisition module, used for acquiring frame type parameters corresponding to video frames in each group of pictures GOP of the video file to be encoded; A first complexity calculation module, used for calculating the intra-frame complexity and inter-frame complexity of each of the GOPs according to the frame type parameter; A second complexity calculation module is used to calculate the scene complexity corresponding to each of the GOPs according to the intra-frame complexity and the inter-frame complexity; the second complexity calculation module is specifically used to: calculate the scene complexity corresponding to each of the GOPs through a weighted formula of the intra-frame complexity and the inter-frame complexity; The video encoding module is used to adopt an encoding strategy that matches the complexity of the scene to perform video encoding on each GOP in the video file.

9. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the video encoding method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the video encoding method as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Method for judging frame type of video frame, and electronic device

    CN107277519A