Video transcoding method and device, electronic equipment, storage medium and program product
By combining reinforcement learning agents and reward functions, video transcoding parameters are dynamically adjusted, solving the problem in existing technologies where video transcoding models cannot adapt to dynamic changes. This achieves a balance between high quality and high compression rate, and improves the adaptability and efficiency of video transcoding.
Patent Information
- Application Number
- CN202510780842.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-11
- Publication Date
- 2025-09-12
AI Technical Summary
In the existing technology, the video transcoding model cannot adapt to dynamic changes, resulting in the inability to achieve efficient dynamic adjustment of video quality and compression rate in practical applications.
A reinforcement learning agent combined with a reward function is used to obtain the state vector of the video clip and dynamically adjust the transcoding parameters to achieve a balance between video quality and compression rate.
It achieves the pursuit of high compression rate on the basis of high-quality video, dynamically adjusts transcoding parameters, and improves the adaptability and efficiency of video transcoding.
Smart Images

Figure CN120640068A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to a video transcoding method, device, electronic device, storage medium, and program product. Background Art
[0002] Video transcoding cards are widely used in various fields due to their powerful hardware acceleration capabilities and efficient video processing performance. For example, video transcoding cards can encode and compress videos from surveillance cameras in real time, reducing storage space usage and improving data transmission efficiency.
[0003] In related technologies, a model is trained based on historical data through supervised learning, the extracted video features are input into the model, and the model is used to predict the encoding parameters corresponding to the optimal transcoding effect.
[0004] The above optimal transcoding effect has been determined during the model training process and cannot adapt to dynamic changes in actual applications.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the Invention
[0006] The present disclosure provides a video transcoding method, apparatus, electronic device, storage medium, and program product, which at least to some extent overcome the problem of related technologies being unable to adapt to dynamic changes.
[0007] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by practice of the present disclosure.
[0008] According to one aspect of the present disclosure, a video transcoding method is provided, comprising:
[0009] Obtaining a first video segment and a second video segment, wherein the second video segment is a transcoded video segment of the first video segment;
[0010] Determining a video quality parameter and a compression ratio based on the first video segment and the second video segment;
[0011] Calculate the reward value based on the video quality parameter and the compression rate using the reward function;
[0012] Use reward values to adjust the model parameters of the reinforcement learning agent;
[0013] generating target transcoding parameters based on a state vector of the first video segment using the tuned reinforcement learning agent;
[0014] The third video segment is transcoded using the transcoding parameters and outputted.
[0015] In some possible embodiments, a reward function is used to calculate a reward value based on a video quality parameter and a compression rate, including:
[0016] Inputting the video quality parameter and the compression rate into the reward function so that the reward function is calculated based on the video quality parameter and the compression rate;
[0017] The reward value output by the receiving reward function is positively correlated with the video quality parameter and the compression rate.
[0018] In some possible embodiments, a reward function is used to calculate a reward value based on a video quality parameter and a compression rate, including:
[0019] Extracting the bit rate of the second video segment and the target bit rate;
[0020] inputting the video quality parameter, the compression ratio, the bit rate of the second video segment, and the target bit rate into the reward function, so that the reward function is calculated based on the video quality parameter, the compression ratio, the bit rate of the second video segment, and the target bit rate;
[0021] A reward value output by the reward function is received, where the reward value is negatively correlated with the first difference, where the first difference is a difference between a bit rate of the second video segment and a target bit rate.
[0022] In some possible embodiments, the reward value is positively correlated with the logarithm of the compression rate.
[0023] In some possible embodiments, the reward function includes a first weight and a second weight, wherein the first weight is used to adjust the proportion of the video quality parameter in the reward value; and the second weight is used to adjust the proportion of the bit rate in the reward value.
[0024] In some possible embodiments, the following further comprises:
[0025] Obtain historical scenario complexity, historical actual quality parameters, and historical predicted quality parameters;
[0026] The first weight is calculated based on the historical scenario complexity, the historical actual quality parameters, and the historical predicted quality parameters, wherein the first weight is positively correlated with the historical scenario complexity, the first weight is positively correlated with the historical actual quality parameters, and the first weight is negatively correlated with the historical predicted quality parameters.
[0027] In some possible embodiments, the following further comprises:
[0028] Obtaining a target compression ratio, a compression ratio of a first cycle, and a compression ratio of a cycle before the first cycle;
[0029] The second weight is calculated based on the target compression rate, the compression rate of the first cycle, and the compression rate of the cycle before the first cycle, wherein the second weight is negatively correlated with the first value, and the first value is the absolute value of the difference between the compression rate of the first cycle and the target compression rate; the second weight is positively correlated with the change in the compression rate, and the change in the compression rate is determined by the compression rate of the first cycle and the compression rate of the cycle before the first cycle.
[0030] In some possible embodiments, the following further comprises:
[0031] Extracting a status value of the first video clip, wherein the status value includes one or more of the following: the compression rate, the bit rate, the group of pictures parameter, and the scene complexity;
[0032] A state vector of the first video segment is generated based on the state value of the first video segment.
[0033] According to another aspect of the present disclosure, a video transcoding apparatus is provided, comprising:
[0034] An acquisition module, configured to acquire a first video segment and a second video segment, wherein the second video segment is a transcoded video segment of the first video segment;
[0035] a determination module, configured to determine a video quality parameter and a compression ratio based on the first video segment and the second video segment;
[0036] A calculation module, configured to calculate a reward value based on a video quality parameter and a compression rate using a reward function;
[0037] An adjustment module, which uses reward values to adjust the model parameters of the reinforcement learning agent;
[0038] a generation module for generating target transcoding parameters based on the state vector of the first video segment using the adjusted reinforcement learning agent;
[0039] The transcoding module is used to transcode the third video segment using the transcoding parameters and output the transcoded video segment.
[0040] According to another aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform any one of the above-mentioned video transcoding methods by executing the executable instructions.
[0041] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, any one of the above-mentioned video transcoding methods is implemented.
[0042] According to another aspect of the present disclosure, a computer program product is further provided, including: a computer program or instructions, which implements any of the above-mentioned video transcoding methods when the computer program or instructions are executed by a processor.
[0043] The video transcoding method provided in an embodiment of the present disclosure includes: obtaining a first video clip and a second video clip, wherein the second video clip is a video clip after transcoding the first video clip; determining a video quality parameter and a compression ratio based on the first video clip and the second video clip; calculating a reward value based on the video quality parameter and the compression ratio using a reward function; adjusting the model parameters of a reinforcement learning agent using the reward value; generating target transcoding parameters based on the state vector of the first video clip using the adjusted reinforcement learning agent; and transcoding and outputting the third video clip using the transcoding parameters. In this embodiment, a reward function is used to balance the relationship between video quality and compression ratio, and the reward value is used to dynamically adjust the reinforcement learning agent. The target transcoding parameters are selected based on the adjusted reinforcement learning agent, thereby achieving dynamic adjustment of the transcoding parameters and pursuing a high compression ratio on the basis of high quality.
[0044] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The accompanying drawings are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification, are used to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and those skilled in the art can derive other drawings based on these drawings without inventive effort.
[0046] Figure 1 A schematic diagram of an exemplary application system architecture using the video transcoding method according to an embodiment of the present disclosure is shown;
[0047] Figure 2 A flow chart of a video transcoding method according to an embodiment of the present disclosure is shown;
[0048] Figure 3 A flow chart of a method for determining a state vector according to an embodiment of the present disclosure is shown;
[0049] Figure 4 A flow chart of a reward value calculation method according to an embodiment of the present disclosure is shown;
[0050] Figure 5 A flow chart of another reward value calculation method according to an embodiment of the present disclosure is shown;
[0051] Figure 6A flowchart of a first weight calculation method according to an embodiment of the present disclosure is shown;
[0052] Figure 7 A flow chart showing a second weight calculation method according to an embodiment of the present disclosure is shown;
[0053] Figure 8 A schematic diagram of a framework based on reinforcement learning in an embodiment of the present disclosure is shown;
[0054] Figure 9 A flow chart showing a method for optimizing transcoding parameters according to an embodiment of the present disclosure is shown;
[0055] Figure 10 A schematic diagram of a video transcoding device according to an embodiment of the present disclosure is shown;
[0056] Figure 11 A structural block diagram of an electronic device in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0057] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be embodied in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete and will fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0058] In addition, the accompanying drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. Identical reference numerals in the figures denote identical or similar parts, and thus repetitive descriptions thereof will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities that do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0059] For ease of understanding, before introducing the embodiments of the present disclosure, several terms involved in the embodiments of the present disclosure are first explained as follows:
[0060] Video transcoding card (Visual Processing Unit, VPU): A hardware acceleration device specifically used for video encoding, decoding and format conversion. Its core function is to quickly complete the compression, decompression and format conversion tasks of video data through a dedicated chip or coprocessor.
[0061] Reinforcement Learning (RL): A branch of machine learning, the core concept is to enable an intelligent agent to learn optimal behavioral strategies to maximize cumulative rewards through trial and error through dynamic interaction with the environment. The agent performs actions, observes the rewards reflected in the environment, and continuously adjusts its strategy, ultimately forming behavioral patterns that maximize long-term benefits. Unlike supervised learning (which relies on labeled data) and unsupervised learning (which mines data patterns), reinforcement learning emphasizes autonomous optimization of goals through environmental exploration. It is suitable for scenarios with clear objectives but complex environments, such as game AI (artificial intelligence), robotic control, and resource scheduling.
[0062] DQN (Deep Q-Network): A classic deep reinforcement learning algorithm, it combines deep learning with Q-learning to address the difficulties traditional reinforcement learning faces in high-dimensional state spaces. Its core concept is to approximate the Q-value function using a neural network. Experience replay is used to store and randomly sample historical interaction data to reduce the correlation of training samples. A target network is introduced to separate parameter updates and enhance training stability.
[0063] VMAF (Video Multimethod Assessment Fusion) is a comprehensive video quality assessment algorithm that combines multiple underlying features, such as PSNR (Peak Signal-to-Noise Ratio), SSIM (Structural Similarity Index), motion information, and structural distortion, with machine learning techniques to predict a video's Mean Opinion Score (MOS). The core of VMAF is to build a multi-dimensional evaluation model by learning from human subjective perception of video quality. This model more accurately reflects the impact of various coding impairments, such as blur, blocking, and ringing, on the visual experience.
[0064] The specific implementation of the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
[0065] Figure 1 FIG. 1 shows an exemplary application system architecture diagram to which the video transcoding method in the embodiment of the present disclosure can be applied. Figure 1 As shown, the system architecture may include a terminal device 101 , a network 102 and a server 103 .
[0066] The network 102 is a medium for providing a communication link between the terminal device 101 and the server 103 , and can be a wired network or a wireless network.
[0067] Optionally, the above-mentioned wireless network or wired network uses standard communication technologies and / or protocols. The network is typically the Internet, but can also be any network, including but not limited to a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a private network or any combination of a virtual private network). In some embodiments, technologies and / or formats including Hypertext Markup Language (HTML), Extensible Markup Language (XML), etc. are used to represent data exchanged over the network. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPSec) can be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies can also be used to replace or supplement the above-mentioned data communication technologies.
[0068] The terminal device 101 can be various electronic devices, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, smart speakers, smart watches, wearable devices, augmented reality devices, virtual reality devices, etc.
[0069] Optionally, the client of the application installed in different terminal devices 101 is the same, or the client of the same type of application based on different operating systems. Based on the different terminal platforms, the specific form of the client of the application can also be different, for example, the application client can be a mobile phone client, a PC client, etc.
[0070] The server 103 may be a server that provides various services, such as a background management server that provides support for the devices operated by the user using the terminal device 101. The background management server may analyze and process the received request and other data, and feed back the processing results to the terminal device.
[0071] Optionally, the server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0072] Those skilled in the art will know that Figure 1 The number of terminal devices, networks, and servers in the embodiment is merely illustrative, and any number of terminal devices, networks, and servers may be provided based on actual needs. This embodiment of the present disclosure does not limit this.
[0073] Under the above system architecture, an embodiment of the present disclosure provides a video transcoding method, which can be executed by any electronic device with computing and processing capabilities.
[0074] In some embodiments, the video transcoding method provided in the embodiments of the present disclosure can be executed by the terminal device of the above-mentioned system architecture; in other embodiments, the video transcoding method provided in the embodiments of the present disclosure can be executed by the server in the above-mentioned system architecture; in other embodiments, the video transcoding method provided in the embodiments of the present disclosure can be implemented by the terminal device and the server in the above-mentioned system architecture through interaction.
[0075] Figure 2 A flow chart of a video transcoding method according to an embodiment of the present disclosure is shown as follows: Figure 2 As shown, the video transcoding method provided in the embodiment of the present disclosure includes the following steps: S202-S212.
[0076] S202: Obtain a first video segment and a second video segment, wherein the second video segment is a transcoded video segment of the first video segment.
[0077] A video clip can be understood as a segment of a complete video or video stream segmented according to certain rules. Segmentation methods include, but are not limited to, segmentation by time length, segmentation by scene changes, and segmentation by frame number. It should be noted that the segmented video clips are arranged in chronological order. The first video clip can be understood as any video clip after the original video is segmented. Optionally, the first video clip is the first video clip after the original video is segmented.
[0078] Segmentation by time length includes segmenting the original video into fixed time lengths, for example, if the fixed time length is 10 seconds, capturing the 0th to 10th seconds of the original video as a video segment, and capturing the 10th to 20th seconds of the original video as a video segment, and so on. It should be noted that the fixed time lengths can be set according to actual circumstances.
[0079] Segmentation based on scene switching includes: detecting scene switching points in the original video, segmenting the video at the scene switching points, and obtaining multiple video segments. In this way, each video segment includes a scene to ensure the continuity of the video content.
[0080] Segmentation by frame number includes segmenting the original video according to a fixed frame number, for example, if the fixed frame number is 100, intercepting frames 0-100 of the original video as a video segment, and intercepting frames 101-200 of the original video as a video segment, and intercepting the fixed frame number in sequence. It should be noted that the fixed frame number can be set according to actual conditions.
[0081] Transcoding can be understood as the process of converting a video from one encoding format and parameter configuration to another. The second video clip is generated by transcoding the first video clip. The first and second video clips have the same or substantially the same video content, but different encoding parameters or formats.
[0082] Furthermore, transcoding parameters corresponding to the first video segment are obtained, and the first video segment is transcoded using the transcoding parameters corresponding to the first video segment to obtain a second video segment, wherein the transcoding parameters corresponding to the first video segment are determined by the reinforcement learning agent and the reward function based on the state vector of the video segment preceding the first video segment.
[0083] S204: Determine a video quality parameter and a compression ratio based on the first video segment and the second video segment.
[0084] The video quality parameter is a quantitative indicator used to measure the image quality of the second video clip and is used to evaluate the effectiveness of the transcoding parameters. Video quality parameters include but are not limited to: PSNR, SSIM, VMAF, etc.
[0085] PSNR is a statistical indicator based on pixel error. A higher PSNR value indicates that the image quality of the second video clip is closer to the first video clip. SSIM is used to measure image structural similarity. A PSNR value closer to 1 indicates better image quality in the second video clip. VMAF is a perceptual quality metric that integrates multiple features. Exemplary video quality parameters include, but are not limited to: PSNR = 32dB, SSIM = 0.85, and VMAF = 75.
[0086] VMAF and SSIM are obtained by inputting the first video clip and the second video clip into a quality assessment tool.
[0087] Metrics like VMAF and SSIM, core indicators for video quality evaluation, directly influence reinforcement learning decisions. For example, if VMAF < 80 and SSIM < 0.85, the video quality is very poor, and the system's action should be to increase the bitrate, such as by 10%.
[0088] In a possible implementation, the video quality parameter may further include a fusion quality parameter obtained by fusing PSNR, SSIM, and VMAF. Specifically, the fusion quality parameter may be calculated using formula (1).
[0089] Fusion quality parameter = θ PSNR ×PSNR′+θ SSIM ×SSIM′+θ VMAF ×VMAF′(1)
[0090] Among them, θ PSNR represents the weight of PSNR, PSNR′ represents the normalized PSNR; θ SSIM represents the weight of SSIM, SSIM′ represents the normalized SSIM; θ VMAF represents the weight of VMAF, and VMAF′ represents the normalized VMAF.
[0091] In one possible implementation, θ PSNR ,θ SSIM and θ VMAF The weights can be configured according to the scenario type. For example, the weight configuration table is shown in Table 1.
[0092] Table 1
[0093] Scenario Type <![CDATA[θ PSNR ]]> <![CDATA[θ SSIM ]]> <![CDATA[θ VMAF ]]> High-level operation scenarios 0.1 0.2 0.7 Low-light scenes 0.7 0.1 0.2 Normal scenes 0.2 0.4 0.4
[0094] In one possible implementation, the scene type of the second video clip is determined based on visual features. The visual features include motion intensity and average brightness. When the motion intensity exceeds a first preset threshold, the scene corresponding to the second video clip is determined to be a high-speed motion scene. When the average brightness is lower than a second preset threshold, the scene corresponding to the second video clip is determined to be a low-light scene. When the motion intensity is lower than the second preset threshold, or the average brightness is higher than the second preset threshold, the scene corresponding to the second video clip is determined to be a normal scene.
[0095] PSNR, SSIM, and VMAF are normalized separately to obtain normalized PSNR′, SSIM′, and VMAF′. Normalization unifies indicators of different dimensions to the range of 0-1.
[0096] PSNR′ is the ratio of the actual PSNR value to 50, where a PSNR greater than 50 indicates that the video is of perfect quality.
[0097] Since SSIM itself is in the range of 0-1, SSIM′ directly uses the original value SSIM.
[0098] Since VMAF itself is in the range of 0-100, VMAF′ is the ratio of the actual VMAF value to 100.
[0099] The compression ratio is calculated by comparing the size of the video before and after compression. Specifically, it's the ratio of the data size of the first video clip to the data size of the second video clip, reflecting the transcoding parameters' ability to compress data. The compression ratio is a ratio representing the size of the first video clip relative to the size of the second video clip. A compression ratio greater than 1 indicates that the data has indeed been reduced after processing, and a higher compression ratio indicates a more effective compression effect. A CR of 1 indicates ineffective data compression.
[0100] The higher the compression rate, the smaller the amount of data after transcoding and the stronger the compression effect, but it may be accompanied by a loss of image quality; the lower the compression rate, the closer the data amount of the second video clip is to the data amount of the first video clip, and the more complete the image quality is retained.
[0101] If the first video clip is 100MB in size and the second video clip is 25MB in size after transcoding, the ratio of 100MB to 25MB is 4, indicating that the transcoding process reduces the data size to one-quarter of the original, or a compression ratio of 4:1.
[0102] S206: Calculate a reward value based on the quality parameter and the compression rate using a reward function.
[0103] The reward function is used to evaluate the effectiveness of the reinforcement learning agent's actions. It is a mathematical function or model whose inputs are the aforementioned video quality parameters and compression ratio, and whose output is a numerical value, the reward value. A higher reward value indicates that the transcoding parameters used for the first video clip are more appropriate for its corresponding state vector.
[0104] The reward value is a number output by the reward function that quantifies how good the transcoding parameters output by the reinforcement learning agent are. In video processing, the reward value can be positive or negative.
[0105] The purpose of the reward function is to pursue high compression rate on the basis of high quality (high video quality parameters). In other words, the positive incentive part of the reward function encourages both high quality and high compression rate.
[0106] S208. Use the reward value to adjust the model parameters of the reinforcement learning agent.
[0107] A reinforcement learning agent is an intelligent agent in a reinforcement learning framework that interacts with its environment and makes decisions. Through trial and error, it optimizes its strategy based on reward signals from the environment to maximize long-term goals. In a video transcoding scenario, the goal of the reinforcement learning agent is to select the optimal transcoding parameters based on the input state vector.
[0108] Model parameters are the trainable weight parameters of a reinforcement learning agent, such as the connection weights of a neural network and the parameter vector of a policy gradient. Model parameters determine the probability of the reinforcement learning agent choosing a set of transcoding parameters. Parameter adjustment is the process of updating model parameters based on the reward value of the reward function to maximize the cumulative reward of the reinforcement learning agent's behavior.
[0109] In one possible implementation, an objective function is calculated based on the reward value, where the objective function represents the expectation of the cumulative reward. The parameters of the reinforcement learning agent are adjusted through gradient descent or policy gradient algorithm to maximize the objective function.
[0110] In one possible implementation, a Q-learning algorithm is used to calculate the temporal difference error between the state vector of the previous video segment of the first video segment and the transcoding parameters used by the first video segment; and a mean square error loss function is constructed as the objective function based on the temporal difference error.
[0111] S210 : Generate target transcoding parameters based on the state vector of the first video clip using the adjusted reinforcement learning agent.
[0112] The state vector of the first video clip maps the state value of the first video clip to a numerical vector. This serves as the input format for the reinforcement learning agent. This vector form converts complex states into a computer-processable mathematical structure, making it easier for the reinforcement learning agent to learn the mapping between states and actions.
[0113] The status value of the first video segment includes, but is not limited to: a compression ratio of the first video segment, transcoding parameters corresponding to the first video segment, and scene complexity of the first video segment.
[0114] Transcoding parameters can be understood as parameter configurations used when transcoding the first video segment, which are used to control encoding behavior and output characteristics. Transcoding parameters include, but are not limited to, bitrate and Group of Pictures (GOP) parameters. GOP parameters include GOP length, I-frame interval, and number of B-frames.
[0115] Scene complexity describes the degree of dramatic changes in the content of the first video clip and is a key indicator for measuring encoding difficulty. Examples include the speed of object movement, texture complexity, and shot switching frequency.
[0116] Normalize or standardize the transcoding parameters, scene complexity, and compression ratio in the state value of the first video clip. Arrange the normalized state values in a fixed order to form a vector, which is the state vector of the first video clip. The state vector of the first video clip can be stored in an array, list, or other form.
[0117] A fixed set of actions is preset in the reinforcement learning agent, which selects the optimal action based on the state vector of the first video clip. For example, action 1 is a 10% increase in bitrate with no change in GOP; action 2 is a 10% decrease in bitrate with no change in GOP; and action 3 is a GOP + 10% increase with no change in bitrate. The reinforcement learning agent selects actions using a policy function π(a|s). For example, a value-based approach selects the action that maximizes Q(s,a), or a policy gradient method directly outputs the action probability distribution, using sampling or greedy strategies to select actions.
[0118] After the action is selected, target transcoding parameters are calculated based on the selected action and the transcoding parameters used for the first video clip. For example, if the selected action is action 1, the bitrate used for the first video clip is increased by 10% to set the target bitrate, and the GOP parameters used for transcoding the first video clip are used as the target GOP parameters.
[0119] S212: Transcode the third video segment using the target transcoding parameters and output the transcoded video segment.
[0120] The third video segment is the video segment that is immediately after the first video segment in the chronological order. For example, if a video is divided into segments 1, 2, and 3, then segment 2 is the first video segment, segment 3 is the third video segment, and segment 1 is the video segment immediately preceding the first video segment.
[0121] The third video clip and the determined target transcoding parameters are input into a transcoding engine, which encodes the third video clip according to the target transcoding parameters. The transcoding engine includes, but is not limited to, a video transcoding card, a video transcoding tool, or a hardware accelerator. The encoding method includes, but is not limited to, changing the resolution, bit rate, frame rate, etc. of the third video clip.
[0122] In one possible implementation, after transcoding the third video segment, the third video segment is used as the first video segment, and the transcoded third video segment is used as the second video segment, and the process returns to executing the step of "determining the video quality parameters and compression rate based on the first video segment and the second video segment" and subsequent steps until all video segments after the original video is segmented are transcoded.
[0123] In a possible implementation, the transcoded third video segment is played.
[0124] In an embodiment of the present disclosure, a video transcoding method is provided, comprising: obtaining a first video clip and a second video clip, wherein the second video clip is a transcoded video clip of the first video clip; determining a video quality parameter and a compression ratio based on the first and second video clips; calculating a reward value based on the video quality parameter and the compression ratio using a reward function; adjusting model parameters of a reinforcement learning agent using the reward value; generating target transcoding parameters based on a state vector of the first video clip using the adjusted reinforcement learning agent; and transcoding and outputting a third video clip using the transcoding parameters. In this embodiment, a reward function is used to balance the relationship between video quality and compression ratio, and the reward value is used to dynamically adjust the reinforcement learning agent. Target transcoding parameters are selected based on the adjusted reinforcement learning agent, thereby achieving dynamic adjustment of transcoding parameters and pursuing a high compression ratio while maintaining high quality.
[0125] Based on the above embodiment, this embodiment further optimizes the method for determining the state vector of the first video segment in the video transcoding method, such as Figure 3 As shown, the method for determining the state vector provided in the embodiment of the present disclosure includes the following steps: S302-S304.
[0126] S302: Extract a status value of the first video clip, where the status value includes one or more of the following: compression rate, bit rate, group of picture parameters, and scene complexity.
[0127] The compression ratio of the first video segment is the compression ratio in the above step S204. The specific calculation method can refer to the description in the above embodiment.
[0128] The bit rate of the first video segment refers to the amount of data required to transmit or store the first video segment per unit time, and is usually expressed as a bit rate. The bit rate of the first video segment is extracted from the transcoding parameters corresponding to the first video segment.
[0129] The GOP parameters include the GOP length, which refers to the number of frames contained in a GOP and is usually represented by N. For example, N=12 means one GOP with 12 frames. The GOP parameters of the first video segment are extracted from the transcoding parameters corresponding to the first video segment.
[0130] A video frame is the basic unit of video, a single image in a continuous image sequence. Adjacent video frames may show either continuity or abrupt changes in content. Scene change frequency refers to the number of scene changes in a video per unit of time. A scene change occurs when the video content transitions abruptly or smoothly from one scene to another, such as in editing clips like "hard cuts," "fades," and "wipes."
[0131] Scene complexity is a measure of the intensity of scene changes within a video clip. A higher scene switching frequency indicates more frequent scene changes within the video content and a higher scene complexity; a lower scene switching frequency indicates lower scene complexity.
[0132] Scene complexity is quantified by detecting scene switching points in a video frame sequence and counting the number of switching points per unit time. Specifically, image features such as color histogram, texture features, and motion vectors are extracted from each frame. Feature differences between adjacent and non-adjacent frames are calculated to determine whether a scene switch has occurred. Switching points are determined based on a difference threshold, and the total number of switching points is counted and the frequency is calculated. The scene switching frequency is directly used as a scene complexity indicator.
[0133] S304: Generate a state vector of the first video segment based on the state value of the first video segment.
[0134] Normalize or standardize the compression ratio, bit rate, group of picture parameters, and scene complexity of the first video clip. Arrange the standardized state values in a fixed order to form a vector, which is the state vector of the first video clip. The state vector of the first video clip can be stored in an array, list, or other form.
[0135] In this embodiment, key indicators are extracted from four aspects: compression rate, bit rate, picture group parameters, and scene complexity, to comprehensively characterize the technical status and content characteristics of the video clips, so as to improve the accuracy of the target parameters.
[0136] Based on the above embodiment, this embodiment optimizes the calculation method of the reward value, such as Figure 4 As shown, the reward value calculation process includes steps S402-S404.
[0137] S402: Input the video quality parameter and the compression ratio into the reward function, so that the reward function is calculated based on the video quality parameter and the compression ratio.
[0138] S404: Receive a reward value output by the reward function, wherein the reward value is positively correlated with the video quality parameter, the compression ratio, and the logarithm of the compression ratio.
[0139] Video quality parameters are a core indicator of user experience. The reward value is positively correlated with the video quality parameters. This means that if the clarity and smoothness of the second video clip improve—that is, if the video quality parameters increase—then the reward function will award a higher reward value.
[0140] The compression rate reflects the efficiency of resource utilization, and the reward value is positively correlated with the compression rate. It can be understood that the smaller the amount of second video data, the higher the compression rate, and the lower the storage cost and transmission cost. Therefore, the reward function encourages high compression rate, and the reward function gives a higher reward value.
[0141] In this embodiment, the reward function uses a positively correlated dual-metric design to force the algorithm to find a balance between video quality and compression rate. The synergy between rate control and the above two metrics ensures optimal image quality and compression rate.
[0142] The positive correlation between the reward value and the logarithm of the second compression ratio indicates that the reward value increases with the logarithm of the compression ratio, rather than linearly with the compression ratio itself. A logarithmic function is a concave function, and its growth rate gradually slows as the compression ratio increases. Avoid blindly selecting extremely high compression ratios in pursuit of reward value, which can lead to severe image quality loss. Instead, optimize the compression ratio more gradually, balancing compression efficiency with image quality and bitrate.
[0143] Based on the above embodiment, this embodiment optimizes the calculation method of the reward value, such as Figure 5 As shown, the reward value calculation process includes steps S502-S506.
[0144] S502: Extract the bit rate and target bit rate of the second video segment.
[0145] The target bit rate refers to the pre-set average data rate that a video stream is expected to achieve during transmission or storage.
[0146] The bit rate of the second video segment is extracted from the transcoding parameters corresponding to the first video segment. Alternatively, a bit rate extraction tool is used to extract the bit rate of the second video segment to obtain the bit rate of the second video segment.
[0147] S504: Input the video quality parameter, the compression ratio, the bit rate of the second video clip, and the target bit rate into a reward function, so that the reward function is calculated based on the video quality parameter, the compression ratio, the bit rate of the second video clip, and the target bit rate, wherein the reward function includes a first weight and a second weight, the first weight being used to adjust the proportion of the video quality parameter in the reward value; the second weight being used to adjust the proportion of the bit rate in the reward value.
[0148] S506: Receive a reward value output by the reward function, where the reward value is negatively correlated with the first difference, and the first difference is the difference between the bit rate of the second video segment and the target bit rate.
[0149] In this example, the bitrate of the second video clip is the bitrate in the transcoding parameters used for the first video clip. The bitrate in the transcoding parameters must match the target bitrate constraint. The first difference reflects the controllability of the transcoded bitrate. The smaller the first difference, the smaller the difference between the bitrate of the second video clip and the target bitrate, and the more precise the reinforcement learning agent's bitrate control.
[0150] A negative correlation between the reward value and the first difference means that the reward value and the first difference change in opposite directions. In other words, the larger the first difference, the lower the reward value; the smaller the first difference, the higher the reward value. For example, if the bitrate of the second video clip is equal to the target bitrate, the difference is 0, and the reward value is maximum. If the bitrate of the second video clip deviates from the target bitrate, the difference increases, and the reward value decreases proportionally.
[0151] The negative correlation between the reward value and the first difference serves as a feedback mechanism to guide the reinforcement learning agent to choose actions that can reduce the difference, so that the bitrate in the transcoding parameters is as close to the target bitrate as possible.
[0152] Through the negative correlation reward mechanism, closed-loop feedback control can be achieved, and encoding parameters can be continuously corrected so that the bit rate in the transcoding parameters approaches the target bit rate.
[0153] In one possible implementation, the reward function can be expressed as follows:
[0154]
[0155] Among them, R t represents the reward value of the first video segment, VMAF(t) represents the video quality parameter of the first video segment, and compressionRatio(t) represents the compression ratio of the first video segment. Bitrate target represents the target bitrate, Bitrate(t) represents the bitrate of the second video segment, and γ represents the penalty coefficient. log(1+CompressionRatio) represents the compression rate adjuster to avoid over-rewarding extreme compression.
[0156] The first half of formula (1), VMAF(t)·log(1+compressionRatio(t)), is the positive excitation part, which stimulates both high quality and high compression rate. This is a penalty mechanism. When the bitrate in the transcoding parameters exceeds the target bitrate, a linear penalty is applied. When the bitrate in the transcoding parameters is less than the target bitrate, a negative penalty is applied, i.e., a reward compensation. This prevents encoding delays or freezes caused by bitrate exceeding the limit, and avoids sacrificing image quality due to low bitrate.
[0157] The reward function includes a first weight and a second weight. The first weight is used to adjust the proportion of the video quality parameter in the reward value; the second weight is used to adjust the proportion of the bit rate change in the reward value.
[0158] In one possible implementation, the reward function can be expressed by formula (3).
[0159]
[0160] The first weight α(t), also known as the quality assessment weight coefficient, represents the emphasis the reinforcement learning agent places on video quality parameters. In the reward function, the first weight α(t) is used to amplify or reduce the weight of video quality parameters. Increasing the first weight α(t) increases the weight of video quality parameters in the reward, while decreasing the first weight α(t) decreases the weight of video quality parameters in the reward.
[0161] The second weight, β(t), can also be called the bitrate stability coefficient, represents the degree to which the reinforcement learning agent requires bitrate stability. In the reward function, the second weight, β(t), is used to control the intensity of the bitrate variation penalty.
[0162] The first weight α(t) is the image quality preference knob, and the second weight β(t) is the stability control valve. Together, they determine the decision direction of the reinforcement learning agent during parameter optimization.
[0163] The first weight α(t) and the second weight β(t) are dynamically updated based on historical data such as scene complexity and video quality parameters.
[0164] In this embodiment, the proportion of the video quality parameter and the bit rate change in the reward function can be adjusted by adjusting the weight, so as to achieve automatic switching in different application scenarios.
[0165] Based on the above embodiment, this embodiment provides a first weight calculation process. Figure 6 As shown, the calculation process of the first weight provided by this embodiment includes steps S602-S604.
[0166] S602: Obtain historical scene complexity, historical actual quality parameters, and historical predicted quality parameters.
[0167] Historical data is a set of past data used to calculate weights, and contains multi-dimensional information related to the first weight.
[0168] Historical data includes historical scene complexity, historical actual quality parameters, and historical predicted quality parameters. Historical scene complexity refers to the frequency of scene switching or the severity of content changes between frames in a video clip within a period. Historical actual quality parameters refer to the actual measured video quality parameters of transcoded video clips within a period. Historical predicted quality parameters refer to the quality parameters of transcoded video clips within a period predicted by a machine learning model, which are compared with the actual quality parameters.
[0169] The above-mentioned period can be daily, hourly, etc., which is not specifically limited in this embodiment.
[0170] The historical scene complexity is the average scene complexity of all video clips within a period. The historical actual quality parameter is the average of the actually measured video quality parameters of all video clips within a period. For example, the historical actual quality parameter can be the average VMAF. The historical predicted quality parameter is the average of the model-predicted video quality parameters of all video clips within a period.
[0171] S604. Calculate a first weight based on historical scenario complexity, historical actual quality parameters, and historical predicted quality parameters, wherein the first weight is positively correlated with historical scenario complexity, the first weight is positively correlated with historical actual quality parameters, and the first weight is negatively correlated with historical predicted quality parameters.
[0172] The first weight is positively correlated with the complexity of historical scenarios. Higher complexity results in a larger weight, indicating a more significant impact of complex scenarios on quality. The first weight is positively correlated with historical actual quality parameters, indicating that higher actual quality parameters result in a larger first weight, emphasizing the importance of high-quality scenarios. The first weight is negatively correlated with historical forecast quality parameters, indicating that higher forecast quality results in a smaller weight, potentially used to penalize large forecast deviations.
[0173] In one possible implementation, the first weight is calculated using formula (4).
[0174] α(t)=Δα·SceneComplextity(t)+Δα Qoe (VMAF user -VMAF pred ) (4)
[0175] Among them, α(t) represents the first weight, Δα is a scene complexity gain coefficient, which is associated with the historical scene complexity and determines the degree of influence of the historical scene complexity on the first weight α(t).
[0176] SceneComplexity(t) represents the scene complexity in the tth cycle. A larger value indicates a more complex scene, such as one containing a large number of moving objects, rich texture details, etc.Qoe It is a coefficient related to the video quality parameter, reflecting the influence of the video quality parameter on the adjustment of the first weight α(t). VMAF user VMAF represents the historical actual quality parameters in the tth period, the fusion score of the multi-method video evaluation actually perceived by the user, and reflects the video quality in the user's eyes. pred It represents the historical prediction quality parameter in the t-th period. The VMAF score of the video clip predicted by the model is the video quality estimated by the algorithm.
[0177] The first weight α(t) consists of two parts. One part is Δα·SceneComplexity(t) related to the scene complexity of the first video clip, which indicates that the more complex the scene, the larger the SceneComplexity(t) value, and the greater the contribution to the first weight α(t) under the action of the scene complexity gain coefficient Δα; the other part is Δα related to the video quality parameter. Qoe (VMAF user -VMAF pred ), when the actual measured video quality parameter (VMAF user ) and prediction quality parameter (VMAF pred ) The larger the difference, the greater the Qoe The greater the adjustment effect on the first weight α(t), the greater the effect. That is, the value of the first weight α(t) is determined by the two factors of scene complexity and video quality difference.
[0178] In this embodiment, the first weight α(t) is adjusted in real time. When the scene complexity is high, the first weight α(t) is automatically increased; when the actual quality parameter is greater than the predicted quality parameter, the first weight α(t) is appropriately increased; when the actual quality parameter is less than the predicted quality parameter, the first weight α(t) is reduced.
[0179] In this embodiment, the first weight coefficient is dynamically updated according to the current scene complexity and historical actual quality parameters, which can continuously optimize the strategy based on past experience, making the long-term strategy more in line with the actual situation and improving the overall performance of the reinforcement learning agent.
[0180] Based on the above embodiment, this embodiment provides a second weight calculation process. Figure 7 As shown, the calculation process of the second weight provided by this embodiment includes steps S702-S704.
[0181] S702: Obtain a target compression ratio, a compression ratio of a first cycle, and a compression ratio of a cycle before the first cycle.
[0182] The second weight reference value is a preset reference value and can be adjusted according to the target compression rate.
[0183] The compression ratio of the first cycle is an average of the compression ratios of all video segments in the current cycle, and the compression ratio of the cycle before the first cycle is an average of the compression ratios of all video segments in the cycle before the current cycle.
[0184] S704. Calculate a second weight based on the target compression rate, the compression rate of the first cycle, and the compression rate of the cycle before the first cycle, wherein the second weight is negatively correlated with the first value, the first value is the absolute value of the difference between the compression rate of the first cycle and the target compression rate, and the second weight is positively correlated with the change in the compression rate, which is determined by the compression rate of the first cycle and the compression rate of the cycle before the first cycle.
[0185] The second difference refers to the absolute value of the difference between the compression rate of the first cycle and the target compression rate. The second difference is used to measure the degree of deviation between the compression rate of the first cycle and the target compression rate. The larger the second difference is, the lower the compression rate of the second cycle is or the more excessive the compression is.
[0186] The second weight is negatively correlated with the second difference. It can be understood that the greater the deviation between the compression rate of the first cycle and the target compression rate, the smaller the second weight; conversely, the smaller the deviation between the compression rate of the first cycle and the target compression rate, the greater the second weight.
[0187] If the second difference is large, for example, the compression ratio in the first cycle is far below the target compression ratio, indicating that the current compression efficiency is insufficient, the weight should be reduced to reduce the restrictions on certain constraints, such as relaxing the bitrate limit to allow higher bitrates to improve the compression ratio. If the second difference is small, indicating that the compression ratio in the first cycle is close to the target, the weight can be increased to strengthen the constraints on other parameters, such as strictly controlling the bitrate or quality.
[0188] The second weight is positively correlated with changes in the compression ratio. This means that the more pronounced the compression ratio's fluctuations or growth, the larger the second weight; the smaller the second weight, the more stable or declining the compression ratio. If the compression ratio is on an upward trend, this indicates improved compression efficiency and the effectiveness of the current strategy. The weight can be increased to strengthen the influence of related parameters, such as by continuing to optimize bitrate allocation. If the compression ratio fluctuates significantly or decreases, this indicates an unstable compression process. The weight should be reduced to avoid over-reliance on a single parameter and increase strategy flexibility.
[0189] In one possible implementation, the second weight is calculated using formula (5).
[0190]
[0191] β(t) represents the second weight, which is used to adjust the importance of compression rate and other related factors in the reinforcement learning agent, and will change dynamically over time based on the compression rate. baseIs the basic stability coefficient, based on which adjustments are made according to other conditions. CR(t) represents the compression ratio of the first cycle, and CR(t-1) represents the compression ratio of the cycle before the first cycle. target represents the target compression ratio, which is the preset desired compression ratio. n is the fluctuation suppression factor, which is used to control the impact of the compression ratio change on the adjustment of the second weight β(t). It is an adjustable hyperparameter.
[0192] The calculation of the second weight is based on three parts. First, β base is the basic stability coefficient, Reflects the compression ratio CR(t) of the first cycle and the target compression ratio CR target The smaller the deviation (|CR(t)-CR target The smaller the value of |), the closer the value of this part is to 1, and the greater the positive contribution to the second weight β(t); (e -n|CR(t)-C(t-1)| ) reflects the change of compression rate in adjacent cycles. The smaller the change of compression rate in adjacent cycles, the smaller (|CR(t)-CR(t-1)|) is, the closer the value of this part is to 1, and the greater the positive contribution to the second weight β(t).
[0193] In this embodiment, the second weight β(t) is a dual constraint, ensuring that the bit rate accurately hits the target bit rate to achieve bandwidth control, and preventing bit rate jumps between adjacent frames to avoid screen flickering.
[0194] In one possible example, this embodiment provides a framework based on reinforcement learning to build a dynamic and adaptive video transcoding parameter optimization system. Through environmental interaction, multimodal quality assessment and online learning mechanism, real-time dynamic adjustment of transcoding parameters is achieved to balance video quality, bit rate compression and computational efficiency. Figure 8 As shown, the video transcoding parameter optimization system includes: a video preprocessing module 810, an intelligent parameter optimization module 820, a multimodal quality assessment module 830, an adaptive learning engine 840 and a video processing core module 850.
[0195] The video preprocessing module 810 cuts the original video into segments of fixed or dynamically adjustable lengths based on keyframe detection and content coherence analysis. It also extracts features such as video resolution, frame rate, and dynamic scene complexity to provide prior information for subsequent parameter optimization.
[0196] The intelligent parameter optimization module 820 generates transcoding parameter adjustment actions based on the RL algorithm and ensures parameter feasibility through state space perception and boundary protection mechanism.
[0197] The multimodal quality assessment module 830 calculates the PSNR, SSIM, and VMAF indicators in parallel, dynamically integrates the evaluation results, obtains the video quality parameters, and provides a reward signal for RL.
[0198] The adaptive learning engine 840 uses experience replay and exploration rate decay strategies to optimize RL models and supports multi-video alternating training to improve generalization capabilities.
[0199] The video processing core module 850 dynamically generates transcoding commands based on transcoding parameters, executes transcoding tasks and detects anomalies.
[0200] It should be noted that the reinforcement learning-based framework is a plug-in architecture that supports rapid switching of multiple RL algorithms such as DQN.
[0201] Based on the above reinforcement learning framework, video transcoding mainly includes the following steps.
[0202] Step 1: Raw video input and segmentation.
[0203] The original video pre-processing module 810 cuts the video into multiple video segments of fixed length.
[0204] Step 2: VPU encoding processing.
[0205] The video clip stream is input into the video processing core module 850 , which simultaneously receives the bit rate and GOP parameters output by the intelligent parameter optimization module 820 , such as bit rate = 4 Mbps, GOP = 12.
[0206] The video processing core module 850 performs dynamic bit rate encoding and GOP optimization according to the bit rate and GOP parameters, and outputs the transcoded video clips.
[0207] Step 3: Quality assessment and feedback.
[0208] The transcoded segmented videos are compared with the pre-transcoded video clips obtained from the pre-processing module cache to calculate VMAF, SSIM and compression ratio.
[0209] Indicators such as VMAF, SSIM, and compression ratio are immediately sent to the intelligent parameter optimization module 820.
[0210] Send the hourly or daily average compression rate, quality fluctuation, etc. to the adaptive learning engine.
[0211] Step 4: Dynamic parameter optimization.
[0212] The state vector is formed by combining the compression rate, bitrate, GOP and scene complexity of the current video clip. The reinforcement learning agent generates and adjusts the bitrate or GOP parameters based on the reward function.
[0213] Step 5: Long-term policy update.
[0214] Global optimization strategy generates bitrate allocation rules based on historical data, such as a 20% bitrate increase for complex scenarios and a GOP adaptive table.
[0215] External constraint injection: If the target compression rate is increased, the engine adjusts the policy weight to prioritize compression rate over VMAF, SSIM, and other indicators.
[0216] Step 6: Closed-loop iteration.
[0217] The updated bitrate / GOP parameters are applied to the next video segment in real time, forming a closed-loop optimization.
[0218] Based on the above embodiment, an application example is provided. The video transcoding method is used in computer room monitoring. The computer room camera is connected to a video transcoding card. By automatically adjusting parameters, the compression rate of the original video is improved while ensuring the video quality. Figure 9 As shown, it mainly includes the following steps: S902-S910.
[0219] S902: Input original video.
[0220] The execution subject is the video pre-processing module 810, the trigger condition is real-time triggering, and the processing object is the original video captured by the camera.
[0221] Specifically, the original video from the camera is received, and the original video input is passed to the video pre-processing module 810 for preliminary processing to obtain multiple video clips of the original video.
[0222] The multiple video segments obtained by segmenting the original video are provided to the subsequent video processing core module 850 and the multimodal quality assessment module 830 .
[0223] S904: Processing by the video processing core module.
[0224] The execution subject is the video processing core module 850, and the trigger condition is triggered by the video clip output by the video pre-processing module. The processing object is the video clip after the original video is segmented.
[0225] The video clip stream is fed into the video processing core module 850, which also receives the bitrate / GOP parameters output by the intelligent parameter optimization module 820. The video processing core module 850 performs dynamic bitrate encoding and GOP optimization based on the bitrate / GOP parameters and outputs the transcoded video clip.
[0226] The multimodal quality assessment module 820 is provided with the transcoded compressed video segments.
[0227] S906, Quality assessment and feedback.
[0228] The execution body is the multimodal quality assessment module 830, and the processing object is the transcoded video clip.
[0229] The transcoded video clip is compared with the pre-transcoded video clip obtained from the pre-processing module cache to calculate VMAF, SSIM, and compression ratio. The quality parameters and compression ratio of the transcoded video clip are output.
[0230] Get the video quality parameters and compression ratio of the transcoded video clip.
[0231] S908. Dynamic parameter optimization.
[0232] The intelligent parameter optimization module 820 executes this process, triggered by obtaining video quality parameters and compression ratio. The module then processes the pre-transcoding compression ratio, bitrate, GOP, and scene complexity to form a state vector. Adjustment actions are generated based on the reward function, and the adjusted transcoding parameters are output to the video transcoding card.
[0233] Find the optimal solution between video quality and compression rate.
[0234] S910, long-term strategy update.
[0235] The execution entity is the adaptive learning engine. The trigger condition is obtaining video quality parameters and compression ratio. The processing object is the video quality parameters and compression ratio over a period of time.
[0236] A bit rate allocation rule is generated based on historical data, such as a 20% bit rate increase for complex scenes and a GOP adaptive table, and the updated first weight and second weight are passed to the intelligent parameter optimization module 820 .
[0237] Improve global parameter adjustment rules and fully understand user intent.
[0238] This video transcoding method based on a video transcoding card builds a dynamic and adaptive video transcoding parameter optimization system. Through environmental interaction, multimodal quality assessment, and online learning mechanisms, it enables real-time dynamic adjustment of transcoding parameters, balancing video quality, bitrate compression, and computational efficiency. This effectively improves the parameter adjustment efficiency of the video transcoding card.
[0239] It should be noted that the acquisition, storage, use, and processing of data in the technical solution disclosed herein are in compliance with the relevant provisions of national laws and regulations. Various types of data such as personal identity data, operation data, behavioral data, etc. related to individuals, customers, and groups obtained in the embodiments of the present disclosure have been authorized.
[0240] Based on the same inventive concept, the present disclosure also provides a video transcoding device, such as the following embodiment. Since the principle of solving the problem in the device embodiment is similar to that in the above method embodiment, the implementation of the device embodiment can refer to the implementation of the above method embodiment, and the repeated parts will not be repeated.
[0241] Figure 10 A schematic diagram of a video transcoding device according to an embodiment of the present disclosure is shown in FIG. Figure 10 As shown, the apparatus includes: an acquisition module 1010 , a determination module 1020 , a calculation module 1030 , an adjustment module 1040 , a generation module 1050 and a transcoding module 1060 .
[0242] An acquisition module 1010 is used to acquire a first video clip and a second video clip, wherein the second video clip is a video clip after transcoding the first video clip; a determination module 1020 is used to determine a video quality parameter and a compression rate based on the first video clip and the second video clip; a calculation module 1030 is used to calculate a reward value based on the video quality parameter and the compression rate using a reward function; an adjustment module 1040 is used to adjust the model parameters of the reinforcement learning agent using the reward value; a generation module 1050 is used to generate target transcoding parameters based on the state vector of the first video clip using the adjusted reinforcement learning agent; and a transcoding module 1060 is used to transcode and output the third video clip using the transcoding parameters.
[0243] The third video segment is transcoded using the transcoding parameters and outputted.
[0244] In some possible embodiments, the calculation module 1030 is specifically configured to input the video quality parameter and the compression ratio into the reward function so that the reward function is calculated based on the video quality parameter and the compression ratio; and receive a reward value output by the reward function, where the reward value is positively correlated with the video quality parameter and the compression ratio.
[0245] In some possible embodiments, the calculation module 1030 is specifically configured to extract the bit rate of the second video clip and the target bit rate; input the video quality parameter, the compression ratio, the bit rate of the second video clip, and the target bit rate into the reward function, so that the reward function performs calculations based on the video quality parameter, the compression ratio, the bit rate of the second video clip, and the target bit rate; and receive a reward value output by the reward function, where the reward value is negatively correlated with the first difference, where the first difference is the difference between the bit rate of the second video clip and the target bit rate.
[0246] In some possible embodiments, the reward value is positively correlated with the logarithm of the compression rate.
[0247] In some possible embodiments, the reward function includes a first weight and a second weight, wherein the first weight is used to adjust the proportion of the video quality parameter in the reward value; and the second weight is used to adjust the proportion of the bit rate in the reward value.
[0248] In some possible embodiments, it also includes: a first weight calculation module, used to obtain historical scenario complexity, historical actual quality parameters, and historical predicted quality parameters; calculate the first weight based on the historical scenario complexity, historical actual quality parameters, and historical predicted quality parameters, wherein the first weight is positively correlated with the historical scenario complexity, the first weight is positively correlated with the historical actual quality parameters, and the first weight is negatively correlated with the historical predicted quality parameters.
[0249] In some possible embodiments, it also includes: a second weight calculation module, used to obtain the target compression rate, the compression rate of the first cycle, and the compression rate of the cycle before the first cycle; calculate the second weight based on the target compression rate, the compression rate of the first cycle, and the compression rate of the cycle before the first cycle, wherein the second weight is negatively correlated with the first value, the first value is the absolute value of the difference between the compression rate of the first cycle and the target compression rate; the second weight is positively correlated with the change in compression rate, and the change in compression rate is determined by the compression rate of the first cycle and the compression rate of the cycle before the first cycle.
[0250] In some possible embodiments, the present invention further includes: a state vector generation module for extracting a state value of the first video clip, wherein the state value includes one or more of the following: the compression rate, bit rate, picture group parameters, and scene complexity; and generating a state vector of the first video clip based on the state value of the first video clip.
[0251] It should be noted that the examples and application scenarios implemented by the modules in the above-mentioned apparatus embodiment are the same as those implemented by the corresponding steps in the method embodiment, but are not limited to the contents disclosed in the above-mentioned method embodiment. It should be noted that the above-mentioned modules, as part of the apparatus, can be executed in a computer system, such as a set of computer-executable instructions.
[0252] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or an implementation that combines hardware and software aspects, which may be collectively referred to herein as a "circuit," "module," or "system."
[0253] Based on the same inventive concept, an embodiment of the present disclosure further provides an electronic device, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any of the above-described video transcoding methods by executing the executable instructions. Because the principles for solving the problem in this electronic device embodiment are similar to those in the above-described method embodiment, the implementation of this electronic device embodiment can refer to the implementation of the above-described method embodiment, and any repetitions will not be repeated.
[0254] Refer to the following Figure 11 1100 according to this embodiment of the present disclosure will be described. Figure 11 The electronic device 1100 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0255] like Figure 11 As shown, electronic device 1100 is implemented as a general-purpose computing device. Components of electronic device 1100 may include, but are not limited to, the aforementioned at least one processing unit 1110, the aforementioned at least one storage unit 1120, and a bus 1130 connecting various system components (including storage unit 1120 and processing unit 1110).
[0256] The storage unit stores program code, and the program code can be executed by the processing unit 1110, so that the processing unit 1110 performs the steps described in the "Exemplary Method" section of this specification according to various exemplary embodiments of the present disclosure. For example, the processing unit 1110 can perform the following steps of the above-mentioned method embodiment: obtaining a first video clip and a second video clip, wherein the second video clip is a video clip after transcoding the first video clip; determining a video quality parameter and a compression ratio based on the first video clip and the second video clip; calculating a reward value based on the video quality parameter and the compression ratio using a reward function; adjusting the model parameters of the reinforcement learning agent using the reward value; generating target transcoding parameters based on the state vector of the first video clip using the adjusted reinforcement learning agent; and transcoding and outputting a third video clip using the transcoding parameters.
[0257] The storage unit 1120 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 11201 and / or a cache 11202 , and may further include a read-only memory unit (ROM) 11203 .
[0258] The storage unit 1120 may also include a program / utility 11204 having a set (at least one) of program modules 11205, such program modules 11205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0259] The bus 1130 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0260] Electronic device 1100 may also communicate with one or more external devices 1140 (e.g., a keyboard, pointing device, Bluetooth device, etc.), one or more devices that enable a user to interact with electronic device 1100, and / or any device that enables electronic device 1100 to communicate with one or more other computing devices (e.g., a router, modem, etc.). Such communication may occur via input / output (I / O) interface 1150. Furthermore, electronic device 1100 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via network adapter 1160. As shown, network adapter 1160 communicates with other modules of electronic device 1100 via bus 1130. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with electronic device 1100, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0261] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
[0262] Based on the same inventive concept, embodiments of the present disclosure also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements any of the aforementioned video transcoding methods. Because the principles underlying the problems solved by this computer-readable storage medium embodiment are similar to those of the aforementioned method embodiment, the implementation of this computer-readable storage medium embodiment can be referenced to the implementation of the aforementioned method embodiment, and any repetitive details will not be repeated.
[0263] More specific examples of computer-readable storage media in the present disclosure may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fibers, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0264] In the present disclosure, a computer-readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, which carries readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0265] Alternatively, the program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination thereof.
[0266] In a specific implementation, the program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, and the like, as well as conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0267] Based on the same inventive concept, embodiments of the present disclosure further provide a computer program product, including a computer program or instructions. When executed by a processor, the computer program or instructions implement the video transcoding method described in any of the aforementioned method embodiments. Because the principles underlying the problems solved by this computer program product embodiment are similar to those of the aforementioned method embodiments, the implementation of this computer program product embodiment can be referenced to the implementation of the aforementioned method embodiments, and any repetitions will not be repeated.
[0268] It should be noted that although several modules or units of the device for action execution are mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be concretized in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be concretized.
[0269] Furthermore, although the steps of the method of the present disclosure are described in a particular order in the drawings, this does not require or imply that the steps must be performed in this particular order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0270] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
[0271] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the appended claims.
Claims
1. A video transcoding method, characterized in that: include: Obtaining a first video segment and a second video segment, wherein the second video segment is a transcoded video segment of the first video segment; determining a video quality parameter and a compression ratio based on the first video segment and the second video segment; calculating a reward value based on the video quality parameter and the compression rate using a reward function; adjusting model parameters of a reinforcement learning agent using the reward value; generating target transcoding parameters based on the state vector of the first video clip using the adjusted reinforcement learning agent; The third video segment is transcoded using the target transcoding parameters and outputted.
2. The video transcoding method according to claim 1, wherein: The calculating a reward value based on the quality parameter and the compression rate using a reward function includes: inputting the video quality parameter and the compression rate into the reward function so that the reward function is calculated based on the video quality parameter and the compression rate; A reward value output by the reward function is received, where the reward value is positively correlated with the video quality parameter and the reward value is positively correlated with the compression rate.
3. The video transcoding method according to claim 2, wherein: The method of calculating a reward value based on a video quality parameter and a compression rate using a reward function includes: extracting a bit rate and a target bit rate of the second video segment; inputting the video quality parameter, the compression ratio, the bit rate of the second video segment, and the target bit rate into the reward function, so that the reward function is calculated based on the video quality parameter, the compression ratio, the bit rate of the second video segment, and the target bit rate; A reward value output by the reward function is received, where the reward value is negatively correlated with a first difference value, where the first difference value is a difference between a bit rate of the second video segment and a target bit rate.
4. The video transcoding method according to claim 3, wherein: The reward value is positively correlated with the logarithm of the compression rate.
5. The video transcoding method according to any one of claims 2 to 4, characterized in that: The reward function includes a first weight and a second weight; the first weight is used to adjust the proportion of the video quality parameter in the reward value; the second weight is used to adjust the proportion of the bit rate in the reward value.
6. The video transcoding method according to claim 5, wherein: Also includes: Obtain historical scenario complexity, historical actual quality parameters, and historical predicted quality parameters; The first weight is calculated based on the historical scenario complexity, the historical actual quality parameter, and the historical predicted quality parameter, wherein the first weight is positively correlated with the historical scenario complexity, the first weight is positively correlated with the historical actual quality parameter, and the first weight is negatively correlated with the historical predicted quality parameter.
7. The video transcoding method according to claim 5, wherein: Also includes: Obtaining a target compression ratio, a compression ratio of a first cycle, and a compression ratio of a cycle before the first cycle; The second weight is calculated based on the target compression rate, the compression rate of the first cycle, and the compression rate of the cycle before the first cycle, wherein the second weight is negatively correlated with the first value, the first value is the absolute value of the difference between the compression rate of the first cycle and the target compression rate, and the second weight is positively correlated with the change in the compression rate, which is determined by the compression rate of the first cycle and the compression rate of the cycle before the first cycle.
8. The video transcoding method according to claim 1, wherein: Also includes: Extracting a status value of the first video clip, wherein the status value includes one or more of the following: the compression rate, the bit rate, the group of pictures parameter, and the scene complexity; A state vector of the first video segment is generated based on the state value of the first video segment.
9. A video transcoding device, characterized in that: include: An acquisition module, configured to acquire a first video segment and a second video segment, wherein the second video segment is a transcoded video segment of the first video segment; a determination module, configured to determine a video quality parameter and a compression ratio based on the first video segment and the second video segment; A calculation module, configured to calculate a reward value based on a video quality parameter and a compression rate using a reward function; an adjustment module, configured to adjust model parameters of the reinforcement learning agent using the reward value; a generating module, configured to generate target transcoding parameters based on the state vector of the first video clip using the adjusted reinforcement learning agent; The transcoding module is configured to transcode the third video segment using the transcoding parameters and output the transcoded video segment.
10. An electronic device, characterized in that: include: processor; as well as a memory for storing executable instructions of the processor; The processor is configured to execute the video transcoding method according to any one of claims 1 to 8 by executing the executable instructions.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the video transcoding method according to any one of claims 1 to 8 is implemented.
12. A computer program product comprising: A computer program or instruction, characterized in that when the computer program or instruction is executed by a processor, it implements the video transcoding method according to any one of claims 1 to 8.