Video encoding method, device, computer equipment and storage medium
By obtaining encoding parameters that meet the encoding time threshold, the problem of video encoding time too long caused by the server's fixed parameters is solved, the stability of video encoding frames is improved and the delay is reduced, and a more efficient video encoding process is achieved.
Patent Information
- Application Number
- CN202010880222.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-27
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2040-08-27
AI Technical Summary
In the prior art, when a server uses fixed parameters to encode videos, the encoding time is too long when rendering complex images, affecting the stability of the video encoding frames.
By obtaining encoding parameters that meet the encoding duration less than the duration threshold, the video screen is encoded, and the use of fixed parameters is avoided, and flexible encoding parameters are adopted to adapt to video screens of different complexities.
The video encoding time is reduced, the stability of the video encoding frame is improved, and the AC energy of the video screen is calculated through pixel difference accuracy, reducing the overall delay, ensuring the video quality while reducing the first frame delay.
Smart Images

Figure CN111970508B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of video coding technology, and particularly relates to a video coding method, apparatus, computer device, and storage medium. Background Art
[0002] With the continuous development of the mobile Internet, there is an increasing amount of video data to be displayed in a terminal, including various types of video data such as game screens, game videos, and live videos.
[0003] In the related art, the video data displayed in the terminal is all encoded by an encoder on the server side. When encoding on the server side, the server often encodes the video with fixed encoding parameters and sends the encoded video data to the terminal for display. For example, when displaying a game screen in the terminal, the server can render a video image corresponding to the logical action received from the terminal uploading to the server, encode the video image, and return the encoded video image to the terminal.
[0004] However, in the related art, since the server always encodes the video with fixed parameters, when the image rendered by the server is relatively complex, the time taken by the server to encode the video is relatively long, affecting the stability of the video encoding frame rate. Summary of the Invention
[0005] Embodiments of this application provide a video coding method, apparatus, computer device, and storage medium, which can improve the stability of the video encoding frame rate. The technical solution is as follows:
[0006] On the one hand, embodiments of this application provide a video coding method, and the method includes:
[0007] Start a video encoder, where the video encoder is used to encode a video picture;
[0008] Obtain a first coding parameter, where the first coding parameter is a coding parameter that satisfies a preset coding condition, and the preset coding condition is that the coding duration is less than a preset duration, and the coding duration is the duration used by the video encoder for encoding;
[0009] Encode the video picture according to the first coding parameter.
[0010] On the other hand, embodiments of this application provide a video coding apparatus, and the apparatus includes:
[0011] An encoder startup module, configured to start a video encoder, where the video encoder is used to encode a video picture;
[0012] The encoding parameter acquisition module is configured to acquire a first encoding parameter, where the first encoding parameter is an encoding parameter that meets a preset encoding condition, and the preset encoding condition includes that the encoding duration is less than a preset duration, and the encoding duration is the duration used by the video encoder for encoding;
[0013] The video encoding module is configured to encode the video picture according to the first encoding parameter.
[0014] On the other hand, an embodiment of the present application provides a computer device, which includes a processor and a memory. At least one instruction, at least one program, a code set or an instruction set is stored in the memory, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the above video encoding method.
[0015] On another aspect, an embodiment of the present application provides a computer-readable storage medium, in which at least one instruction, at least one program, a code set or an instruction set is stored, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the above video encoding method.
[0016] In one aspect, an embodiment of the present application provides a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the video encoding method provided in the above one aspect.
[0017] The technical solution provided by the present application may include the following beneficial effects:
[0018] Through the solution shown in the present application, when performing video encoding through a video encoder, an encoding parameter that meets the condition that the encoding duration is less than the duration threshold can be used to encode the video picture, avoiding the server always encoding the video with fixed parameters, reducing the time spent on encoding the video, and improving the stability of the video encoding frame output. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings here are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0020] Figure 1 It is a schematic structural diagram of a video stream pushing system shown according to an exemplary embodiment;
[0021] Figure 2It is a schematic structural diagram of a cloud server and a terminal involved in an exemplary embodiment of the present application;
[0022] Figure 3 It is a schematic flow chart of a video encoding process of a video encoder involved in an exemplary embodiment of the present application;
[0023] Figure 4 It is a method flow chart of a video encoding method provided by an embodiment of the present application;
[0024] Figure 5 It is a method flow chart of a video encoding method provided by an embodiment of the present application;
[0025] Figure 6 It is a bar chart of the server counting the search times involved in an exemplary embodiment of the present application;
[0026] Figure 7 It is a schematic diagram of a video frame extracted during a video encoding process with a pixel difference accuracy of one quarter involved in an exemplary embodiment of the present application;
[0027] Figure 8 It is a schematic block diagram of the structure of a video encoding device involved in an exemplary embodiment of the present application;
[0028] Figure 9 It is a structural block diagram of a computer device shown according to an exemplary embodiment. Detailed implementation
[0029] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0030] Before describing the various embodiments shown in the present application, several concepts related to the present application will be introduced first:
[0031] 1) Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to achieve data computing, storage, processing, and sharing. Cloud technology is the general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, be used on demand, and is flexible and convenient. Cloud computing technology will become an important support. The back-end services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites, and more portal websites. With the high development and application of the Internet industry, in the future, each item may have its own identification mark and needs to be transmitted to the back-end system for logical processing. Data at different levels will be processed separately, and various industry data requires a powerful system back-end support, which can only be achieved through cloud computing.
[0032] 2) Cloud gaming, also known as gaming on demand, is an online gaming technology based on cloud computing technology. Cloud gaming technology enables thin client devices with relatively limited graphics processing and data computing capabilities to run high-quality games. In the cloud gaming scenario, the game does not run on the player's game terminal but on the cloud server. The cloud server renders the game scene into a video and audio stream and transmits it to the player's game terminal through the network. The player's game terminal only needs to have basic streaming media playback capabilities and the ability to obtain the player's input instructions and send them to the cloud server.
[0033] 3) Transport stream file
[0034] A transport stream (TS) file is a file format for streaming media transmission. In a TS file, the main video encoding formats are H264 or mpeg4, and the main audio encoding formats are acc / MP3.
[0035] 4) H264
[0036] H.264 is a highly compressed digital video codec standard proposed by the Joint Video Team (JVT), which is jointly composed of the Video Coding Experts Group (VCEG) of the ITU-T (ITU Telecommunication Standardization Sector) and the Moving Picture Experts Group (MPEG) of ISO (International Organization for Standardization) / IEC (International Education Consortium).
[0037] 5) X264
[0038] X264: It is an open-source H.264 video encoder.
[0039] 6) First-frame display time
[0040] The first-frame display time refers to the time from the start of the video request stream to the rendering of the first frame, and it can also be called the first-frame time.
[0041] 7) Encoding delay
[0042] The encoding delay refers to the time from the input of a frame of image into the encoder to the output of an encoded frame of image.
[0043] 8) Quantization
[0044] Quantization refers to the process of approximating the continuous values (or a large number of possible discrete values) of a signal to a finite number (or fewer) of discrete values. In video coding, it is the process of quantizing the signal after DCT transformation. The larger the QP (Quantization Parameter), the more discrete the values taken, and the lower the ability to restore the original signal, and vice versa.
[0045] 9) DCT transformation
[0046] DCT (Discrete Cosine Transform) is a transform related to the Fourier transform. It is similar to the Discrete Fourier Transform (DFT), but only uses real numbers.
[0047] 10) MV (Motion Vector) prediction
[0048] MV prediction refers to searching for a suitable motion reference block in an image and calculating the corresponding motion vector based on this motion reference block.
[0049] 11) Entropy coding
[0050] Entropy coding is a coding method that does not lose any information according to the entropy principle during the coding process. Information entropy is the average amount of information (a measure of uncertainty) of the information source. Common entropy codings include: Shannon coding, Huffman coding, and arithmetic coding. In video coding, entropy coding transforms a series of element symbols used to represent a video sequence into a compressed bitstream for transmission or storage. The input symbols may include quantized transform coefficients, motion vectors, header information (macroblock headers, picture headers, sequence headers, etc.), and additional information (important flag bit information for correct decoding).
[0051] 12) A macroblock, in English it is "Macroblock", is a basic concept in video coding technology. By dividing the picture into blocks of different sizes, different compression strategies are implemented at different positions. In video coding, an encoded image is usually divided into several macroblocks. A macroblock consists of a luminance pixel block and two additional chrominance pixel blocks. Generally, the luminance block is a pixel block of 16x16 size, and the sizes of the two chrominance image pixel blocks depend on the sampling format of the image. For example, for a YUV420 sampled image, the chrominance block is a pixel block of 8x8 size. In each image, several macroblocks are arranged in the form of slices. The video coding algorithm encodes each macroblock one by one and organizes them into a continuous video bitstream.
[0052] Figure 1 It is a schematic structural diagram of a video stream push system shown according to an exemplary embodiment. The system includes: a server 110 and a terminal 120.
[0053] The server 110 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0054] The terminal 120 may be a terminal device with video display function. For example, the terminal may be a mobile phone, a tablet computer, a laptop computer, an e-book reader, smart glasses, a smart watch, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV) player, a laptop portable computer, a desktop computer, and so on.
[0055] The user terminal 120 is directly or indirectly connected to the server 110 through a communication network. Optionally, the communication network is a wired network or a wireless network.
[0056] Optionally, the above-mentioned wireless network or wired network uses standard communication technologies and / or protocols. The network is usually the Internet, but can also be any network, including but not limited to any combination of a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a private network or a virtual private network. In some embodiments, technologies and / or formats including Hyper Text Mark-up Language (HTML), Extensible Markup Language (XML), etc. are used to represent the data exchanged through the network. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec), etc. can be used to encrypt all or some of the links. In other embodiments, custom and / or proprietary data communication technologies can also be used to replace or supplement the above data communication technologies.
[0057] Please refer to Figure 2 , which shows a schematic structural diagram of a cloud server and a terminal according to an exemplary embodiment of the present application. As Figure 2As shown in the figure, the cloud game engine module 201, the terminal system module 202, the logic processing module 203, the image rendering module 204, and the video encoder 205 are included in the cloud service 200. The video decoder 207 and the image display module 208 are included in the terminal 206.
[0058] Among them, the terminal 206 can run the cloud game provided by the cloud server 200. The terminal 206 can send logical actions to the cloud server 200 through the above communication network. For example, in response to a trigger operation on the first control in the display interface, the terminal 206 generates a corresponding logical action and sends it to the cloud server. Correspondingly, the cloud game engine module 201 in the cloud server 200 receives the logical action sent by the terminal 206. The terminal system module 202 can determine the operating system corresponding to the terminal 206, such as the Android system or the IOS (iPhone Operation System, Apple operating system). The logic processing module 203 can be used to parse the logical action. The image rendering module 204 can render the game screen corresponding to the logical action. The video encoder 205 can be used to encode the game screen rendered by the image rendering module 204, so that the cloud server 200 can send the encoded video data to the terminal 206.
[0059] Correspondingly, after receiving the video data, the terminal 206 can decode the video data according to the video decoder 207 and display the corresponding game image in the terminal according to the image display module 208, thus completing the display of the game screen of the cloud game.
[0060] In the related art, when the video encoder included in the above cloud server encodes a video image, it usually encodes the video with fixed encoding parameters and sends the encoded video data to the terminal for display. For example, when displaying a game screen on the terminal, the server can render the video image corresponding to the logical action received from the terminal uploading to the server and encode the video image according to the fixed encoding parameters, and return the encoded video image to the terminal.
[0061] Please refer to Figure 3 , which shows a schematic flowchart of the video encoding process of a video encoder according to an exemplary embodiment of the present application. As Figure 3 shown, the video encoding process may include the following steps:
[0062] Step 301, perform pre-analysis on the video screen.
[0063] Among them, in the process of performing pre-analysis on the video screen, it includes the budget of the memory size occupied when encoding the video screen and the determination of the reference frame.
[0064] Step 302, encode the video frame.
[0065] Among them, during the encoding process, it includes calculating the motion vector MV of the video frame and the calculation of the actual memory occupied.
[0066] Step 303, perform DCT transformation on the video frame.
[0067] Step 304, quantize the video frame after DCT transformation.
[0068] Step 305, perform entropy encoding on the quantized video frame.
[0069] Step 306, encapsulate the video frame after entropy encoding.
[0070] Step 307, dequantize the quantized video frame.
[0071] Step 308, perform inverse DCT transformation on the dequantized video frame.
[0072] Step 309, perform image restoration processing on the video frame after inverse DCT transformation.
[0073] Step 310, perform deblocking on the video frame after image restoration processing.
[0074] Step 311, insert the deblocked video frame into the reference frame queue.
[0075] Optionally, the above fixed encoding parameters can be as follows: -preset:v superfast -tune zerolatency -profile:v main -vcodec libx264 -x264opts threads=1:bitrate=3000:vbv -maxrate=3000:vbv -bufsize=3000:ref=1:vbv -init=0.5:rate tol=0.1:qpmax=45:qpmin=20:level=42:bframes=0:keyint=120:sliced -threads=0:intra -refresh=1:slices=1:subme=2.
[0076] Among them, -preset:v superfast means that the parameter preset is superfast. -tunezerolatency means that the type of tune is zerolatency. -profile:v main means that the type of profile is main. threads = 1 represents the number of encoding threads, bitrate = 3000 represents the target bitrate, vbv-maxrate = 3000 represents the maximum bitrate, vbv-bufsize = 3000 represents the maximum encoding buffer size, ref = 1 represents the number of reference frames, vbv-init = 0.5 represents the initial bitrate ratio, ratetol = 0.1 represents the bitrate fluctuation ratio, qpmax = 45 represents the maximum value of the quantization qp, qpmin = 20 represents the minimum value of the quantization qp, level = 42 represents the quantization degree, bframes = 0 represents the number of b-frames, keyint = 120 represents the interval at which key frames appear, sliced-threads = 0 means it is not sliced encoding, intra-refresh = 1 means intra-refresh is enabled, slices = 1 represents the number of slices in a video frame, and subme = 2 represents the motion compensation level.
[0077] In practical applications, due to the different complexities of the images to be displayed in the terminal, the complexities of the images rendered by the image rendering module in the cloud server are also different. For images with different complexities, the time taken by the video encoding module of the cloud server to obtain the encoded video image is also different, which affects the efficiency of the cloud server in video encoding the image frames with high complexity and reduces the video encoding efficiency.
[0078] To solve the technical problems existing in the above related technologies, an embodiment of the present application provides a video encoding method. Please refer to Figure 4 , which shows a flowchart of a video encoding method provided by an embodiment of the present application. This method can be used in the system structure shown in the above Figure 1 and is executed by the server in the system. As shown in Figure 4 , this method may include the following steps:
[0079] Step 401, start a video encoder, where the video encoder is used to encode video frames.
[0080] Among them, the server may include a video encoder. When it is necessary to encode the rendered video frames, the video encoder can be started to encode the video frames.
[0081] Step 402, obtain first encoding parameters, where the first encoding parameters are encoding parameters that meet the first encoding conditions.
[0082] Among them, the first encoding condition is that the encoding duration is less than the duration threshold, and the encoding duration is the duration used by the video encoder for encoding. The duration threshold can be the duration required when the video encoder performs video encoding using default encoding parameters.
[0083] Step 403: Encode the video picture according to the first encoding parameter.
[0084] That is, the server encodes the rendered video picture according to the first encoding parameter.
[0085] In summary, through the solution shown in this application, when performing video encoding through a video encoder, encoding parameters that satisfy the encoding duration being less than the duration threshold can be used to encode the video picture, avoiding the server always encoding the video using fixed parameters, reducing the time spent on encoding the video, and improving the stability of the video encoding frame output.
[0086] In a possible implementation manner, the above first encoding parameter may include one or more of a search method for searching a motion reference block, a search range for searching a motion reference block, and a pixel difference accuracy. Among them, the motion reference block is a reference block of a target macroblock in the video picture, and the pixel difference accuracy is used to indicate the proportion of the pixels extracted from the video picture in the total pixels of the video picture.
[0087] Please refer to Figure 5 , which shows a flowchart of a video encoding method provided by an embodiment of this application. This method can be used in the Figure 1 system structure shown above, and is executed by the server in the system. As Figure 5 shown, this method may include the following steps:
[0088] Step 501: Start the video encoder, and the video encoder is used to encode the video picture.
[0089] Among them, after the server generates a video picture by the above image rendering module, it generates a corresponding video encoding request, and this video encoding request is used to start the video encoder and cause the video encoder to encode the rendered video picture.
[0090] Step 502: Obtain a duration threshold corresponding to the video picture according to the video picture.
[0091] Among them, when the server encodes video frames with different complexities, there will be different encoding durations. The server can establish a corresponding relationship table in advance for these video frames and duration thresholds. When a video frame is rendered, the server can obtain the duration threshold corresponding to the video frame according to this relationship table. Among them, the duration threshold in the relationship table can be the encoding duration corresponding to each video frame after the server encodes it under the default encoding parameters.
[0092] Step 503, obtain a first encoding parameter according to the duration threshold. The first encoding parameter is an encoding parameter that meets the first encoding condition. The first encoding condition includes that the encoding duration is less than the duration threshold, and the encoding duration is the duration used by the video encoder for encoding.
[0093] Optionally, the first encoding parameter can be pre-stored in the server. The first encoding parameter meets the first encoding condition, that is, when the server encodes the same video frame according to the first encoding parameter, the encoding time spent by the server is less than the duration threshold, that is, less than the time spent by the server for encoding according to the default encoding parameters.
[0094] Step 504, encode the video frame according to the first encoding parameter.
[0095] Among them, the first encoding parameter includes the search method for searching the motion reference block. The motion reference block is the reference block of the target macroblock in the video frame. The server can search for the motion reference block corresponding to the video frame according to the search method. According to the motion reference block corresponding to the video frame, calculate the motion vector corresponding to the video frame. The motion vector is used to indicate the movement vector of the target macroblock. Encode the video frame according to the motion vector corresponding to the video frame. Optionally, the search method can be hexagonal search, diamond search, etc.
[0096] In a possible implementation manner, the server can also count the number of searches. The number of searches is the number of times of searching for the motion reference block corresponding to the video frame. Obtain a search number threshold according to the number of searches. Search for the motion reference block corresponding to the video frame according to the search number threshold according to the search method.
[0097] Please refer to Figure 6 , which shows a bar chart of the server counting the number of searches involved in an exemplary embodiment of the present application. As Figure 6 shown, after each count, the server can obtain the number of times of searching for the motion reference block corresponding to the video frame. In this solution, it can be selected to start recording from the statistical count with the largest number of searches. If the proportion of the number of searches greater than a fixed value exceeds 20%, this fixed value will be used as the search number threshold. In Figure 6 , the obtained search number threshold is 5.
[0098] Optionally, the first encoding parameter further includes a search range for searching for a motion reference block; within the search range, according to the search method, a motion reference block corresponding to the video frame is searched. Among them, the search range can be represented by the distance from the position of the search point in the search method to the search center. For example, if the above search method is hexagonal search and the search range is 6 pixels, it means that the distance from the position of the search point to the center of the hexagon is 6 pixels, thereby realizing the limitation of the search range.
[0099] Optionally, the first encoding parameter includes pixel difference precision, which is used to indicate the proportion of pixels extracted from the video frame in the total number of pixels of the video frame; the server can also determine each target pixel in the video frame used for encoding the video frame according to the pixel difference precision; according to each target pixel, calculate the image alternating current energy value of the video frame, and the image alternating current energy value is used to indicate the complexity of the video frame; encode the video frame according to the image alternating current energy value.
[0100] That is, in the process of image encoding, it involves the extraction of pixels from the video frame. Pixel points with pixel difference precision are extracted from the video frame to form a new video frame, and the image alternating current energy value of the new video frame is calculated. For example, if the pixel difference precision is one quarter, for a rectangular video frame, the server can extract the video frame according to half of each side length to obtain the extracted video frame.
[0101] For example, the first encoding parameter can be as follows:
[0102] inter = X264_ANALYSE_4x4, and the inter-frame parameter is X264_ANALYSE_14x4;
[0103] me_method = X264_ME_DIA, and the search method function is X264_ME_DIA;
[0104] subpel_refine = 1, and the search range value is 1;
[0105] deblocking_filter = 0, and the deblocking filter is 0.
[0106] Please refer to Figure 7 , which shows a schematic diagram of the video frame extracted during a video encoding process with a pixel difference precision of one quarter according to an exemplary embodiment of the present application. As Figure 6 shown, the video frame pointed by the arrow is the result of the video frame extracted according to the 1 / 4 pixel difference precision.
[0107] Step 505, obtain the first number of frames, where the first number of frames is the number of video frames encoded according to the first encoding parameter.
[0108] That is, the server can count the number of video frames encoded according to the first encoding parameter.
[0109] Step 506: In response to the number of the first frames being greater than the number threshold, obtain a second encoding parameter, where the second encoding parameter is an encoding parameter that meets the second encoding condition.
[0110] Among them, the second encoding condition is that the encoding quality is higher than the quality threshold. When the number of the first frames is greater than the number threshold, obtain the second encoding parameter. For example, when the number threshold is 60 frames, after 60 frames, the server can obtain the second encoding parameter.
[0111] For example, the second encoding parameter can be as follows:
[0112] inter =
[0113] X264_ANALYSE_|4x4|*264_A
[0114] NALYSE_PSUB|16*16|*264_A
[0115] NALYSE_BSUB16*16;
[0116] me_method = X264_ME_HEX;
[0117] subpel_refine = 2;
[0118] deblocking_filter = 1.
[0119] Step 507: Encode subsequent video frames according to the second encoding parameter.
[0120] That is, when the number of the first frames is greater than the number threshold, convert the first encoding parameter into the second encoding parameter, so as to encode subsequent video frames according to the second encoding parameter.
[0121] Please refer to Table 1, which shows a comparison table of a video quality involved in an exemplary embodiment of the present application.
[0122]
[0123] Table 1
[0124] Among them, Table 1 is the test result of 6 different cloud games. In the present solution, flexibly adopting the encoding parameter can improve the PSNR (Peak Signal to Noise Ratio) by 0.26%.
[0125] Please refer to Table 2, which shows a comparison table of another video quality involved in an exemplary embodiment of the present application.
[0126]
[0127] Table 2
[0128] Among them, Table 2 is the result of testing 6 different cloud games. In this solution, flexibly using coding parameters can increase the SSIM (Structural SIMilarity) by 0.20%.
[0129] Please refer to Table 3, which shows a comparison table of another video quality involved in an exemplary embodiment of the present application.
[0130]
[0131] Table 3
[0132] Among them, Table 3 is the result of testing 6 different cloud games. In this solution, flexibly using coding parameters can increase the VMAF (Video Multi-method Assessment Fusion) by 0.46%.
[0133] In summary, through the solution shown in the present application, when performing video encoding through a video encoder, coding parameters that meet the condition that the coding duration is less than the duration threshold can be used to encode the video picture, avoiding the server always using fixed parameters to encode the video, reducing the time spent on encoding the video, and improving the stability of the video encoding frame output.
[0134] In addition, by calculating the AC energy of the video picture through the pixel difference accuracy and using this AC energy as the adaptive quantization factor in the subsequent quantization process, the overall delay of the video encoding can be reduced.
[0135] In addition, this solution also reduces the first-frame delay during the video encoding process by switching different coding parameters, achieving the effect of reducing the first-frame delay while ensuring the video quality during the video encoding process.
[0136] Please refer to Figure 8 , which shows a schematic block diagram of the structure of a video encoding device involved in an exemplary embodiment of the present application. This video encoding device can be used in a server to execute Figure 4 or Figure 5 all or part of the steps executed by the server in the corresponding method shown in the embodiment. This video encoding device may include the following modules:
[0137] An encoder startup module 801 for starting a video encoder, which is used to encode video frames;
[0138] An encoding parameter acquisition module 802 for acquiring first encoding parameters, which are encoding parameters meeting preset encoding conditions. The preset encoding conditions include that the encoding duration is less than a preset duration, and the encoding duration is the duration used by the video encoder for encoding;
[0139] A video encoding module 803 for encoding the video frames according to the first encoding parameters.
[0140] The first encoding parameters include a search method for searching motion reference blocks, where the motion reference blocks are reference blocks of target macroblocks in the video frames;
[0141] Optionally, the video encoding module 803 includes: a first search unit, a first calculation unit, and a first encoding unit;
[0142] The first search unit is used to search for the corresponding motion reference blocks of the video frames according to the search method;
[0143] The first calculation unit is used to calculate a motion vector corresponding to the video frames according to the corresponding motion reference blocks of the video frames, and the motion vector is used to indicate the movement vector of the target macroblock;
[0144] The first encoding unit is used to encode the video frames according to the motion vector corresponding to the video frames.
[0145] Optionally, the first encoding parameters further include a search range for searching the motion reference blocks;
[0146] The first search unit is further used to search for the corresponding motion reference blocks of the video frames within the search range according to the search method.
[0147] Optionally, the first encoding parameters include pixel difference accuracy, which is used to indicate the proportion of pixels extracted from the video frames in the total pixels of the video frames;
[0148] The video encoding module 803 further includes: a first determination unit, a second calculation unit, and a second encoding unit;
[0149] The first determination unit is used to determine respective target pixels in the video frames for use in encoding the video frames according to the pixel difference accuracy;
[0150] The second calculation unit is used to calculate the image alternating current energy value of the video frames according to the respective target pixels;
[0151] The second encoding unit is configured to encode the video picture according to the image AC energy value.
[0152] Optionally, the apparatus further includes:
[0153] A quantity acquisition module, configured to acquire a first picture quantity after the video encoding module 803 encodes the video picture according to a first encoding parameter, where the first picture quantity is the quantity of video pictures encoded according to the first encoding parameter;
[0154] A second parameter acquisition module, configured to acquire a second encoding parameter in response to the first picture quantity being greater than a quantity threshold, where the second encoding parameter is an encoding parameter that satisfies a second encoding condition, and the second encoding condition includes that the encoding quality is higher than a quality threshold;
[0155] A first encoding module, configured to encode subsequent video pictures according to the second encoding parameter.
[0156] Optionally, the apparatus further includes:
[0157] A times statistics module, configured to count the number of searches, where the number of searches is the number of times of searching for the motion reference block corresponding to the video picture;
[0158] A threshold acquisition module, configured to acquire a search times threshold according to the number of searches;
[0159] Searching for the motion reference block corresponding to the video picture according to the search method includes:
[0160] Searching for the motion reference block corresponding to the video picture according to the search method and according to the search times threshold.
[0161] Optionally, the encoding parameter acquisition module includes: a first acquisition unit and a second acquisition unit;
[0162] The first acquisition unit is configured to acquire a duration threshold corresponding to the video picture according to the video picture;
[0163] The second acquisition unit is configured to acquire the first encoding parameter according to the duration threshold.
[0164] In summary, through the solution shown in this application, when performing video encoding through a video encoder, encoding parameters that satisfy the encoding duration being less than the duration threshold can be used to encode video pictures, avoiding the server always encoding the video with fixed parameters, reducing the time spent on encoding the video, and improving the stability of video encoding frame output.
[0165] Figure 9 It is a block diagram of a computer device 900 shown in an exemplary embodiment of the present application. The computer device 900 includes a central processing unit (CPU) 901, a system memory 904 including a random access memory (RAM) 902 and a read only memory (ROM) 903, and a system bus 905 connecting the system memory 904 and the central processing unit 901. The computer device 900 also includes a basic input / output system (Input / Output system, I / O system) 906 for facilitating information transmission between various components within the computer, and a mass storage device 907 for storing an operating system 913, application programs 914, and other program modules 915.
[0166] The basic input / output system 906 includes a display 908 for displaying information and input devices 909 such as a mouse, keyboard, etc. for user input of information. Among them, both the display 908 and the input devices 909 are connected to the central processing unit 901 through an input / output controller 910 connected to the system bus 905. The basic input / output system 906 may also include an input / output controller 910 for receiving and processing inputs from multiple other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 910 also provides outputs to a display screen, printer, or other types of output devices.
[0167] The mass storage device 907 is connected to the central processing unit 901 through a mass storage controller (not shown) connected to the system bus 905. The mass storage device 907 and its associated computer-readable medium provide non-volatile storage for the computer device 900. That is to say, the mass storage device 907 may include computer-readable media (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.
[0168] Without loss of generality, the computer-readable medium may include computer storage media and communication media. Computer storage media includes volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes RAM, ROM, EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory or other solid-state storage technologies, CD-ROM, DVD (Digital Video Disc), or other optical storage, magnetic tape cartridges, tapes, disk storage, or other magnetic storage devices. Of course, those skilled in the art will appreciate that the computer storage media is not limited to the above several types. The above system memory 904 and mass storage device 907 may be collectively referred to as memory.
[0169] The computer device 900 may be connected to the Internet or other network devices through a network interface unit 911 connected to the system bus 905.
[0170] The memory further includes one or more programs, and the one or more programs are stored in the memory. The central processing unit 901 implements Figure 4 or Figure 5 all or part of the steps performed by the server in any of the methods shown.
[0171] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory including a computer program (instructions). The above program (instructions) can be executed by a processor of a computer device to complete the methods performed by the server or the user terminal in the methods shown in various embodiments of the present application. For example, the non-transitory computer-readable storage medium may be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage devices, etc.
[0172] After considering the specification and practicing the invention disclosed herein, those skilled in the art will readily conceive of other embodiments of the present application. The present application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include known common knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and embodiments are only to be considered as exemplary, and the true scope and spirit of the present application are pointed out by the following claims.
[0173] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.
Claims
1. A video encoding method, characterized in that, The method includes: Starting a video encoder for encoding video frames; In a correspondence table, obtaining a duration threshold corresponding to the video frame according to the complexity of the video frame, where the correspondence table includes duration thresholds corresponding to video frames of different complexities; Obtaining first encoding parameters according to the duration threshold, where the first encoding parameters are encoding parameters that meet a first encoding condition, and the first encoding condition includes that the encoding duration is less than the duration threshold, and the encoding duration is the duration used by the video encoder to encode the video frame; Encoding the video frame according to the first encoding parameters.
2. The method according to claim 1, characterized in that, The first encoding parameters include a search method for searching motion reference blocks, where the motion reference blocks are reference blocks of target macroblocks in the video frame; The encoding the video frame according to the first encoding parameters includes: Searching for the motion reference blocks corresponding to the video frame according to the search method; Calculating a motion vector corresponding to the video frame according to the motion reference blocks corresponding to the video frame, where the motion vector is used to indicate the movement vector of the target macroblock; Encoding the video frame according to the motion vector corresponding to the video frame.
3. The method according to claim 2, wherein The first encoding parameters further include a search range for searching the motion reference blocks; The searching for the motion reference blocks corresponding to the video frame according to the search method includes: Searching for the motion reference blocks corresponding to the video frame according to the search method within the search range.
4. The method according to claim 1, characterized in that The first encoding parameters include pixel difference precision, where the pixel difference precision is used to indicate the proportion of pixels extracted from the video frame in the total pixels of the video frame; The encoding the video frame according to the first encoding parameters includes: Determining respective target pixels in the video frame to be used for encoding the video frame according to the pixel difference precision; Calculating an image alternating current energy value of the video frame according to the respective target pixels; Encoding the video frame according to the image alternating current energy value.
5. The method according to claim 1, wherein After the encoding the video frame according to the first encoding parameters, it further includes: Obtaining a first number of frames, where the first number of frames is the number of video frames encoded according to the first encoding parameters; In response to the first number of frames being greater than a number threshold, obtaining second encoding parameters, where the second encoding parameters are encoding parameters that meet a second encoding condition, and the second encoding condition includes that the encoding quality is higher than a quality threshold; Encoding subsequent video frames according to the second encoding parameters.
6. The method according to claim 2 or 3, characterized in that, The method further includes: Counting the number of searches, where the number of searches is the number of times of searching for the motion reference blocks corresponding to the video frame; Obtaining a search number threshold according to the number of searches; The searching for the motion reference blocks corresponding to the video frame according to the search method includes: Searching for the motion reference blocks corresponding to the video frame according to the search method according to the search number threshold.
7. A video encoding device, characterized in that, The apparatus includes: An encoder startup module for starting a video encoder, which is used to encode video frames; An encoding parameter acquisition module for obtaining a duration threshold corresponding to the video frame according to the complexity of the video frame in a correspondence table, where the correspondence table includes duration thresholds corresponding to video frames of different complexities; The encoding parameter acquisition module is further configured to obtain a first encoding parameter according to the duration threshold, where the first encoding parameter is an encoding parameter that meets a preset encoding condition, and the preset encoding condition is that the encoding duration is less than the duration threshold, and the encoding duration is the duration used by the video encoder to encode the video frame; A video encoding module for encoding the video frame according to the first encoding parameter.
8. The device according to claim 7, characterized in that, The first encoding parameter includes a search method for searching a motion reference block, where the motion reference block is a reference block of a target macroblock in the video frame; the video encoding module includes a first search unit, a first calculation unit, and a first encoding unit; The first search unit is configured to search for the motion reference block corresponding to the video frame according to the search method; The first calculation unit is configured to calculate a motion vector corresponding to the video frame according to the motion reference block corresponding to the video frame, where the motion vector is used to indicate the movement vector of the target macroblock; The first encoding unit is configured to encode the video frame according to the motion vector corresponding to the video frame.
9. The device according to claim 8, characterized in that, The first encoding parameter further includes a search range for searching the motion reference block; The first search unit is configured to search for the motion reference block corresponding to the video frame within the search range according to the search method.
10. The device according to claim 7, characterized in that, The first encoding parameter includes a pixel difference accuracy, which is used to indicate the proportion of pixels extracted from the video frame in the total pixels of the video frame; the video encoding module includes a first determination unit, a second calculation unit, and a second encoding unit; The first determination unit is configured to determine each target pixel in the video frame used for encoding the video frame according to the pixel difference accuracy; The second calculation unit is configured to calculate an image alternating current energy value of the video frame according to the respective target pixels; The second encoding unit is configured to encode the video frame according to the image alternating current energy value.
11. The device according to claim 7, characterized in that, The device further includes: A quantity acquisition module for acquiring a first frame quantity, where the first frame quantity is the quantity of video frames encoded according to the first encoding parameter; A second parameter acquisition module for acquiring a second encoding parameter in response to the first frame quantity being greater than a quantity threshold, where the second encoding parameter is an encoding parameter that meets a second encoding condition, and the second encoding condition includes that the encoding quality is higher than a quality threshold; A first encoding module for encoding subsequent video frames according to the second encoding parameter.
12. The device according to claim 8 or 9, characterized in that, The device further includes: A times statistics module for counting the search times, where the search times are the times of searching for the motion reference block corresponding to the video frame; A threshold acquisition module, configured to acquire a search count threshold according to the search count. The first search unit is configured to search for the motion reference block corresponding to the video frame according to the search method and in accordance with the search count threshold.
13. A computer device, characterized in that, The computer device includes a processor and a memory. At least one instruction, at least one program, a code set, or an instruction set is stored in the memory. The at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the video encoding method according to any one of claims 1 to 6.
14. A computer-readable storage medium, characterized in that, At least one instruction, at least one program, a code set, or an instruction set is stored in the storage medium. The at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the video encoding method according to any one of claims 1 to 6.
15. A computer program product, characterized in that, The computer program product includes computer instructions. The computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the video encoding method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Video encoding method and device, equipment and storage medium
CN111263153A