A video transcoding method, device, apparatus and computer readable storage medium
Patent Information
- Application Number
- CN202110813902.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-19
- Publication Date
- 2026-08-28
- Estimated Expiration
- 2041-07-19
AI Technical Summary
相关技术中,需要花费较多的时间才能得到不同码率的转码视频,从而,视频的转码效率较低
[0019]本申请实施例具有以下有益效果:视频转码设备能够获取视频帧图像的编码块的历史模式信息,以明确编码块在基于已编码码率进行编码时的编码模式,基于历史模式信息,筛选出等待计算编码代价的候选编码要素,从而减少需要计算编码代价的编码要素的数量,接着依据候选编码要素的编码代价,确定编码块在目标码率的目标编码要素,最后采用目标编码要素和目标码率,对视频帧图像的编码块进行编码。如此,视频转码设备能够减少选择编码要素的耗时,从而实现利用已编码码率时的编码要素,来对目标码率的编码要素的选择过程进行加速,最终提高视频转码的效率。
Smart Images

Figure CN115643410B_ABST
Abstract
Description
Technical Field
[0001] This application relates to video processing technology, and more particularly to a video transcoding method, apparatus, device, and computer-readable storage medium. Background Technology
[0002] In video services, different bitrate videos need to be delivered based on the user's network conditions, i.e., bandwidth. For example, when the user's bandwidth is low, a low-bitrate transcoded video is delivered to ensure smooth playback; when the user's bandwidth is high, a high-bitrate transcoded video is delivered to improve the viewing experience. However, related technologies require a significant amount of time to obtain transcoded videos of different bitrates, resulting in low transcoding efficiency. Summary of the Invention
[0003] This application provides a video transcoding method, apparatus, device, and computer-readable storage medium that can improve the efficiency of video transcoding.
[0004] The technical solution of this application embodiment is implemented as follows: This application provides a video transcoding method, including: Obtain historical mode information of the encoded block of a video frame image at the encoded bitrate, wherein the historical mode information represents the encoding mode selected by the encoded block when encoding based on the encoded bitrate; Based on the historical pattern information, candidate coding elements corresponding to the target bit rate are selected for the coding block, wherein the candidate coding elements are coding elements waiting to calculate the coding cost; Based on the coding cost of the candidate coding elements, the target coding elements of the coding block at the target code rate are determined; The target coding elements and the target bitrate are used to encode the coding block to achieve video transcoding.
[0005] This application provides a video transcoding device, including: The information acquisition module is used to acquire historical mode information of the encoded block of a video frame image at the encoded bitrate, wherein the historical mode information represents the encoding mode selected by the encoded block when encoding based on the encoded bitrate. The element screening module is used to screen out candidate coding elements corresponding to the target code rate for the coding block based on the historical pattern information, wherein the candidate coding elements are coding elements waiting to calculate the coding cost; The element determination module is used to determine the target coding element of the coding block at the target code rate based on the coding cost of the candidate coding elements; The image encoding module is used to encode the encoding block using the target encoding elements and the target bitrate to achieve video transcoding.
[0006] In some embodiments of this application, the candidate coding elements include: candidate coding modes; the element screening module is further configured to determine each first prediction mode of the intra-frame prediction as the candidate coding mode when the historical mode information characterizes the selection of intra-frame prediction to encode the coding block at the encoded bitrate, wherein each first prediction mode differs in at least one or more of the segmentation rules, prediction methods, and offset angles.
[0007] In some embodiments of this application, the target coding element includes: a target coding mode; the element determination module is further configured to calculate the coding cost of each first prediction mode in the candidate coding modes to obtain a first coding cost corresponding to each first prediction mode; and determine the first prediction mode corresponding to the minimum first coding cost as the target coding mode of the coding block at the target code rate.
[0008] In some embodiments of this application, the candidate coding elements include: candidate reference frames; the element screening module is further configured to determine the candidate reference frames based on the set of historical reference frames corresponding to the encoded bitrate when the historical pattern information characterizes the selection of inter-frame prediction to encode the coding block at the encoded bitrate.
[0009] In some embodiments of this application, the element screening module is further configured to select the N smallest historical coding costs from the historical coding costs corresponding to each historical reference frame in the historical reference frame set; wherein N is a positive integer greater than or equal to 2; and determine the candidate reference frame of the coding block based on the N smallest historical coding costs.
[0010] In some embodiments of this application, when N=2, the minimum N historical coding costs include the minimum historical coding cost and the second smallest historical coding cost; the element screening module is further configured to increase the minimum historical coding cost to obtain the increased minimum historical coding cost; when the second smallest historical coding cost is greater than the increased minimum historical coding cost, the historical reference frame corresponding to the minimum historical coding cost is determined as the candidate reference frame; when the second smallest historical coding cost is less than or equal to the increased minimum historical coding cost, the historical reference frames corresponding to the minimum historical coding cost and the second smallest historical coding cost are determined as the candidate reference frames.
[0011] In some embodiments of this application, the element screening module is further configured to increase the minimum historical coding cost by an amplification factor to obtain the increased minimum historical coding cost, wherein the amplification factor is greater than or equal to 1; or, to superimpose a preset value on the minimum historical coding cost to obtain the increased minimum historical coding cost.
[0012] In some embodiments of this application, the candidate reference frame includes: a plurality of reference frames; the target coding element includes: a target reference frame; the element determination module is further configured to calculate the coding cost for the plurality of reference frames respectively, to obtain a plurality of second coding costs corresponding to the plurality of reference frames; and to determine the reference frame corresponding to the smallest second coding cost among the plurality of second coding costs as the target reference frame of the coding block at the target bit rate.
[0013] In some embodiments of this application, the candidate coding elements include: candidate coding modes; the element screening module is further configured to determine each second prediction mode of the inter-frame prediction as the candidate coding mode when the historical mode information characterizes the selection of inter-frame prediction to encode the coding block at the already encoded bitrate.
[0014] In some embodiments of this application, the target coding element includes: a target coding mode; the element determination module is further configured to calculate the coding cost of each second prediction mode in the candidate coding modes to obtain a third coding cost corresponding to each second prediction mode, wherein each second prediction mode differs in at least one or more of the segmentation rules and motion vector estimation methods; and the second prediction mode corresponding to the minimum third coding cost is determined as the target coding mode of the coding block at the target bit rate.
[0015] In some embodiments of this application, the video transcoding device further includes: a video decoding module; The video decoding module is used to decode the original video to obtain video frame images; The image encoding module is further configured to encode the encoding blocks of the video frame image according to the encoded bitrate, to obtain the historical mode information of the encoding blocks corresponding to the encoded bitrate, wherein the encoded bitrate includes one or more preset bitrates.
[0016] In some embodiments of this application, the video transcoding device further includes: a video analysis module; The video analysis module is used to analyze the video frame image and determine auxiliary coding parameters; the auxiliary coding parameters include at least one or more of the following: video frame image type, region of interest, and quality quantization parameters; based on the auxiliary coding parameters, an actual bitrate is allocated to the coding blocks of the video frame image, and the encoded bitrate is the average of the actual bitrates of the coding blocks of the video frame image; The image encoding module is further configured to encode the encoding blocks of the video frame image according to the actual bitrate, so as to obtain the historical mode information corresponding to the encoded bitrate.
[0017] This application provides a video transcoding device, including: Memory, used to store executable video transcoding instructions; The processor is configured to execute executable video transcoding instructions stored in the memory to implement the video transcoding method provided in the embodiments of this application.
[0018] This application provides a computer-readable storage medium storing executable video transcoding instructions, which, when executed by a processor, implement the video transcoding method provided in this application.
[0019] The embodiments of this application have the following beneficial effects: The video transcoding device can acquire historical mode information of the coded blocks of a video frame image to clarify the encoding mode of the coded block when it is encoded based on the already encoded bitrate. Based on the historical mode information, candidate coded elements waiting to calculate the encoding cost are selected, thereby reducing the number of coded elements that need to have their encoding cost calculated. Then, based on the encoding cost of the candidate coded elements, the target coded elements of the coded block at the target bitrate are determined. Finally, the target coded elements and the target bitrate are used to encode the coded blocks of the video frame image. In this way, the video transcoding device can reduce the time spent selecting coded elements, thereby accelerating the selection process of coded elements at the target bitrate using coded elements at the already encoded bitrate, ultimately improving the efficiency of video transcoding. Attached Figure Description
[0020] Figure 1 This is a diagram illustrating the distribution of videos to different users; Figure 2 This is a diagram illustrating video compression encoding for different bitrates; Figure 3A This is an optional architecture diagram of the video transcoding system provided in this application embodiment; Figure 3B This is another optional architecture diagram of the video transcoding system provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of the video transcoding device provided in the embodiments of this application; Figure 5 This is an optional flowchart illustrating the video transcoding method provided in this application embodiment. Figure 1 ; Figure 6 This is a schematic diagram illustrating the selection of a target reference frame from multiple reference frames, provided in an embodiment of this application. Figure 7 This is an optional flowchart illustrating the video transcoding method provided in this application embodiment. Figure 2 ; Figure 8 This is a schematic diagram illustrating the process of transcoding video according to the encoded bitrate provided in an embodiment of this application; Figure 9 This is a schematic diagram illustrating the process of transcoding video provided in an embodiment of this application; Figure 10 This is a schematic diagram illustrating an optional range of encoded bitrates provided in an embodiment of this application; Figure 11 This is a schematic diagram illustrating another optional range of encoded bitrates provided in the embodiments of this application. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0022] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0023] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0025] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.
[0026] 1) Video compression aims to reduce the video data rate while preserving the visual quality of the video as much as possible. Digital videos require a considerable amount of storage space before compression. Video compression reduces the portion of the video that is imperceptible to the human eye, thus ensuring that the compressed video does not affect the final visual quality and is easy to store.
[0027] 2) Bitrate refers to the amount of data encoded by the encoder per second, measured in kbps. For example, 800kbps means the encoder generates 800kb of data per second. With a fixed resolution, a higher bitrate results in a clearer video, while a lower bitrate results in a less clear video.
[0028] 3) Video analysis refers to the basic work that needs to be done before encoding video, which may include adaptive quantization of subjective quality, bitrate allocation of video frames, frame type selection, and determination of regions of interest.
[0029] 4) Encoding elements, namely, the encoding mode and reference frame used by each block during encoding.
[0030] 5) Intra-frame prediction utilizes the correlation in the video spatial domain to predict the current pixel using neighboring encoded pixels within the same video frame, thereby achieving the purpose of removing spatial redundancy during encoding.
[0031] 6) Inter-frame prediction utilizes the correlation in the temporal domain of video. It is the process of predicting the current frame sample from samples of adjacent frames reconstructed after past encoding, in order to remove temporal redundancy during encoding.
[0032] 7) The reference frame is a video frame that serves as the reference for inter-frame coding.
[0033] 8) Cloud computing is a computing model that distributes computing tasks across a resource pool composed of a large number of computers, enabling various application systems to obtain computing power, storage space, and information services as needed. The network providing these resources is called the "cloud." From the user's perspective, the resources in the "cloud" are infinitely scalable, readily available, on-demand, expandable, and pay-as-you-go.
[0034] As a provider of fundamental cloud computing capabilities, a cloud resource pool (referred to as a cloud platform, generally called IaaS (Infrastructure as a Service)) platform is established. Various types of virtual resources are deployed in the resource pool for external customers to choose from. The cloud resource pool mainly includes: computing devices (virtualized machines containing operating systems), storage devices, and network devices.
[0035] Based on logical function, a PaaS (Platform as a Service) layer can be deployed on top of the IaaS (Infrastructure as a Service) layer, and a SaaS (Software as a Service) layer can be deployed on top of the PaaS layer. Alternatively, SaaS can be deployed directly on top of IaaS. PaaS is a platform for running software, such as databases and web containers. SaaS refers to various types of business software, such as web portals and bulk SMS senders. Generally speaking, SaaS and PaaS are upper layers compared to IaaS.
[0036] In video services, different bitrate videos need to be delivered based on the user's network conditions, i.e., bandwidth. For example, when the user's bandwidth is low, a low-bitrate transcoded video is delivered to ensure smooth playback; when the user's bandwidth is high, a high-bitrate transcoded video is delivered to improve the viewing experience. To deliver videos for different bandwidths, the original video needs to be transcoded at different bitrates beforehand to obtain videos with varying bitrates. For example... Figure 1 This is a diagram illustrating how videos are delivered to different users. See also... Figure 1 The original video 1-1 needs to be transcoded 1-2 at different bitrates to obtain transcoded videos of the original video at bitrates 1-3, 1-4, 1-5 and 1-6 respectively. This allows the transcoded videos of different bitrates to be sent to different users according to their bandwidth.
[0037] In related technologies, when transcoding the original video at different bitrates, video compression encoding needs to be performed independently for each bitrate. This means that video decoding, video analysis, and video encoding operations are performed independently for each bitrate. For example, Figure 2 This is a diagram illustrating video compression encoding at different bitrates. See also... Figure 2 For bitrate 2-1, the original video needs to be decoded (2-11), analyzed (2-12), and encoded based on bitrate 2-1 (2-13) to obtain the corresponding transcoded video (2-14). For bitrate 2-2, the original video needs to be decoded (2-21), analyzed (2-22), and encoded based on bitrate 2-2 (2-23) to obtain the corresponding transcoded video (2-24). For bitrate 2-n, the original video also needs to be decoded (2-n1), analyzed (2-n2), and encoded based on bitrate 2-n (2-n3) to obtain the corresponding transcoded video (2-n4).
[0038] However, by independently compressing and encoding the video for each bitrate, it takes a considerable amount of time to obtain transcoded videos with different bitrates, resulting in low transcoding efficiency.
[0039] This application provides a video transcoding method, apparatus, device, and computer-readable storage medium, which can improve the efficiency of video transcoding. The following describes exemplary applications of the video transcoding device provided in this application. This video transcoding device can be implemented as various types of terminals such as laptops, tablets, desktop computers, set-top boxes, and mobile devices (e.g., mobile phones, portable music players, personal digital assistants, dedicated messaging devices, portable gaming devices), or as a server, or as a device cluster composed of servers and terminals. The following describes exemplary applications when the video transcoding device is implemented as a server.
[0040] See Figure 3A , Figure 3A This is an optional architecture diagram of the video transcoding system provided in this application embodiment. In order to support a video transcoding application, in the video transcoding system 100, the terminal 400 (terminal 400-1 and terminal 400-2 are shown as examples) connects to the server 200 through the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two.
[0041] Terminal 400-1 is used to respond to user operations on graphical interface 400-11, perform video capture, obtain raw video, and send the raw video to server 200 through network 300 so that server 200 can convert the raw video into video with different bitrates.
[0042] Server 200 is used to obtain historical mode information of the encoded blocks of the original video frame image at the encoded bitrate. The historical mode information represents the encoding mode selected by the encoded block when encoding based on the encoded bitrate. Based on the historical mode information, candidate encoded elements corresponding to the target bitrate are selected for the encoded block. Candidate encoded elements refer to encoded elements waiting to calculate the encoding cost. Based on the encoding cost of the candidate encoded elements, the target encoded elements of the encoded block at the target bitrate are determined. The encoded block is encoded using the target encoded elements and the target bitrate to realize video transcoding, thereby obtaining the transcoded video at the target bitrate.
[0043] When terminal 400-2 requests video, server 200 sends the transcoded video to terminal 400-2 via network 300.
[0044] Terminal 400-2 is used to display transcoded video on graphical interface 400-21.
[0045] In some embodiments, server 200 may be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Terminal 400 may be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, etc., but is not limited to these. The terminal and server can be directly or indirectly connected via wired or wireless communication, which is not limited in this embodiment of the invention.
[0046] This application's embodiments can also be implemented using blockchain technology; see [link to relevant documentation]. Figure 3B , Figure 3B This is another optional architecture diagram of the video transcoding system provided in the embodiments of this application. Figure 3B In the video transcoding system 100, the server 200 uploads the historical pattern information of the encoded bitrate and the target encoding elements determined for the target bitrate to the blockchain to ensure that the historical pattern information and the target encoding elements can be recorded and that the records cannot be tampered with.
[0047] In some embodiments, server 200 can join blockchain network 700 and become a node within it. The type of blockchain network 700 is flexible and diverse; for example, it can be any of a public blockchain, private blockchain, or consortium blockchain. Taking a public blockchain as an example, any electronic device of any business entity can access blockchain network 700 without authorization to act as a consensus node in blockchain network 700. For example, terminal 400 can be mapped to consensus node 700-1 in blockchain network 700 to achieve consensus when uploading metadata to the blockchain.
[0048] Taking blockchain network 700 as a consortium blockchain as an example, terminal 400 can become a node after obtaining authorization and accessing blockchain network 700. Server 200 obtains the historical mode information corresponding to the encoded bitrate of the video frame image's encoded block. Based on the historical mode information, it filters out candidate encoded elements corresponding to the target bitrate for the encoded block. According to the encoding cost of the candidate encoded elements, it determines the target encoded element of the encoded block at the target bitrate. Using the target encoded element and the target bitrate, the encoded block is encoded to achieve video transcoding. At the same time, the encoded bitrate and its corresponding historical mode information, the target bitrate and its corresponding target encoded element are sent to blockchain network 700 for consensus. When consensus is passed, blockchain network 700 allocates a new block for the encoded bitrate, historical mode information, target bitrate and target encoded element, writes the encoded bitrate, historical mode information, target bitrate and target encoded element into the new block, and adds the new block to the end of the blockchain.
[0049] See Figure 4 , Figure 4 This is a schematic diagram of the structure of the video transcoding device provided in the embodiments of this application. Figure 4 The video transcoding device 500 shown includes at least one processor 510, a memory 550, at least one network interface 520, and a user interface 530. The various components in the video transcoding device 500 are coupled together via a bus system 540. It is understood that the bus system 540 is used to implement communication between these components. In addition to a data bus, the bus system 540 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in… Figure 4 The general labeled all buses as Bus System 540.
[0050] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.
[0051] User interface 530 includes one or more output devices 531 that enable the presentation of media content, including one or more speakers and / or one or more visual displays. User interface 530 also includes one or more input devices 532, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0052] The memory 550 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state storage, hard disk drives, optical disk drives, etc. The memory 550 may optionally include one or more storage devices physically located away from the processor 510.
[0053] The memory 550 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 550 described in this application embodiment is intended to include any suitable type of memory.
[0054] In some embodiments, memory 550 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.
[0055] Operating system 551 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic business functions and handling hardware-based tasks; The network communication module 552 is used to reach other computing devices via one or more (wired or wireless) network interfaces 520, exemplary network interfaces 520 including: Bluetooth, Wi-Fi, and Universal Serial Bus (USB), etc. Presentation module 553 is used to enable the presentation of information (e.g., user interface for operating peripheral devices and displaying content and information) via one or more output devices 531 (e.g., display screen, speaker, etc.) associated with user interface 530. The input processing module 554 is used to detect and translate one or more user inputs or interactions from one or more input devices 532.
[0056] In some embodiments, the video transcoding apparatus provided in this application can be implemented in software. Figure 4 A video transcoding device 555 stored in memory 550 is shown. It can be software in the form of programs and plug-ins, including the following software modules: information acquisition module 5551, element screening module 5552, element determination module 5553, image encoding module 5554, video decoding module 5555, and video analysis module 5556. These modules are logically connected and can therefore be arbitrarily combined or further split according to the functions they implement.
[0057] The functions of each module will be explained below.
[0058] In other embodiments, the video transcoding apparatus provided in this application can be implemented in hardware. As an example, the video transcoding apparatus provided in this application can be a processor in the form of a hardware decoding processor, which is programmed to execute the video transcoding method provided in this application. For example, the processor in the form of a hardware decoding processor can be one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.
[0059] For example, this application provides a video transcoding device, including: Memory, used to store executable video transcoding instructions; The processor is configured to execute executable video transcoding instructions stored in the memory to implement the video transcoding method provided in the embodiments of this application.
[0060] The video transcoding method provided in this application will be described below with reference to exemplary applications and implementations of the video transcoding device provided in the embodiments of this application. It should be noted that when the video transcoding device is implemented as a cluster of devices consisting of servers and terminals, the video transcoding method provided in the embodiments of this application can be implemented using cloud computing technology.
[0061] See Figure 5 , Figure 5 This is an optional flowchart illustrating the video transcoding method provided in this application embodiment. Figure 1 , will combine Figure 5 The steps shown are explained.
[0062] S101. Obtain the historical mode information of the encoded block of the video frame image at the encoded bitrate.
[0063] This application embodiment is implemented in a scenario where video is transcoded at different bitrates, thereby obtaining transcoded videos with different bitrates. Transcoding video at different bitrates essentially involves compressing and encoding the video stream at different bitrates. Since video frames are encoded in units of coding blocks, the video transcoding device must first determine the encoding mode of the coding blocks when transcoding the video. In this application embodiment, the video transcoding device acquires information about the prediction mode selected by the coding blocks in the video frame images when encoding using the already encoded bitrate, obtaining the historical mode information of the coding blocks. In other words, the historical mode information represents the encoding mode selected by the coding blocks when encoding based on the already encoded bitrate.
[0064] It should be noted that the pre-encoded bitrate can be a pre-set bitrate or a bitrate automatically determined by the video transcoding device. In this embodiment, the encoded blocks are encoded using the pre-encoded bitrate before being encoded at the target bitrate. Therefore, after encoding the encoded blocks using the target bitrate, the encoding results of the encoded blocks at multiple bitrates are obtained. By using this method to encode all encoded blocks of each video frame, transcoded videos with different bitrates can be obtained.
[0065] It is understood that historical pattern information can characterize whether the prediction method selected by the coding block when encoding based on the already encoded bit rate is intra-frame prediction or inter-frame prediction. This application does not limit this.
[0066] In this embodiment, "video frame image" does not specifically refer to the image data of a single frame of a video, but rather to the image data of all frames of a video. Video frame images can be obtained by decoding the encoded data of the video, or they can be recorded in real time. Videos can include user-recorded videos, such as dance videos or funny videos recorded and published by the user, or videos released by production companies, such as TV series, movies, and variety shows.
[0067] The coding block can refer to a macroblock, or it can refer to a coding tree unit (CTU), coding unit (CU), etc. This application does not limit it.
[0068] It should be noted that the encoded bitrate may include only one specified bitrate or multiple specified bitrates.
[0069] S102. Based on historical pattern information, select candidate coding elements corresponding to the target code rate for the coding block.
[0070] The encoding pattern of the same coding block does not differ significantly at different bitrates. Therefore, after obtaining the historical pattern information of the coding block, the video transcoding device selects candidate coding elements from various coding elements based on this information. These candidate coding elements are those that the coding block may use; thus, they are coding elements awaiting the calculation of the coding cost.
[0071] In other words, in this embodiment of the application, the video transcoding device initially selects some coding elements for the coding block based on historical pattern information. Subsequently, the coding cost is calculated only for these coding elements to select the final target coding elements. Therefore, it is not necessary to calculate the coding cost for all coding elements, thus reducing the number of coding elements for which the coding cost needs to be calculated.
[0072] It should be noted that the target bitrate is the bitrate currently awaiting encoding, which is set by the user or specified by the video transcoding device after analyzing the video. Furthermore, both the target bitrate and the encoded bitrate refer to the overall bitrate of the video. This overall bitrate can be the average bitrate of each video frame or the average bitrate of different coding blocks.
[0073] It is understood that candidate coding elements may include candidate coding modes and candidate reference frames, which are not limited herein.
[0074] In some embodiments, since the encoded bitrate includes only one specified bitrate, the video transcoding device can only obtain historical mode information corresponding to one specified bitrate. Therefore, it will only use the historical mode information to determine the candidate coding elements corresponding to the target bitrate, so as to accelerate the video transcoding process.
[0075] In other embodiments, the encoded bitrate includes multiple specified bitrates. In this case, the video transcoding device can arbitrarily select one or more historical pattern information from the historical pattern information corresponding to the multiple specified bitrates, and then use these selected historical pattern information to determine the candidate coding elements corresponding to the target bitrate, so as to accelerate the video transcoding process.
[0076] S103. Based on the coding cost of the candidate coding elements, determine the target coding elements of the coding block at the target code rate.
[0077] The video transcoding device first calculates the encoding cost for the candidate encoding elements. Then, based on the encoding cost, it selects the encoding elements to be used by the encoding block when encoding according to the target bit rate from the candidate encoding elements, thus obtaining the target encoding elements.
[0078] It should be noted that the video transcoding device can determine the coding element corresponding to the minimum coding cost as the target coding mode, or it can select the coding element corresponding to the second minimum coding cost as the target coding mode. This application does not limit this.
[0079] In this embodiment, the video transcoding device can use common inter-frame prediction cost calculation methods and intra-frame prediction cost calculation methods to calculate the coding cost of candidate coding elements, or it can use a self-designed cost calculation method to calculate the coding cost of candidate coding elements. This application does not limit this.
[0080] It is understandable that the target coding elements may include the target coding mode and the target reference frame.
[0081] S104. Using the target coding elements and target bit rate, the coding block is encoded to achieve video transcoding.
[0082] After obtaining the target coding elements, the video transcoding device uses the target coding elements and the target bitrate to encode the coding blocks. Once the video transcoding device has completed encoding all coding blocks in all video frame images, it can achieve video transcoding and obtain transcoded video at the target bitrate.
[0083] In this embodiment, the video transcoding device can acquire historical mode information of the coded blocks of a video frame image to clarify the encoding mode of the coded block when encoded based on the already encoded bitrate. Based on the historical mode information, candidate coded elements waiting to have their encoding costs calculated are selected, thereby reducing the number of coded elements that need to have their encoding costs calculated. Then, based on the encoding costs of the candidate coded elements, the target coded elements of the coded block at the target bitrate are determined. Finally, the target coded elements and the target bitrate are used to encode the coded blocks of the video frame image. In this way, the video transcoding device can reduce the time spent selecting coded elements, thereby accelerating the selection process of coded elements at the target bitrate using coded elements at the already encoded bitrate, ultimately improving the efficiency of video transcoding.
[0084] In some embodiments of this application, candidate coding elements include candidate coding patterns. In this case, based on historical pattern information, candidate coding elements corresponding to the target code rate are selected for the coding block. The specific implementation process of S102 may include: S1021, as follows: S1021. When the historical pattern information characterizes the selection of intra-frame prediction to encode the coding block at the already coded bit rate, each first prediction mode of the intra-frame prediction is determined as a candidate coding mode.
[0085] When the video transcoding device reads the historical mode information and finds that it represents the intra-frame prediction mode selected when the coding block is encoded based on the already encoded bitrate, the video transcoding device will exclude various prediction modes and reference frames of inter-frame prediction and determine each first prediction mode of intra-frame prediction as a candidate coding mode.
[0086] It should be noted that each first prediction mode differs in at least one or more of the segmentation rules, prediction methods, and offset angles.
[0087] The segmentation rule refers to the rule for subdividing the coded block into sub-blocks, which may include no segmentation, four-eighths division, horizontal bisection, vertical bisection, horizontal four-eighths division, first horizontal three-thirds division, second horizontal three-thirds division, first vertical three-thirds division, second vertical three-thirds division, vertical four-eighths division, etc.
[0088] Prediction methods can include mean prediction based on reference pixels above and to the left, prediction combining horizontal and vertical differences, vertical interpolation prediction, horizontal interpolation prediction, prediction in the direction of minimum gradient, and prediction in eight different main directions, namely: vertical direction prediction, horizontal direction prediction, 45-degree angle direction prediction, 67-degree angle direction prediction, 113-degree angle direction prediction, 135-degree angle direction prediction, 157-degree angle direction prediction, and 203-degree angle direction prediction. It can also include palette prediction and intra-block copy prediction.
[0089] Offset angle refers to the offset angle in the main direction, which can be plus or minus 3 degrees, plus or minus 6 degrees, plus or minus 9 degrees, etc.
[0090] The target coding elements include: target coding modes; when the video transcoding device determines each first prediction mode of intra-frame prediction as a candidate coding mode, the target coding elements of the coding block at the target bit rate are determined according to the coding cost of the candidate coding elements, i.e., the specific implementation process of S103 may include: S1031-S1032, as follows: S1031. Calculate the coding cost for each first prediction mode in the candidate coding modes to obtain the first coding cost corresponding to each first prediction mode.
[0091] S1032. Determine the first prediction mode corresponding to the minimum first coding cost as the target coding mode of the coding block at the target code rate.
[0092] The video transcoding device calculates the encoding cost when encoding a coding block using each first prediction mode, thus obtaining a first encoding cost corresponding to each first prediction mode. Next, the video transcoding device selects the minimum first encoding cost from all the first encoding costs. Finally, combining the correspondence between the first encoding costs and the first prediction modes, it selects the target coding mode corresponding to the minimum first encoding cost from each first prediction mode in the intra-frame prediction.
[0093] In this embodiment, when the video transcoding device clearly indicates that the historical mode information characterization coding block has selected intra-frame prediction when encoding based on the already encoded bitrate, it will determine each first prediction mode of intra-frame prediction as a candidate coding mode. This eliminates the need to calculate the coding cost for each prediction mode and reference frame in the subsequent inter-frame prediction, reducing the number of coding elements for calculating the coding cost and improving the efficiency of video transcoding.
[0094] In some embodiments of this application, candidate coding elements include: candidate reference frames; based on historical pattern information, candidate coding elements corresponding to the target bit rate are selected for the coding block, i.e., the specific implementation process of S102 may include: S1022, as follows: S1022. When the historical mode information represents the selection of inter-frame prediction to encode the coded block at the already coded bit rate, candidate reference frames are determined based on the set of historical reference frames corresponding to the already coded bit rate.
[0095] When a video transcoding device reads historical mode information and determines that the encoding mode selected for the encoded block at the encoded bitrate is inter-frame prediction, the video transcoding device can directly determine all historical reference frames in the historical reference frame set at the encoded bitrate as candidate encoding reference frames, or it can select some historical reference frames from the historical reference frame set as candidate reference frames.
[0096] It is understandable that the historical reference frame set refers to the range of reference frames when encoding a coded block based on the already encoded bitrate, and does not refer to the final reference frame when the coded block is encoded based on the already encoded bitrate.
[0097] In some embodiments of this application, the target coding element includes a target reference frame. When the video transcoding device determines candidate reference frames based on a set of historical reference frames corresponding to the encoded bitrate, and the candidate reference frames include multiple reference frames, the target coding element of the coding block at the target bitrate is determined based on the coding cost of the candidate coding elements. The specific implementation process of S103 may include S1033-S1034, as follows: S1033. Calculate the coding cost for each of the multiple reference frames to obtain multiple second coding costs corresponding to the multiple reference frames.
[0098] S1034. The reference frame corresponding to the smallest second coding cost among multiple second coding costs is determined as the target reference frame of the coding block at the target bit rate.
[0099] The video transcoding device calculates the encoding cost for each coding block for multiple reference frames, obtaining a second encoding cost for each reference frame. Then, the device selects the reference frame with the smallest second encoding cost from among the multiple second encoding costs, and determines the reference frame corresponding to the smallest second encoding cost as the target reference frame.
[0100] It should be noted that when the encoded bitrate contains only one bitrate, the number of reference frames in the candidate reference frames is generally not too large (this is because one or more historical reference frames corresponding to the smallest N historical coding costs are selected as candidate reference frames); when the encoded bitrate contains multiple bitrates, the candidate reference frames will be composed of reference frames selected from the historical reference frames corresponding to the smallest N historical coding costs for each bitrate in the encoded bitrate, so the number of reference frames may be large, and it is necessary to calculate the coding cost of these reference frames one by one in order to select the target reference frame.
[0101] For example, Figure 6 This is a schematic diagram illustrating the selection of a target reference frame from multiple reference frames, provided in an embodiment of this application. See also... Figure 6The video transcoding device needs to calculate the encoding cost C1 for reference frame f1, C2 for reference frame f2, and so on, until the encoding cost Ck is calculated for reference frame fk. Then, the reference frame with the minimum encoding cost Ci is selected as the target reference frame.
[0102] In this embodiment, the video transcoding device calculates the encoding cost for multiple reference frames among the candidate reference frames. Compared with calculating the encoding cost for all reference frames, this undoubtedly reduces the time spent calculating the encoding cost and improves the efficiency of video transcoding.
[0103] In some embodiments of this application, there is only one reference frame among the candidate reference frames. The video transcoding device can directly determine the reference frame as the target reference frame, or it can determine the reference frame as the target reference frame when the encoding cost corresponding to the reference frame is greater than a certain value when encoding with the target bit rate.
[0104] In some embodiments of this application, the candidate reference frame is determined based on the set of historical reference frames corresponding to the encoded bitrate. The specific implementation process of S1022 may include: S1022a-S1022b, as follows: S1022a. From the historical coding costs corresponding to each historical reference frame in the historical reference frame set, select the N smallest historical coding costs; where N is a positive integer greater than or equal to 2. When encoding a block based on the encoded bitrate, the encoding cost has already been calculated for the historical reference frames in the historical reference frame set. At this time, the video transcoding device sorts the historical encoding costs corresponding to each historical reference frame in the historical reference frame set by size and determines the N smallest historical encoding costs.
[0105] For example, assuming the encoded code rate is n-1, then the historical reference frames included in the candidate reference frames are as follows: , ... The historical coding cost corresponding to each historical reference frame is , ... The video transcoding device selects the two lowest historical encoding costs from these historical encoding costs; this is the minimum value. and second smallest value .
[0106] S1022b: Based on the minimum N historical coding costs, determine the candidate reference frames for the coding block.
[0107] Video transcoding devices can directly use the historical reference frames corresponding to the N smallest historical coding costs as candidate reference frames, or they can determine whether the smallest historical coding cost among the N smallest historical coding costs is much smaller than the remaining historical coding costs. If it is much smaller than the remaining historical coding costs, the historical reference frame corresponding to the smallest historical coding cost can be used as a candidate reference frame.
[0108] For example, when N=2, the minimum N historical coding costs include: minimum historical coding cost Much less than the cost of the remaining historical encoding The video transcoding device can convert the two corresponding encoding costs into historical reference frames. and Candidate reference frames are jointly determined as the target bit rate, or a historical reference frame can be selected as a candidate reference frame.
[0109] In this embodiment, the video transcoding device first selects the N smallest historical coding costs, and then determines the candidate reference frames of the coding block from the historical reference frames corresponding to the N smallest historical coding costs, thereby reducing the number of reference frames that need to be calculated for coding costs and obtaining the candidate reference frames.
[0110] In some embodiments of this application, when N=2, the minimum N historical coding costs include the minimum historical coding cost and the second smallest historical coding cost; the specific implementation process of determining the candidate reference frame of the coding block based on the minimum N historical coding costs, i.e., S1022b, may include: S201, and any one of S202 and S203, as follows: S201. Increase the minimum historical coding cost to obtain the increased minimum historical coding cost.
[0111] In this embodiment of the application, the video transcoding device first increases the minimum historical coding cost so that the increased minimum historical coding cost can be compared with the second smallest historical coding cost to determine whether the minimum historical coding cost is much smaller than the second smallest historical coding cost.
[0112] S202. When the minimum historical coding cost is greater than the increased minimum historical coding cost, the historical reference frame corresponding to the minimum historical coding cost is determined as the candidate reference frame.
[0113] When the second smallest historical coding cost is greater than the increased minimum historical coding cost, it means that the minimum historical coding cost is much smaller than the second smallest historical coding cost. Therefore, the video transcoding device will use the historical reference frame corresponding to the minimum historical coding cost as the candidate reference frame.
[0114] S203. When the second smallest historical coding cost is less than or equal to the increased minimum historical coding cost, the historical reference frames corresponding to the minimum historical coding cost and the second smallest historical coding cost are determined as candidate reference frames.
[0115] When the second smallest historical coding cost is less than or equal to the increased minimum historical coding cost, it means that the minimum historical coding cost and the second smallest historical coding cost are similar in size, making it impossible to determine which is the better reference frame for the target bit rate. Therefore, the video transcoding device will use the historical reference frames corresponding to the minimum historical coding cost and the second smallest historical coding cost as candidate reference frames to further calculate the coding cost of the coding block at the target bit rate.
[0116] In this embodiment of the application, the video transcoding device can first increase the minimum historical coding cost, and then compare the second smallest historical coding cost with the increased minimum historical coding cost to determine whether the minimum historical coding cost is much smaller than the second smallest historical coding cost, so as to decide which historical reference frames to use as candidate reference frames, thereby reducing the number of reference frames that need to be calculated for coding cost.
[0117] In some embodiments of this application, the minimum historical coding cost is increased to obtain the increased minimum historical coding cost. The specific implementation process of S201 may include: S2011 or S2012, as follows: S2011. Increase the minimum historical coding cost by the amplification factor to obtain the increased minimum historical coding cost.
[0118] The video transcoding device multiplies the minimum historical coding cost by the amplification factor, and the resulting product is the increased minimum historical coding cost. It should be noted that the amplification factor must be greater than or equal to 1.
[0119] In some embodiments, the amplification factor can be a pre-set fixed factor, such as 3 times, 10 times, etc. In other embodiments, the amplification factor can be a random factor, as long as it is greater than or equal to 1, which is not limited herein.
[0120] S2012. Add a preset value to the minimum historical coding cost to obtain the increased minimum historical coding cost.
[0121] In addition to multiplying the minimum historical coding cost, video transcoding devices can also add a preset value to the minimum historical coding cost. The result of this addition is the increased minimum historical coding cost.
[0122] It is understandable that the preset value can be set according to the actual situation, such as setting it to 2, setting it to 0.5, etc., and this application does not limit it here.
[0123] In this embodiment of the application, the video transcoding device can increase the minimum historical coding cost by either increasing the minimum historical coding cost by a factor of 1 or by adding a preset value to the minimum historical coding cost, so as to facilitate subsequent judgment on whether the minimum historical coding cost is much smaller than the second smallest historical coding cost.
[0124] In some embodiments of this application, candidate coding elements include: candidate coding patterns; based on historical pattern information, candidate coding elements corresponding to the target code rate are selected for the coding block, i.e., the specific implementation process of S102 may include: S1023, as follows: S1023. When the historical mode information characterizes the selection of inter-frame prediction to encode the coding block at the already coded bit rate, each second prediction mode of the inter-frame prediction is determined as a candidate coding mode.
[0125] When the video conversion device reads historical mode information and determines that the coding mode selected for the coded block at the encoded bitrate is inter-frame prediction, it will identify each second prediction mode of inter-frame prediction as a candidate coding mode. This eliminates the need to calculate the coding cost for each first prediction mode of intra-frame prediction in subsequent steps, reducing the number of coding modes for which coding costs need to be calculated.
[0126] The target coding elements include: the target coding mode; when the video transcoding device determines each second prediction mode of the inter-frame prediction as a candidate coding mode, the target coding elements of the coding block at the target bit rate are determined according to the coding cost of the candidate coding elements, i.e., the specific implementation process of S103 can include: S1035-S1036, as follows: S1035. Calculate the coding cost for each second prediction mode in the candidate coding modes to obtain the third coding cost corresponding to each second prediction mode.
[0127] The video transcoding device calculates the coding cost of the coding block for each second prediction mode in the inter-frame prediction, and obtains a third coding cost corresponding to each second prediction mode.
[0128] It should be noted that each second prediction mode differs in at least one or more of the segmentation rules and motion vector estimation methods. The motion vector estimation method refers to the process of estimating motion vectors, which may include derivation based on surrounding blocks, derivation based on transmitted motion vector difference (MVD), and derivation based on global motion, etc.
[0129] S1036. The second prediction mode corresponding to the minimum third coding cost is determined as the target coding mode of the coding block at the target code rate.
[0130] After obtaining the third coding cost corresponding to each second prediction mode of inter-frame prediction, the video transcoding device compares these third coding costs to determine the smallest third coding cost. Then, the second prediction mode corresponding to the smallest third coding cost is determined as the target coding mode used by the coding block when encoding based on the target bit rate.
[0131] In this embodiment, the video transcoding device calculates the encoding cost only for each second prediction mode of inter-frame prediction, in order to select the target encoding mode for the target bitrate for the coding block. This reduces the number of encoding modes for which encoding costs need to be calculated, thus improving the efficiency of video transcoding.
[0132] See Figure 7 , Figure 7 This is an optional flowchart illustrating the video transcoding method provided in this application embodiment. Figure 2 In some embodiments of this application, before obtaining the historical mode information corresponding to the encoded bitrate of the coded block of the video frame image, i.e., before S101, the method may further include: S105-S106, as follows: S105. Decode the original video to obtain video frame images.
[0133] It should be noted that the original video is an encoded video file, such as a pre-produced movie or TV series file, in which all video frame images are stored in the storage space as encoded data. Therefore, in this embodiment, the video transcoding device decodes the original video to obtain video frame images, so that the video frame images can be re-encoded according to the encoded bitrate in the future.
[0134] S106. Encode the coding blocks of the video frame image according to the encoded bitrate to obtain the historical mode information of the coding blocks at the encoded bitrate.
[0135] It should be noted that the encoded bitrate includes one or more pre-set bitrates. When the encoded bitrate includes only one pre-set bitrate, in this embodiment, the original video is first decoded, and then encoded only based on that single bitrate. When the encoded bitrate includes multiple pre-set bitrates, in this embodiment, different bitrates are first decoded uniformly to obtain video frame images, and then the video frame images obtained from the uniform decoding are encoded according to different bitrates. This allows the decoding process to be merged during video transcoding based on different bitrates, reducing repetitive operations during decoding.
[0136] For example, Figure 8 This is a schematic diagram illustrating the process of transcoding video according to the encoded bitrate, as provided in an embodiment of this application. See also... Figure 8Video transcoding equipment first performs a unified 8-A decoding on the original video. Then, it encodes each video frame individually based on different bitrates from the pre-encoded bitrates. For example, it encodes based on bitrate 1, bitrate 2, and so on, up to bitrate n, thus obtaining video 8-1 corresponding to bitrate 1, video 8-2 corresponding to bitrate 2, and so on, up to video 8-n corresponding to bitrate n. In this way, videos with different bitrates can be obtained with only one decoding operation, reducing repetitive operations during decoding.
[0137] In this embodiment, the video transcoding device decodes the original video uniformly, and then encodes the video frame images according to one or more bitrates included in the encoded bitrate. During the encoding process, the historical mode information of the encoded blocks of the video frame images corresponding to the encoded bitrates is determined. In this way, the decoding processes of different bitrates can be merged, reducing the time consumption caused by repetitive operations during decoding and further improving the efficiency of video transcoding.
[0138] In some embodiments of this application, after decoding the original video to obtain video frame images, the coding blocks of the video frame images are encoded according to the encoded bitrate to obtain the coding blocks before the historical mode information corresponding to the encoded bitrate. The method may further include: S107-S108, as follows: S107. Analyze the video frame images to determine the auxiliary coding parameters.
[0139] The bitrate specified for a video does not necessarily refer to the bitrate of each individual video frame, but rather the bitrate of the video as a whole. Different video frames, and even different coding blocks, may have different bitrates. For example, some video frames may have high bitrates, while others may have low bitrates. The average bitrate of these different video frames reaches the specified bitrate. In this embodiment, based on the specified encoded bitrate, the bitrate corresponding to each different video frame, and even different coding blocks within a video frame, is determined.
[0140] First, the video transcoding device analyzes the video frame images to determine parameters such as the type of the video frame image, the region of interest, and the quality quantization parameters, and uses these parameters as auxiliary coding parameters. In other words, in this embodiment, the auxiliary coding parameters include at least one or more of the following: the type of the video frame image, the region of interest, and the quality quantization parameters.
[0141] The type of video frame image can refer to whether it belongs to a reference frame and its type, or whether it contains key content from the video. The region of interest (ROI) refers to the area in the video frame image that needs to be highlighted, such as the area in a movie scene containing main characters and props. The quality quantization parameter reflects the compression of spatial details.
[0142] S108. Based on the auxiliary coding parameters, allocate the actual bit rate to the coding blocks of the video frame image.
[0143] After obtaining the auxiliary coding parameters, the video transcoding device allocates the corresponding actual bitrate to different coding blocks in different video frames based on these parameters. It should be noted that the encoded bitrate is the average of the actual bitrates of the coding blocks in the video frame image. In other words, the required encoded bitrate is achieved by balancing the actual bitrates of different coding blocks in different video frames as a whole.
[0144] In this case, encoding the video frame image into coding blocks according to the encoded bitrate to obtain the historical mode information of the coding blocks at the encoded bitrate, i.e., the specific implementation process of S106, can include: S1061, as follows: S1061. Encode the coding blocks of the video frame image according to the actual bit rate to obtain the historical mode information corresponding to the encoded bit rate.
[0145] Understandably, video transcoding devices will allocate higher bitrates to reference frames and video frames containing key content, and lower bitrates to video frames that do not contain key content; they will allocate higher bitrates to coded blocks in the region of interest within the video frame image, and lower bitrates to coded blocks that are not in the region of interest; they will allocate higher bitrates to video frames or coded blocks with higher quality quantization parameters, and lower bitrates to video frames or coded blocks with lower quality quantization parameters.
[0146] It should be noted that, in this embodiment of the application, the video transcoding device only begins encoding the coding blocks of different video frame images at different bitrates after uniformly determining the bitrate for different video frame images and different coding blocks, that is, after uniformly analyzing different video frame images. This reduces repetitive operations during video analysis.
[0147] For example, based on Figure 8 See Figure 9 , Figure 9This is a schematic diagram illustrating the video transcoding process provided in this application embodiment. After obtaining the video frame images, the video transcoding device analyzes the video frame images uniformly 9-1, and then encodes the video frame images separately based on different bitrates in the encoded bitrate, thereby realizing the merging of video analyses with different bitrates.
[0148] In this embodiment, the video transcoding device can determine auxiliary encoding parameters for video frame images to allocate actual bitrates to the encoding blocks of the video frame images, and then encode the encoding blocks according to the actual bitrates. This eliminates the need for video analysis for different bitrates, thus merging video analyses of different bitrates and reducing the time consumed by repetition during video analysis.
[0149] The following will describe an exemplary application of the embodiments of this application in a real-world application scenario.
[0150] The embodiments of this application are implemented in a scenario where a server (video transcoding device) performs multi-bitrate transcoding on a user's short video.
[0151] In this embodiment of the application, since the original video, i.e., the user-recorded short video, is identical during multi-bitrate transcoding, the decoding and video analysis processes in the multi-bitrate transcoding process can be merged, thereby reducing the complexity of multi-bitrate transcoding. For example, it can be achieved through... Figure 9 The merging is performed as shown.
[0152] In related technologies, video compression encoding processes at different bitrates are independent of each other. However, in this embodiment, the encoding information of the already encoded bitrate is used to accelerate the encoding process at the target bitrate.
[0153] First, we will introduce the selectable range of encoded bitrates when accelerating the encoding process of the target bitrate.
[0154] One possible approach is to utilize the encoding mode selection information of target bitrate 1 to accelerate the encoding mode selection process of target bitrate 2. Specifically, this involves using the mode selection information (historical mode information) of target bitrate n-1 (already encoded bitrates) to accelerate the mode selection process of target bitrate n (target bitrate). See also Figure 10 , Figure 10This is a schematic diagram illustrating an optional range of encoded bitrates provided in an embodiment of this application. The server uses encoding mode 10-1 of the target bitrate n-1 to compress and encode the decoded image based on the target bitrate n-1, obtaining the bitstream 10-3 corresponding to the target bitrate n-1. Simultaneously, using encoding mode 10-1 of the target bitrate n-1, the selection process of encoding mode 10-5 of the target bitrate n is accelerated, and then the decoded image is compressed and encoded based on the target bitrate n using the selected encoding mode 10-5 of the target bitrate n, obtaining the bitstream 10-7 corresponding to the target bitrate n.
[0155] Another possible approach is to utilize the encoding mode selection information of target bitrate 1 to accelerate the encoding mode selection process of target bitrate 2 when n is greater than or equal to 3; select one or more target bitrates (encoded bitrates include one or more specified bitrates) from target bitrate 1, target bitrate 2, ..., target bitrate n-1, and use the encoding mode selection information (historical mode information) corresponding to these target bitrates to accelerate the encoding mode selection process of target bitrate n. For example, based on... Figure 10 , Figure 11 This is a schematic diagram illustrating another optional range of encoded bitrates provided in an embodiment of this application. The server utilizes encoding mode 11-1 of the target bitrate n-2 to accelerate the selection process of encoding mode 10-1 of the target bitrate n-1. Simultaneously, it uses encoding mode 11-1 of the target bitrate n-2 to perform compression encoding 11-3 on the decoded image data at the target bitrate n-2, obtaining the bitstream 11-4 corresponding to the target bitrate n-2. When accelerating the selection process of the encoding mode for the target bitrate n, the server simultaneously uses encoding mode 11-1 of the target bitrate n-2 and encoding mode 10-1 of the target bitrate n-1 to obtain encoding mode 10-5 of the target bitrate n.
[0156] After introducing the range of selectable encoded bitrates, we will continue to introduce the specific selection method of the encoding mode for each block (the encoded block of a video frame image).
[0157] Block-based video compression coding techniques allow for the selection of multiple coding modes for each block, such as intra-frame prediction and inter-frame prediction. Mode selection involves calculating the coding costs of various modes and choosing the one with the lowest cost. For example, if the coding cost of intra-frame prediction is lower than that of inter-frame prediction, then the current coding block will be encoded using intra-frame prediction.
[0158] In this embodiment, the current coded block (the coded block at the target bitrate) belongs to the target bitrate n, and the corresponding coded block (the coded block at the already encoded bitrate) belongs to the target bitrate n-1. The corresponding coded block is a coded block at the same position in the same frame within the bitstream at the target bitrate n-1. The bitrate n can be greater than or less than the bitrate n-1. If the corresponding coded block selects an intra-prediction mode (the historical mode information corresponding to the coded block at the already encoded bitrate indicates that the selected coded mode is intra-prediction), the server only calculates the coded modes for the current coded block (each first prediction mode of intra-prediction is determined as a candidate coded mode), and selects the mode with the minimum coding cost from the coded modes (the first prediction mode corresponding to the minimum first coding cost is determined as the target coded mode of the coded block at the target bitrate). There is no need to calculate the coding cost of each inter-prediction mode.
[0159] Inter-frame prediction in video compression coding requires selecting a block from one or more encoded frames for each block as the coding prediction value for the current coding block. Reference frame selection in inter-frame prediction is a part of inter-frame coding mode selection, which requires choosing the reference frame with the lowest coding cost from multiple reference frames.
[0160] In this embodiment, the current encoded block belongs to the target bitrate n, and the corresponding encoded block belongs to the target bitrate n-1. The corresponding encoded block is the encoded block at the same position in the same frame within the bitstream of the target bitrate n-1. The target bitrate n can be greater than or less than the target bitrate n-1. The server first determines the range of selectable reference frames for the encoded blocks (candidate reference frames corresponding to the encoded bitrates), i.e. , ... The corresponding encoding cost is , ... Sort these encoding costs, with the minimum being [value]. (Minimum historical encoding cost), the second smallest value is (Second smallest history encoding cost), the corresponding reference frame is , The reference frame corresponding to the current coded block is , (Reference Frame). Therefore, when selecting a reference frame for the current coding block, one or more reference frames can be selected (candidate coding costs include multiple reference frames) by referring to the coding cost ranking of already coded blocks, and the coding cost can be calculated without calculating the coding cost of each reference frame. The specific process can be as follows: when When this happens, the current coding block only needs to calculate the reference frame. The encoding cost, where, It is a value greater than or equal to 1, and can be a fixed value or a non-fixed value.
[0161] Otherwise, the current coding block needs to calculate the reference frame. , The encoding cost is calculated, and a reference frame (target reference frame) with a smaller encoding cost is selected from it.
[0162] By employing the above methods, not only can the transcoding process be accelerated by reducing repetitive operations during video compression encoding, but the current mode selection process can also be improved by referencing encoded information from other bitrates, thereby increasing encoding speed and ultimately improving transcoding efficiency.
[0163] The following description continues to illustrate the exemplary structure of the video transcoding device 555 provided in the embodiments of this application as a software module. In some embodiments, such as Figure 4 As shown, the software modules stored in the video transcoding device 555 in the memory 550 may include: The information acquisition module 5551 is used to acquire historical mode information of the coding block of a video frame image at the encoded bitrate, wherein the historical mode information represents the coding mode selected by the coding block when it is encoded based on the encoded bitrate. The element screening module 5552 is used to screen out candidate coding elements corresponding to the target code rate for the coding block based on the historical pattern information, wherein the candidate coding elements are coding elements waiting to calculate the coding cost. The element determination module 5553 is used to determine the target coding element of the coding block at the target code rate based on the coding cost of the candidate coding elements; The image encoding module 5554 is used to encode the encoding block using the target encoding elements and the target bit rate to achieve video transcoding.
[0164] In some embodiments of this application, the candidate coding elements include: candidate coding modes; the element screening module 5552 is further configured to determine each first prediction mode of the intra-frame prediction as the candidate coding mode when the historical mode information characterizes the selection of intra-frame prediction to encode the coding block at the encoded bitrate, wherein each first prediction mode differs in at least one or more of the segmentation rules, prediction methods, and offset angles.
[0165] In some embodiments of this application, the target coding element includes: a target coding mode; the element determination module 5553 is further configured to calculate the coding cost of each first prediction mode in the candidate coding modes to obtain the first coding cost corresponding to each first prediction mode; and determine the first prediction mode corresponding to the minimum first coding cost as the target coding mode of the coding block at the target code rate.
[0166] In some embodiments of this application, the candidate coding elements include: candidate reference frames; the element screening module 5552 is further configured to determine the candidate reference frames based on the set of historical reference frames corresponding to the encoded bitrate when the historical pattern information characterizes the selection of inter-frame prediction to encode the coding block at the encoded bitrate.
[0167] In some embodiments of this application, the element screening module 5552 is further configured to select the N smallest historical coding costs from the historical coding costs corresponding to each historical reference frame in the historical reference frame set; wherein N is a positive integer greater than or equal to 2; and determine the candidate reference frame of the coding block based on the N smallest historical coding costs.
[0168] In some embodiments of this application, when N=2, the minimum N historical coding costs include the minimum historical coding cost and the second smallest historical coding cost; the element screening module 5552 is further configured to increase the minimum historical coding cost to obtain the increased minimum historical coding cost; when the second smallest historical coding cost is greater than the increased minimum historical coding cost, the historical reference frame corresponding to the minimum historical coding cost is determined as the candidate reference frame; when the second smallest historical coding cost is less than or equal to the increased minimum historical coding cost, the historical reference frames corresponding to the minimum historical coding cost and the second smallest historical coding cost are determined as the candidate reference frames.
[0169] In some embodiments of this application, the element screening module 5552 is further configured to increase the minimum historical coding cost by an amplification factor to obtain the increased minimum historical coding cost, wherein the amplification factor is greater than or equal to 1; or, to superimpose a preset value on the minimum historical coding cost to obtain the increased minimum historical coding cost.
[0170] In some embodiments of this application, the candidate reference frame includes: a plurality of reference frames; the target coding element includes: a target reference frame; the element determination module 5553 is further configured to calculate the coding cost for the plurality of reference frames respectively, to obtain a plurality of second coding costs corresponding to the plurality of reference frames; and to determine the reference frame corresponding to the smallest second coding cost among the plurality of second coding costs as the target reference frame of the coding block at the target bit rate.
[0171] In some embodiments of this application, the candidate coding elements include: candidate coding modes; the element screening module 5552 is further configured to determine each second prediction mode of the inter-frame prediction as the candidate coding mode when the historical mode information characterizes the selection of inter-frame prediction to encode the coding block at the already encoded bitrate.
[0172] In some embodiments of this application, the element determination module 5553 is further configured to calculate the encoding cost of each second prediction mode in the candidate encoding modes to obtain a third encoding cost corresponding to each second prediction mode, wherein each second prediction mode differs in at least one or more of the segmentation rules and motion vector estimation methods; and the second prediction mode corresponding to the minimum third encoding cost is determined as the target encoding mode of the encoding block at the target bit rate.
[0173] In some embodiments of this application, the video transcoding device 555 further includes a video decoding module 5555; The video decoding module 5555 is used to decode the original video to obtain video frame images; The image encoding module 5554 is further configured to encode the encoding blocks of the video frame image according to the encoded bitrate, to obtain the historical mode information of the encoding blocks corresponding to the encoded bitrate, wherein the encoded bitrate includes one or more preset bitrates.
[0174] In some embodiments of this application, the video transcoding device 555 further includes: a video analysis module 5556; The video analysis module 5556 is used to analyze the video frame image and determine auxiliary coding parameters; the auxiliary coding parameters include at least one or more of the following: video frame image type, region of interest, and quality quantization parameters; based on the auxiliary coding parameters, an actual bitrate is allocated to the coding blocks of the video frame image, and the encoded bitrate is the average of the actual bitrates of the coding blocks of the video frame image; The image encoding module 5554 is further configured to encode the encoding blocks of the video frame image according to the actual bitrate, so as to obtain the historical mode information corresponding to the encoded bitrate.
[0175] This application provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the video transcoding method described in this application.
[0176] This application provides a computer-readable storage medium storing executable instructions, including executable video transcoding instructions. When these executable video transcoding instructions are executed by a processor, the processor will execute the video transcoding method provided in this application. For example, ... Figure 5 The method shown.
[0177] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.
[0178] In some embodiments, executable video transcoding instructions may take the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0179] As an example, executable video transcoding instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple collaborative files (e.g., files that store one or more modules, subroutines, or code sections).
[0180] As an example, executable video transcoding instructions can be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.
[0181] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.
Claims
1. A video transcoding method, characterized in that, include: The original video is decoded to obtain video frame images; the encoded blocks of the video frame images are encoded according to the encoded bitrate to obtain the historical mode information of the encoded blocks corresponding to the encoded bitrate. The historical mode information of the encoded block of the video frame image corresponding to the encoded bitrate is obtained, and the historical mode information represents the encoding mode selected by the encoded block when encoding based on the encoded bitrate. Based on the historical pattern information, candidate coding elements corresponding to the target bitrate are selected for the coding block, wherein the candidate coding elements are coding elements awaiting coding cost calculation; the step of selecting candidate coding elements corresponding to the target bitrate for the coding block based on the historical pattern information includes: When the historical pattern information indicates that inter-frame prediction is selected to encode the coding block at the coded bitrate, the candidate coding elements include candidate reference frames; From the historical coding costs corresponding to each historical reference frame in the historical reference frame set, select the N smallest historical coding costs, where N is a positive integer greater than or equal to 2; where N = 2, the N smallest historical coding costs include the smallest historical coding cost and the second smallest historical coding cost. The minimum historical coding cost is increased to obtain an increased minimum historical coding cost; when the second smallest historical coding cost is greater than the increased minimum historical coding cost, the historical reference frame corresponding to the minimum historical coding cost is determined as the candidate reference frame; when the second smallest historical coding cost is less than or equal to the increased minimum historical coding cost, the historical reference frames corresponding to the minimum historical coding cost and the second smallest historical coding cost are determined as the candidate reference frames. Based on the coding cost of the candidate coding elements, the target coding elements of the coding block at the target code rate are determined; The target coding elements and the target bitrate are used to encode the coding block to achieve video transcoding.
2. The method according to claim 1, characterized in that, The candidate coding elements further include: candidate coding patterns; the step of selecting candidate coding elements corresponding to the target bitrate for the coding block based on the historical pattern information includes: When the historical pattern information indicates that intra-prediction is selected to encode the coding block at the encoded bitrate, each first prediction mode of the intra-prediction is determined as the candidate coding mode, wherein each first prediction mode is different in at least one or more of the segmentation rules, prediction methods and offset angles.
3. The method according to claim 2, characterized in that, The target coding elements include: a target coding pattern; determining the target coding elements of the coding block at the target code rate based on the coding cost of the candidate coding elements includes: The coding cost is calculated for each first prediction mode in the candidate coding modes to obtain the first coding cost corresponding to each first prediction mode; The first prediction mode corresponding to the minimum first coding cost is determined as the target coding mode of the coding block at the target code rate.
4. The method according to claim 1, characterized in that, The process of increasing the minimum historical coding cost to obtain the increased minimum historical coding cost includes: The minimum historical coding cost is increased by an amplification factor to obtain the increased minimum historical coding cost, wherein the amplification factor is greater than or equal to 1; or, The minimum historical coding cost is increased by adding a preset value to it.
5. The method according to claim 1 or 4, characterized in that, The candidate reference frames include: multiple reference frames; the target coding elements include: target reference frames; determining the target coding elements of the coding block at the target bit rate based on the coding cost of the candidate coding elements includes: The coding cost is calculated for each of the multiple reference frames to obtain multiple second coding costs corresponding to the multiple reference frames; The reference frame corresponding to the smallest second coding cost among the plurality of second coding costs is determined as the target reference frame of the coding block at the target bit rate.
6. The method according to claim 1, characterized in that, The candidate coding elements further include: candidate coding patterns; the step of selecting candidate coding elements corresponding to the target bitrate for the coding block based on the historical pattern information includes: When the historical pattern information indicates that inter-frame prediction is selected to encode the coding block at the coded bitrate, each second prediction mode of the inter-frame prediction is determined as the candidate coding mode.
7. The method according to claim 6, characterized in that, The target coding elements include: a target coding pattern; determining the target coding elements of the coding block at the target code rate based on the coding cost of the candidate coding elements includes: The encoding cost is calculated for each second prediction mode in the candidate encoding modes to obtain the third encoding cost corresponding to each second prediction mode, wherein each second prediction mode differs in at least one or more of the segmentation rules and motion vector estimation methods; The second prediction mode corresponding to the minimum third coding cost is determined as the target coding mode of the coding block at the target code rate.
8. The method according to any one of claims 1 to 4, 6, and 7, characterized in that, The encoded bitrate includes one or more pre-set bitrates.
9. The method according to claim 8, characterized in that, After decoding the original video to obtain video frame images, the method further includes encoding the coded blocks of the video frame images according to the encoded bitrate to obtain the coded blocks before the historical mode information corresponding to the encoded bitrate. The video frame images are analyzed to determine auxiliary coding parameters; the auxiliary coding parameters include at least one or more of the following: video frame image type, region of interest, and quality quantization parameters; Based on the auxiliary coding parameters, an actual bitrate is allocated to the coding blocks of the video frame image, and the encoded bitrate is the average of the actual bitrates of the coding blocks of the video frame image; The step of encoding the video frame image into coded blocks according to the encoded bitrate to obtain the historical mode information of the coded blocks corresponding to the encoded bitrate includes: The video frame image is encoded according to the actual bitrate to obtain the historical mode information corresponding to the encoded bitrate.
10. A video transcoding device, characterized in that, include: The video decoding module is used to decode the original video to obtain video frame images; An image encoding module is used to encode the encoding blocks of the video frame image according to the encoded bitrate, and obtain the historical mode information of the encoding blocks corresponding to the encoded bitrate. The information acquisition module is used to acquire the historical mode information of the coding block of the video frame image at the encoded bitrate, wherein the historical mode information represents the coding mode selected by the coding block when encoding based on the encoded bitrate. The element screening module is used to screen candidate coding elements corresponding to the target bitrate for the coding block based on the historical pattern information, wherein the candidate coding elements are coding elements waiting to calculate the coding cost; wherein, when the historical pattern information indicates that inter-frame prediction is selected to encode the coding block at the already encoded bitrate, the candidate coding elements include candidate reference frames. From the historical coding costs corresponding to each historical reference frame in the historical reference frame set, select the N smallest historical coding costs, where N is a positive integer greater than or equal to 2; where N = 2, the N smallest historical coding costs include the smallest historical coding cost and the second smallest historical coding cost. The minimum historical coding cost is increased to obtain an increased minimum historical coding cost; when the second smallest historical coding cost is greater than the increased minimum historical coding cost, the historical reference frame corresponding to the minimum historical coding cost is determined as the candidate reference frame; when the second smallest historical coding cost is less than or equal to the increased minimum historical coding cost, the historical reference frames corresponding to the minimum historical coding cost and the second smallest historical coding cost are determined as the candidate reference frames. The element determination module is used to determine the target coding element of the coding block at the target code rate based on the coding cost of the candidate coding elements; The image encoding module is further configured to encode the encoding block using the target encoding elements and the target bitrate, thereby achieving video transcoding.
11. The apparatus according to claim 10, characterized in that, The candidate coding elements also include: candidate coding patterns; The element screening module is further configured to determine each first prediction mode of the intra-frame prediction as the candidate coding mode when the historical pattern information characterizes the selection of intra-frame prediction to encode the coding block at the encoded bitrate, wherein each first prediction mode differs in at least one or more of the segmentation rules, prediction methods, and offset angles.
12. The apparatus according to claim 11, characterized in that, The target encoding elements include: target encoding pattern; The element determination module is further configured to calculate the encoding cost for each first prediction mode in the candidate encoding modes, and obtain the first encoding cost corresponding to each first prediction mode. The first prediction mode corresponding to the minimum first coding cost is determined as the target coding mode of the coding block at the target code rate.
13. The apparatus according to claim 10, characterized in that, The element initial screening module is further configured to increase the minimum historical coding cost by an amplification factor to obtain the increased minimum historical coding cost, wherein the amplification factor is greater than or equal to 1; or, The minimum historical coding cost is increased by adding a preset value to it.
14. The apparatus according to claim 10 or 13, characterized in that, The candidate reference frame includes: multiple reference frames; the target coding element includes: the target reference frame; The element determination module is also used to calculate the encoding cost for each of the multiple reference frames to obtain multiple second encoding costs corresponding to the multiple reference frames. The reference frame corresponding to the smallest second coding cost among the plurality of second coding costs is determined as the target reference frame of the coding block at the target bit rate.
15. The apparatus according to claim 10, characterized in that, The candidate coding elements also include: candidate coding patterns; The element screening module is further configured to determine each second prediction mode of the inter-frame prediction as the candidate coding mode when the historical pattern information characterizes the selection of inter-frame prediction to encode the coding block at the encoded bitrate.
16. The apparatus according to claim 15, characterized in that, The target encoding elements include: target encoding pattern; The element determination module is further configured to calculate the encoding cost for each second prediction mode in the candidate encoding modes to obtain a third encoding cost corresponding to each second prediction mode, wherein each second prediction mode differs in at least one or more of the segmentation rules and motion vector estimation methods; The second prediction mode corresponding to the minimum third coding cost is determined as the target coding mode of the coding block at the target code rate.
17. The apparatus according to any one of claims 10 to 13, 15, and 16, characterized in that, The encoded bitrate includes one or more pre-set bitrates.
18. The apparatus according to claim 17, characterized in that, The device further includes: The video analysis module is used to analyze the video frame image after decoding the original video to obtain video frame images, encode the coding blocks of the video frame images according to the encoded bitrate, and obtain the historical mode information corresponding to the encoded bitrate of the coding blocks, and determine auxiliary coding parameters; the auxiliary coding parameters include at least one or more of the following: the type of video frame image, region of interest, and quality quantization parameters. Based on the auxiliary coding parameters, an actual bitrate is allocated to the coding blocks of the video frame image, and the encoded bitrate is the average of the actual bitrates of the coding blocks of the video frame image; The image encoding module is further configured to encode the encoding blocks of the video frame image according to the actual bitrate, so as to obtain the historical mode information corresponding to the encoded bitrate.
19. A video transcoding device, characterized in that, include: Memory, used to store executable video transcoding instructions; A processor, when executing executable video transcoding instructions stored in the memory, implements the method according to any one of claims 1 to 9.
20. A computer-readable storage medium, characterized in that, The device stores executable video transcoding instructions, which, when executed by a processor, implement the method described in any one of claims 1 to 9.
21. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the method described in any one of claims 1 to 9.
Citation Information
Patent Citations
Reference frame selection method, video transcoding method, electronic device and storage medium
CN108401185A
Multichannel same-resolution video transcoding method
CN108924550A